Why do I do this to myself? sometimes I make only a few notes then I come back to my set up and say WTF was I thinking?!?! Its not like I can't read any one thing, I wrote it. But why some numbers are there, what settings were doing what, relating to each other how, why, damn. I hate going back to work on old code, even with notes. Often I feel like screw it just re-write it, easier than fixing what was previously broken.
This is one of a few sparks particle expressions... and my eye glaze over when trying to understand this initially, but I have to cram this back into my head. Honestly its not that much code, but to make this code do what you want artistically with easy is another thing altogether. You have to have the math, connections and settings back in your head working congruently.
//creation
//spark strong %
sparkShape.strongPercent = rand(1);
float $strongPercent = sparkShape.strongPercentage *.01;
if (sparkShape.strongPercent < $strongPercent) {
sparkShape.indexPP = 10;
} else {
sparkShape.indexPP = 0;
}
//short %
float $shortPercent = sparkShape.shortPercent *.01;
sparkShape.shortPercentage = rand(1);
//spark scale
float $length = rand(2.5, 3.5);
float $yScale;
float $zScale = $yScale = gauss(0.55, 1) * sparkShape.widthMult;
if (sparkShape.shortPercentage < $shortPercent) {
float $shortRand = rand(.15, .3);
sparkShape.scalePP = <<($length * $shortRand), $yScale, $zScale>>;
} else {
sparkShape.scalePP = <<$length, $yScale, $zScale>>;
}
//index start value
sparkShape.splitIndexPP = 0;
//split scale
sparkShape.splitScalePP = <<0, 0, 0>>;
//split pop amount
sparkShape.splitPopEmitter_emitterRatePP = rand((sparkShape.splitPop * 0.5), sparkShape.splitPop);
//lifespan
float $life = 24.0 / sparkShape.life;
float $lifeRand = 24.0 / sparkShape.lifeRand;
sparkShape.lifespanPP = $life * (rand(($lifeRand * -1), $lifeRand));
//scale spark on second frame of life
if(sparkShape.age > 0.042 && sparkShape.age < 0.08) {
float $mag = mag(sparkShape.velocity) * sparkShape.lengthVelocityMult;
vector $sclPP = sparkShape.scalePP;
float $velLengthMult = $sclPP.x * $mag;
sparkShape.scalePP = <<$velLengthMult, $sclPP.y, $sclPP.z>>;
}
//runtime
//vary fade out speed
float $randFadeOut = rand(1);
if($randFadeOut < .05) {
sparkShape.indexPP += .4;
sparkShape.splitIndexPP += .4;
} else {
sparkShape.indexPP += .2;
sparkShape.splitIndexPP += .2;
}