* Tweak the BulletSimN API a bit.
							parent
							
								
									10de5d8169
								
							
						
					
					
						commit
						82b954b212
					
				|  | @ -106,11 +106,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | ||||||
| 
 | 
 | ||||||
|     // Pinned memory used to pass step information between managed and unmanaged |     // Pinned memory used to pass step information between managed and unmanaged | ||||||
|     internal int m_maxCollisionsPerFrame; |     internal int m_maxCollisionsPerFrame; | ||||||
|     private List<BulletXNA.CollisionDesc> m_collisionArray; |     private BulletXNA.CollisionDesc[] m_collisionArray; | ||||||
|     //private GCHandle m_collisionArrayPinnedHandle; |     //private GCHandle m_collisionArrayPinnedHandle; | ||||||
| 
 | 
 | ||||||
|     internal int m_maxUpdatesPerFrame; |     internal int m_maxUpdatesPerFrame; | ||||||
|     private List<BulletXNA.EntityProperties> m_updateArray; |     private BulletXNA.EntityProperties[] m_updateArray; | ||||||
|     //private GCHandle m_updateArrayPinnedHandle; |     //private GCHandle m_updateArrayPinnedHandle; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -201,9 +201,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | ||||||
|         GetInitialParameterValues(config); |         GetInitialParameterValues(config); | ||||||
| 
 | 
 | ||||||
|         // allocate more pinned memory close to the above in an attempt to get the memory all together |         // allocate more pinned memory close to the above in an attempt to get the memory all together | ||||||
|         m_collisionArray = new List<BulletXNA.CollisionDesc>(); |         m_collisionArray = new BulletXNA.CollisionDesc[0]; | ||||||
|         //m_collisionArrayPinnedHandle = GCHandle.Alloc(m_collisionArray, GCHandleType.Pinned); |         //m_collisionArrayPinnedHandle = GCHandle.Alloc(m_collisionArray, GCHandleType.Pinned); | ||||||
|         m_updateArray = new List<BulletXNA.EntityProperties>(); |         m_updateArray = new BulletXNA.EntityProperties[0]; | ||||||
|         //m_updateArrayPinnedHandle = GCHandle.Alloc(m_updateArray, GCHandleType.Pinned); |         //m_updateArrayPinnedHandle = GCHandle.Alloc(m_updateArray, GCHandleType.Pinned); | ||||||
| 
 | 
 | ||||||
|         // Enable very detailed logging. |         // Enable very detailed logging. | ||||||
|  |  | ||||||
|  | @ -894,7 +894,7 @@ static class BulletSimAPI { | ||||||
|         return capsuleShapeZ; |         return capsuleShapeZ; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public static object Initialize2(Vector3 worldExtent, ConfigurationParameters[] o, int mMaxCollisionsPerFrame, ref List<BulletXNA.CollisionDesc> collisionArray, int mMaxUpdatesPerFrame, ref List<BulletXNA.EntityProperties> updateArray, object mDebugLogCallbackHandle) |     public static object Initialize2(Vector3 worldExtent, ConfigurationParameters[] o, int mMaxCollisionsPerFrame, ref BulletXNA.CollisionDesc[] collisionArray, int mMaxUpdatesPerFrame, ref BulletXNA.EntityProperties[] updateArray, object mDebugLogCallbackHandle) | ||||||
|     { |     { | ||||||
|         CollisionWorld.WorldData.ParamData p = new CollisionWorld.WorldData.ParamData(); |         CollisionWorld.WorldData.ParamData p = new CollisionWorld.WorldData.ParamData(); | ||||||
| 
 | 
 | ||||||
|  | @ -1436,14 +1436,14 @@ static class BulletSimAPI { | ||||||
| 
 | 
 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     internal static int PhysicsStep2(object pWorld, float timeStep, int m_maxSubSteps, float m_fixedTimeStep, out int updatedEntityCount, out List<BulletXNA.EntityProperties> updatedEntities, out int collidersCount, out List<BulletXNA.CollisionDesc>colliders) |     internal static int PhysicsStep2(object pWorld, float timeStep, int m_maxSubSteps, float m_fixedTimeStep, out int updatedEntityCount, out BulletXNA.EntityProperties[] updatedEntities, out int collidersCount, out BulletXNA.CollisionDesc[] colliders) | ||||||
|     { |     { | ||||||
|         int epic = PhysicsStepint2(pWorld, timeStep, m_maxSubSteps, m_fixedTimeStep, out updatedEntityCount, out updatedEntities, |         int epic = PhysicsStepint2(pWorld, timeStep, m_maxSubSteps, m_fixedTimeStep, out updatedEntityCount, out updatedEntities, | ||||||
|                                 out collidersCount, out colliders); |                                 out collidersCount, out colliders); | ||||||
|         return epic; |         return epic; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private static int PhysicsStepint2(object pWorld,float timeStep, int m_maxSubSteps, float m_fixedTimeStep, out int updatedEntityCount, out List<BulletXNA.EntityProperties> updatedEntities, out int collidersCount, out List<BulletXNA.CollisionDesc> colliders) |     private static int PhysicsStepint2(object pWorld,float timeStep, int m_maxSubSteps, float m_fixedTimeStep, out int updatedEntityCount, out BulletXNA.EntityProperties[] updatedEntities, out int collidersCount, out BulletXNA.CollisionDesc[] colliders) | ||||||
|     { |     { | ||||||
|         int numSimSteps = 0; |         int numSimSteps = 0; | ||||||
|        |        | ||||||
|  | @ -1462,16 +1462,16 @@ static class BulletSimAPI { | ||||||
|             numSimSteps = world.StepSimulation(timeStep, m_maxSubSteps, m_fixedTimeStep); |             numSimSteps = world.StepSimulation(timeStep, m_maxSubSteps, m_fixedTimeStep); | ||||||
|             int updates = 0; |             int updates = 0; | ||||||
| 
 | 
 | ||||||
|             updatedEntityCount = world.UpdatedObjects.Count; |             updatedEntityCount = world.UpdatedObjects.Length; | ||||||
|             updatedEntities = new List<BulletXNA.EntityProperties>(world.UpdatedObjects); |             updatedEntities = (world.UpdatedObjects); | ||||||
|             updatedEntityCount = updatedEntities.Count; |             updatedEntityCount = updatedEntities.Length; | ||||||
|             world.UpdatedObjects.Clear(); |             //world.UpdatedObjects = ; | ||||||
|              |              | ||||||
| 
 | 
 | ||||||
|             collidersCount = world.UpdatedCollisions.Count; |             collidersCount = world.UpdatedCollisions.Length; | ||||||
|             colliders = new List<BulletXNA.CollisionDesc>(world.UpdatedCollisions); |             colliders = (world.UpdatedCollisions); | ||||||
| 
 | 
 | ||||||
|             world.UpdatedCollisions.Clear(); |             world.UpdatedCollisions = new BulletXNA.CollisionDesc[0]; | ||||||
|             m_collisionsThisFrame = 0; |             m_collisionsThisFrame = 0; | ||||||
|             int numManifolds = world.GetDispatcher().GetNumManifolds(); |             int numManifolds = world.GetDispatcher().GetNumManifolds(); | ||||||
|             for (int j = 0; j < numManifolds; j++) |             for (int j = 0; j < numManifolds; j++) | ||||||
|  | @ -1501,10 +1501,10 @@ static class BulletSimAPI { | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             //if (updatedEntities is null) |             //if (updatedEntities is null) | ||||||
|             updatedEntities = new List<BulletXNA.EntityProperties>(); |             updatedEntities = new BulletXNA.EntityProperties[0]; | ||||||
|             updatedEntityCount = 0; |             updatedEntityCount = 0; | ||||||
|             //if (colliders is null) |             //if (colliders is null) | ||||||
|             colliders = new List<BulletXNA.CollisionDesc>(); |             colliders = new BulletXNA.CollisionDesc[0]; | ||||||
|             collidersCount = 0; |             collidersCount = 0; | ||||||
|         } |         } | ||||||
|         return numSimSteps; |         return numSimSteps; | ||||||
|  | @ -1538,7 +1538,8 @@ static class BulletSimAPI { | ||||||
|                                                 point = contact, |                                                 point = contact, | ||||||
|                                                 normal = contactNormal |                                                 normal = contactNormal | ||||||
|                                             }; |                                             }; | ||||||
|         world.UpdatedCollisions.Add(cDesc); |         if (world.LastCollisionDesc < world.UpdatedCollisions.Length) | ||||||
|  |             world.UpdatedCollisions[world.LastCollisionDesc++] = (cDesc); | ||||||
|         m_collisionsThisFrame++; |         m_collisionsThisFrame++; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 teravus
						teravus