Setting mass after LocalInertiaTensorInverse - error

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
cjhazard
Posts: 35
Joined: Mon Aug 01, 2011 8:05 pm

Setting mass after LocalInertiaTensorInverse - error

Post 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.
Fe_Yoshi
Posts: 397
Joined: Tue Jul 04, 2006 5:05 pm
Location: New Tower!

Re: Setting mass after LocalInertiaTensorInverse - error

Post 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.
It's simple, just take the hydraulic phase ship emulator and attach it to the photon particle emitter, BAM, new tower!
cjhazard
Posts: 35
Joined: Mon Aug 01, 2011 8:05 pm

Re: Setting mass after LocalInertiaTensorInverse - error

Post 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:
cjhazard
Posts: 35
Joined: Mon Aug 01, 2011 8:05 pm

Re: Setting mass after LocalInertiaTensorInverse - error

Post 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)?
cjhazard
Posts: 35
Joined: Mon Aug 01, 2011 8:05 pm

Re: Setting mass after LocalInertiaTensorInverse - error

Post 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.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Setting mass after LocalInertiaTensorInverse - error

Post by Norbo »

Thanks for the report, this should be fixed in the development version: http://bepuphysics.codeplex.com/SourceC ... evelopment
cjhazard
Posts: 35
Joined: Mon Aug 01, 2011 8:05 pm

Re: Setting mass after LocalInertiaTensorInverse - error

Post by cjhazard »

That was quick! Many thanks Norbo. Great work as always.
:D
Post Reply