BulletSim: add ClearCollisionProxyCache function to API.
Add proxy cache clearing when some properties are changed. This fixes a problem where objects would stop colliding of they were moved with setPosition mulitple times.0.7.6-extended
							parent
							
								
									b6568c7e22
								
							
						
					
					
						commit
						568ff6fddc
					
				|  | @ -725,6 +725,13 @@ public override bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj) | |||
|     return BSAPICPP.RemoveObjectFromWorld2(worldu.ptr, bodyu.ptr); | ||||
| } | ||||
| 
 | ||||
| public override bool ClearCollisionProxyCache(BulletWorld world, BulletBody obj) | ||||
| { | ||||
|     BulletWorldUnman worldu = world as BulletWorldUnman; | ||||
|     BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||||
|     return BSAPICPP.ClearCollisionProxyCache2(worldu.ptr, bodyu.ptr); | ||||
| } | ||||
| 
 | ||||
| public override bool AddConstraintToWorld(BulletWorld world, BulletConstraint constrain, bool disableCollisionsBetweenLinkedObjects) | ||||
| { | ||||
|     BulletWorldUnman worldu = world as BulletWorldUnman; | ||||
|  | @ -1712,6 +1719,9 @@ public static extern bool AddObjectToWorld2(IntPtr world, IntPtr obj); | |||
| [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||||
| public static extern bool RemoveObjectFromWorld2(IntPtr world, IntPtr obj); | ||||
| 
 | ||||
| [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||||
| public static extern bool ClearCollisionProxyCache2(IntPtr world, IntPtr obj); | ||||
| 
 | ||||
| [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||||
| public static extern bool AddConstraintToWorld2(IntPtr world, IntPtr constrain, bool disableCollisionsBetweenLinkedObjects); | ||||
| 
 | ||||
|  |  | |||
|  | @ -169,6 +169,19 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     public override bool ClearCollisionProxyCache(BulletWorld pWorld, BulletBody pBody) | ||||
|     { | ||||
|         DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world; | ||||
|         RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||||
|         CollisionObject collisionObject = ((BulletBodyXNA)pBody).body; | ||||
|         if (body != null && collisionObject != null && collisionObject.GetBroadphaseHandle() != null) | ||||
|         { | ||||
|             world.RemoveCollisionObject(collisionObject); | ||||
|             world.AddCollisionObject(collisionObject); | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     public override bool AddConstraintToWorld(BulletWorld pWorld, BulletConstraint pConstraint, bool pDisableCollisionsBetweenLinkedObjects) | ||||
|     { | ||||
|         DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world; | ||||
|  |  | |||
|  | @ -498,6 +498,8 @@ public abstract bool AddObjectToWorld(BulletWorld world, BulletBody obj); | |||
| 
 | ||||
| public abstract bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj); | ||||
| 
 | ||||
| public abstract bool ClearCollisionProxyCache(BulletWorld world, BulletBody obj); | ||||
| 
 | ||||
| public abstract bool AddConstraintToWorld(BulletWorld world, BulletConstraint constrain, bool disableCollisionsBetweenLinkedObjects); | ||||
| 
 | ||||
| public abstract bool RemoveConstraintFromWorld(BulletWorld world, BulletConstraint constrain); | ||||
|  |  | |||
|  | @ -300,8 +300,16 @@ public abstract class BSPhysObject : PhysicsActor | |||
|     // Called in taint-time!! | ||||
|     public void ActivateIfPhysical(bool forceIt) | ||||
|     { | ||||
|         if (IsPhysical && PhysBody.HasPhysicalBody) | ||||
|             PhysScene.PE.Activate(PhysBody, forceIt); | ||||
|         if (PhysBody.HasPhysicalBody) | ||||
|         { | ||||
|             // Clear the collision cache since we've changed some properties. | ||||
|             PhysScene.PE.ClearCollisionProxyCache(PhysScene.World, PhysBody); | ||||
|             if (IsPhysical) | ||||
|             { | ||||
|                 // Physical objects might need activating | ||||
|                 PhysScene.PE.Activate(PhysBody, forceIt); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // 'actors' act on the physical object to change or constrain its motion. These can range from | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Robert Adams
						Robert Adams