[sldev] Re: Reviewing/Fixing the Particle System

Argent Stonecutter secret.argent at gmail.com
Fri May 25 19:06:55 PDT 2007


Ah, yes, picking random particle systems should definitely go back in.

And particle systems that are out of view distance shouldn't be  
generating new particles. So this should go in update:

	if (mSourceObjectp->mDrawable.isNull()) return 0;

Another hack that could be implemented, efficiently, if they don't  
want to sort the list... since you're continually running through the  
particle generator list you can run a "slow bubble-sort" on the  
particles that will tend to move close particle systems closer to you...

Don't throttle based on the camera, I don't think. Nothing else does  
LoD based on camera distance, and particles are long lasting... you  
don't want particles around you coming and going as the camera swoops  
around.

	F32 scaleSq, distSq;

	distSq  = (mPosAgent - gCamera->getOrigin()).magVec();
	distSq /= view_limit; /* scale to view limit */
	distSq *= distSq; /* So we don't have to make with square roots */

	if(mFlags & LLPartData::LL_PART_INTERP_SCALE_MASK) {
		scaleSq = (mEndScale[0] + mStartScale[0]) * (mEndScale[1] +  
mStartScale[1]) / 4.0f; /* avg(x) = (x1+x2)/2, factored out */
	} else {
		scaleSq = mStartScale[0] * mStartScale[1];
	}
	scaleSq /= 16.0f; /* biggest particle is 4x4, so this scales  
"particle scale factor" to a range 1...0 */

	pass = scaleSq / distSq;




More information about the SLDev mailing list