aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
diff options
context:
space:
mode:
authorMelanie2012-12-16 21:19:30 +0000
committerMelanie2012-12-16 21:19:30 +0000
commit0a876a305c32e52d7d0b437c8246119227fce51c (patch)
tree59772311fcbaf528749b3b9661b252d99f0776ba /OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
parentMerge branch 'master' into careminster (diff)
parentMake WebStatsModule properly handle scenes added or removed after initial sta... (diff)
downloadopensim-SC_OLD-0a876a305c32e52d7d0b437c8246119227fce51c.zip
opensim-SC_OLD-0a876a305c32e52d7d0b437c8246119227fce51c.tar.gz
opensim-SC_OLD-0a876a305c32e52d7d0b437c8246119227fce51c.tar.bz2
opensim-SC_OLD-0a876a305c32e52d7d0b437c8246119227fce51c.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/Framework/Scenes/SceneObjectPart.cs OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs160
1 files changed, 7 insertions, 153 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index 2671995..962b540 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27using System; 27using System;
28using System.Collections.Generic;
28using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
29using System.Security; 30using System.Security;
30using System.Text; 31using System.Text;
@@ -32,93 +33,6 @@ using OpenMetaverse;
32 33
33namespace OpenSim.Region.Physics.BulletSPlugin { 34namespace OpenSim.Region.Physics.BulletSPlugin {
34 35
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
39public struct BulletSim
40{
41 public BulletSim(uint worldId, BSScene bss, IntPtr xx)
42 {
43 ptr = xx;
44 worldID = worldId;
45 physicsScene = bss;
46 }
47 public IntPtr ptr;
48 public uint worldID;
49 // The scene is only in here so very low level routines have a handle to print debug/error messages
50 public BSScene physicsScene;
51}
52
53// An allocated Bullet btRigidBody
54public struct BulletBody
55{
56 public BulletBody(uint id, IntPtr xx)
57 {
58 ID = id;
59 ptr = xx;
60 collisionGroup = 0;
61 collisionMask = 0;
62 }
63 public IntPtr ptr;
64 public uint ID;
65 public CollisionFilterGroups collisionGroup;
66 public CollisionFilterGroups collisionMask;
67 public override string ToString()
68 {
69 StringBuilder buff = new StringBuilder();
70 buff.Append("<id=");
71 buff.Append(ID.ToString());
72 buff.Append(",p=");
73 buff.Append(ptr.ToString("X"));
74 if (collisionGroup != 0 || collisionMask != 0)
75 {
76 buff.Append(",g=");
77 buff.Append(collisionGroup.ToString("X"));
78 buff.Append(",m=");
79 buff.Append(collisionMask.ToString("X"));
80 }
81 buff.Append(">");
82 return buff.ToString();
83 }
84}
85
86public struct BulletShape
87{
88 public BulletShape(IntPtr xx)
89 {
90 ptr = xx;
91 type=BSPhysicsShapeType.SHAPE_UNKNOWN;
92 shapeKey = (System.UInt64)FixedShapeKey.KEY_NONE;
93 isNativeShape = false;
94 }
95 public BulletShape(IntPtr xx, BSPhysicsShapeType typ)
96 {
97 ptr = xx;
98 type = typ;
99 shapeKey = 0;
100 isNativeShape = false;
101 }
102 public IntPtr ptr;
103 public BSPhysicsShapeType type;
104 public System.UInt64 shapeKey;
105 public bool isNativeShape;
106 public override string ToString()
107 {
108 StringBuilder buff = new StringBuilder();
109 buff.Append("<p=");
110 buff.Append(ptr.ToString("X"));
111 buff.Append(",s=");
112 buff.Append(type.ToString());
113 buff.Append(",k=");
114 buff.Append(shapeKey.ToString("X"));
115 buff.Append(",n=");
116 buff.Append(isNativeShape.ToString());
117 buff.Append(">");
118 return buff.ToString();
119 }
120}
121
122 // Constraint type values as defined by Bullet 36 // Constraint type values as defined by Bullet
123public enum ConstraintType : int 37public enum ConstraintType : int
124{ 38{
@@ -132,44 +46,6 @@ public enum ConstraintType : int
132 MAX_CONSTRAINT_TYPE 46 MAX_CONSTRAINT_TYPE
133} 47}
134 48
135// An allocated Bullet btConstraint
136public struct BulletConstraint
137{
138 public BulletConstraint(IntPtr xx)
139 {
140 ptr = xx;
141 }
142 public IntPtr ptr;
143}
144
145// An allocated HeightMapThing which holds various heightmap info.
146// Made a class rather than a struct so there would be only one
147// instance of this and C# will pass around pointers rather
148// than making copies.
149public class BulletHeightMapInfo
150{
151 public BulletHeightMapInfo(uint id, float[] hm, IntPtr xx) {
152 ID = id;
153 Ptr = xx;
154 heightMap = hm;
155 terrainRegionBase = Vector3.Zero;
156 minCoords = new Vector3(100f, 100f, 25f);
157 maxCoords = new Vector3(101f, 101f, 26f);
158 minZ = maxZ = 0f;
159 sizeX = sizeY = 256f;
160 }
161 public uint ID;
162 public IntPtr Ptr;
163 public float[] heightMap;
164 public Vector3 terrainRegionBase;
165 public Vector3 minCoords;
166 public Vector3 maxCoords;
167 public float sizeX, sizeY;
168 public float minZ, maxZ;
169 public BulletShape terrainShape;
170 public BulletBody terrainBody;
171}
172
173// =============================================================================== 49// ===============================================================================
174[StructLayout(LayoutKind.Sequential)] 50[StructLayout(LayoutKind.Sequential)]
175public struct ConvexHull 51public struct ConvexHull
@@ -362,21 +238,15 @@ public enum CollisionFlags : uint
362 BS_FLOATS_ON_WATER = 1 << 11, 238 BS_FLOATS_ON_WATER = 1 << 11,
363 BS_VEHICLE_COLLISIONS = 1 << 12, 239 BS_VEHICLE_COLLISIONS = 1 << 12,
364 BS_NONE = 0, 240 BS_NONE = 0,
365 BS_ALL = 0xFFFFFFFF, 241 BS_ALL = 0xFFFFFFFF
366
367 // These are the collision flags switched depending on physical state.
368 // The other flags are used for other things and should not be fooled with.
369 BS_ACTIVE = CF_STATIC_OBJECT
370 | CF_KINEMATIC_OBJECT
371 | CF_NO_CONTACT_RESPONSE
372}; 242};
373 243
374// Values for collisions groups and masks 244// Values f collisions groups and masks
375public enum CollisionFilterGroups : uint 245public enum CollisionFilterGroups : uint
376{ 246{
377 // Don't use the bit definitions!! Define the use in a 247 // Don't use the bit definitions!! Define the use in a
378 // filter/mask definition below. This way collision interactions 248 // filter/mask definition below. This way collision interactions
379 // are more easily debugged. 249 // are more easily found and debugged.
380 BNoneGroup = 0, 250 BNoneGroup = 0,
381 BDefaultGroup = 1 << 0, 251 BDefaultGroup = 1 << 0,
382 BStaticGroup = 1 << 1, 252 BStaticGroup = 1 << 1,
@@ -390,24 +260,8 @@ public enum CollisionFilterGroups : uint
390 BTerrainGroup = 1 << 11, 260 BTerrainGroup = 1 << 11,
391 BRaycastGroup = 1 << 12, 261 BRaycastGroup = 1 << 12,
392 BSolidGroup = 1 << 13, 262 BSolidGroup = 1 << 13,
393 BLinksetGroup = 1 << 14, 263 // BLinksetGroup = xx // a linkset proper is either static or dynamic
394 264 BLinksetChildGroup = 1 << 14,
395 // The collsion filters and masked are defined in one place -- don't want them scattered
396 AvatarGroup = BCharacterGroup,
397 AvatarMask = BAllGroup,
398 ObjectGroup = BSolidGroup,
399 ObjectMask = BAllGroup,
400 StaticObjectGroup = BStaticGroup,
401 StaticObjectMask = AvatarGroup | ObjectGroup, // static things don't interact with much
402 LinksetGroup = BLinksetGroup,
403 LinksetMask = BAllGroup & ~BLinksetGroup, // linkset objects don't collide with each other
404 VolumeDetectGroup = BSensorTrigger,
405 VolumeDetectMask = ~BSensorTrigger,
406 TerrainGroup = BTerrainGroup,
407 TerrainMask = BAllGroup & ~BStaticGroup, // static objects on the ground don't collide
408 GroundPlaneGroup = BGroundPlaneGroup,
409 GroundPlaneMask = BAllGroup
410
411}; 265};
412 266
413// CFM controls the 'hardness' of the constraint. 0=fixed, 0..1=violatable. Default=0 267// CFM controls the 'hardness' of the constraint. 0=fixed, 0..1=violatable. Default=0
@@ -434,7 +288,7 @@ public enum ConstraintParamAxis : int
434 288
435// =============================================================================== 289// ===============================================================================
436static class BulletSimAPI { 290static class BulletSimAPI {
437 291// ===============================================================================
438// Link back to the managed code for outputting log messages 292// Link back to the managed code for outputting log messages
439[UnmanagedFunctionPointer(CallingConvention.Cdecl)] 293[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
440public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg); 294public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);