Game Development Community

Zero or negative size particles not recommended

by Henry Shilling · in Torque X 2D · 07/17/2009 (9:12 am) · 4 replies

I have created a projectile that explodes after a certain range of travel. Simple code:

if (_flakTemplate != null)
{
       T2DParticleEffect flak = _flakTemplate.Clone() as T2DParticleEffect;
       flak.Position = ((T2DSceneObject)Owner).Position;
       TorqueObjectDatabase.Instance.Register(flak);
}
Owner.MarkForDelete = true;

If the particle effect has more than one emitter I get the error "Zero or negative size particles not recommended"

If the effect has only one emitter no problems. I have checked the effects and the "particle life variance" is no where near 4. I have the feeling this is not a problem with my code.

I put a break in T2DParticleEmitter.cs on the line
Assert.Fatal(particle.SizeX > 0.0f && particle.SizeY > 0.0f, "Zero or negative size particles not recommended.");

Neither the particle.SizeX or the particle.SizeY are zero or negative. I guess I don't understand the Assert totally. If the parameter is TRUE it gets triggered?

#1
07/17/2009 (6:09 pm)
Quote:I guess I don't understand the Assert totally. If the parameter is TRUE it gets triggered?

Actually it is the opposite. If the Assert is false then it is triggered. Kind of think of it as saying, "I'm asserting (declaring, affirming, etc) that this condition exists at this point in time". So in your case the assert should be triggered when the condition particle.SizeX <= 0.0f || particle.SizeY <= 0.0f is true.

However, I'm not sure why your not seeing this in the debugger.
#2
07/17/2009 (6:57 pm)
You say that you checked the "particle life variance", but the error is clearly about the size, not lifespan. Check the SizeX Base, SizeX Variance, and SizeX Life, as well as the same for Y. It seems logical that the variance would need to be < double the Base just like it is for particle life.
#3
07/17/2009 (8:40 pm)
The first particle effect fires off fine. It is weirding me out because it's only the second and after that trigger the assert. When tracing in the debugger I don't see the sizeX and sizeY being negative.

I checked the life variance because there is a bug there apparently.

I had the size at 5 and the variance at 10, life went from 1 to like 1.5. I changed the variance to just below 10 and OK everything is fine.

This is an effect I copied from an effect in TGB. So why does it work in TGB and not in TXB? Maybe the code should catch the variance and use an absoulute?
#4
07/17/2009 (9:22 pm)
You're right about there being a problem with the code for life variance, whereby it doesn't allow a variance greater than or equal to 4. You can see in this thread how to fix it so it can be anything, as long as it is >= 0 and < double the base.

P.S. Interesting avatar; it's got me wondering what that is in the background.