Exception in StaticTriangleGroup.addAllNecessaryTriangles()

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
BrianL
Posts: 54
Joined: Wed Jun 25, 2008 4:41 pm
Location: Panama City Beach, FL

Exception in StaticTriangleGroup.addAllNecessaryTriangles()

Post by BrianL »

I'm having trouble with a StaticTriangleGroup throwing the following exception. This doesn't happen until contact has been made by another Entity. The STG is a simple 4x4 flat plane consisting of 25 vertices and 32 triangles. Any ideas? Thanks.

Object reference not set to an instance of an object.

at BEPUphysics.StaticTriangleGroup.addAllNecessaryTriangles()
at BEPUphysics.StaticTriangleGroup.updateBeforeCollisionDetection(Single dt, Single timeScale, Single timeSinceLastFrame)
at BEPUphysics.Space.updateBeforeCollisionDetectionUpdateables(Single dt, Single timeSinceLastFrame)
at BEPUphysics.Space.updateCCD(Single timeSinceLastFrame)
at BEPUphysics.Space.updateWithoutInternalTimeSteps(Single timeSinceLastFrame)
at BEPUphysics.Space.update(Single timeSinceLastFrame)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Exception in StaticTriangleGroup.addAllNecessaryTriangles()

Post by Norbo »

This is likely caused by giving vertices to the StaticTriangleGroup's TriangleMesh which are not of the type StaticTriangleGroupVertex or a subclass. Passing in a superclass (like TriangleMeshVertex) will cause a cast to null in the add method. Using the StaticTriangleGroup's static getVerticesAndIndicesFromModel provides an easy way to get an array of the right type.

I plan to make this a little more forgiving/intuitive.
BrianL
Posts: 54
Joined: Wed Jun 25, 2008 4:41 pm
Location: Panama City Beach, FL

Re: Exception in StaticTriangleGroup.addAllNecessaryTriangles()

Post by BrianL »

Passing in a superclass (like TriangleMeshVertex) will cause a cast to null in the add method.
Yes, that's got to be it. I'm currently passing in an array of TriangleMeshVertex. I haven't tested it yet, but I'll make the switch to StaticTriangleGroupVertex. Thanks.
Post Reply