BulletSim: Fix crash on the destruction of physical linksets.

While fixing the above, add methods to physical body and shape pointer
wrapper so routines won't have to know that IntPtr.Zero means no
physical instance.
Fix problem with physical linksets failing after a few sits and
unsits by properly restoring child prom positions for compound
linksets after multiple selection and deselections.
This commit is contained in:
Robert Adams
2012-12-10 15:35:53 -08:00
parent a19896cc56
commit 9df85eadf4
12 changed files with 155 additions and 38 deletions

View File

@@ -75,6 +75,7 @@ public abstract class BSPhysObject : PhysicsActor
public string TypeName { get; protected set; }
public BSLinkset Linkset { get; set; }
public BSLinksetInfo LinksetInfo { get; set; }
// Return the object mass without calculating it or having side effects
public abstract float RawMass { get; }
@@ -253,7 +254,9 @@ public abstract class BSPhysObject : PhysicsActor
SubscribedEventsMs = 0;
PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate()
{
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
// Make sure there is a body there because sometimes destruction happens in an un-ideal order.
if (PhysBody.HasPhysicalBody)
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
});
}
// Return 'true' if the simulator wants collision events