aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
diff options
context:
space:
mode:
authorRobert Adams2012-09-23 18:39:46 -0700
committerRobert Adams2012-09-27 22:01:37 -0700
commitd016051fa028a485b09fac47b3fa3d8fd08e207a (patch)
tree8f483976bb64b1328439b76754675126b09943b0 /OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
parentBulletSim: fix regression that caused cylindar shapes to have a box collision... (diff)
downloadopensim-SC-d016051fa028a485b09fac47b3fa3d8fd08e207a.zip
opensim-SC-d016051fa028a485b09fac47b3fa3d8fd08e207a.tar.gz
opensim-SC-d016051fa028a485b09fac47b3fa3d8fd08e207a.tar.bz2
opensim-SC-d016051fa028a485b09fac47b3fa3d8fd08e207a.tar.xz
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.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs49
1 files changed, 31 insertions, 18 deletions
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
40{ 40{
41 public BulletSim(uint worldId, BSScene bss, IntPtr xx) 41 public BulletSim(uint worldId, BSScene bss, IntPtr xx)
42 { 42 {
43 ptr = xx;
43 worldID = worldId; 44 worldID = worldId;
44 scene = bss; 45 scene = bss;
45 Ptr = xx;
46 } 46 }
47 public IntPtr ptr;
47 public uint worldID; 48 public uint worldID;
48 // The scene is only in here so very low level routines have a handle to print debug/error messages 49 // The scene is only in here so very low level routines have a handle to print debug/error messages
49 public BSScene scene; 50 public BSScene scene;
50 public IntPtr Ptr;
51} 51}
52 52
53// An allocated Bullet btRigidBody 53// An allocated Bullet btRigidBody
@@ -56,9 +56,9 @@ public struct BulletBody
56 public BulletBody(uint id, IntPtr xx) 56 public BulletBody(uint id, IntPtr xx)
57 { 57 {
58 ID = id; 58 ID = id;
59 Ptr = xx; 59 ptr = xx;
60 } 60 }
61 public IntPtr Ptr; 61 public IntPtr ptr;
62 public uint ID; 62 public uint ID;
63 public override string ToString() 63 public override string ToString()
64 { 64 {
@@ -66,7 +66,7 @@ public struct BulletBody
66 buff.Append("<id="); 66 buff.Append("<id=");
67 buff.Append(ID.ToString()); 67 buff.Append(ID.ToString());
68 buff.Append(",p="); 68 buff.Append(",p=");
69 buff.Append(Ptr.ToString("X")); 69 buff.Append(ptr.ToString("X"));
70 buff.Append(">"); 70 buff.Append(">");
71 return buff.ToString(); 71 return buff.ToString();
72 } 72 }
@@ -76,28 +76,39 @@ public struct BulletShape
76{ 76{
77 public BulletShape(IntPtr xx) 77 public BulletShape(IntPtr xx)
78 { 78 {
79 Ptr = xx; 79 ptr = xx;
80 type=ShapeData.PhysicsShapeType.SHAPE_UNKNOWN; 80 type=ShapeData.PhysicsShapeType.SHAPE_UNKNOWN;
81 shapeKey = 0; 81 shapeKey = 0;
82 isNativeShape = false;
83 meshPtr = IntPtr.Zero;
82 } 84 }
83 public BulletShape(IntPtr xx, ShapeData.PhysicsShapeType typ) 85 public BulletShape(IntPtr xx, ShapeData.PhysicsShapeType typ)
84 { 86 {
85 Ptr = xx; 87 ptr = xx;
86 type = typ; 88 type = typ;
87 shapeKey = 0; 89 shapeKey = 0;
90 isNativeShape = false;
91 meshPtr = IntPtr.Zero;
88 } 92 }
89 public IntPtr Ptr; 93 public IntPtr ptr;
90 public ShapeData.PhysicsShapeType type; 94 public ShapeData.PhysicsShapeType type;
91 public ulong shapeKey; 95 public ulong shapeKey;
96 public bool isNativeShape;
97 // Hulls have an underlying mesh. A pointer to it is hidden here.
98 public IntPtr meshPtr;
92 public override string ToString() 99 public override string ToString()
93 { 100 {
94 StringBuilder buff = new StringBuilder(); 101 StringBuilder buff = new StringBuilder();
95 buff.Append("<p="); 102 buff.Append("<p=");
96 buff.Append(Ptr.ToString("X")); 103 buff.Append(ptr.ToString("X"));
97 buff.Append(",s="); 104 buff.Append(",s=");
98 buff.Append(type.ToString()); 105 buff.Append(type.ToString());
99 buff.Append(",k="); 106 buff.Append(",k=");
100 buff.Append(shapeKey.ToString("X")); 107 buff.Append(shapeKey.ToString("X"));
108 buff.Append(",n=");
109 buff.Append(isNativeShape.ToString());
110 buff.Append(",m=");
111 buff.Append(meshPtr.ToString("X"));
101 buff.Append(">"); 112 buff.Append(">");
102 return buff.ToString(); 113 return buff.ToString();
103 } 114 }
@@ -314,10 +325,10 @@ public enum CollisionFlags : uint
314 CF_DISABLE_SPU_COLLISION_PROCESS = 1 << 6, 325 CF_DISABLE_SPU_COLLISION_PROCESS = 1 << 6,
315 // Following used by BulletSim to control collisions 326 // Following used by BulletSim to control collisions
316 BS_SUBSCRIBE_COLLISION_EVENTS = 1 << 10, 327 BS_SUBSCRIBE_COLLISION_EVENTS = 1 << 10,
317 BS_VOLUME_DETECT_OBJECT = 1 << 11, 328 // BS_VOLUME_DETECT_OBJECT = 1 << 11,
318 BS_PHANTOM_OBJECT = 1 << 12, 329 // BS_PHANTOM_OBJECT = 1 << 12,
319 BS_PHYSICAL_OBJECT = 1 << 13, 330 // BS_PHYSICAL_OBJECT = 1 << 13,
320 BS_TERRAIN_OBJECT = 1 << 14, 331 // BS_TERRAIN_OBJECT = 1 << 14,
321 BS_NONE = 0, 332 BS_NONE = 0,
322 BS_ALL = 0xFFFFFFFF, 333 BS_ALL = 0xFFFFFFFF,
323 334
@@ -326,9 +337,9 @@ public enum CollisionFlags : uint
326 BS_ACTIVE = CF_STATIC_OBJECT 337 BS_ACTIVE = CF_STATIC_OBJECT
327 | CF_KINEMATIC_OBJECT 338 | CF_KINEMATIC_OBJECT
328 | CF_NO_CONTACT_RESPONSE 339 | CF_NO_CONTACT_RESPONSE
329 | BS_VOLUME_DETECT_OBJECT 340 // | BS_VOLUME_DETECT_OBJECT
330 | BS_PHANTOM_OBJECT 341 // | BS_PHANTOM_OBJECT
331 | BS_PHYSICAL_OBJECT, 342 // | BS_PHYSICAL_OBJECT,
332}; 343};
333 344
334// Values for collisions groups and masks 345// Values for collisions groups and masks
@@ -552,8 +563,7 @@ public static extern IntPtr CreateHullShape2(IntPtr world,
552public static extern IntPtr BuildHullShape2(IntPtr world, IntPtr meshShape); 563public static extern IntPtr BuildHullShape2(IntPtr world, IntPtr meshShape);
553 564
554[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 565[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
555public static extern IntPtr BuildNativeShape2(IntPtr world, 566public static extern IntPtr BuildNativeShape2(IntPtr world, ShapeData shapeData);
556 float shapeType, float collisionMargin, Vector3 scale);
557 567
558[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 568[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
559public static extern bool IsNativeShape2(IntPtr shape); 569public static extern bool IsNativeShape2(IntPtr shape);
@@ -568,6 +578,9 @@ public static extern void AddChildToCompoundShape2(IntPtr cShape, IntPtr addShap
568public static extern void RemoveChildFromCompoundShape2(IntPtr cShape, IntPtr removeShape); 578public static extern void RemoveChildFromCompoundShape2(IntPtr cShape, IntPtr removeShape);
569 579
570[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 580[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
581public static extern IntPtr DuplicateCollisionShape2(IntPtr sim, IntPtr srcShape, uint id);
582
583[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
571public static extern IntPtr CreateBodyFromShapeAndInfo2(IntPtr sim, IntPtr shape, IntPtr constructionInfo); 584public static extern IntPtr CreateBodyFromShapeAndInfo2(IntPtr sim, IntPtr shape, IntPtr constructionInfo);
572 585
573[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 586[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]