From d016051fa028a485b09fac47b3fa3d8fd08e207a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 23 Sep 2012 18:39:46 -0700 Subject: BulletSim: renamed members of BulletShape, BulletSim and BulletBody so the members case is consistant. Caused modifications everywhere. New logic in BSShapeCollection to track use and sharing of shapes. I just reslized, though, that shapes cannot be shared because the shape's UserPointer is the localID of the prim and is required for tracking collisions. More changes coming. Added DuplicateCollisionShape2() to API and changed BuildNativeShape2 to take a ShapeData structure so don't have to pass so many parameters. This matches the latest version of BulletSim.dll. Additions and removal of DetailLog() statements for debugging. --- .../Region/Physics/BulletSPlugin/BulletSimAPI.cs | 49 ++++++++++++++-------- 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index 47875b0..8480dd1 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs @@ -40,14 +40,14 @@ public struct BulletSim { public BulletSim(uint worldId, BSScene bss, IntPtr xx) { + ptr = xx; worldID = worldId; scene = bss; - Ptr = xx; } + public IntPtr ptr; public uint worldID; // The scene is only in here so very low level routines have a handle to print debug/error messages public BSScene scene; - public IntPtr Ptr; } // An allocated Bullet btRigidBody @@ -56,9 +56,9 @@ public struct BulletBody public BulletBody(uint id, IntPtr xx) { ID = id; - Ptr = xx; + ptr = xx; } - public IntPtr Ptr; + public IntPtr ptr; public uint ID; public override string ToString() { @@ -66,7 +66,7 @@ public struct BulletBody buff.Append(""); return buff.ToString(); } @@ -76,28 +76,39 @@ public struct BulletShape { public BulletShape(IntPtr xx) { - Ptr = xx; + ptr = xx; type=ShapeData.PhysicsShapeType.SHAPE_UNKNOWN; shapeKey = 0; + isNativeShape = false; + meshPtr = IntPtr.Zero; } public BulletShape(IntPtr xx, ShapeData.PhysicsShapeType typ) { - Ptr = xx; + ptr = xx; type = typ; shapeKey = 0; + isNativeShape = false; + meshPtr = IntPtr.Zero; } - public IntPtr Ptr; + public IntPtr ptr; public ShapeData.PhysicsShapeType type; public ulong shapeKey; + public bool isNativeShape; + // Hulls have an underlying mesh. A pointer to it is hidden here. + public IntPtr meshPtr; public override string ToString() { StringBuilder buff = new StringBuilder(); buff.Append(""); return buff.ToString(); } @@ -314,10 +325,10 @@ public enum CollisionFlags : uint CF_DISABLE_SPU_COLLISION_PROCESS = 1 << 6, // Following used by BulletSim to control collisions BS_SUBSCRIBE_COLLISION_EVENTS = 1 << 10, - BS_VOLUME_DETECT_OBJECT = 1 << 11, - BS_PHANTOM_OBJECT = 1 << 12, - BS_PHYSICAL_OBJECT = 1 << 13, - BS_TERRAIN_OBJECT = 1 << 14, + // BS_VOLUME_DETECT_OBJECT = 1 << 11, + // BS_PHANTOM_OBJECT = 1 << 12, + // BS_PHYSICAL_OBJECT = 1 << 13, + // BS_TERRAIN_OBJECT = 1 << 14, BS_NONE = 0, BS_ALL = 0xFFFFFFFF, @@ -326,9 +337,9 @@ public enum CollisionFlags : uint BS_ACTIVE = CF_STATIC_OBJECT | CF_KINEMATIC_OBJECT | CF_NO_CONTACT_RESPONSE - | BS_VOLUME_DETECT_OBJECT - | BS_PHANTOM_OBJECT - | BS_PHYSICAL_OBJECT, + // | BS_VOLUME_DETECT_OBJECT + // | BS_PHANTOM_OBJECT + // | BS_PHYSICAL_OBJECT, }; // Values for collisions groups and masks @@ -552,8 +563,7 @@ public static extern IntPtr CreateHullShape2(IntPtr world, public static extern IntPtr BuildHullShape2(IntPtr world, IntPtr meshShape); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern IntPtr BuildNativeShape2(IntPtr world, - float shapeType, float collisionMargin, Vector3 scale); +public static extern IntPtr BuildNativeShape2(IntPtr world, ShapeData shapeData); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern bool IsNativeShape2(IntPtr shape); @@ -568,6 +578,9 @@ public static extern void AddChildToCompoundShape2(IntPtr cShape, IntPtr addShap public static extern void RemoveChildFromCompoundShape2(IntPtr cShape, IntPtr removeShape); [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, IntPtr constructionInfo); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -- cgit v1.1