Torque X 2D: SceneContainer:getBinRange() - Bad Range! Issue
by Christian Bodmer · in Torque X 2D · 02/22/2008 (6:23 am) · 1 replies
I've set up a small physics demo using TorqueX 2D + TXB. The setup is a follows:
- a tilelayer (similar to a pinball machine) that provides surfaces for bouncing off of
- objects are cloned from a standard object defined as a template
- objects (balls) entering the tilelayer at different points, following the course of gravity
- the objects have their world limits set to match position and extent of the tilelayer
- the tilelayer contains several spots where objects can land and rest
- the tilelayer is completly closed off; no object can fall out of it
- gravity is provided by a T2DForceComponent with a constant direction
- gravity is along the Y axis (+Y)
This works as intended, for a while. Then, after a certain amount of frames have elapsed,
I receive the assert error "SceneContainer:getBinRange() - Bad Range!".
I then replaced the Force Component and wrote my own ProcessTick function, which basically
does nothing other than SceneObject.Physics.ApplyImpulse() in the direction of gravity.
This version lasted a few frames longer but I eventually it fails with the same assert error as the
ForceComponent.
Finally, I changed my code so that once an object is at rest, gravity is no longer applied to it. This version worked without assert error, but the physics are obviously and visibly altered, so it's really only a testing solution.
I am wondering if anyone has some insights to share on this issue, maybe you've seen it yourself, maybe you've found a solution?
Thanks,
-Chris
- a tilelayer (similar to a pinball machine) that provides surfaces for bouncing off of
- objects are cloned from a standard object defined as a template
- objects (balls) entering the tilelayer at different points, following the course of gravity
- the objects have their world limits set to match position and extent of the tilelayer
- the tilelayer contains several spots where objects can land and rest
- the tilelayer is completly closed off; no object can fall out of it
- gravity is provided by a T2DForceComponent with a constant direction
- gravity is along the Y axis (+Y)
This works as intended, for a while. Then, after a certain amount of frames have elapsed,
I receive the assert error "SceneContainer:getBinRange() - Bad Range!".
I then replaced the Force Component and wrote my own ProcessTick function, which basically
does nothing other than SceneObject.Physics.ApplyImpulse() in the direction of gravity.
This version lasted a few frames longer but I eventually it fails with the same assert error as the
ForceComponent.
Finally, I changed my code so that once an object is at rest, gravity is no longer applied to it. This version worked without assert error, but the physics are obviously and visibly altered, so it's really only a testing solution.
I am wondering if anyone has some insights to share on this issue, maybe you've seen it yourself, maybe you've found a solution?
Thanks,
-Chris
Torque Owner Christian Bodmer
The problem is triggered by collisions of sprites with the tilelayer. Under certain circumstances, this collision generates a T2DCollisionInfo with Position and Penetration vectors, which contain NaN's (Not a Number) for their X and Y float components.
If such a collision info structure is passed to T2DPhysicsComponent.RigidCollision() the "SceneContainer:getBinRange() - Bad Range!" error happens. As far as I know, NaN is the result of a floating point operation with an undefined result (such as 0.0 / 0.0), which, in this case, must happen inside the collision detection routines of the Torque X framework.
I work around this now by using my own ResolveCollision function which makes sure that the collision info structure contains valid numbers before passing it on to T2DPhysicsComponent.RigidCollision().
-Chris