aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
diff options
context:
space:
mode:
authorRobert Adams2012-08-29 09:20:09 -0700
committerRobert Adams2012-08-31 11:41:28 -0700
commitae852bb8738c7bce60c8fee9fbf6038288bd9363 (patch)
treec729bdaa28bc827f0729f7c5a4882b351bf64996 /OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
parentBulletSim: fix line endings. (diff)
downloadopensim-SC_OLD-ae852bb8738c7bce60c8fee9fbf6038288bd9363.zip
opensim-SC_OLD-ae852bb8738c7bce60c8fee9fbf6038288bd9363.tar.gz
opensim-SC_OLD-ae852bb8738c7bce60c8fee9fbf6038288bd9363.tar.bz2
opensim-SC_OLD-ae852bb8738c7bce60c8fee9fbf6038288bd9363.tar.xz
BulletSim: clean up some variable naming for consistancy.
Update DLL API for new terrain and shape/body pattern methods. Terrain creation and modification uses new shape/body pattern. Move debug logging callback set to initialization call so logging is per physics engine.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs55
1 files changed, 37 insertions, 18 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index 3b319fb..804d2ea 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -38,13 +38,19 @@ 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 id, BSScene bss, IntPtr xx) { ID = id; scene = bss; Ptr = xx; } 41 public BulletSim(uint worldId, BSScene bss, IntPtr xx) { worldID = worldId; scene = bss; Ptr = xx; }
42 public uint ID; 42 public uint worldID;
43 // The scene is only in here so very low level routines have a handle to print debug/error messages 43 // The scene is only in here so very low level routines have a handle to print debug/error messages
44 public BSScene scene; 44 public BSScene scene;
45 public IntPtr Ptr; 45 public IntPtr Ptr;
46} 46}
47 47
48public struct BulletShape
49{
50 public BulletShape(IntPtr xx) { Ptr = xx; }
51 public IntPtr Ptr;
52}
53
48// An allocated Bullet btRigidBody 54// An allocated Bullet btRigidBody
49public struct BulletBody 55public struct BulletBody
50{ 56{
@@ -66,18 +72,22 @@ public struct BulletConstraint
66// than making copies. 72// than making copies.
67public class BulletHeightMapInfo 73public class BulletHeightMapInfo
68{ 74{
69 public BulletHeightMapInfo(IntPtr xx, float[] hm) { 75 public BulletHeightMapInfo(uint id, float[] hm, IntPtr xx) {
76 ID = id;
70 Ptr = xx; 77 Ptr = xx;
71 heightMap = hm; 78 heightMap = hm;
72 terrainRegionBase = new Vector2(0f, 0f); 79 terrainRegionBase = new Vector2(0f, 0f);
73 maxRegionExtent = new Vector3(100f, 100f, 25f); 80 minCoords = new Vector3(100f, 100f, 25f);
81 maxCoords = new Vector3(101f, 101f, 26f);
74 minZ = maxZ = 0f; 82 minZ = maxZ = 0f;
75 sizeX = sizeY = 256f; 83 sizeX = sizeY = 256f;
76 } 84 }
85 public uint ID;
77 public IntPtr Ptr; 86 public IntPtr Ptr;
78 public float[] heightMap; 87 public float[] heightMap;
79 public Vector2 terrainRegionBase; 88 public Vector2 terrainRegionBase;
80 public Vector3 maxRegionExtent; 89 public Vector3 minCoords;
90 public Vector3 maxCoords;
81 public float sizeX, sizeY; 91 public float sizeX, sizeY;
82 public float minZ, maxZ; 92 public float minZ, maxZ;
83} 93}
@@ -248,6 +258,10 @@ public enum ConstraintParamAxis : int
248// =============================================================================== 258// ===============================================================================
249static class BulletSimAPI { 259static class BulletSimAPI {
250 260
261// Link back to the managed code for outputting log messages
262[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
263public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);
264
251[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 265[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
252[return: MarshalAs(UnmanagedType.LPStr)] 266[return: MarshalAs(UnmanagedType.LPStr)]
253public static extern string GetVersion(); 267public static extern string GetVersion();
@@ -255,7 +269,8 @@ public static extern string GetVersion();
255[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 269[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
256public static extern uint Initialize(Vector3 maxPosition, IntPtr parms, 270public static extern uint Initialize(Vector3 maxPosition, IntPtr parms,
257 int maxCollisions, IntPtr collisionArray, 271 int maxCollisions, IntPtr collisionArray,
258 int maxUpdates, IntPtr updateArray); 272 int maxUpdates, IntPtr updateArray,
273 DebugLogCallback logRoutine);
259 274
260[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 275[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
261public static extern void CreateInitialGroundPlaneAndTerrain(uint worldID); 276public static extern void CreateInitialGroundPlaneAndTerrain(uint worldID);
@@ -372,8 +387,6 @@ public static extern Vector3 RecoverFromPenetration(uint worldID, uint id);
372public static extern void DumpBulletStatistics(); 387public static extern void DumpBulletStatistics();
373 388
374// Log a debug message 389// Log a debug message
375[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
376public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);
377[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 390[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
378public static extern void SetDebugLogCallback(DebugLogCallback callback); 391public static extern void SetDebugLogCallback(DebugLogCallback callback);
379 392
@@ -407,7 +420,7 @@ public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms,
407public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value); 420public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value);
408 421
409[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 422[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
410public static extern void SetHeightmap2(IntPtr world, float[] heightmap); 423public static extern void SetHeightMap2(IntPtr world, float[] heightmap);
411 424
412[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 425[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
413public static extern void Shutdown2(IntPtr sim); 426public static extern void Shutdown2(IntPtr sim);
@@ -442,25 +455,31 @@ public static extern IntPtr BuildNativeShape2(IntPtr world,
442[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 455[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
443public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape); 456public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape);
444 457
458[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
459public static extern IntPtr CreateBodyFromShape2(IntPtr sim, IntPtr shape, Vector3 pos, Quaternion rot);
460
461[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
462public static extern IntPtr CreateBodyWithDefaultMotionState2(IntPtr shape, Vector3 pos, Quaternion rot);
463
464[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
465public static extern bool ReplaceBodyShape2(IntPtr sim, IntPtr obj, IntPtr shape);
445// ===================================================================================== 466// =====================================================================================
446[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 467[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
447public static extern IntPtr CreateGroundPlaneBody2(uint id, float height, float collisionMargin); 468public static extern IntPtr CreateHeightMapInfo2(uint id, Vector3 minCoords, Vector3 maxCoords,
469 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin);
448 470
449[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 471[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
450public static extern IntPtr CreateTerrainBody2(uint id, 472public static extern IntPtr FillHeightMapInfo2(IntPtr mapInfo, uint id, Vector3 minCoords, Vector3 maxCoords,
451 IntPtr heightMapInfo, 473 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin);
452 float collisionMargin);
453 474
454[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 475[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
455public static extern IntPtr CreateHeightmap2(Vector3 minCoords, Vector3 maxCoords, 476public static extern bool ReleaseHeightMapInfo2(IntPtr heightMapInfo);
456 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
457 477
458[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 478[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
459public static extern bool ReleaseHeightmapInfo2(IntPtr heightMapInfo); 479public static extern IntPtr CreateGroundPlaneShape2(uint id, float height, float collisionMargin);
460 480
461[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 481[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
462public static extern void UpdateHeightMap2(IntPtr world, IntPtr heightMapInfo, 482public static extern IntPtr CreateTerrainShape2(IntPtr mapInfo);
463 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
464 483
465// ===================================================================================== 484// =====================================================================================
466[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 485[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]