aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
diff options
context:
space:
mode:
authorRobert Adams2012-09-19 08:21:29 -0700
committerRobert Adams2012-09-27 22:01:21 -0700
commita27e4ce6cbfb0a2e852624fd4d81121ca829f85c (patch)
treecd467ddf5dcc8a7109eef5d82f1929c1b5bf77b8 /OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
parentBulletSim: Convert BSCharacter to use common BSPhysObject code and variables. (diff)
downloadopensim-SC_OLD-a27e4ce6cbfb0a2e852624fd4d81121ca829f85c.zip
opensim-SC_OLD-a27e4ce6cbfb0a2e852624fd4d81121ca829f85c.tar.gz
opensim-SC_OLD-a27e4ce6cbfb0a2e852624fd4d81121ca829f85c.tar.bz2
opensim-SC_OLD-a27e4ce6cbfb0a2e852624fd4d81121ca829f85c.tar.xz
BulletSim: add class and infrastructure for shape and object
tracking in the C# code. Needed for the changing body type (to and from GhostObjects) for volumeDetect.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs91
1 files changed, 66 insertions, 25 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index 4d2d962..52c8a24 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -38,31 +38,54 @@ namespace OpenSim.Region.Physics.BulletSPlugin {
38// The physics engine controller class created at initialization 38// The physics engine controller class created at initialization
39public struct BulletSim 39public struct BulletSim
40{ 40{
41 public BulletSim(uint worldId, BSScene bss, IntPtr xx) { worldID = worldId; scene = bss; Ptr = xx; } 41 public BulletSim(uint worldId, BSScene bss, IntPtr xx)
42 {
43 worldID = worldId; scene = bss; Ptr = xx;
44 }
42 public uint worldID; 45 public uint worldID;
43 // The scene is only in here so very low level routines have a handle to print debug/error messages 46 // The scene is only in here so very low level routines have a handle to print debug/error messages
44 public BSScene scene; 47 public BSScene scene;
45 public IntPtr Ptr; 48 public IntPtr Ptr;
46} 49}
47 50
48public struct BulletShape 51// An allocated Bullet btRigidBody
52public struct BulletBody
49{ 53{
50 public BulletShape(IntPtr xx) { Ptr = xx; } 54 public BulletBody(uint id, IntPtr xx)
55 {
56 ID = id;
57 Ptr = xx;
58 }
51 public IntPtr Ptr; 59 public IntPtr Ptr;
60 public uint ID;
52} 61}
53 62
54// An allocated Bullet btRigidBody 63public struct BulletShape
55public struct BulletBody
56{ 64{
57 public BulletBody(uint id, IntPtr xx) { ID = id; Ptr = xx; } 65 public BulletShape(IntPtr xx)
66 {
67 Ptr = xx;
68 type=ShapeData.PhysicsShapeType.SHAPE_UNKNOWN;
69 hashKey = 0;
70 }
71 public BulletShape(IntPtr xx, ShapeData.PhysicsShapeType typ)
72 {
73 Ptr = xx;
74 type = typ;
75 hashKey = 0;
76 }
58 public IntPtr Ptr; 77 public IntPtr Ptr;
59 public uint ID; 78 public ShapeData.PhysicsShapeType type;
79 public ulong hashKey;
60} 80}
61 81
62// An allocated Bullet btConstraint 82// An allocated Bullet btConstraint
63public struct BulletConstraint 83public struct BulletConstraint
64{ 84{
65 public BulletConstraint(IntPtr xx) { Ptr = xx; } 85 public BulletConstraint(IntPtr xx)
86 {
87 Ptr = xx;
88 }
66 public IntPtr Ptr; 89 public IntPtr Ptr;
67} 90}
68 91
@@ -96,14 +119,14 @@ public class BulletHeightMapInfo
96 119
97// =============================================================================== 120// ===============================================================================
98[StructLayout(LayoutKind.Sequential)] 121[StructLayout(LayoutKind.Sequential)]
99public struct ConvexHull 122public struct ConvexHull
100{ 123{
101 Vector3 Offset; 124 Vector3 Offset;
102 int VertexCount; 125 int VertexCount;
103 Vector3[] Vertices; 126 Vector3[] Vertices;
104} 127}
105[StructLayout(LayoutKind.Sequential)] 128[StructLayout(LayoutKind.Sequential)]
106public struct ShapeData 129public struct ShapeData
107{ 130{
108 public enum PhysicsShapeType 131 public enum PhysicsShapeType
109 { 132 {
@@ -114,7 +137,9 @@ public struct ShapeData
114 SHAPE_CYLINDER = 4, 137 SHAPE_CYLINDER = 4,
115 SHAPE_SPHERE = 5, 138 SHAPE_SPHERE = 5,
116 SHAPE_MESH = 6, 139 SHAPE_MESH = 6,
117 SHAPE_HULL = 7 140 SHAPE_HULL = 7,
141 SHAPE_GROUNDPLANE = 8,
142 SHAPE_TERRAIN = 9,
118 }; 143 };
119 public uint ID; 144 public uint ID;
120 public PhysicsShapeType Type; 145 public PhysicsShapeType Type;
@@ -136,7 +161,7 @@ public struct ShapeData
136 public const float numericFalse = 0f; 161 public const float numericFalse = 0f;
137} 162}
138[StructLayout(LayoutKind.Sequential)] 163[StructLayout(LayoutKind.Sequential)]
139public struct SweepHit 164public struct SweepHit
140{ 165{
141 public uint ID; 166 public uint ID;
142 public float Fraction; 167 public float Fraction;
@@ -227,7 +252,17 @@ public enum ActivationState : uint
227 ISLAND_SLEEPING, 252 ISLAND_SLEEPING,
228 WANTS_DEACTIVATION, 253 WANTS_DEACTIVATION,
229 DISABLE_DEACTIVATION, 254 DISABLE_DEACTIVATION,
230 DISABLE_SIMULATION 255 DISABLE_SIMULATION,
256}
257
258public enum CollisionObjectTypes : int
259{
260 CO_COLLISION_OBJECT = 1 << 0,
261 CO_RIGID_BODY = 1 << 1,
262 CO_GHOST_OBJECT = 1 << 2,
263 CO_SOFT_BODY = 1 << 3,
264 CO_HF_FLUID = 1 << 4,
265 CO_USER_TYPE = 1 << 5,
231} 266}
232 267
233// Values used by Bullet and BulletSim to control object properties. 268// Values used by Bullet and BulletSim to control object properties.
@@ -313,8 +348,8 @@ public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg
313public static extern string GetVersion(); 348public static extern string GetVersion();
314 349
315[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 350[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
316public static extern uint Initialize(Vector3 maxPosition, IntPtr parms, 351public static extern uint Initialize(Vector3 maxPosition, IntPtr parms,
317 int maxCollisions, IntPtr collisionArray, 352 int maxCollisions, IntPtr collisionArray,
318 int maxUpdates, IntPtr updateArray, 353 int maxUpdates, IntPtr updateArray,
319 DebugLogCallback logRoutine); 354 DebugLogCallback logRoutine);
320 355
@@ -333,19 +368,19 @@ public static extern bool UpdateParameter(uint worldID, uint localID,
333 368
334// =============================================================================== 369// ===============================================================================
335[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 370[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
336public static extern int PhysicsStep(uint worldID, float timeStep, int maxSubSteps, float fixedTimeStep, 371public static extern int PhysicsStep(uint worldID, float timeStep, int maxSubSteps, float fixedTimeStep,
337 out int updatedEntityCount, 372 out int updatedEntityCount,
338 out IntPtr updatedEntitiesPtr, 373 out IntPtr updatedEntitiesPtr,
339 out int collidersCount, 374 out int collidersCount,
340 out IntPtr collidersPtr); 375 out IntPtr collidersPtr);
341 376
342[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 377[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
343public static extern bool CreateHull(uint worldID, System.UInt64 meshKey, 378public static extern bool CreateHull(uint worldID, System.UInt64 meshKey,
344 int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls 379 int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls
345 ); 380 );
346 381
347[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 382[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
348public static extern bool CreateMesh(uint worldID, System.UInt64 meshKey, 383public static extern bool CreateMesh(uint worldID, System.UInt64 meshKey,
349 int indexCount, [MarshalAs(UnmanagedType.LPArray)] int[] indices, 384 int indexCount, [MarshalAs(UnmanagedType.LPArray)] int[] indices,
350 int verticesCount, [MarshalAs(UnmanagedType.LPArray)] float[] vertices 385 int verticesCount, [MarshalAs(UnmanagedType.LPArray)] float[] vertices
351 ); 386 );
@@ -459,7 +494,7 @@ public static extern void Shutdown2(IntPtr sim);
459 494
460[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 495[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
461public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep, 496public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep,
462 out int updatedEntityCount, 497 out int updatedEntityCount,
463 out IntPtr updatedEntitiesPtr, 498 out IntPtr updatedEntitiesPtr,
464 out int collidersCount, 499 out int collidersCount,
465 out IntPtr collidersPtr); 500 out IntPtr collidersPtr);
@@ -470,8 +505,8 @@ public static extern bool PushUpdate2(IntPtr obj);
470// ===================================================================================== 505// =====================================================================================
471// Mesh, hull, shape and body creation helper routines 506// Mesh, hull, shape and body creation helper routines
472[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 507[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
473public static extern IntPtr CreateMeshShape2(IntPtr world, 508public static extern IntPtr CreateMeshShape2(IntPtr world,
474 int indicesCount, [MarshalAs(UnmanagedType.LPArray)] int[] indices, 509 int indicesCount, [MarshalAs(UnmanagedType.LPArray)] int[] indices,
475 int verticesCount, [MarshalAs(UnmanagedType.LPArray)] float[] vertices ); 510 int verticesCount, [MarshalAs(UnmanagedType.LPArray)] float[] vertices );
476 511
477[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 512[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@@ -504,12 +539,18 @@ public static extern IntPtr CreateBodyFromShapeAndInfo2(IntPtr sim, IntPtr shape
504public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape); 539public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape);
505 540
506[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 541[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
542public static extern int GetBodyType2(IntPtr obj);
543
544[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
507public static extern IntPtr CreateBodyFromShape2(IntPtr sim, IntPtr shape, Vector3 pos, Quaternion rot); 545public static extern IntPtr CreateBodyFromShape2(IntPtr sim, IntPtr shape, Vector3 pos, Quaternion rot);
508 546
509[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 547[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
510public static extern IntPtr CreateBodyWithDefaultMotionState2(IntPtr shape, Vector3 pos, Quaternion rot); 548public static extern IntPtr CreateBodyWithDefaultMotionState2(IntPtr shape, Vector3 pos, Quaternion rot);
511 549
512[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 550[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
551public static extern IntPtr CreateGhostFromShape2(IntPtr sim, IntPtr shape, Vector3 pos, Quaternion rot);
552
553[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
513public static extern IntPtr AllocateBodyInfo2(IntPtr obj); 554public static extern IntPtr AllocateBodyInfo2(IntPtr obj);
514 555
515[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 556[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@@ -521,11 +562,11 @@ public static extern void DestroyObject2(IntPtr sim, IntPtr obj);
521// ===================================================================================== 562// =====================================================================================
522// Terrain creation and helper routines 563// Terrain creation and helper routines
523[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 564[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
524public static extern IntPtr CreateHeightMapInfo2(IntPtr sim, uint id, Vector3 minCoords, Vector3 maxCoords, 565public static extern IntPtr CreateHeightMapInfo2(IntPtr sim, uint id, Vector3 minCoords, Vector3 maxCoords,
525 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin); 566 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin);
526 567
527[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 568[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
528public static extern IntPtr FillHeightMapInfo2(IntPtr sim, IntPtr mapInfo, uint id, Vector3 minCoords, Vector3 maxCoords, 569public static extern IntPtr FillHeightMapInfo2(IntPtr sim, IntPtr mapInfo, uint id, Vector3 minCoords, Vector3 maxCoords,
529 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin); 570 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin);
530 571
531[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 572[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@@ -563,7 +604,7 @@ public static extern void SetConstraintEnable2(IntPtr constrain, float numericTr
563public static extern void SetConstraintNumSolverIterations2(IntPtr constrain, float iterations); 604public static extern void SetConstraintNumSolverIterations2(IntPtr constrain, float iterations);
564 605
565[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 606[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
566public static extern bool SetFrames2(IntPtr constrain, 607public static extern bool SetFrames2(IntPtr constrain,
567 Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot); 608 Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot);
568 609
569[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 610[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]