Browse Source

BulletSim: first round of conversion from direct BulletSimAPI interfacing by BulletSim core to using the BulletSimAPITemplate. Physical object creation and destruction first.

Robert Adams 11 years ago
parent
commit
48f718f39f

+ 3 - 5
OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs

@@ -210,8 +210,7 @@ public sealed class BSCharacter : BSPhysObject
             if (!Flying && !IsColliding)
             {
                 stepVelocity.Z = _velocity.Z;
-                DetailLog("{0},BSCharacter.MoveMotor,taint,overrideStepZWithWorldZ,stepVel={1}",
-                            LocalID, stepVelocity);
+                // DetailLog("{0},BSCharacter.MoveMotor,taint,overrideStepZWithWorldZ,stepVel={1}", LocalID, stepVelocity);
             }
 
             // 'stepVelocity' is now the speed we'd like the avatar to move in. Turn that into an instantanous force.
@@ -231,8 +230,7 @@ public sealed class BSCharacter : BSPhysObject
                 AddForce(moveForce, false, true);
             }
             */
-            DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}",
-                                    LocalID, stepVelocity, _velocity, Mass, moveForce);
+            // DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", LocalID, stepVelocity, _velocity, Mass, moveForce);
             AddForce(moveForce, false, true);
         });
     }
@@ -736,7 +734,7 @@ public sealed class BSCharacter : BSPhysObject
             PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate()
             {
                 // Bullet adds this central force to the total force for this tick
-                DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce);
+                // DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce);
                 if (PhysBody.HasPhysicalBody)
                 {
                     BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, addForce);

+ 3 - 3
OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs

@@ -359,7 +359,7 @@ public sealed class BSLinksetCompound : BSLinkset
                         PhysicsScene.Shapes.CreateGeomMeshOrHull(cPrim, null);
                         BulletShape newShape = cPrim.PhysShape;
                         cPrim.PhysShape = saveShape;
-                        BulletSimAPI.AddChildShapeToCompoundShape2(LinksetRoot.PhysShape.ptr, newShape.ptr, lci.OffsetPos, lci.OffsetRot);
+                        PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, newShape, lci.OffsetPos, lci.OffsetRot);
                     }
                     else
                     {
@@ -371,7 +371,7 @@ public sealed class BSLinksetCompound : BSLinkset
                             PhysicsScene.Logger.ErrorFormat("{0} Rebuilt sharable shape when building linkset! Region={1}, primID={2}, shape={3}",
                                                 LogHeader, PhysicsScene.RegionName, cPrim.LocalID, cPrim.PhysShape);
                         }
-                        BulletSimAPI.AddChildShapeToCompoundShape2(LinksetRoot.PhysShape.ptr, cPrim.PhysShape.ptr, lci.OffsetPos, lci.OffsetRot);
+                        PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, cPrim.PhysShape, lci.OffsetPos, lci.OffsetRot);
                     }
                 }
                 return false;   // 'false' says to move onto the next child in the list
@@ -386,7 +386,7 @@ public sealed class BSLinksetCompound : BSLinkset
             Rebuilding = false;
         }
 
-        BulletSimAPI.RecalculateCompoundShapeLocalAabb2(LinksetRoot.PhysShape.ptr);
+        PhysicsScene.PE.RecalculateCompoundShapeLocalAabb(LinksetRoot.PhysShape);
 
         // DEBUG: see of inter-linkset collisions are causing problems for constraint linksets.
         // BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr, 

+ 1 - 1
OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs

@@ -845,7 +845,7 @@ public sealed class BSPrim : BSPhysObject
     //     the functions after this one set up the state of a possibly newly created collision body.
     private void MakeSolid(bool makeSolid)
     {
-        CollisionObjectTypes bodyType = (CollisionObjectTypes)BulletSimAPI.GetBodyType2(PhysBody.ptr);
+        CollisionObjectTypes bodyType = (CollisionObjectTypes)PhysicsScene.PE.GetBodyType(PhysBody);
         if (makeSolid)
         {
             // Verify the previous code created the correct shape for this type of thing.

+ 8 - 2
OpenSim/Region/Physics/BulletSPlugin/BSScene.cs

@@ -50,6 +50,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
 
     public string BulletSimVersion = "?";
 
+    // The handle to the underlying managed or unmanaged version of Bullet being used.
+    public BulletSimAPITemplate PE;
+
     public Dictionary<uint, BSPhysObject> PhysObjects;
     public BSShapeCollection Shapes;
 
@@ -187,12 +190,15 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
 
         // Allocate pinned memory to pass parameters.
         UnmanagedParams = new ConfigurationParameters[1];
-        m_paramsHandle = GCHandle.Alloc(UnmanagedParams, GCHandleType.Pinned);
 
         // Set default values for physics parameters plus any overrides from the ini file
         GetInitialParameterValues(config);
 
-        // allocate more pinned memory close to the above in an attempt to get the memory all together
+        // For the moment, only one version of the interface
+        PE = new BSAPIUnman();
+
+        // Allocate more pinned memory. Do this early to try and get all pinned memory close together.
+        m_paramsHandle = GCHandle.Alloc(UnmanagedParams, GCHandleType.Pinned);
         m_collisionArray = new CollisionDesc[m_maxCollisionsPerFrame];
         m_collisionArrayPinnedHandle = GCHandle.Alloc(m_collisionArray, GCHandleType.Pinned);
         m_updateArray = new EntityProperties[m_maxUpdatesPerFrame];

+ 28 - 35
OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs

@@ -174,7 +174,7 @@ public sealed class BSShapeCollection : IDisposable
 
                 // Zero any reference to the shape so it is not freed when the body is deleted.
                 BulletSimAPI.SetCollisionShape2(PhysicsScene.World.ptr, body.ptr, IntPtr.Zero);
-                BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, body.ptr);
+                PhysicsScene.PE.DestroyObject(PhysicsScene.World, body);
             });
         }
     }
@@ -261,7 +261,7 @@ public sealed class BSShapeCollection : IDisposable
                     if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,ptr={1},taintTime={2}",
                                     BSScene.DetailLogZero, shape.ptr.ToString("X"), inTaintTime);
                     if (shapeCallback != null) shapeCallback(shape);
-                    BulletSimAPI.DeleteCollisionShape2(PhysicsScene.World.ptr, shape.ptr);
+                    PhysicsScene.PE.DeleteCollisionShape(PhysicsScene.World, shape);
                 }
                 else
                 {
@@ -342,26 +342,26 @@ public sealed class BSShapeCollection : IDisposable
             return;
         }
 
-        int numChildren = BulletSimAPI.GetNumberOfCompoundChildren2(shape.ptr);
+        int numChildren = PhysicsScene.PE.GetNumberOfCompoundChildren(shape);
         if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceCompound,shape={1},children={2}", BSScene.DetailLogZero, shape, numChildren);
 
         for (int ii = numChildren - 1; ii >= 0; ii--)
         {
-            IntPtr childShape = BulletSimAPI.RemoveChildShapeFromCompoundShapeIndex2(shape.ptr, ii);
+            BulletShape childShape = PhysicsScene.PE.RemoveChildShapeFromCompoundShapeIndex(shape, ii);
             DereferenceAnonCollisionShape(childShape);
         }
-        BulletSimAPI.DeleteCollisionShape2(PhysicsScene.World.ptr, shape.ptr);
+        PhysicsScene.PE.DeleteCollisionShape(PhysicsScene.World, shape);
     }
 
     // Sometimes we have a pointer to a collision shape but don't know what type it is.
     // Figure out type and call the correct dereference routine.
     // Called at taint-time.
-    private void DereferenceAnonCollisionShape(IntPtr cShape)
+    private void DereferenceAnonCollisionShape(BulletShape shapeInfo)
     {
         MeshDesc meshDesc;
         HullDesc hullDesc;
 
-        BulletShape shapeInfo = new BulletShape(cShape);
+        IntPtr cShape = shapeInfo.ptr;
         if (TryGetMeshByPtr(cShape, out meshDesc))
         {
             shapeInfo.type = BSPhysicsShapeType.SHAPE_MESH;
@@ -382,7 +382,7 @@ public sealed class BSShapeCollection : IDisposable
                 }
                 else
                 {
-                    if (BulletSimAPI.IsNativeShape2(cShape))
+                    if (PhysicsScene.PE.IsNativeShape(shapeInfo))
                     {
                         shapeInfo.isNativeShape = true;
                         shapeInfo.type = BSPhysicsShapeType.SHAPE_BOX; // (technically, type doesn't matter)
@@ -570,19 +570,15 @@ public sealed class BSShapeCollection : IDisposable
 
         if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE)
         {
-            // The proper scale has been calculated in the prim.
-            newShape = new BulletShape(
-                        // Bullet's capsule total height is the passed "height + (radius * 2)" so, the base
-                        //     capsule is radius of 0.5f (1 diameter) and height of two (1.0f + 0.5f * 2)".
-                        //     This must be taken into account when computing the scaling of the capsule.
-                        BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1f, 1f, prim.Scale)
-                        , shapeType);
+
+            newShape = PhysicsScene.PE.BuildCapsuleShape(PhysicsScene.World, 1f, 1f, prim.Scale);
             if (DDetail) DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale);
         }
         else
         {
             // Native shapes are scaled in Bullet so set the scaling to the size
-            newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, nativeShapeData), shapeType);
+            newShape = PhysicsScene.PE.BuildNativeShape(PhysicsScene.World, nativeShapeData);
+
         }
         if (!newShape.HasPhysicalShape)
         {
@@ -629,13 +625,14 @@ public sealed class BSShapeCollection : IDisposable
 
     private BulletShape CreatePhysicalMesh(string objName, System.UInt64 newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod)
     {
+        BulletShape newShape = new BulletShape();
         IMesh meshData = null;
-        IntPtr meshPtr = IntPtr.Zero;
+
         MeshDesc meshDesc;
         if (Meshes.TryGetValue(newMeshKey, out meshDesc))
         {
             // If the mesh has already been built just use it.
-            meshPtr = meshDesc.ptr;
+            newShape = new BulletShape(meshDesc.ptr, BSPhysicsShapeType.SHAPE_MESH);
         }
         else
         {
@@ -658,11 +655,10 @@ public sealed class BSShapeCollection : IDisposable
                 // m_log.DebugFormat("{0}: BSShapeCollection.CreatePhysicalMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}",
                 //                  LogHeader, prim.LocalID, newMeshKey, indices.Length, vertices.Count);
 
-                meshPtr = BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr,
+                newShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World,
                                     indices.GetLength(0), indices, vertices.Count, verticesAsFloats);
             }
         }
-        BulletShape newShape = new BulletShape(meshPtr, BSPhysicsShapeType.SHAPE_MESH);
         newShape.shapeKey = newMeshKey;
 
         return newShape;
@@ -700,12 +696,14 @@ public sealed class BSShapeCollection : IDisposable
     private BulletShape CreatePhysicalHull(string objName, System.UInt64 newHullKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod)
     {
 
+        BulletShape newShape = new BulletShape();
         IntPtr hullPtr = IntPtr.Zero;
+
         HullDesc hullDesc;
         if (Hulls.TryGetValue(newHullKey, out hullDesc))
         {
             // If the hull shape already is created, just use it.
-            hullPtr = hullDesc.ptr;
+            newShape = new BulletShape(hullDesc.ptr, BSPhysicsShapeType.SHAPE_HULL);
         }
         else
         {
@@ -793,11 +791,10 @@ public sealed class BSShapeCollection : IDisposable
                     }
                 }
                 // create the hull data structure in Bullet
-                hullPtr = BulletSimAPI.CreateHullShape2(PhysicsScene.World.ptr, hullCount, convHulls);
+                newShape = PhysicsScene.PE.CreateHullShape(PhysicsScene.World, hullCount, convHulls);
             }
         }
 
-        BulletShape newShape = new BulletShape(hullPtr, BSPhysicsShapeType.SHAPE_HULL);
         newShape.shapeKey = newHullKey;
 
         return newShape;
@@ -819,12 +816,12 @@ public sealed class BSShapeCollection : IDisposable
         // Don't need to do this as the shape is freed when the new root shape is created below.
         // DereferenceShape(prim.PhysShape, true, shapeCallback);
 
-        BulletShape cShape = new BulletShape(
-            BulletSimAPI.CreateCompoundShape2(PhysicsScene.World.ptr, false), BSPhysicsShapeType.SHAPE_COMPOUND);
+
+        BulletShape cShape = PhysicsScene.PE.CreateCompoundShape(PhysicsScene.World, false);
 
         // Create the shape for the root prim and add it to the compound shape. Cannot be a native shape.
         CreateGeomMeshOrHull(prim, shapeCallback);
-        BulletSimAPI.AddChildShapeToCompoundShape2(cShape.ptr, prim.PhysShape.ptr, OMV.Vector3.Zero, OMV.Quaternion.Identity);
+        PhysicsScene.PE.AddChildShapeToCompoundShape(cShape, prim.PhysShape, OMV.Vector3.Zero, OMV.Quaternion.Identity);
         if (DDetail) DetailLog("{0},BSShapeCollection.GetReferenceToCompoundShape,addRootPrim,compShape={1},rootShape={2}",
                                     prim.LocalID, cShape, prim.PhysShape);
 
@@ -932,7 +929,7 @@ public sealed class BSShapeCollection : IDisposable
         // If not a solid object, body is a GhostObject. Otherwise a RigidBody.
         if (!mustRebuild)
         {
-            CollisionObjectTypes bodyType = (CollisionObjectTypes)BulletSimAPI.GetBodyType2(prim.PhysBody.ptr);
+            CollisionObjectTypes bodyType = (CollisionObjectTypes)PhysicsScene.PE.GetBodyType(prim.PhysBody);
             if (prim.IsSolid && bodyType != CollisionObjectTypes.CO_RIGID_BODY
                 || !prim.IsSolid && bodyType != CollisionObjectTypes.CO_GHOST_OBJECT)
             {
@@ -947,20 +944,16 @@ public sealed class BSShapeCollection : IDisposable
             DereferenceBody(prim.PhysBody, true, bodyCallback);
 
             BulletBody aBody;
-            IntPtr bodyPtr = IntPtr.Zero;
             if (prim.IsSolid)
             {
-                bodyPtr = BulletSimAPI.CreateBodyFromShape2(sim.ptr, shape.ptr,
-                                        prim.LocalID, prim.RawPosition, prim.RawOrientation);
-                if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,mesh,ptr={1}", prim.LocalID, bodyPtr.ToString("X"));
+                aBody = PhysicsScene.PE.CreateBodyFromShape(sim, shape, prim.LocalID, prim.RawPosition, prim.RawOrientation);
+                if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,mesh,body={1}", prim.LocalID, aBody);
             }
             else
             {
-                bodyPtr = BulletSimAPI.CreateGhostFromShape2(sim.ptr, shape.ptr,
-                                        prim.LocalID, prim.RawPosition, prim.RawOrientation);
-                if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,ghost,ptr={1}", prim.LocalID, bodyPtr.ToString("X"));
+                aBody = PhysicsScene.PE.CreateGhostFromShape(sim, shape, prim.LocalID, prim.RawPosition, prim.RawOrientation);
+                if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,ghost,body={1}", prim.LocalID, aBody);
             }
-            aBody = new BulletBody(prim.LocalID, bodyPtr);
 
             ReferenceBody(aBody, true);
 

+ 6 - 1
OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs

@@ -126,7 +126,8 @@ public class BSShapeNative : BSShape
                     BSPhysicsShapeType shapeType, FixedShapeKey shapeKey) 
     {
         // Native shapes are not shared and are always built anew.
-        return new BSShapeNative(physicsScene, prim, shapeType, shapeKey);
+        //return new BSShapeNative(physicsScene, prim, shapeType, shapeKey);
+        return null;
     }
 
     private BSShapeNative(BSScene physicsScene, BSPhysObject prim,
@@ -141,6 +142,7 @@ public class BSShapeNative : BSShape
         nativeShapeData.HullKey = (ulong)shapeKey;
 
        
+        /*
         if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE)
         {
             ptr = BulletSimAPI.BuildCapsuleShape2(physicsScene.World.ptr, 1f, 1f, prim.Scale);
@@ -157,15 +159,18 @@ public class BSShapeNative : BSShape
         }
         type = shapeType;
         key = (UInt64)shapeKey;
+         */
     }
     // Make this reference to the physical shape go away since native shapes are not shared.
     public override void Dereference(BSScene physicsScene)
     {
+        /*
         // Native shapes are not tracked and are released immediately
         physicsScene.DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,shape={1}", BSScene.DetailLogZero, this);
         BulletSimAPI.DeleteCollisionShape2(physicsScene.World.ptr, ptr);
         ptr = IntPtr.Zero;
         // Garbage collection will free up this instance.
+         */
     }
 }
 

+ 3 - 4
OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs

@@ -105,9 +105,8 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
         centerPos.Y = m_mapInfo.minCoords.Y + (m_mapInfo.sizeY / 2f);
         centerPos.Z = m_mapInfo.minZ + ((m_mapInfo.maxZ - m_mapInfo.minZ) / 2f);
 
-        m_mapInfo.terrainBody = new BulletBody(m_mapInfo.ID,
-                BulletSimAPI.CreateBodyWithDefaultMotionState2(m_mapInfo.terrainShape.ptr,
-                                            m_mapInfo.ID, centerPos, Quaternion.Identity));
+        m_mapInfo.terrainBody = PhysicsScene.PE.CreateBodyWithDefaultMotionState(m_mapInfo.terrainShape, 
+                                m_mapInfo.ID, centerPos, Quaternion.Identity);
 
         // Set current terrain attributes
         BulletSimAPI.SetFriction2(m_mapInfo.terrainBody.ptr, BSParam.TerrainFriction);
@@ -139,7 +138,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
             {
                 BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr);
                 // Frees both the body and the shape.
-                BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr);
+                PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_mapInfo.terrainBody);
                 BulletSimAPI.ReleaseHeightMapInfo2(m_mapInfo.Ptr);
             }
         }

+ 4 - 4
OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs

@@ -137,9 +137,9 @@ public sealed class BSTerrainManager : IDisposable
                     BulletSimAPI.CreateGroundPlaneShape2(BSScene.GROUNDPLANE_ID, 1f, 
                                     BSParam.TerrainCollisionMargin),
                     BSPhysicsShapeType.SHAPE_GROUNDPLANE);
-        m_groundPlane = new BulletBody(BSScene.GROUNDPLANE_ID,
-                        BulletSimAPI.CreateBodyWithDefaultMotionState2(groundPlaneShape.ptr, BSScene.GROUNDPLANE_ID,
-                                                            Vector3.Zero, Quaternion.Identity));
+        m_groundPlane = PhysicsScene.PE.CreateBodyWithDefaultMotionState(groundPlaneShape, 
+                                        BSScene.GROUNDPLANE_ID, Vector3.Zero, Quaternion.Identity);
+
         BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr);
         BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_groundPlane.ptr);
         // Ground plane does not move
@@ -160,7 +160,7 @@ public sealed class BSTerrainManager : IDisposable
         {
             if (BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr))
             {
-                BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_groundPlane.ptr);
+                PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_groundPlane);
             }
             m_groundPlane.Clear();
         }

+ 3 - 5
OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs

@@ -91,9 +91,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
         PhysicsScene.DetailLog("{0},BSTerrainMesh.create,meshed,indices={1},indSz={2},vertices={3},vertSz={4}", 
                                 ID, indicesCount, indices.Length, verticesCount, vertices.Length);
 
-        m_terrainShape = new BulletShape(BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr,
-                                                    indicesCount, indices, verticesCount, vertices),
-                                        BSPhysicsShapeType.SHAPE_MESH);
+        m_terrainShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World, indicesCount, indices, verticesCount, vertices);
         if (!m_terrainShape.HasPhysicalShape)
         {
             // DISASTER!!
@@ -106,7 +104,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
         Vector3 pos = regionBase;
         Quaternion rot = Quaternion.Identity;
 
-        m_terrainBody = new BulletBody(id, BulletSimAPI.CreateBodyWithDefaultMotionState2( m_terrainShape.ptr, ID, pos, rot));
+        m_terrainBody = PhysicsScene.PE.CreateBodyWithDefaultMotionState(m_terrainShape, ID, pos, rot);
         if (!m_terrainBody.HasPhysicalBody)
         {
             // DISASTER!!
@@ -143,7 +141,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
         {
             BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_terrainBody.ptr);
             // Frees both the body and the shape.
-            BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_terrainBody.ptr);
+            PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_terrainBody);
         }
     }
 

+ 169 - 778
OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs

@@ -292,985 +292,376 @@ public enum ConstraintParamAxis : int
 
 public abstract class BulletSimAPITemplate
 {
+    /*
 // Initialization and simulation
-public abstract BulletWorld Initialize2(Vector3 maxPosition, IntPtr parms,
+public abstract BulletWorld Initialize(Vector3 maxPosition, IntPtr parms,
 											int maxCollisions,  IntPtr collisionArray,
 											int maxUpdates, IntPtr updateArray
                                             );
 
-public abstract bool UpdateParameter2(BulletWorld world, uint localID, String parm, float value);
+public abstract bool UpdateParameter(BulletWorld world, uint localID, String parm, float value);
 
-public abstract void SetHeightMap2(BulletWorld world, float[] heightmap);
+public abstract void SetHeightMap(BulletWorld world, float[] heightmap);
 
-public abstract void Shutdown2(BulletWorld sim);
+public abstract void Shutdown(BulletWorld sim);
 
-public abstract int PhysicsStep2(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep,
+public abstract int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep,
                         out int updatedEntityCount,
                         out IntPtr updatedEntitiesPtr,
                         out int collidersCount,
                         out IntPtr collidersPtr);
 
-public abstract bool PushUpdate2(BulletBody obj);
+public abstract bool PushUpdate(BulletBody obj);
+     */
 
 // =====================================================================================
 // Mesh, hull, shape and body creation helper routines
-public abstract BulletShape CreateMeshShape2(BulletWorld world,
-                int indicesCount, [MarshalAs(UnmanagedType.LPArray)] int[] indices,
-                int verticesCount, [MarshalAs(UnmanagedType.LPArray)] float[] vertices );
+public abstract BulletShape CreateMeshShape(BulletWorld world,
+                int indicesCount, int[] indices,
+                int verticesCount, float[] vertices );
 
-public abstract BulletShape CreateHullShape2(BulletWorld world,
-                int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls);
+public abstract BulletShape CreateHullShape(BulletWorld world,
+                int hullCount, float[] hulls);
 
-public abstract BulletShape BuildHullShapeFromMesh2(BulletWorld world, BulletShape meshShape);
+public abstract BulletShape BuildHullShapeFromMesh(BulletWorld world, BulletShape meshShape);
 
-public abstract BulletShape BuildNativeShape2(BulletWorld world, ShapeData shapeData);
+public abstract BulletShape BuildNativeShape(BulletWorld world, ShapeData shapeData);
 
-public abstract bool IsNativeShape2(BulletShape shape);
+public abstract bool IsNativeShape(BulletShape shape);
 
 public abstract void SetShapeCollisionMargin(BulletShape shape, float margin);
 
-public abstract BulletShape BuildCapsuleShape2(BulletWorld world, float radius, float height, Vector3 scale);
-
-public abstract BulletShape CreateCompoundShape2(BulletWorld sim, bool enableDynamicAabbTree);
-
-public abstract int GetNumberOfCompoundChildren2(BulletShape cShape);
-
-public abstract void AddChildShapeToCompoundShape2(BulletShape cShape, BulletShape addShape, Vector3 pos, Quaternion rot);
-
-public abstract BulletShape GetChildShapeFromCompoundShapeIndex2(BulletShape cShape, int indx);
-
-public abstract BulletShape RemoveChildShapeFromCompoundShapeIndex2(BulletShape cShape, int indx);
-
-public abstract void RemoveChildShapeFromCompoundShape2(BulletShape cShape, BulletShape removeShape);
-
-public abstract void RecalculateCompoundShapeLocalAabb2(BulletShape cShape);
-
-public abstract BulletShape DuplicateCollisionShape2(BulletWorld sim, BulletShape srcShape, uint id);
-
-public abstract BulletBody CreateBodyFromShapeAndInfo2(BulletWorld sim, BulletShape shape, uint id, IntPtr constructionInfo);
-
-public abstract bool DeleteCollisionShape2(BulletWorld world, BulletShape shape);
-
-public abstract int GetBodyType2(BulletBody obj);
-
-public abstract BulletBody CreateBodyFromShape2(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot);
-
-public abstract BulletBody CreateBodyWithDefaultMotionState2(BulletShape shape, uint id, Vector3 pos, Quaternion rot);
-
-public abstract BulletBody CreateGhostFromShape2(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot);
-
-public abstract IntPtr AllocateBodyInfo2(BulletBody obj);
-
-public abstract void ReleaseBodyInfo2(IntPtr obj);
-
-public abstract void DestroyObject2(BulletWorld sim, BulletBody obj);
-
-// =====================================================================================
-// Terrain creation and helper routines
-public abstract IntPtr CreateHeightMapInfo2(BulletWorld sim, uint id, Vector3 minCoords, Vector3 maxCoords,
-        [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin);
-
-public abstract IntPtr FillHeightMapInfo2(BulletWorld sim, IntPtr mapInfo, uint id, Vector3 minCoords, Vector3 maxCoords,
-        [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin);
-
-public abstract bool ReleaseHeightMapInfo2(IntPtr heightMapInfo);
-
-public abstract BulletBody CreateGroundPlaneShape2(uint id, float height, float collisionMargin);
-
-public abstract BulletBody CreateTerrainShape2(IntPtr mapInfo);
-
-// =====================================================================================
-// Constraint creation and helper routines
-public abstract BulletConstraint Create6DofConstraint2(BulletWorld world, BulletBody obj1, BulletBody obj2,
-                    Vector3 frame1loc, Quaternion frame1rot,
-                    Vector3 frame2loc, Quaternion frame2rot,
-                    bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
-
-public abstract BulletConstraint Create6DofConstraintToPoint2(BulletWorld world, BulletBody obj1, BulletBody obj2,
-                    Vector3 joinPoint,
-                    bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
-
-public abstract BulletConstraint CreateHingeConstraint2(BulletWorld world, BulletBody obj1, BulletBody obj2,
-                    Vector3 pivotinA, Vector3 pivotinB,
-                    Vector3 axisInA, Vector3 axisInB,
-                    bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
-
-public abstract void SetConstraintEnable2(BulletConstraint constrain, float numericTrueFalse);
-
-public abstract void SetConstraintNumSolverIterations2(BulletConstraint constrain, float iterations);
-
-public abstract bool SetFrames2(BulletConstraint constrain,
-                Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot);
-
-public abstract bool SetLinearLimits2(BulletConstraint constrain, Vector3 low, Vector3 hi);
-
-public abstract bool SetAngularLimits2(BulletConstraint constrain, Vector3 low, Vector3 hi);
-
-public abstract bool UseFrameOffset2(BulletConstraint constrain, float enable);
-
-public abstract bool TranslationalLimitMotor2(BulletConstraint constrain, float enable, float targetVel, float maxMotorForce);
-
-public abstract bool SetBreakingImpulseThreshold2(BulletConstraint constrain, float threshold);
-
-public abstract bool CalculateTransforms2(BulletConstraint constrain);
-
-public abstract bool SetConstraintParam2(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis);
-
-public abstract bool DestroyConstraint2(BulletWorld world, BulletConstraint constrain);
-
-// =====================================================================================
-// btCollisionWorld entries
-public abstract void UpdateSingleAabb2(BulletWorld world, BulletBody obj);
-
-public abstract void UpdateAabbs2(BulletWorld world);
-
-public abstract bool GetForceUpdateAllAabbs2(BulletWorld world);
-
-public abstract void SetForceUpdateAllAabbs2(BulletWorld world, bool force);
-
-// =====================================================================================
-// btDynamicsWorld entries
-public abstract bool AddObjectToWorld2(BulletWorld world, BulletBody obj);
-
-public abstract bool RemoveObjectFromWorld2(BulletWorld world, BulletBody obj);
-
-public abstract bool AddConstraintToWorld2(BulletWorld world, BulletConstraint constrain, bool disableCollisionsBetweenLinkedObjects);
-
-public abstract bool RemoveConstraintFromWorld2(BulletWorld world, BulletConstraint constrain);
-// =====================================================================================
-// btCollisionObject entries
-public abstract Vector3 GetAnisotripicFriction2(BulletConstraint constrain);
-
-public abstract Vector3 SetAnisotripicFriction2(BulletConstraint constrain, Vector3 frict);
-
-public abstract bool HasAnisotripicFriction2(BulletConstraint constrain);
-
-public abstract void SetContactProcessingThreshold2(BulletBody obj, float val);
-
-public abstract float GetContactProcessingThreshold2(BulletBody obj);
-
-public abstract bool IsStaticObject2(BulletBody obj);
-
-public abstract bool IsKinematicObject2(BulletBody obj);
-
-public abstract bool IsStaticOrKinematicObject2(BulletBody obj);
-
-public abstract bool HasContactResponse2(BulletBody obj);
-
-public abstract void SetCollisionShape2(BulletWorld sim, BulletBody obj, BulletBody shape);
-
-public abstract BulletShape GetCollisionShape2(BulletBody obj);
-
-public abstract int GetActivationState2(BulletBody obj);
-
-public abstract void SetActivationState2(BulletBody obj, int state);
-
-public abstract void SetDeactivationTime2(BulletBody obj, float dtime);
-
-public abstract float GetDeactivationTime2(BulletBody obj);
-
-public abstract void ForceActivationState2(BulletBody obj, ActivationState state);
-
-public abstract void Activate2(BulletBody obj, bool forceActivation);
-
-public abstract bool IsActive2(BulletBody obj);
-
-public abstract void SetRestitution2(BulletBody obj, float val);
-
-public abstract float GetRestitution2(BulletBody obj);
-
-public abstract void SetFriction2(BulletBody obj, float val);
-
-public abstract float GetFriction2(BulletBody obj);
-
-    /* Haven't defined the type 'Transform'
-public abstract Transform GetWorldTransform2(BulletBody obj);
-
-public abstract void setWorldTransform2(BulletBody obj, Transform trans);
-     */
-
-public abstract Vector3 GetPosition2(BulletBody obj);
-
-public abstract Quaternion GetOrientation2(BulletBody obj);
-
-public abstract void SetTranslation2(BulletBody obj, Vector3 position, Quaternion rotation);
-
-public abstract IntPtr GetBroadphaseHandle2(BulletBody obj);
-
-public abstract void SetBroadphaseHandle2(BulletBody obj, IntPtr handle);
-
-    /*
-public abstract Transform GetInterpolationWorldTransform2(IntPtr obj);
-
-public abstract void SetInterpolationWorldTransform2(IntPtr obj, Transform trans);
-     */
-
-public abstract void SetInterpolationLinearVelocity2(BulletBody obj, Vector3 vel);
-
-public abstract void SetInterpolationAngularVelocity2(BulletBody obj, Vector3 vel);
-
-public abstract void SetInterpolationVelocity2(BulletBody obj, Vector3 linearVel, Vector3 angularVel);
-
-public abstract float GetHitFraction2(BulletBody obj);
-
-public abstract void SetHitFraction2(BulletBody obj, float val);
-
-public abstract CollisionFlags GetCollisionFlags2(BulletBody obj);
-
-public abstract CollisionFlags SetCollisionFlags2(BulletBody obj, CollisionFlags flags);
-
-public abstract CollisionFlags AddToCollisionFlags2(BulletBody obj, CollisionFlags flags);
-
-public abstract CollisionFlags RemoveFromCollisionFlags2(BulletBody obj, CollisionFlags flags);
-
-public abstract float GetCcdMotionThreshold2(BulletBody obj);
-
-public abstract void SetCcdMotionThreshold2(BulletBody obj, float val);
-
-public abstract float GetCcdSweptSphereRadius2(BulletBody obj);
-
-public abstract void SetCcdSweptSphereRadius2(BulletBody obj, float val);
-
-public abstract IntPtr GetUserPointer2(BulletBody obj);
-
-public abstract void SetUserPointer2(BulletBody obj, IntPtr val);
-
-// =====================================================================================
-// btRigidBody entries
-public abstract void ApplyGravity2(BulletBody obj);
-
-public abstract void SetGravity2(BulletBody obj, Vector3 val);
-
-public abstract Vector3 GetGravity2(BulletBody obj);
-
-public abstract void SetDamping2(BulletBody obj, float lin_damping, float ang_damping);
-
-public abstract void SetLinearDamping2(BulletBody obj, float lin_damping);
-
-public abstract void SetAngularDamping2(BulletBody obj, float ang_damping);
-
-public abstract float GetLinearDamping2(BulletBody obj);
+public abstract BulletShape BuildCapsuleShape(BulletWorld world, float radius, float height, Vector3 scale);
 
-public abstract float GetAngularDamping2(BulletBody obj);
+public abstract BulletShape CreateCompoundShape(BulletWorld sim, bool enableDynamicAabbTree);
 
-public abstract float GetLinearSleepingThreshold2(BulletBody obj);
+public abstract int GetNumberOfCompoundChildren(BulletShape cShape);
 
+public abstract void AddChildShapeToCompoundShape(BulletShape cShape, BulletShape addShape, Vector3 pos, Quaternion rot);
 
-public abstract void ApplyDamping2(BulletBody obj, float timeStep);
+public abstract BulletShape GetChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx);
 
-public abstract void SetMassProps2(BulletBody obj, float mass, Vector3 inertia);
+public abstract BulletShape RemoveChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx);
 
-public abstract Vector3 GetLinearFactor2(BulletBody obj);
+public abstract void RemoveChildShapeFromCompoundShape(BulletShape cShape, BulletShape removeShape);
 
-public abstract void SetLinearFactor2(BulletBody obj, Vector3 factor);
+public abstract void RecalculateCompoundShapeLocalAabb(BulletShape cShape);
 
-    /*
-public abstract void SetCenterOfMassTransform2(BulletBody obj, Transform trans);
-     */
-
-public abstract void SetCenterOfMassByPosRot2(BulletBody obj, Vector3 pos, Quaternion rot);
-
-// Add a force to the object as if its mass is one.
-public abstract void ApplyCentralForce2(BulletBody obj, Vector3 force);
-
-// Set the force being applied to the object as if its mass is one.
-public abstract void SetObjectForce2(BulletBody obj, Vector3 force);
-
-public abstract Vector3 GetTotalForce2(BulletBody obj);
+public abstract BulletShape DuplicateCollisionShape(BulletWorld sim, BulletShape srcShape, uint id);
 
-public abstract Vector3 GetTotalTorque2(BulletBody obj);
+public abstract BulletBody CreateBodyFromShapeAndInfo(BulletWorld sim, BulletShape shape, uint id, IntPtr constructionInfo);
 
-public abstract Vector3 GetInvInertiaDiagLocal2(BulletBody obj);
+public abstract bool DeleteCollisionShape(BulletWorld world, BulletShape shape);
 
-public abstract void SetInvInertiaDiagLocal2(BulletBody obj, Vector3 inert);
+public abstract int GetBodyType(BulletBody obj);
 
-public abstract void SetSleepingThresholds2(BulletBody obj, float lin_threshold, float ang_threshold);
+public abstract BulletBody CreateBodyFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot);
 
-public abstract void ApplyTorque2(BulletBody obj, Vector3 torque);
-
-// Apply force at the given point. Will add torque to the object.
-public abstract void ApplyForce2(BulletBody obj, Vector3 force, Vector3 pos);
-
-// Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass.
-public abstract void ApplyCentralImpulse2(BulletBody obj, Vector3 imp);
-
-// Apply impulse to the object's torque. Force is scaled by object's mass.
-public abstract void ApplyTorqueImpulse2(BulletBody obj, Vector3 imp);
-
-// Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces.
-public abstract void ApplyImpulse2(BulletBody obj, Vector3 imp, Vector3 pos);
+public abstract BulletBody CreateBodyWithDefaultMotionState(BulletShape shape, uint id, Vector3 pos, Quaternion rot);
 
-public abstract void ClearForces2(BulletBody obj);
+public abstract BulletBody CreateGhostFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot);
 
-public abstract void ClearAllForces2(BulletBody obj);
+public abstract IntPtr AllocateBodyInfo(BulletBody obj);
 
-public abstract void UpdateInertiaTensor2(BulletBody obj);
+public abstract void ReleaseBodyInfo(IntPtr obj);
 
+public abstract void DestroyObject(BulletWorld sim, BulletBody obj);
 
     /*
-public abstract Transform GetCenterOfMassTransform2(BulletBody obj);
-     */
-
-public abstract Vector3 GetLinearVelocity2(BulletBody obj);
-
-public abstract Vector3 GetAngularVelocity2(BulletBody obj);
-
-public abstract void SetLinearVelocity2(BulletBody obj, Vector3 val);
-
-public abstract void SetAngularVelocity2(BulletBody obj, Vector3 angularVelocity);
-
-public abstract Vector3 GetVelocityInLocalPoint2(BulletBody obj, Vector3 pos);
-
-public abstract void Translate2(BulletBody obj, Vector3 trans);
-
-public abstract void UpdateDeactivation2(BulletBody obj, float timeStep);
-
-public abstract bool WantsSleeping2(BulletBody obj);
-
-public abstract void SetAngularFactor2(BulletBody obj, float factor);
-
-public abstract void SetAngularFactorV2(BulletBody obj, Vector3 factor);
-
-public abstract Vector3 GetAngularFactor2(BulletBody obj);
-
-public abstract bool IsInWorld2(BulletBody obj);
-
-public abstract void AddConstraintRef2(BulletBody obj, BulletConstraint constrain);
-
-public abstract void RemoveConstraintRef2(BulletBody obj, BulletConstraint constrain);
-
-public abstract BulletConstraint GetConstraintRef2(BulletBody obj, int index);
-
-public abstract int GetNumConstraintRefs2(BulletBody obj);
-
-public abstract bool SetCollisionGroupMask2(BulletBody body, uint filter, uint mask);
-
-// =====================================================================================
-// btCollisionShape entries
-
-public abstract float GetAngularMotionDisc2(BulletShape shape);
-
-public abstract float GetContactBreakingThreshold2(BulletShape shape, float defaultFactor);
-
-public abstract bool IsPolyhedral2(BulletShape shape);
-
-public abstract bool IsConvex2d2(BulletShape shape);
-
-public abstract bool IsConvex2(BulletShape shape);
-
-public abstract bool IsNonMoving2(BulletShape shape);
-
-public abstract bool IsConcave2(BulletShape shape);
-
-public abstract bool IsCompound2(BulletShape shape);
-
-public abstract bool IsSoftBody2(BulletShape shape);
-
-public abstract bool IsInfinite2(BulletShape shape);
-
-public abstract void SetLocalScaling2(BulletShape shape, Vector3 scale);
-
-public abstract Vector3 GetLocalScaling2(BulletShape shape);
-
-public abstract Vector3 CalculateLocalInertia2(BulletShape shape, float mass);
-
-public abstract int GetShapeType2(BulletShape shape);
-
-public abstract void SetMargin2(BulletShape shape, float val);
-
-public abstract float GetMargin2(BulletShape shape);
-
-};
-
-// ===============================================================================
-static class BulletSimAPI {
-// ===============================================================================
-// Link back to the managed code for outputting log messages
-[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);
-
-// ===============================================================================
-// Initialization and simulation
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms,
-											int maxCollisions,  IntPtr collisionArray,
-											int maxUpdates, IntPtr updateArray,
-                                            DebugLogCallback logRoutine);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetHeightMap2(IntPtr world, float[] heightmap);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void Shutdown2(IntPtr sim);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep,
-                        out int updatedEntityCount,
-                        out IntPtr updatedEntitiesPtr,
-                        out int collidersCount,
-                        out IntPtr collidersPtr);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool PushUpdate2(IntPtr obj);
-
-// =====================================================================================
-// Mesh, hull, shape and body creation helper routines
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateMeshShape2(IntPtr world,
-                int indicesCount, [MarshalAs(UnmanagedType.LPArray)] int[] indices,
-                int verticesCount, [MarshalAs(UnmanagedType.LPArray)] float[] vertices );
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateHullShape2(IntPtr world,
-                int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr BuildHullShapeFromMesh2(IntPtr world, IntPtr meshShape);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr BuildNativeShape2(IntPtr world, ShapeData shapeData);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool IsNativeShape2(IntPtr shape);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetShapeCollisionMargin(IntPtr shape, float margin);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr BuildCapsuleShape2(IntPtr world, float radius, float height, Vector3 scale);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateCompoundShape2(IntPtr sim, bool enableDynamicAabbTree);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern int GetNumberOfCompoundChildren2(IntPtr cShape);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void AddChildShapeToCompoundShape2(IntPtr cShape, IntPtr addShape, Vector3 pos, Quaternion rot);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr GetChildShapeFromCompoundShapeIndex2(IntPtr cShape, int indx);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr RemoveChildShapeFromCompoundShapeIndex2(IntPtr cShape, int indx);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void RemoveChildShapeFromCompoundShape2(IntPtr cShape, IntPtr removeShape);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void RecalculateCompoundShapeLocalAabb2(IntPtr cShape);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr DuplicateCollisionShape2(IntPtr sim, IntPtr srcShape, uint id);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateBodyFromShapeAndInfo2(IntPtr sim, IntPtr shape, uint id, IntPtr constructionInfo);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern int GetBodyType2(IntPtr obj);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateBodyFromShape2(IntPtr sim, IntPtr shape, uint id, Vector3 pos, Quaternion rot);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateBodyWithDefaultMotionState2(IntPtr shape, uint id, Vector3 pos, Quaternion rot);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateGhostFromShape2(IntPtr sim, IntPtr shape, uint id, Vector3 pos, Quaternion rot);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr AllocateBodyInfo2(IntPtr obj);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void ReleaseBodyInfo2(IntPtr obj);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void DestroyObject2(IntPtr sim, IntPtr obj);
-
 // =====================================================================================
 // Terrain creation and helper routines
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateHeightMapInfo2(IntPtr sim, uint id, Vector3 minCoords, Vector3 maxCoords,
-        [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin);
+public abstract IntPtr CreateHeightMapInfo(BulletWorld sim, uint id, Vector3 minCoords, Vector3 maxCoords,
+        float[] heightMap, float collisionMargin);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr FillHeightMapInfo2(IntPtr sim, IntPtr mapInfo, uint id, Vector3 minCoords, Vector3 maxCoords,
-        [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin);
+public abstract IntPtr FillHeightMapInfo(BulletWorld sim, IntPtr mapInfo, uint id, Vector3 minCoords, Vector3 maxCoords,
+        float[] heightMap, float collisionMargin);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool ReleaseHeightMapInfo2(IntPtr heightMapInfo);
+public abstract bool ReleaseHeightMapInfo(IntPtr heightMapInfo);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateGroundPlaneShape2(uint id, float height, float collisionMargin);
+public abstract BulletBody CreateGroundPlaneShape(uint id, float height, float collisionMargin);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateTerrainShape2(IntPtr mapInfo);
+public abstract BulletBody CreateTerrainShape(IntPtr mapInfo);
 
 // =====================================================================================
 // Constraint creation and helper routines
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr Create6DofConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2,
+public abstract BulletConstraint Create6DofConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
                     Vector3 frame1loc, Quaternion frame1rot,
                     Vector3 frame2loc, Quaternion frame2rot,
                     bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr Create6DofConstraintToPoint2(IntPtr world, IntPtr obj1, IntPtr obj2,
+public abstract BulletConstraint Create6DofConstraintToPoint(BulletWorld world, BulletBody obj1, BulletBody obj2,
                     Vector3 joinPoint,
                     bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateHingeConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2,
+public abstract BulletConstraint CreateHingeConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
                     Vector3 pivotinA, Vector3 pivotinB,
                     Vector3 axisInA, Vector3 axisInB,
                     bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetConstraintEnable2(IntPtr constrain, float numericTrueFalse);
+public abstract void SetConstraintEnable(BulletConstraint constrain, float numericTrueFalse);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetConstraintNumSolverIterations2(IntPtr constrain, float iterations);
+public abstract void SetConstraintNumSolverIterations(BulletConstraint constrain, float iterations);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool SetFrames2(IntPtr constrain,
+public abstract bool SetFrames(BulletConstraint constrain,
                 Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool SetLinearLimits2(IntPtr constrain, Vector3 low, Vector3 hi);
+public abstract bool SetLinearLimits(BulletConstraint constrain, Vector3 low, Vector3 hi);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool SetAngularLimits2(IntPtr constrain, Vector3 low, Vector3 hi);
+public abstract bool SetAngularLimits(BulletConstraint constrain, Vector3 low, Vector3 hi);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool UseFrameOffset2(IntPtr constrain, float enable);
+public abstract bool UseFrameOffset(BulletConstraint constrain, float enable);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enable, float targetVel, float maxMotorForce);
+public abstract bool TranslationalLimitMotor(BulletConstraint constrain, float enable, float targetVel, float maxMotorForce);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool SetBreakingImpulseThreshold2(IntPtr constrain, float threshold);
+public abstract bool SetBreakingImpulseThreshold(BulletConstraint constrain, float threshold);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool CalculateTransforms2(IntPtr constrain);
+public abstract bool CalculateTransforms(BulletConstraint constrain);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool SetConstraintParam2(IntPtr constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis);
+public abstract bool SetConstraintParam(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool DestroyConstraint2(IntPtr world, IntPtr constrain);
+public abstract bool DestroyConstraint(BulletWorld world, BulletConstraint constrain);
 
 // =====================================================================================
 // btCollisionWorld entries
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void UpdateSingleAabb2(IntPtr world, IntPtr obj);
+public abstract void UpdateSingleAabb(BulletWorld world, BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void UpdateAabbs2(IntPtr world);
+public abstract void UpdateAabbs(BulletWorld world);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool GetForceUpdateAllAabbs2(IntPtr world);
+public abstract bool GetForceUpdateAllAabbs(BulletWorld world);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetForceUpdateAllAabbs2(IntPtr world, bool force);
+public abstract void SetForceUpdateAllAabbs(BulletWorld world, bool force);
 
 // =====================================================================================
 // btDynamicsWorld entries
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool AddObjectToWorld2(IntPtr world, IntPtr obj);
+public abstract bool AddObjectToWorld(BulletWorld world, BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool RemoveObjectFromWorld2(IntPtr world, IntPtr obj);
+public abstract bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool AddConstraintToWorld2(IntPtr world, IntPtr constrain, bool disableCollisionsBetweenLinkedObjects);
+public abstract bool AddConstraintToWorld(BulletWorld world, BulletConstraint constrain, bool disableCollisionsBetweenLinkedObjects);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool RemoveConstraintFromWorld2(IntPtr world, IntPtr constrain);
+public abstract bool RemoveConstraintFromWorld(BulletWorld world, BulletConstraint constrain);
 // =====================================================================================
 // btCollisionObject entries
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 GetAnisotripicFriction2(IntPtr constrain);
+public abstract Vector3 GetAnisotripicFriction(BulletConstraint constrain);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 SetAnisotripicFriction2(IntPtr constrain, Vector3 frict);
+public abstract Vector3 SetAnisotripicFriction(BulletConstraint constrain, Vector3 frict);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool HasAnisotripicFriction2(IntPtr constrain);
+public abstract bool HasAnisotripicFriction(BulletConstraint constrain);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetContactProcessingThreshold2(IntPtr obj, float val);
+public abstract void SetContactProcessingThreshold(BulletBody obj, float val);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern float GetContactProcessingThreshold2(IntPtr obj);
+public abstract float GetContactProcessingThreshold(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool IsStaticObject2(IntPtr obj);
+public abstract bool IsStaticObject(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool IsKinematicObject2(IntPtr obj);
+public abstract bool IsKinematicObject(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool IsStaticOrKinematicObject2(IntPtr obj);
+public abstract bool IsStaticOrKinematicObject(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool HasContactResponse2(IntPtr obj);
+public abstract bool HasContactResponse(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetCollisionShape2(IntPtr sim, IntPtr obj, IntPtr shape);
+public abstract void SetCollisionShape(BulletWorld sim, BulletBody obj, BulletBody shape);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr GetCollisionShape2(IntPtr obj);
+public abstract BulletShape GetCollisionShape(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern int GetActivationState2(IntPtr obj);
+public abstract int GetActivationState(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetActivationState2(IntPtr obj, int state);
+public abstract void SetActivationState(BulletBody obj, int state);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetDeactivationTime2(IntPtr obj, float dtime);
+public abstract void SetDeactivationTime(BulletBody obj, float dtime);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern float GetDeactivationTime2(IntPtr obj);
+public abstract float GetDeactivationTime(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void ForceActivationState2(IntPtr obj, ActivationState state);
+public abstract void ForceActivationState(BulletBody obj, ActivationState state);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void Activate2(IntPtr obj, bool forceActivation);
+public abstract void Activate(BulletBody obj, bool forceActivation);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool IsActive2(IntPtr obj);
+public abstract bool IsActive(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetRestitution2(IntPtr obj, float val);
+public abstract void SetRestitution(BulletBody obj, float val);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern float GetRestitution2(IntPtr obj);
+public abstract float GetRestitution(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetFriction2(IntPtr obj, float val);
+public abstract void SetFriction(BulletBody obj, float val);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern float GetFriction2(IntPtr obj);
+public abstract float GetFriction(BulletBody obj);
 
-    /* Haven't defined the type 'Transform'
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Transform GetWorldTransform2(IntPtr obj);
+public abstract Vector3 GetPosition(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void setWorldTransform2(IntPtr obj, Transform trans);
-     */
+public abstract Quaternion GetOrientation(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 GetPosition2(IntPtr obj);
+public abstract void SetTranslation(BulletBody obj, Vector3 position, Quaternion rotation);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Quaternion GetOrientation2(IntPtr obj);
+public abstract IntPtr GetBroadphaseHandle(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetTranslation2(IntPtr obj, Vector3 position, Quaternion rotation);
+public abstract void SetBroadphaseHandle(BulletBody obj, IntPtr handle);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr GetBroadphaseHandle2(IntPtr obj);
+public abstract void SetInterpolationLinearVelocity(BulletBody obj, Vector3 vel);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetBroadphaseHandle2(IntPtr obj, IntPtr handle);
+public abstract void SetInterpolationAngularVelocity(BulletBody obj, Vector3 vel);
 
-    /*
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Transform GetInterpolationWorldTransform2(IntPtr obj);
+public abstract void SetInterpolationVelocity(BulletBody obj, Vector3 linearVel, Vector3 angularVel);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetInterpolationWorldTransform2(IntPtr obj, Transform trans);
-     */
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetInterpolationLinearVelocity2(IntPtr obj, Vector3 vel);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetInterpolationAngularVelocity2(IntPtr obj, Vector3 vel);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetInterpolationVelocity2(IntPtr obj, Vector3 linearVel, Vector3 angularVel);
+public abstract float GetHitFraction(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern float GetHitFraction2(IntPtr obj);
+public abstract void SetHitFraction(BulletBody obj, float val);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetHitFraction2(IntPtr obj, float val);
+public abstract CollisionFlags GetCollisionFlags(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern CollisionFlags GetCollisionFlags2(IntPtr obj);
+public abstract CollisionFlags SetCollisionFlags(BulletBody obj, CollisionFlags flags);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern CollisionFlags SetCollisionFlags2(IntPtr obj, CollisionFlags flags);
+public abstract CollisionFlags AddToCollisionFlags(BulletBody obj, CollisionFlags flags);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern CollisionFlags AddToCollisionFlags2(IntPtr obj, CollisionFlags flags);
+public abstract CollisionFlags RemoveFromCollisionFlags(BulletBody obj, CollisionFlags flags);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern CollisionFlags RemoveFromCollisionFlags2(IntPtr obj, CollisionFlags flags);
+public abstract float GetCcdMotionThreshold(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern float GetCcdMotionThreshold2(IntPtr obj);
+public abstract void SetCcdMotionThreshold(BulletBody obj, float val);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetCcdMotionThreshold2(IntPtr obj, float val);
+public abstract float GetCcdSweptSphereRadius(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern float GetCcdSweptSphereRadius2(IntPtr obj);
+public abstract void SetCcdSweptSphereRadius(BulletBody obj, float val);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetCcdSweptSphereRadius2(IntPtr obj, float val);
+public abstract IntPtr GetUserPointer(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr GetUserPointer2(IntPtr obj);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetUserPointer2(IntPtr obj, IntPtr val);
+public abstract void SetUserPointer(BulletBody obj, IntPtr val);
 
 // =====================================================================================
 // btRigidBody entries
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void ApplyGravity2(IntPtr obj);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetGravity2(IntPtr obj, Vector3 val);
+public abstract void ApplyGravity(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 GetGravity2(IntPtr obj);
+public abstract void SetGravity(BulletBody obj, Vector3 val);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetDamping2(IntPtr obj, float lin_damping, float ang_damping);
+public abstract Vector3 GetGravity(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetLinearDamping2(IntPtr obj, float lin_damping);
+public abstract void SetDamping(BulletBody obj, float lin_damping, float ang_damping);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetAngularDamping2(IntPtr obj, float ang_damping);
+public abstract void SetLinearDamping(BulletBody obj, float lin_damping);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern float GetLinearDamping2(IntPtr obj);
+public abstract void SetAngularDamping(BulletBody obj, float ang_damping);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern float GetAngularDamping2(IntPtr obj);
+public abstract float GetLinearDamping(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern float GetLinearSleepingThreshold2(IntPtr obj);
+public abstract float GetAngularDamping(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern float GetAngularSleepingThreshold2(IntPtr obj);
+public abstract float GetLinearSleepingThreshold(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void ApplyDamping2(IntPtr obj, float timeStep);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetMassProps2(IntPtr obj, float mass, Vector3 inertia);
+public abstract void ApplyDamping(BulletBody obj, float timeStep);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 GetLinearFactor2(IntPtr obj);
+public abstract void SetMassProps(BulletBody obj, float mass, Vector3 inertia);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetLinearFactor2(IntPtr obj, Vector3 factor);
+public abstract Vector3 GetLinearFactor(BulletBody obj);
 
-    /*
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetCenterOfMassTransform2(IntPtr obj, Transform trans);
-     */
+public abstract void SetLinearFactor(BulletBody obj, Vector3 factor);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetCenterOfMassByPosRot2(IntPtr obj, Vector3 pos, Quaternion rot);
+public abstract void SetCenterOfMassByPosRot(BulletBody obj, Vector3 pos, Quaternion rot);
 
 // Add a force to the object as if its mass is one.
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void ApplyCentralForce2(IntPtr obj, Vector3 force);
+public abstract void ApplyCentralForce(BulletBody obj, Vector3 force);
 
 // Set the force being applied to the object as if its mass is one.
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetObjectForce2(IntPtr obj, Vector3 force);
+public abstract void SetObjectForce(BulletBody obj, Vector3 force);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 GetTotalForce2(IntPtr obj);
+public abstract Vector3 GetTotalForce(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 GetTotalTorque2(IntPtr obj);
+public abstract Vector3 GetTotalTorque(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 GetInvInertiaDiagLocal2(IntPtr obj);
+public abstract Vector3 GetInvInertiaDiagLocal(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetInvInertiaDiagLocal2(IntPtr obj, Vector3 inert);
+public abstract void SetInvInertiaDiagLocal(BulletBody obj, Vector3 inert);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetSleepingThresholds2(IntPtr obj, float lin_threshold, float ang_threshold);
+public abstract void SetSleepingThresholds(BulletBody obj, float lin_threshold, float ang_threshold);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void ApplyTorque2(IntPtr obj, Vector3 torque);
+public abstract void ApplyTorque(BulletBody obj, Vector3 torque);
 
 // Apply force at the given point. Will add torque to the object.
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void ApplyForce2(IntPtr obj, Vector3 force, Vector3 pos);
+public abstract void ApplyForce(BulletBody obj, Vector3 force, Vector3 pos);
 
 // Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass.
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void ApplyCentralImpulse2(IntPtr obj, Vector3 imp);
+public abstract void ApplyCentralImpulse(BulletBody obj, Vector3 imp);
 
 // Apply impulse to the object's torque. Force is scaled by object's mass.
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void ApplyTorqueImpulse2(IntPtr obj, Vector3 imp);
+public abstract void ApplyTorqueImpulse(BulletBody obj, Vector3 imp);
 
 // Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces.
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void ApplyImpulse2(IntPtr obj, Vector3 imp, Vector3 pos);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void ClearForces2(IntPtr obj);
+public abstract void ApplyImpulse(BulletBody obj, Vector3 imp, Vector3 pos);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void ClearAllForces2(IntPtr obj);
+public abstract void ClearForces(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void UpdateInertiaTensor2(IntPtr obj);
+public abstract void ClearAllForces(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 GetCenterOfMassPosition2(IntPtr obj);
-
-    /*
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Transform GetCenterOfMassTransform2(IntPtr obj);
-     */
+public abstract void UpdateInertiaTensor(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 GetLinearVelocity2(IntPtr obj);
+public abstract Vector3 GetLinearVelocity(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 GetAngularVelocity2(IntPtr obj);
+public abstract Vector3 GetAngularVelocity(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetLinearVelocity2(IntPtr obj, Vector3 val);
+public abstract void SetLinearVelocity(BulletBody obj, Vector3 val);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetAngularVelocity2(IntPtr obj, Vector3 angularVelocity);
+public abstract void SetAngularVelocity(BulletBody obj, Vector3 angularVelocity);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 GetVelocityInLocalPoint2(IntPtr obj, Vector3 pos);
+public abstract Vector3 GetVelocityInLocalPoint(BulletBody obj, Vector3 pos);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void Translate2(IntPtr obj, Vector3 trans);
+public abstract void Translate(BulletBody obj, Vector3 trans);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void UpdateDeactivation2(IntPtr obj, float timeStep);
+public abstract void UpdateDeactivation(BulletBody obj, float timeStep);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool WantsSleeping2(IntPtr obj);
+public abstract bool WantsSleeping(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetAngularFactor2(IntPtr obj, float factor);
+public abstract void SetAngularFactor(BulletBody obj, float factor);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetAngularFactorV2(IntPtr obj, Vector3 factor);
+public abstract void SetAngularFactorV(BulletBody obj, Vector3 factor);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 GetAngularFactor2(IntPtr obj);
+public abstract Vector3 GetAngularFactor(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool IsInWorld2(IntPtr obj);
+public abstract bool IsInWorld(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void AddConstraintRef2(IntPtr obj, IntPtr constrain);
+public abstract void AddConstraintRef(BulletBody obj, BulletConstraint constrain);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void RemoveConstraintRef2(IntPtr obj, IntPtr constrain);
+public abstract void RemoveConstraintRef(BulletBody obj, BulletConstraint constrain);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr GetConstraintRef2(IntPtr obj, int index);
+public abstract BulletConstraint GetConstraintRef(BulletBody obj, int index);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern int GetNumConstraintRefs2(IntPtr obj);
+public abstract int GetNumConstraintRefs(BulletBody obj);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool SetCollisionGroupMask2(IntPtr body, uint filter, uint mask);
+public abstract bool SetCollisionGroupMask(BulletBody body, uint filter, uint mask);
 
 // =====================================================================================
 // btCollisionShape entries
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern float GetAngularMotionDisc2(IntPtr shape);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern float GetContactBreakingThreshold2(IntPtr shape, float defaultFactor);
+public abstract float GetAngularMotionDisc(BulletShape shape);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool IsPolyhedral2(IntPtr shape);
+public abstract float GetContactBreakingThreshold(BulletShape shape, float defaultFactor);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool IsConvex2d2(IntPtr shape);
+public abstract bool IsPolyhedral(BulletShape shape);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool IsConvex2(IntPtr shape);
+public abstract bool IsConvex2d(BulletShape shape);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool IsNonMoving2(IntPtr shape);
+public abstract bool IsConvex(BulletShape shape);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool IsConcave2(IntPtr shape);
+public abstract bool IsNonMoving(BulletShape shape);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool IsCompound2(IntPtr shape);
+public abstract bool IsConcave(BulletShape shape);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool IsSoftBody2(IntPtr shape);
+public abstract bool IsCompound(BulletShape shape);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool IsInfinite2(IntPtr shape);
+public abstract bool IsSoftBody(BulletShape shape);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetLocalScaling2(IntPtr shape, Vector3 scale);
+public abstract bool IsInfinite(BulletShape shape);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 GetLocalScaling2(IntPtr shape);
+public abstract void SetLocalScaling(BulletShape shape, Vector3 scale);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 CalculateLocalInertia2(IntPtr shape, float mass);
+public abstract Vector3 GetLocalScaling(BulletShape shape);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern int GetShapeType2(IntPtr shape);
+public abstract Vector3 CalculateLocalInertia(BulletShape shape, float mass);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetMargin2(IntPtr shape, float val);
+public abstract int GetShapeType(BulletShape shape);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern float GetMargin2(IntPtr shape);
-
-// =====================================================================================
-// Debugging
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void DumpRigidBody2(IntPtr sim, IntPtr collisionObject);
+public abstract void SetMargin(BulletShape shape, float val);
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void DumpCollisionShape2(IntPtr sim, IntPtr collisionShape);
+public abstract float GetMargin(BulletShape shape);
+    */
 
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void DumpMapInfo2(IntPtr sim, IntPtr manInfo);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void DumpConstraint2(IntPtr sim, IntPtr constrain);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void DumpActivationInfo2(IntPtr sim);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void DumpAllInfo2(IntPtr sim);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void DumpPhysicsStatistics2(IntPtr sim);
-
-}
+};
 }

+ 6 - 1
OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt

@@ -31,6 +31,7 @@ CRASHES
 
 VEHICLES TODO LIST:
 =================================================
+Angular motor direction is global coordinates rather than local coordinates
 Border crossing with linked vehicle causes crash
 Vehicles (Move smoothly)
 Add vehicle collisions so IsColliding is properly reported.
@@ -78,7 +79,7 @@ Small physical objects do not interact correctly
     Create chain of .5x.5x.1 torui and make all but top physical so to hang.
         The chain will fall apart and pairs will dance around on ground
     Chains of 1x1x.2 will stay connected but will dance.
-    Chains above 2x2x.4 are move stable and get stablier as torui get larger.
+    Chains above 2x2x.4 are more stable and get stablier as torui get larger.
 Add PID motor for avatar movement (slow to stop, ...)
 setForce should set a constant force. Different than AddImpulse.
 Implement raycast.
@@ -100,9 +101,13 @@ More efficient memory usage when passing hull information from BSPrim to BulletS
 Avatar movement motor check for zero or small movement. Somehow suppress small movements
 	when avatar has stopped and is just standing. Simple test for near zero has
 	the problem of preventing starting up (increase from zero) especially when falling.
+Physical and phantom will drop through the terrain
+
 
 LINKSETS
 ======================================================
+Offset the center of the linkset to be the geometric center of all the prims
+	Not quite the same as the center-of-gravity
 Linksets should allow collisions to individual children
 	Add LocalID to children shapes in LinksetCompound and create events for individuals
 LinksetCompound: when one of the children changes orientation (like tires

+ 1 - 0
prebuild.xml

@@ -1747,6 +1747,7 @@
       <Reference name="OpenSim.Framework.Console"/>
       <Reference name="OpenSim.Region.Physics.Manager"/>
       <Reference name="OpenSim.Region.Physics.ConvexDecompositionDotNet"/>
+      <Reference name="BulletXNA.dll" path="../../../../bin/"/>
       <Reference name="log4net.dll" path="../../../../bin/"/>
 
       <Files>