Cyclinders and async crash?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
MuletTheGreat
Posts: 8
Joined: Thu May 06, 2010 7:30 am

Cyclinders and async crash?

Post by MuletTheGreat »

Hi,

Just workin' on my level editor placing various physics objects and have encounters a rather nasty bug. When I attempt to place cylinders in my BaseCyclinder class, I get one of these occasionally:

An unhandled exception of type 'System.ArithmeticException' occurred in BEPUphysics.dll

Additional information: Some internal multithreaded arithmetic has encountered an invalid state. Check for invalid entity momentums, velocities, and positions; propagating NaN's will generally trigger this exception in the getExtremePoint function.


It's a freshly created object with no velocity, and the mass and scale do not seem to effect the chances of getting this crash, as it's currently about 1 in 30 of these will crash. It will only crash if the objects are being added to the space, (space is being updated currently with a tiny timestep to get things very close to frozen for editing)

I have tried converting my Ball class to use cyclinders of various sizes, and that won't crash. I have tried making this BaseCyclinder class use spheres and it won't crash.

What could I be doing to cause this?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Cyclinders and async crash?

Post by Norbo »

My first guess would be the timestep. If it's sufficiently small, single precision floating point numbers will not be sufficient to handle it in some calculations. I'm not sure exactly which calculation is suffering here, though.

Are you updating the engine asynchronously and using internal multithreading, or are you only using internal multithreading? What's the inner exception details? Does the crash only occur on the immediately following space.update call, or is there a delay?
MuletTheGreat
Posts: 8
Joined: Thu May 06, 2010 7:30 am

Re: Cyclinders and async crash?

Post by MuletTheGreat »

Thanks norbo, I fixed it.

I had to change g_EntityManager.GET.space.simulationSettings.timeStep.timeScale = 0.00000000001f; by knocking off one of the zeroes. We only using internal multithreading We were also passing space.update() 1f, instead of gametime, increasing the chances of this happening. We are passing it a tiny value as we want to whole scene to freeze, as this is an editor with edit and run modes.

Inner Exception: Function does not accept floating point Not-a-Number values.

Here is the stack trace of the inner exception:
StackTrace " at System.Math.Sign(Single value)\r\n at BEPUphysics.Entities.Cylinder.getExtremePoint(Vector3& d, Vector3& positionToUse, Quaternion& orientationToUse, Single margin, Vector3& extremePoint)\r\n at BEPUphysics.Toolbox.areObjectsCollidingMPR(Entity objA, Entity objB, Vector3& positionA, Vector3& positionB, Quaternion& orientationA, Quaternion& orientationB, Single marginA, Single marginB, Vector3& contactLocation, Vector3& contactNormal, Single& depth)\r\n at BEPUphysics.Toolbox.areObjectsCollidingMPR(Entity objA, Entity objB, Single marginA, Single marginB, Vector3& contactLocation, Vector3& contactNormal, Single& depth)\r\n at BEPUphysics.CollisionPair.updateCollisionDiscreteMPRGJK(Single dt)\r\n at BEPUphysics.CollisionPair.updateContactManifold(Single dt)\r\n at BEPUphysics.Space.updateCollisionDetectionDiscreteMultithreadedSubFunction(Object information)\r\n at BEPUphysics.ThreadManager.WorkerThread.threadExecutionLoop()" string
Post Reply