I'm having problem with overgrowing 'World.Dispatcher.NumManifold'. In my app there are walls of balls which are moving from one direction to another. I create a wall of.. let's say 100 balls (RigidBodies) apply them the same force, and when they reach certain point I remove them all. Repeat.
The problem is that along with new walls, Manifold number is growing (4096 is max) and it finaly crashes the app. I'm new to bullet so maby there is something I'm missing.
I tried to clean it somehow but after that I get access violations. I'm sure that I remove all bodies. 'NumOverlappingPairs' is the same as 'NumManifold'.
I uploaded a short movie showing that app and what I mean (that guy is just a mesh):
http://www.youtube.com/watch?v=ejeBUVoVCWs
As you can see Number of Manifolds is growing quite fast (that simulation will be much faster and with more balls)
Code in C#.
Code: Select all
// in constructor
broadphase = new DbvtBroadphase();
collisionConf = new DefaultCollisionConfiguration();
dispatcher = new CollisionDispatcher(collisionConf);
World = new DiscreteDynamicsWorld(dispatcher, broadphase, null, collisionConf);
World.PerformDiscreteCollisionDetection();
World.Gravity = new Vector3(0, 0, 0);
collisionShapes = new AlignedCollisionShapeArray();
collisionShapes.Add(ballShape);
// creating new wall of balls and add force to it
for (j = 0; j < ballsNumber; j++)
{
for (i = 0; i < ballsNumber; i++)
{
// set position for each ball
currentBallPosition = spherePosition[j * ballsNumber + i];
startTransform = Matrix.CreateTranslation(currentBallPosition) * Matrix.CreateRotationY(Dtr(90)) * rot;
DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
// create rigidbody
RigidBody body = LocalCreateRigidBody(1.0f, ballShape, myMotionState); // simplified rigidbody maker with: World.AddRigidBody(body);
body.CollisionFlags = CollisionFlags.NoContactResponse; // collisions are irrelevant
World.AddCollisionObject(body);
body.ApplyCentralImpulse(Vector3.UnitX); // force
rigidMovingBodies.Add(body); // list of bodies
}
}
// loops somwhere in Update method
for (int i = 0; i < rigidMovingBodies.Count; i++)
{
if (balls reach certaint point)
{
World.RemoveCollisionObject((CollisionObject)rigidMovingBodies[i]);
World.RemoveRigidBody(rigidMovingBodies[i]);
}
}
// clean the list
for (int i = 0; i < rigidMovingBodies.Count; i++)
{
if (balls reach certaint point)
{
rigidMovingBodies.RemoveAt(i);
rigidBodiesStartPosition.RemoveAt(i);
}
}