aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
diff options
context:
space:
mode:
authorRobert Adams2012-09-25 15:01:18 -0700
committerRobert Adams2012-09-27 22:01:42 -0700
commit735d89e3692bb7c620b9e3c248a1dbd5924b8b3f (patch)
tree0d31723cc7302e4928de6ac69905787099442bf1 /OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
parentBulletSim: renamed members of BulletShape, BulletSim and BulletBody (diff)
downloadopensim-SC-735d89e3692bb7c620b9e3c248a1dbd5924b8b3f.zip
opensim-SC-735d89e3692bb7c620b9e3c248a1dbd5924b8b3f.tar.gz
opensim-SC-735d89e3692bb7c620b9e3c248a1dbd5924b8b3f.tar.bz2
opensim-SC-735d89e3692bb7c620b9e3c248a1dbd5924b8b3f.tar.xz
BulletSim: btGhostObjects working to make 'volume detect' work.
Rearrangement and cleanup of shape collection code. Much more readable. Enabling and use of collision filters and masks. Addition of ID to body creation BulletSimAPI calls so always set in shape for collision reporting. Change default of ShouldSplitSimulationIslands and ShouldRandomizeSolverOrder from 'false' to 'true'. When 'false', this suppresses NO_CONTACT_RESPONSE which makes volume detect fail.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs78
1 files changed, 52 insertions, 26 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index 8480dd1..6910050 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -57,9 +57,13 @@ public struct BulletBody
57 { 57 {
58 ID = id; 58 ID = id;
59 ptr = xx; 59 ptr = xx;
60 collisionFilter = 0;
61 collisionMask = 0;
60 } 62 }
61 public IntPtr ptr; 63 public IntPtr ptr;
62 public uint ID; 64 public uint ID;
65 public CollisionFilterGroups collisionFilter;
66 public CollisionFilterGroups collisionMask;
63 public override string ToString() 67 public override string ToString()
64 { 68 {
65 StringBuilder buff = new StringBuilder(); 69 StringBuilder buff = new StringBuilder();
@@ -67,6 +71,13 @@ public struct BulletBody
67 buff.Append(ID.ToString()); 71 buff.Append(ID.ToString());
68 buff.Append(",p="); 72 buff.Append(",p=");
69 buff.Append(ptr.ToString("X")); 73 buff.Append(ptr.ToString("X"));
74 if (collisionFilter != 0 && collisionMask != 0)
75 {
76 buff.Append(",f=");
77 buff.Append(collisionFilter.ToString("X"));
78 buff.Append(",m=");
79 buff.Append(collisionMask.ToString("X"));
80 }
70 buff.Append(">"); 81 buff.Append(">");
71 return buff.ToString(); 82 return buff.ToString();
72 } 83 }
@@ -80,7 +91,6 @@ public struct BulletShape
80 type=ShapeData.PhysicsShapeType.SHAPE_UNKNOWN; 91 type=ShapeData.PhysicsShapeType.SHAPE_UNKNOWN;
81 shapeKey = 0; 92 shapeKey = 0;
82 isNativeShape = false; 93 isNativeShape = false;
83 meshPtr = IntPtr.Zero;
84 } 94 }
85 public BulletShape(IntPtr xx, ShapeData.PhysicsShapeType typ) 95 public BulletShape(IntPtr xx, ShapeData.PhysicsShapeType typ)
86 { 96 {
@@ -88,14 +98,12 @@ public struct BulletShape
88 type = typ; 98 type = typ;
89 shapeKey = 0; 99 shapeKey = 0;
90 isNativeShape = false; 100 isNativeShape = false;
91 meshPtr = IntPtr.Zero;
92 } 101 }
93 public IntPtr ptr; 102 public IntPtr ptr;
94 public ShapeData.PhysicsShapeType type; 103 public ShapeData.PhysicsShapeType type;
95 public ulong shapeKey; 104 public ulong shapeKey;
96 public bool isNativeShape; 105 public bool isNativeShape;
97 // Hulls have an underlying mesh. A pointer to it is hidden here. 106 // Hulls have an underlying mesh. A pointer to it is hidden here.
98 public IntPtr meshPtr;
99 public override string ToString() 107 public override string ToString()
100 { 108 {
101 StringBuilder buff = new StringBuilder(); 109 StringBuilder buff = new StringBuilder();
@@ -107,8 +115,6 @@ public struct BulletShape
107 buff.Append(shapeKey.ToString("X")); 115 buff.Append(shapeKey.ToString("X"));
108 buff.Append(",n="); 116 buff.Append(",n=");
109 buff.Append(isNativeShape.ToString()); 117 buff.Append(isNativeShape.ToString());
110 buff.Append(",m=");
111 buff.Append(meshPtr.ToString("X"));
112 buff.Append(">"); 118 buff.Append(">");
113 return buff.ToString(); 119 return buff.ToString();
114 } 120 }
@@ -124,7 +130,7 @@ public struct BulletConstraint
124 public IntPtr Ptr; 130 public IntPtr Ptr;
125} 131}
126 132
127// An allocated HeightMapThing which hold various heightmap info 133// An allocated HeightMapThing which holds various heightmap info.
128// Made a class rather than a struct so there would be only one 134// Made a class rather than a struct so there would be only one
129// instance of this and C# will pass around pointers rather 135// instance of this and C# will pass around pointers rather
130// than making copies. 136// than making copies.
@@ -345,21 +351,41 @@ public enum CollisionFlags : uint
345// Values for collisions groups and masks 351// Values for collisions groups and masks
346public enum CollisionFilterGroups : uint 352public enum CollisionFilterGroups : uint
347{ 353{
348 NoneFilter = 0, 354 // Don't use the bit definitions!! Define the use in a
349 DefaultFilter = 1 << 0, 355 // filter/mask definition below. This way collision interactions
350 StaticFilter = 1 << 1, 356 // are more easily debugged.
351 KinematicFilter = 1 << 2, 357 BNoneFilter = 0,
352 DebrisFilter = 1 << 3, 358 BDefaultFilter = 1 << 0,
353 SensorTrigger = 1 << 4, 359 BStaticFilter = 1 << 1,
354 CharacterFilter = 1 << 5, 360 BKinematicFilter = 1 << 2,
355 AllFilter = 0xFFFFFFFF, 361 BDebrisFilter = 1 << 3,
362 BSensorTrigger = 1 << 4,
363 BCharacterFilter = 1 << 5,
364 BAllFilter = 0xFFFFFFFF,
356 // Filter groups defined by BulletSim 365 // Filter groups defined by BulletSim
357 GroundPlaneFilter = 1 << 10, 366 BGroundPlaneFilter = 1 << 10,
358 TerrainFilter = 1 << 11, 367 BTerrainFilter = 1 << 11,
359 RaycastFilter = 1 << 12, 368 BRaycastFilter = 1 << 12,
360 SolidFilter = 1 << 13, 369 BSolidFilter = 1 << 13,
370
371 // The collsion filters and masked are defined in one place -- don't want them scattered
372 AvatarFilter = BDefaultFilter | BCharacterFilter | BSolidFilter,
373 AvatarMask = BAllFilter,
374 ObjectFilter = BDefaultFilter | BSolidFilter,
375 ObjectMask = BAllFilter,
376 StaticObjectFilter = BDefaultFilter | BStaticFilter | BSolidFilter,
377 StaticObjectMask = BAllFilter,
378 VolumeDetectFilter = BSensorTrigger,
379 VolumeDetectMask = ~BSensorTrigger,
380 TerrainFilter = BTerrainFilter,
381 TerrainMask = BAllFilter,
382 GroundPlaneFilter = BAllFilter,
383 GroundPlaneMask = BAllFilter
384
361}; 385};
362 386
387
388
363// CFM controls the 'hardness' of the constraint. 0=fixed, 0..1=violatable. Default=0 389// CFM controls the 'hardness' of the constraint. 0=fixed, 0..1=violatable. Default=0
364// ERP controls amount of correction per tick. Usable range=0.1..0.8. Default=0.2. 390// ERP controls amount of correction per tick. Usable range=0.1..0.8. Default=0.2.
365public enum ConstraintParams : int 391public enum ConstraintParams : int
@@ -560,7 +586,7 @@ public static extern IntPtr CreateHullShape2(IntPtr world,
560 int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls); 586 int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls);
561 587
562[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 588[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
563public static extern IntPtr BuildHullShape2(IntPtr world, IntPtr meshShape); 589public static extern IntPtr BuildHullShapeFromMesh2(IntPtr world, IntPtr meshShape);
564 590
565[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 591[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
566public static extern IntPtr BuildNativeShape2(IntPtr world, ShapeData shapeData); 592public static extern IntPtr BuildNativeShape2(IntPtr world, ShapeData shapeData);
@@ -581,7 +607,7 @@ public static extern void RemoveChildFromCompoundShape2(IntPtr cShape, IntPtr re
581public static extern IntPtr DuplicateCollisionShape2(IntPtr sim, IntPtr srcShape, uint id); 607public static extern IntPtr DuplicateCollisionShape2(IntPtr sim, IntPtr srcShape, uint id);
582 608
583[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 609[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
584public static extern IntPtr CreateBodyFromShapeAndInfo2(IntPtr sim, IntPtr shape, IntPtr constructionInfo); 610public static extern IntPtr CreateBodyFromShapeAndInfo2(IntPtr sim, IntPtr shape, uint id, IntPtr constructionInfo);
585 611
586[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 612[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
587public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape); 613public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape);
@@ -590,13 +616,13 @@ public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape);
590public static extern int GetBodyType2(IntPtr obj); 616public static extern int GetBodyType2(IntPtr obj);
591 617
592[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 618[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
593public static extern IntPtr CreateBodyFromShape2(IntPtr sim, IntPtr shape, Vector3 pos, Quaternion rot); 619public static extern IntPtr CreateBodyFromShape2(IntPtr sim, IntPtr shape, uint id, Vector3 pos, Quaternion rot);
594 620
595[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 621[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
596public static extern IntPtr CreateBodyWithDefaultMotionState2(IntPtr shape, Vector3 pos, Quaternion rot); 622public static extern IntPtr CreateBodyWithDefaultMotionState2(IntPtr shape, uint id, Vector3 pos, Quaternion rot);
597 623
598[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 624[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
599public static extern IntPtr CreateGhostFromShape2(IntPtr sim, IntPtr shape, Vector3 pos, Quaternion rot); 625public static extern IntPtr CreateGhostFromShape2(IntPtr sim, IntPtr shape, uint id, Vector3 pos, Quaternion rot);
600 626
601[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 627[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
602public static extern IntPtr AllocateBodyInfo2(IntPtr obj); 628public static extern IntPtr AllocateBodyInfo2(IntPtr obj);
@@ -1015,6 +1041,9 @@ public static extern Vector3 GetPushVelocity2(IntPtr obj);
1015[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1041[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1016public static extern Vector3 GetTurnVelocity2(IntPtr obj); 1042public static extern Vector3 GetTurnVelocity2(IntPtr obj);
1017 1043
1044[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1045public static extern void SetCollisionFilterMask2(IntPtr body, uint filter, uint mask);
1046
1018// ===================================================================================== 1047// =====================================================================================
1019// btCollisionShape entries 1048// btCollisionShape entries
1020 1049
@@ -1066,9 +1095,6 @@ public static extern void SetMargin2(IntPtr shape, float val);
1066[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1095[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1067public static extern float GetMargin2(IntPtr shape); 1096public static extern float GetMargin2(IntPtr shape);
1068 1097
1069[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1070public static extern void SetCollisionFilterMask(IntPtr shape, uint filter, uint mask);
1071
1072// ===================================================================================== 1098// =====================================================================================
1073// Debugging 1099// Debugging
1074[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1100[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]