BulletSim: fix crash when deleting llVolumeDetect enabled objects. Bullet's check for an object being linked into the world does not work for Bullet's ghost objects so BulletSim was deleting the object while it was still linked into the physical world structures.

user_profiles
Robert Adams 2013-04-21 15:59:39 -07:00
parent 293a024c14
commit e1ac683154
1 changed files with 2 additions and 5 deletions

View File

@ -162,11 +162,8 @@ public sealed class BSShapeCollection : IDisposable
// If the caller needs to know the old body is going away, pass the event up. // If the caller needs to know the old body is going away, pass the event up.
if (bodyCallback != null) bodyCallback(body); if (bodyCallback != null) bodyCallback(body);
if (PhysicsScene.PE.IsInWorld(PhysicsScene.World, body)) // Removing an object not in the world is a NOOP
{ PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, body);
PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, body);
if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,removingFromWorld. Body={1}", body.ID, body);
}
// Zero any reference to the shape so it is not freed when the body is deleted. // Zero any reference to the shape so it is not freed when the body is deleted.
PhysicsScene.PE.SetCollisionShape(PhysicsScene.World, body, null); PhysicsScene.PE.SetCollisionShape(PhysicsScene.World, body, null);