From 82b954b2125acf3c3647422fbbe543e96b6d4e91 Mon Sep 17 00:00:00 2001 From: teravus Date: Sun, 20 Jan 2013 08:06:15 -0500 Subject: * Tweak the BulletSimN API a bit. --- OpenSim/Region/Physics/BulletSNPlugin/BSScene.cs | 8 +++---- .../Region/Physics/BulletSNPlugin/BulletSimAPI.cs | 27 +++++++++++----------- 2 files changed, 18 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSNPlugin') diff --git a/OpenSim/Region/Physics/BulletSNPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSNPlugin/BSScene.cs index 1a7c34b..4fc3e2a 100644 --- a/OpenSim/Region/Physics/BulletSNPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSNPlugin/BSScene.cs @@ -106,11 +106,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters // Pinned memory used to pass step information between managed and unmanaged internal int m_maxCollisionsPerFrame; - private List m_collisionArray; + private BulletXNA.CollisionDesc[] m_collisionArray; //private GCHandle m_collisionArrayPinnedHandle; internal int m_maxUpdatesPerFrame; - private List m_updateArray; + private BulletXNA.EntityProperties[] m_updateArray; //private GCHandle m_updateArrayPinnedHandle; @@ -201,9 +201,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters GetInitialParameterValues(config); // allocate more pinned memory close to the above in an attempt to get the memory all together - m_collisionArray = new List(); + m_collisionArray = new BulletXNA.CollisionDesc[0]; //m_collisionArrayPinnedHandle = GCHandle.Alloc(m_collisionArray, GCHandleType.Pinned); - m_updateArray = new List(); + m_updateArray = new BulletXNA.EntityProperties[0]; //m_updateArrayPinnedHandle = GCHandle.Alloc(m_updateArray, GCHandleType.Pinned); // Enable very detailed logging. diff --git a/OpenSim/Region/Physics/BulletSNPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSNPlugin/BulletSimAPI.cs index 93643c9..ba96905 100644 --- a/OpenSim/Region/Physics/BulletSNPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSNPlugin/BulletSimAPI.cs @@ -894,7 +894,7 @@ static class BulletSimAPI { return capsuleShapeZ; } - public static object Initialize2(Vector3 worldExtent, ConfigurationParameters[] o, int mMaxCollisionsPerFrame, ref List collisionArray, int mMaxUpdatesPerFrame, ref List 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(); @@ -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 updatedEntities, out int collidersCount, out Listcolliders) + 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, out collidersCount, out colliders); return epic; } - private static int PhysicsStepint2(object pWorld,float timeStep, int m_maxSubSteps, float m_fixedTimeStep, out int updatedEntityCount, out List updatedEntities, out int collidersCount, out List 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; @@ -1462,16 +1462,16 @@ static class BulletSimAPI { numSimSteps = world.StepSimulation(timeStep, m_maxSubSteps, m_fixedTimeStep); int updates = 0; - updatedEntityCount = world.UpdatedObjects.Count; - updatedEntities = new List(world.UpdatedObjects); - updatedEntityCount = updatedEntities.Count; - world.UpdatedObjects.Clear(); + updatedEntityCount = world.UpdatedObjects.Length; + updatedEntities = (world.UpdatedObjects); + updatedEntityCount = updatedEntities.Length; + //world.UpdatedObjects = ; - collidersCount = world.UpdatedCollisions.Count; - colliders = new List(world.UpdatedCollisions); + collidersCount = world.UpdatedCollisions.Length; + colliders = (world.UpdatedCollisions); - world.UpdatedCollisions.Clear(); + world.UpdatedCollisions = new BulletXNA.CollisionDesc[0]; m_collisionsThisFrame = 0; int numManifolds = world.GetDispatcher().GetNumManifolds(); for (int j = 0; j < numManifolds; j++) @@ -1501,10 +1501,10 @@ static class BulletSimAPI { else { //if (updatedEntities is null) - updatedEntities = new List(); + updatedEntities = new BulletXNA.EntityProperties[0]; updatedEntityCount = 0; //if (colliders is null) - colliders = new List(); + colliders = new BulletXNA.CollisionDesc[0]; collidersCount = 0; } return numSimSteps; @@ -1538,7 +1538,8 @@ static class BulletSimAPI { point = contact, normal = contactNormal }; - world.UpdatedCollisions.Add(cDesc); + if (world.LastCollisionDesc < world.UpdatedCollisions.Length) + world.UpdatedCollisions[world.LastCollisionDesc++] = (cDesc); m_collisionsThisFrame++; -- cgit v1.1