DetectorVolume exception

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
NetSavant
Posts: 28
Joined: Wed Apr 20, 2011 10:50 pm

DetectorVolume exception

Post by NetSavant »

Hey Norbo -

Ran into a DetectorVolume exception that started when I swapped in the latest development fork, looks like it might have been introduced there - I have a class that handles explosions using a low-poly sphere mesh as a detector volume and then applying forces to the objects it intersects:

Code: Select all

            // Ask the broadphase system which entities are in the "explode" region.
            m_AffectedEntries.Clear();
            Space.BroadPhase.QueryAccelerator.GetEntries(
                new BoundingSphere( this.Position, this.ExplodeRadius ), m_AffectedEntries );

            // Also, update detector volume for fine-grained overlap detection
            m_SphereMesh.WorldTransform = new AffineTransform(
                this.ExplodeRadius * new Vector3( 1, 1, 1 ), Quaternion.Identity,
                this.Position );
            m_SphereDetector.TriangleMesh.Data = m_SphereMesh;
            
            // For each nearby collidable...
            for ( int i = 0; i < m_AffectedEntries.Count; i++ ) {

                // If this is a regular entity that intersects the detector...
                EntityCollidable collidable = m_AffectedEntries[ i ] as EntityCollidable;
                if ( collidable != null && collidable.Entity.IsDynamic &&
                    m_SphereDetector.IsEntityIntersectingVolume( collidable.Entity ) ) {
                    
                    // ...applies forces based on radius, etc...
                }
            }
Anyway the exception is thrown on that IsEntityIntersectingVolume() method call, "Object reference not set to an instance of an object." - namely, collidableB.entity on line 201 of GeneralConvexPairTester.cs is null, so the reference to collidableB.entity.linearVelocity fails. When it happens collidableA is a Box entity and collidableB is a TriangleCollidable, so I'm presuming it's a triangle of that detector mesh.

Call stack if it helps is:


BEPUphysics.dll!BEPUphysics.CollisionTests.CollisionAlgorithms.GeneralConvexPairTester.DoDeepContact(out BEPUphysics.CollisionTests.ContactData contact) Line 201 C#
BEPUphysics.dll!BEPUphysics.CollisionTests.CollisionAlgorithms.GeneralConvexPairTester.DoShallowContact(out BEPUphysics.CollisionTests.ContactData contact) Line 148 + 0x12 bytes C#
BEPUphysics.dll!BEPUphysics.CollisionTests.CollisionAlgorithms.GeneralConvexPairTester.GenerateContactCandidate(out BEPUphysics.CollisionTests.ContactData contact) Line 92 + 0xc bytes C#
BEPUphysics.dll!BEPUphysics.CollisionTests.Manifolds.GeneralConvexContactManifold.Update(float dt) Line 81 + 0x11 bytes C#
BEPUphysics.dll!BEPUphysics.NarrowPhaseSystems.Pairs.Type1PairHandler.UpdateCollision(float dt) Line 131 C#
BEPUphysics.dll!BEPUphysics.NarrowPhaseSystems.NarrowPhaseHelper.Intersecting(ref BEPUphysics.Collidables.CollidablePair pair) Line 221 C#
BEPUphysics.dll!BEPUphysics.UpdateableSystems.DetectorVolume.IsEntityIntersectingShell(BEPUphysics.Entities.Entity entity, System.Collections.Generic.IList<int> intersectedTriangleIndices) Line 308 + 0x9 bytes C#
BEPUphysics.dll!BEPUphysics.UpdateableSystems.DetectorVolume.IsEntityIntersectingShell(BEPUphysics.Entities.Entity entity) Line 279 + 0xf bytes C#
BEPUphysics.dll!BEPUphysics.UpdateableSystems.DetectorVolume.IsEntityIntersectingVolume(BEPUphysics.Entities.Entity entity) Line 224 + 0x43 bytes C#

Let me know if you see anything obvious/quick there - otherwise I can maybe dig into the source a bit and figure out what's happening.

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

Re: DetectorVolume exception

Post by Norbo »

That's the new relative velocity penetration test. I'll throw in a quick fix to that in the next development version; thanks for the report.
NetSavant
Posts: 28
Joined: Wed Apr 20, 2011 10:50 pm

Re: DetectorVolume exception

Post by NetSavant »

Cool, thanks - will pull that when it's ready.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: DetectorVolume exception

Post by Norbo »

It's up; I also made another couple of improvements to convex-triangle deep contact. Quality wise, that's probably all I'll be able to eke out of it for v0.16.0. The performance might get better though. In any case, having some nonzero margin will help performance and quality quite a bit.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: DetectorVolume exception

Post by Norbo »

Just found another bug with the convex-triangle when ImproveBoundaryBehavior is on :) One of these times I'll actually get it completely done.
NetSavant
Posts: 28
Joined: Wed Apr 20, 2011 10:50 pm

Re: DetectorVolume exception

Post by NetSavant »

Just grabbed the latest version, took care of that exception - thanks for that - and quality-wise those glitches are pretty rare with the new MPR, definitely a huge improvement.
Post Reply