Page 1 of 1

Setting mass after LocalInertiaTensorInverse - error

Posted: Sun Jan 29, 2012 3:15 pm
by cjhazard
I'm getting a weird error and I can't figure out what's causing it.

If I set LocalInertiaTensorInverse to Matrix3x3() and then change the Mass value I get the following error:
"Function does not accept floating point Not-a-Number values." in GetBoundingBox of the BoxShape class.

The stack trace is as follows:

at System.Math.Sign(Single value)
at BEPUphysics.CollisionShapes.ConvexShapes.BoxShape.GetBoundingBox(RigidTransform& shapeTransform, BoundingBox& boundingBox)
at BEPUphysics.Collidables.MobileCollidables.ConvexCollidable`1.UpdateBoundingBoxInternal(Single dt)
at BEPUphysics.Collidables.MobileCollidables.EntityCollidable.UpdateBoundingBox(Single dt)
at BEPUphysics.OtherSpaceStages.BoundingBoxUpdater.UpdateSingleThreaded()
at BEPUphysics.MultithreadedProcessingStage.Update()
at BEPUphysics.Space.DoTimeStep()
at BEPUphysics.Space.Update()

I've tried debugging (in single threaded mode) but it doesn't seem to occur when I do, which makes me think it's a timing issue.

Any ideas?

Thanks.
CJ.

Re: Setting mass after LocalInertiaTensorInverse - error

Posted: Sun Jan 29, 2012 4:12 pm
by Fe_Yoshi
You're changing the mass? Are you changing the amount of energy as well, because otherwise E=MC squared's going to get all upset and have a tantrum.

Re: Setting mass after LocalInertiaTensorInverse - error

Posted: Sun Jan 29, 2012 4:18 pm
by cjhazard
Fe_Yoshi wrote:You're changing the mass? Are you changing the amount of energy as well, because otherwise E=MC squared's going to get all upset and have a tantrum.
No I'm adjusting the speed of light to compensate. LOL!

I've narrowed down the issue to the call to Solver.Update(). It appears that InertiaTensorInverse is somehow getting set to NaN. Now I just need to find where, how and why! :shock:

Re: Setting mass after LocalInertiaTensorInverse - error

Posted: Sun Jan 29, 2012 4:41 pm
by cjhazard
It seems that when I set LocalInertiaTensorInverse = new Matrix3X3()... it also resets LocalInertiaTensor to all zeros as well.... which I presume the triggers LocalInertiaTensorInverse to become NaN somewhere but I can't yet see where.

Sometimes when I'm debugging it seems to prevent the error from occurring.... aagghh! (actually that could have been down to my numptiness)

I get the feeling that what happens is when I change the mass it then recalculates the LocalInertiaTensorInverse from the LocalInertiaTensor, which being zero will mean that LocalInertiaTensorInverse becomes NaN (or effectively infinite).

So now the question is, how can I get it to do it the other way around (to calculate LocalInertiaTensor from LocalInertiaTensorInverse)?

Re: Setting mass after LocalInertiaTensorInverse - error

Posted: Sun Jan 29, 2012 5:07 pm
by cjhazard
Ok, here's the chain of events...

I set LocalInertiaTensorInverse to zeros...
which sets LocalInertiaTensor to zeros also...
I change the Mass...
which calls BecomeDynamic(float mass, Matrix3X3 localInertiaTensor)...
which sets LocalInertiaTensor = localInertiaTensor...
which in turn recalculates LocalInertiaTensorInverse to NaN!!

At least I now understand what's happening. No idea how to fix it though.

Re: Setting mass after LocalInertiaTensorInverse - error

Posted: Sun Jan 29, 2012 7:58 pm
by Norbo
Thanks for the report, this should be fixed in the development version: http://bepuphysics.codeplex.com/SourceC ... evelopment

Re: Setting mass after LocalInertiaTensorInverse - error

Posted: Sun Jan 29, 2012 8:29 pm
by cjhazard
That was quick! Many thanks Norbo. Great work as always.
:D