Page 1 of 1

BecomeKinematic

Posted: Wed Oct 05, 2011 11:27 pm
by DualOpAmp
I have checked an object to become kinematic at the beginning of my game, but I'm getting this error.

System.ArithmeticException was unhandled
Message=Function does not accept floating point Not-a-Number values.
Source=mscorlib
StackTrace:
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()
at SunBurnBEPUPhysicsManager.BEPUPhysicsManager.Update(GameTime gameTime) in C:\Users\Jeff\Downloads\SunBurnBepuPhysicsManager\SunBurnBepuPhysicsManager\SunBurnBEPUPhysicsManager.cs:line 183
at SynapseGaming.LightingSystem.Core.SceneInterface.Update(GameTime gameTime)
at SunBurnGame1.StarterGame.Update(GameTime gameTime) in C:\Users\Jeff\Documents\Visual Studio 2010\Projects\SunBurnGame1\SunBurnGame1\SunBurnGame1\Game.cs:line 214
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
at Microsoft.Xna.Framework.Game.Run()
at SunBurnGame1.StarterGame.Program.Main(String[] args) in C:\Users\Jeff\Documents\Visual Studio 2010\Projects\SunBurnGame1\SunBurnGame1\SunBurnGame1\Game.cs:line 485
InnerException:

Re: BecomeKinematic

Posted: Wed Oct 05, 2011 11:46 pm
by Norbo
Somewhere along the way, some object is getting a NaN position (probably from a NaN velocity). Could you reproduce the issue in a BEPUphysicsDemos demo simulation? The project is included in the main source download: http://bepuphysics.codeplex.com/SourceC ... changesets

If it only happens when the object is made kinematic at the beginning, there may be something in collision or something relying on noninfinite masses/inertia that gets confused. Having a runnable reproduction case would help diagnose the issue.

Re: BecomeKinematic

Posted: Thu Oct 06, 2011 5:16 pm
by DualOpAmp
I tried it in the demo, and I couldn't reproduce it.

Strange.

Re: BecomeKinematic

Posted: Thu Oct 06, 2011 8:42 pm
by Norbo
It may be that BecomeKinematic is necessary but not sufficient to reproduce the problem. Some other context may also be necessary before the problem will happen; perhaps some set of interacting objects or logic that modifies entity position or velocity is the more direct cause.

Re: BecomeKinematic

Posted: Wed Oct 12, 2011 9:33 pm
by DualOpAmp
I'm using Sunburn Game Engine with a BEPU manager integrated into it. The BEPU manager is just a wrapper for the Space class from BEPU v1.0.
I'm watching all my values, right after I call BecomeKinematic, then space updates once, the angular momentum and angular velocity turn to NaN.
Then, space updates one more time, and TaDa... Error.

Re: BecomeKinematic

Posted: Wed Oct 12, 2011 9:38 pm
by Norbo
That is consistent with my expectations for this kind of error, but unfortunately, it doesn't narrow down the possible causes much. It should be reproducible in the demos if the relevant simulation details are included.

If bits of the original simulation are steadily added into the demos reproduction until the exception occurs, it's very likely that I will be able diagnose it in a couple of minutes by debugging the demo.