// Release the usage of a shape. // The collisionObject is released since it is a copy of the real collision shape. public void DereferenceShape(BulletShape shape, bool atTaintTime, ShapeDestructionCallback shapeCallback) { if (shape.ptr == IntPtr.Zero) { return; } BSScene.TaintCallback dereferenceOperation = delegate() { switch (shape.type) { case ShapeData.PhysicsShapeType.SHAPE_HULL: DereferenceHull(shape, shapeCallback); break; case ShapeData.PhysicsShapeType.SHAPE_MESH: DereferenceMesh(shape, shapeCallback); break; case ShapeData.PhysicsShapeType.SHAPE_UNKNOWN: break; default: // Native shapes are not tracked and are released immediately if (shape.ptr != IntPtr.Zero & shape.isNativeShape) { DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,ptr={1},taintTime={2}", BSScene.DetailLogZero, shape.ptr.ToString("X"), atTaintTime); if (shapeCallback != null) { shapeCallback(shape); } BulletSimAPI.DeleteCollisionShape2(PhysicsScene.World.ptr, shape.ptr); } break; } }; if (atTaintTime) { lock (m_collectionActivityLock) { dereferenceOperation(); } } else { PhysicsScene.TaintedObject("BSShapeCollection.DereferenceShape", dereferenceOperation); } }