aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs167
1 files changed, 105 insertions, 62 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs
index 8ad78ca..3378c93 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs
@@ -6,7 +6,7 @@
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyrightD 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
@@ -70,6 +70,7 @@ public enum BSPhysicsShapeType
70 SHAPE_COMPOUND = 22, 70 SHAPE_COMPOUND = 22,
71 SHAPE_HEIGHTMAP = 23, 71 SHAPE_HEIGHTMAP = 23,
72 SHAPE_AVATAR = 24, 72 SHAPE_AVATAR = 24,
73 SHAPE_CONVEXHULL= 25,
73}; 74};
74 75
75// The native shapes have predefined shape hash keys 76// The native shapes have predefined shape hash keys
@@ -87,7 +88,7 @@ public enum FixedShapeKey : ulong
87[StructLayout(LayoutKind.Sequential)] 88[StructLayout(LayoutKind.Sequential)]
88public struct ShapeData 89public struct ShapeData
89{ 90{
90 public uint ID; 91 public UInt32 ID;
91 public BSPhysicsShapeType Type; 92 public BSPhysicsShapeType Type;
92 public Vector3 Position; 93 public Vector3 Position;
93 public Quaternion Rotation; 94 public Quaternion Rotation;
@@ -111,7 +112,7 @@ public struct ShapeData
111[StructLayout(LayoutKind.Sequential)] 112[StructLayout(LayoutKind.Sequential)]
112public struct SweepHit 113public struct SweepHit
113{ 114{
114 public uint ID; 115 public UInt32 ID;
115 public float Fraction; 116 public float Fraction;
116 public Vector3 Normal; 117 public Vector3 Normal;
117 public Vector3 Point; 118 public Vector3 Point;
@@ -119,27 +120,47 @@ public struct SweepHit
119[StructLayout(LayoutKind.Sequential)] 120[StructLayout(LayoutKind.Sequential)]
120public struct RaycastHit 121public struct RaycastHit
121{ 122{
122 public uint ID; 123 public UInt32 ID;
123 public float Fraction; 124 public float Fraction;
124 public Vector3 Normal; 125 public Vector3 Normal;
125} 126}
126[StructLayout(LayoutKind.Sequential)] 127[StructLayout(LayoutKind.Sequential)]
127public struct CollisionDesc 128public struct CollisionDesc
128{ 129{
129 public uint aID; 130 public UInt32 aID;
130 public uint bID; 131 public UInt32 bID;
131 public Vector3 point; 132 public Vector3 point;
132 public Vector3 normal; 133 public Vector3 normal;
134 public float penetration;
133} 135}
134[StructLayout(LayoutKind.Sequential)] 136[StructLayout(LayoutKind.Sequential)]
135public struct EntityProperties 137public struct EntityProperties
136{ 138{
137 public uint ID; 139 public UInt32 ID;
138 public Vector3 Position; 140 public Vector3 Position;
139 public Quaternion Rotation; 141 public Quaternion Rotation;
140 public Vector3 Velocity; 142 public Vector3 Velocity;
141 public Vector3 Acceleration; 143 public Vector3 Acceleration;
142 public Vector3 RotationalVelocity; 144 public Vector3 RotationalVelocity;
145
146 public override string ToString()
147 {
148 StringBuilder buff = new StringBuilder();
149 buff.Append("<i=");
150 buff.Append(ID.ToString());
151 buff.Append(",p=");
152 buff.Append(Position.ToString());
153 buff.Append(",r=");
154 buff.Append(Rotation.ToString());
155 buff.Append(",v=");
156 buff.Append(Velocity.ToString());
157 buff.Append(",a=");
158 buff.Append(Acceleration.ToString());
159 buff.Append(",rv=");
160 buff.Append(RotationalVelocity.ToString());
161 buff.Append(">");
162 return buff.ToString();
163 }
143} 164}
144 165
145// Format of this structure must match the definition in the C++ code 166// Format of this structure must match the definition in the C++ code
@@ -154,32 +175,6 @@ public struct ConfigurationParameters
154 public float collisionMargin; 175 public float collisionMargin;
155 public float gravity; 176 public float gravity;
156 177
157 public float XlinearDamping;
158 public float XangularDamping;
159 public float XdeactivationTime;
160 public float XlinearSleepingThreshold;
161 public float XangularSleepingThreshold;
162 public float XccdMotionThreshold;
163 public float XccdSweptSphereRadius;
164 public float XcontactProcessingThreshold;
165
166 public float XterrainImplementation;
167 public float XterrainFriction;
168 public float XterrainHitFraction;
169 public float XterrainRestitution;
170 public float XterrainCollisionMargin;
171
172 public float XavatarFriction;
173 public float XavatarStandingFriction;
174 public float XavatarDensity;
175 public float XavatarRestitution;
176 public float XavatarCapsuleWidth;
177 public float XavatarCapsuleDepth;
178 public float XavatarCapsuleHeight;
179 public float XavatarContactProcessingThreshold;
180
181 public float XvehicleAngularDamping;
182
183 public float maxPersistantManifoldPoolSize; 178 public float maxPersistantManifoldPoolSize;
184 public float maxCollisionAlgorithmPoolSize; 179 public float maxCollisionAlgorithmPoolSize;
185 public float shouldDisableContactPoolDynamicAllocation; 180 public float shouldDisableContactPoolDynamicAllocation;
@@ -188,22 +183,30 @@ public struct ConfigurationParameters
188 public float shouldSplitSimulationIslands; 183 public float shouldSplitSimulationIslands;
189 public float shouldEnableFrictionCaching; 184 public float shouldEnableFrictionCaching;
190 public float numberOfSolverIterations; 185 public float numberOfSolverIterations;
186 public float useSingleSidedMeshes;
187 public float globalContactBreakingThreshold;
191 188
192 public float XlinksetImplementation; 189 public float physicsLoggingFrames;
193 public float XlinkConstraintUseFrameOffset;
194 public float XlinkConstraintEnableTransMotor;
195 public float XlinkConstraintTransMotorMaxVel;
196 public float XlinkConstraintTransMotorMaxForce;
197 public float XlinkConstraintERP;
198 public float XlinkConstraintCFM;
199 public float XlinkConstraintSolverIterations;
200
201 public float XphysicsLoggingFrames;
202 190
203 public const float numericTrue = 1f; 191 public const float numericTrue = 1f;
204 public const float numericFalse = 0f; 192 public const float numericFalse = 0f;
205} 193}
206 194
195// Parameters passed for the conversion of a mesh to a hull using Bullet's HACD library.
196[StructLayout(LayoutKind.Sequential)]
197public struct HACDParams
198{
199 // usual default values
200 public float maxVerticesPerHull; // 100
201 public float minClusters; // 2
202 public float compacityWeight; // 0.1
203 public float volumeWeight; // 0.0
204 public float concavity; // 100
205 public float addExtraDistPoints; // false
206 public float addNeighboursDistPoints; // false
207 public float addFacesPoints; // false
208 public float shouldAdjustCollisionMargin; // false
209}
207 210
208// The states a bullet collision object can have 211// The states a bullet collision object can have
209public enum ActivationState : uint 212public enum ActivationState : uint
@@ -238,9 +241,10 @@ public enum CollisionFlags : uint
238 CF_DISABLE_VISUALIZE_OBJECT = 1 << 5, 241 CF_DISABLE_VISUALIZE_OBJECT = 1 << 5,
239 CF_DISABLE_SPU_COLLISION_PROCESS = 1 << 6, 242 CF_DISABLE_SPU_COLLISION_PROCESS = 1 << 6,
240 // Following used by BulletSim to control collisions and updates 243 // Following used by BulletSim to control collisions and updates
241 BS_SUBSCRIBE_COLLISION_EVENTS = 1 << 10, 244 BS_SUBSCRIBE_COLLISION_EVENTS = 1 << 10, // return collision events from unmanaged to managed
242 BS_FLOATS_ON_WATER = 1 << 11, 245 BS_FLOATS_ON_WATER = 1 << 11, // the object should float at water level
243 BS_VEHICLE_COLLISIONS = 1 << 12, 246 BS_VEHICLE_COLLISIONS = 1 << 12, // return collisions for vehicle ground checking
247 BS_RETURN_ROOT_COMPOUND_SHAPE = 1 << 13, // return the pos/rot of the root shape in a compound shape
244 BS_NONE = 0, 248 BS_NONE = 0,
245 BS_ALL = 0xFFFFFFFF 249 BS_ALL = 0xFFFFFFFF
246}; 250};
@@ -294,7 +298,7 @@ public abstract class BSAPITemplate
294{ 298{
295// Returns the name of the underlying Bullet engine 299// Returns the name of the underlying Bullet engine
296public abstract string BulletEngineName { get; } 300public abstract string BulletEngineName { get; }
297public abstract string BulletEngineVersion { get; protected set;} 301public abstract string BulletEngineVersion { get; protected set;}
298 302
299// Initialization and simulation 303// Initialization and simulation
300public abstract BulletWorld Initialize(Vector3 maxPosition, ConfigurationParameters parms, 304public abstract BulletWorld Initialize(Vector3 maxPosition, ConfigurationParameters parms,
@@ -305,7 +309,7 @@ public abstract BulletWorld Initialize(Vector3 maxPosition, ConfigurationParamet
305public abstract int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, 309public abstract int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep,
306 out int updatedEntityCount, out int collidersCount); 310 out int updatedEntityCount, out int collidersCount);
307 311
308public abstract bool UpdateParameter(BulletWorld world, uint localID, String parm, float value); 312public abstract bool UpdateParameter(BulletWorld world, UInt32 localID, String parm, float value);
309 313
310public abstract void Shutdown(BulletWorld sim); 314public abstract void Shutdown(BulletWorld sim);
311 315
@@ -320,7 +324,13 @@ public abstract BulletShape CreateMeshShape(BulletWorld world,
320public abstract BulletShape CreateHullShape(BulletWorld world, 324public abstract BulletShape CreateHullShape(BulletWorld world,
321 int hullCount, float[] hulls); 325 int hullCount, float[] hulls);
322 326
323public abstract BulletShape BuildHullShapeFromMesh(BulletWorld world, BulletShape meshShape); 327public abstract BulletShape BuildHullShapeFromMesh(BulletWorld world, BulletShape meshShape, HACDParams parms);
328
329public abstract BulletShape BuildConvexHullShapeFromMesh(BulletWorld world, BulletShape meshShape);
330
331public abstract BulletShape CreateConvexHullShape(BulletWorld world,
332 int indicesCount, int[] indices,
333 int verticesCount, float[] vertices );
324 334
325public abstract BulletShape BuildNativeShape(BulletWorld world, ShapeData shapeData); 335public abstract BulletShape BuildNativeShape(BulletWorld world, ShapeData shapeData);
326 336
@@ -342,26 +352,28 @@ public abstract BulletShape RemoveChildShapeFromCompoundShapeIndex(BulletShape c
342 352
343public abstract void RemoveChildShapeFromCompoundShape(BulletShape cShape, BulletShape removeShape); 353public abstract void RemoveChildShapeFromCompoundShape(BulletShape cShape, BulletShape removeShape);
344 354
355public abstract void UpdateChildTransform(BulletShape pShape, int childIndex, Vector3 pos, Quaternion rot, bool shouldRecalculateLocalAabb);
356
345public abstract void RecalculateCompoundShapeLocalAabb(BulletShape cShape); 357public abstract void RecalculateCompoundShapeLocalAabb(BulletShape cShape);
346 358
347public abstract BulletShape DuplicateCollisionShape(BulletWorld sim, BulletShape srcShape, uint id); 359public abstract BulletShape DuplicateCollisionShape(BulletWorld sim, BulletShape srcShape, UInt32 id);
348 360
349public abstract bool DeleteCollisionShape(BulletWorld world, BulletShape shape); 361public abstract bool DeleteCollisionShape(BulletWorld world, BulletShape shape);
350 362
351public abstract CollisionObjectTypes GetBodyType(BulletBody obj); 363public abstract CollisionObjectTypes GetBodyType(BulletBody obj);
352 364
353public abstract BulletBody CreateBodyFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot); 365public abstract BulletBody CreateBodyFromShape(BulletWorld sim, BulletShape shape, UInt32 id, Vector3 pos, Quaternion rot);
354 366
355public abstract BulletBody CreateBodyWithDefaultMotionState(BulletShape shape, uint id, Vector3 pos, Quaternion rot); 367public abstract BulletBody CreateBodyWithDefaultMotionState(BulletShape shape, UInt32 id, Vector3 pos, Quaternion rot);
356 368
357public abstract BulletBody CreateGhostFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot); 369public abstract BulletBody CreateGhostFromShape(BulletWorld sim, BulletShape shape, UInt32 id, Vector3 pos, Quaternion rot);
358 370
359public abstract void DestroyObject(BulletWorld sim, BulletBody obj); 371public abstract void DestroyObject(BulletWorld sim, BulletBody obj);
360 372
361// ===================================================================================== 373// =====================================================================================
362public abstract BulletShape CreateGroundPlaneShape(uint id, float height, float collisionMargin); 374public abstract BulletShape CreateGroundPlaneShape(UInt32 id, float height, float collisionMargin);
363 375
364public abstract BulletShape CreateTerrainShape(uint id, Vector3 size, float minHeight, float maxHeight, float[] heightMap, 376public abstract BulletShape CreateTerrainShape(UInt32 id, Vector3 size, float minHeight, float maxHeight, float[] heightMap,
365 float scaleFactor, float collisionMargin); 377 float scaleFactor, float collisionMargin);
366 378
367// ===================================================================================== 379// =====================================================================================
@@ -375,11 +387,38 @@ public abstract BulletConstraint Create6DofConstraintToPoint(BulletWorld world,
375 Vector3 joinPoint, 387 Vector3 joinPoint,
376 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); 388 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
377 389
390public abstract BulletConstraint Create6DofConstraintFixed(BulletWorld world, BulletBody obj1,
391 Vector3 frameInBloc, Quaternion frameInBrot,
392 bool useLinearReferenceFrameB, bool disableCollisionsBetweenLinkedBodies);
393
394public abstract BulletConstraint Create6DofSpringConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
395 Vector3 frame1loc, Quaternion frame1rot,
396 Vector3 frame2loc, Quaternion frame2rot,
397 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
398
378public abstract BulletConstraint CreateHingeConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2, 399public abstract BulletConstraint CreateHingeConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
379 Vector3 pivotinA, Vector3 pivotinB, 400 Vector3 pivotinA, Vector3 pivotinB,
380 Vector3 axisInA, Vector3 axisInB, 401 Vector3 axisInA, Vector3 axisInB,
381 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); 402 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
382 403
404public abstract BulletConstraint CreateSliderConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
405 Vector3 frameInAloc, Quaternion frameInArot,
406 Vector3 frameInBloc, Quaternion frameInBrot,
407 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
408
409public abstract BulletConstraint CreateConeTwistConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
410 Vector3 frameInAloc, Quaternion frameInArot,
411 Vector3 frameInBloc, Quaternion frameInBrot,
412 bool disableCollisionsBetweenLinkedBodies);
413
414public abstract BulletConstraint CreateGearConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
415 Vector3 axisInA, Vector3 axisInB,
416 float ratio, bool disableCollisionsBetweenLinkedBodies);
417
418public abstract BulletConstraint CreatePoint2PointConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
419 Vector3 pivotInA, Vector3 pivotInB,
420 bool disableCollisionsBetweenLinkedBodies);
421
383public abstract void SetConstraintEnable(BulletConstraint constrain, float numericTrueFalse); 422public abstract void SetConstraintEnable(BulletConstraint constrain, float numericTrueFalse);
384 423
385public abstract void SetConstraintNumSolverIterations(BulletConstraint constrain, float iterations); 424public abstract void SetConstraintNumSolverIterations(BulletConstraint constrain, float iterations);
@@ -607,7 +646,7 @@ public abstract BulletConstraint GetConstraintRef(BulletBody obj, int index);
607 646
608public abstract int GetNumConstraintRefs(BulletBody obj); 647public abstract int GetNumConstraintRefs(BulletBody obj);
609 648
610public abstract bool SetCollisionGroupMask(BulletBody body, uint filter, uint mask); 649public abstract bool SetCollisionGroupMask(BulletBody body, UInt32 filter, UInt32 mask);
611 650
612// ===================================================================================== 651// =====================================================================================
613// btCollisionShape entries 652// btCollisionShape entries
@@ -646,17 +685,21 @@ public abstract float GetMargin(BulletShape shape);
646 685
647// ===================================================================================== 686// =====================================================================================
648// Debugging 687// Debugging
649public abstract void DumpRigidBody(BulletWorld sim, BulletBody collisionObject); 688public virtual void DumpRigidBody(BulletWorld sim, BulletBody collisionObject) { }
689
690public virtual void DumpCollisionShape(BulletWorld sim, BulletShape collisionShape) { }
691
692public virtual void DumpConstraint(BulletWorld sim, BulletConstraint constrain) { }
650 693
651public abstract void DumpCollisionShape(BulletWorld sim, BulletShape collisionShape); 694public virtual void DumpActivationInfo(BulletWorld sim) { }
652 695
653public abstract void DumpConstraint(BulletWorld sim, BulletConstraint constrain); 696public virtual void DumpAllInfo(BulletWorld sim) { }
654 697
655public abstract void DumpActivationInfo(BulletWorld sim); 698public virtual void DumpPhysicsStatistics(BulletWorld sim) { }
656 699
657public abstract void DumpAllInfo(BulletWorld sim); 700public virtual void ResetBroadphasePool(BulletWorld sim) { }
658 701
659public abstract void DumpPhysicsStatistics(BulletWorld sim); 702public virtual void ResetConstraintSolver(BulletWorld sim) { }
660 703
661}; 704};
662} 705}