aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
diff options
context:
space:
mode:
authorRobert Adams2012-08-25 23:18:46 -0700
committerRobert Adams2012-08-31 11:41:18 -0700
commit7c140570db3b01eb83efc0d42a47715d3047e376 (patch)
treeb077012e0c00cc7bb07f6e81e07359e14ffd2721 /OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
parentBulletSim: unify physical objects under BSPhysObjects. Now BSScene and BSLink... (diff)
downloadopensim-SC_OLD-7c140570db3b01eb83efc0d42a47715d3047e376.zip
opensim-SC_OLD-7c140570db3b01eb83efc0d42a47715d3047e376.tar.gz
opensim-SC_OLD-7c140570db3b01eb83efc0d42a47715d3047e376.tar.bz2
opensim-SC_OLD-7c140570db3b01eb83efc0d42a47715d3047e376.tar.xz
BulletSim: Changes to terrain storage and management so mega-regions work.
Moved all terrain code out of BSScene and into new BSTerrainManager. Added logic to manage multiple terrains for mega-regions. Added new functions to BulletSimAPI to match the library. Moved all of the terrain creation and setup logic from C++ code to C# code. The unused code has not yet been removed from either place. Soon. Moved checks for avatar above ground and in bounds into BSCharacter.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs61
1 files changed, 55 insertions, 6 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index dab2420..3b319fb 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -33,6 +33,9 @@ using OpenMetaverse;
33namespace OpenSim.Region.Physics.BulletSPlugin { 33namespace OpenSim.Region.Physics.BulletSPlugin {
34 34
35// Classes to allow some type checking for the API 35// Classes to allow some type checking for the API
36// These hold pointers to allocated objects in the unmanaged space.
37
38// The physics engine controller class created at initialization
36public struct BulletSim 39public struct BulletSim
37{ 40{
38 public BulletSim(uint id, BSScene bss, IntPtr xx) { ID = id; scene = bss; Ptr = xx; } 41 public BulletSim(uint id, BSScene bss, IntPtr xx) { ID = id; scene = bss; Ptr = xx; }
@@ -42,6 +45,7 @@ public struct BulletSim
42 public IntPtr Ptr; 45 public IntPtr Ptr;
43} 46}
44 47
48// An allocated Bullet btRigidBody
45public struct BulletBody 49public struct BulletBody
46{ 50{
47 public BulletBody(uint id, IntPtr xx) { ID = id; Ptr = xx; } 51 public BulletBody(uint id, IntPtr xx) { ID = id; Ptr = xx; }
@@ -49,12 +53,35 @@ public struct BulletBody
49 public uint ID; 53 public uint ID;
50} 54}
51 55
56// An allocated Bullet btConstraint
52public struct BulletConstraint 57public struct BulletConstraint
53{ 58{
54 public BulletConstraint(IntPtr xx) { Ptr = xx; } 59 public BulletConstraint(IntPtr xx) { Ptr = xx; }
55 public IntPtr Ptr; 60 public IntPtr Ptr;
56} 61}
57 62
63// An allocated HeightMapThing which hold various heightmap info
64// Made a class rather than a struct so there would be only one
65// instance of this and C# will pass around pointers rather
66// than making copies.
67public class BulletHeightMapInfo
68{
69 public BulletHeightMapInfo(IntPtr xx, float[] hm) {
70 Ptr = xx;
71 heightMap = hm;
72 terrainRegionBase = new Vector2(0f, 0f);
73 maxRegionExtent = new Vector3(100f, 100f, 25f);
74 minZ = maxZ = 0f;
75 sizeX = sizeY = 256f;
76 }
77 public IntPtr Ptr;
78 public float[] heightMap;
79 public Vector2 terrainRegionBase;
80 public Vector3 maxRegionExtent;
81 public float sizeX, sizeY;
82 public float minZ, maxZ;
83}
84
58// =============================================================================== 85// ===============================================================================
59[StructLayout(LayoutKind.Sequential)] 86[StructLayout(LayoutKind.Sequential)]
60public struct ConvexHull 87public struct ConvexHull
@@ -231,6 +258,9 @@ public static extern uint Initialize(Vector3 maxPosition, IntPtr parms,
231 int maxUpdates, IntPtr updateArray); 258 int maxUpdates, IntPtr updateArray);
232 259
233[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 260[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
261public static extern void CreateInitialGroundPlaneAndTerrain(uint worldID);
262
263[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
234public static extern void SetHeightmap(uint worldID, [MarshalAs(UnmanagedType.LPArray)] float[] heightMap); 264public static extern void SetHeightmap(uint worldID, [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
235 265
236[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 266[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@@ -414,12 +444,23 @@ public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape);
414 444
415// ===================================================================================== 445// =====================================================================================
416[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 446[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
417public static extern IntPtr CreateGroundPlaneBody2(uint id, Vector3 center, float collisionMargin); 447public static extern IntPtr CreateGroundPlaneBody2(uint id, float height, float collisionMargin);
418 448
419[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 449[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
420public static extern IntPtr CreateTerrainBody2(uint id, 450public static extern IntPtr CreateTerrainBody2(uint id,
421 Vector3 minCoords, Vector3 maxCoords, float collisionMargin, 451 IntPtr heightMapInfo,
422 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap); 452 float collisionMargin);
453
454[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
455public static extern IntPtr CreateHeightmap2(Vector3 minCoords, Vector3 maxCoords,
456 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
457
458[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
459public static extern bool ReleaseHeightmapInfo2(IntPtr heightMapInfo);
460
461[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
462public static extern void UpdateHeightMap2(IntPtr world, IntPtr heightMapInfo,
463 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
423 464
424// ===================================================================================== 465// =====================================================================================
425[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 466[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@@ -473,11 +514,16 @@ public static extern bool SetConstraintParam2(IntPtr constrain, ConstraintParams
473[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 514[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
474public static extern bool DestroyConstraint2(IntPtr world, IntPtr constrain); 515public static extern bool DestroyConstraint2(IntPtr world, IntPtr constrain);
475 516
517// =====================================================================================
476[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 518[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
477public static extern Vector3 AddObjectToWorld2(IntPtr world, IntPtr obj); 519public static extern bool AddObjectToWorld2(IntPtr world, IntPtr obj);
478 520
479[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 521[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
480public static extern Vector3 RemoveObjectFromWorld2(IntPtr world, IntPtr obj); 522public static extern bool RemoveObjectFromWorld2(IntPtr world, IntPtr obj);
523
524// =====================================================================================
525[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
526public static extern void Activate2(IntPtr obj, bool forceActivation);
481 527
482[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 528[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
483public static extern Vector3 GetPosition2(IntPtr obj); 529public static extern Vector3 GetPosition2(IntPtr obj);
@@ -522,6 +568,9 @@ public static extern bool SetContactProcessingThreshold2(IntPtr obj, float val);
522public static extern bool SetFriction2(IntPtr obj, float val); 568public static extern bool SetFriction2(IntPtr obj, float val);
523 569
524[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 570[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
571public static extern bool SetHitFraction2(IntPtr obj, float val);
572
573[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
525public static extern bool SetRestitution2(IntPtr obj, float val); 574public static extern bool SetRestitution2(IntPtr obj, float val);
526 575
527[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 576[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@@ -564,7 +613,7 @@ public static extern bool SetMargin2(IntPtr obj, float val);
564public static extern bool UpdateSingleAabb2(IntPtr world, IntPtr obj); 613public static extern bool UpdateSingleAabb2(IntPtr world, IntPtr obj);
565 614
566[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 615[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
567public static extern bool DestroyObject2(IntPtr world, uint id); 616public static extern bool DestroyObject2(IntPtr world, IntPtr obj);
568 617
569[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 618[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
570public static extern void DumpPhysicsStatistics2(IntPtr sim); 619public static extern void DumpPhysicsStatistics2(IntPtr sim);