Runtime Error On Collision

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
fullarr
Posts: 2
Joined: Fri Aug 12, 2011 5:03 pm

Runtime Error On Collision

Post by fullarr »

I created a pendulum using code from a forum post on here, and added a player using the character/character controller code from a demo project. The pendulum is created using a rotated Cylinder and two Ball Joints offset to created the motion desired. I then edited the Player's Body to be a Capsule instead of a Cylinder. I set this scene up and everything appears to work correctly, and is a lot of fun to play with, but about a week later I noticed a strange bug that happens.

When the pendulum is swinging away from the player, and the player is jumping into it there is occasionally an unhandled ArithmeticException when space calls Update()

I replaced the Bepu.dll reference with the source code in order to find the exact place where the code is breaking, and discovered that inside Simplex.cs the GetPointOnTriangleClosestToOrigin() function appears to setting CdotAC as Infinity after a dot product.

I was just wondering if anyone could shed some light on the situation and help me figure out if this is a problem with Bepu, this specific physics simulation, or an error within my code. Thanks in advance!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Runtime Error On Collision

Post by Norbo »

Was this using the 'full' character controller that came with v0.16.2?

I can't say for sure what would be causing that exception. My first guess would be that one of the modifications made to the character lead to an obscure corner case. Some parts of the character controller do rely on the fact that the character is mostly a cylinder as opposed to a capsule, though my expectation would be a silent failure or generally worse behavior, not an exception.

In order to know for sure, I'd probably need a stripped down runnable project with source which reliably reproduces the problem.
fullarr
Posts: 2
Joined: Fri Aug 12, 2011 5:03 pm

Re: Runtime Error On Collision

Post by fullarr »

Thanks for the quick response,

I did switch the character controller back to the cylinder shape before posting this, and it happened less frequently, but still occurred in the same scenario. Unfortunately, the problem is not easily repeatable, because sometimes I got it on the first or second try, and other times it took between 30-50 attempts. I'm not sure that I could produce slimmed down source code of the character / character controller, but the pendulum's code is like this

Code: Select all

   
   body = new Cylinder(new Vector3(position.X, position.Y - 9, position.Z), 5, 1, 100);
   body.Orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, -MathHelper.PiOver2);

   //in a separate file...
   Space.Add(Body);
   Vector3 ramJointPosition = new Vector3(Position.X, Position.Y, Position.Z);
   Space.Add(new RevoluteAngularJoint(null, Body, Vector3.UnitZ));
   Space.Add(new BallSocketJoint(null, Body, ramJointPosition));

   // Constraining the pendulum on the XY plane
   Space.Add(new PointOnPlaneJoint(null, Body, Vector3.Zero, Vector3.Forward, Body.Position));

Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Runtime Error On Collision

Post by Norbo »

Nothing in that code jumps out as wrong or as a possible culprit.

It is unlikely that I will be able to reproduce the problem (considering I haven't already) without a runnable project. Anything that shows the problem in action would be extremely helpful. I don't need everything completely stripped to the bones, just something debuggable that eventually reproduces the issue.
Post Reply