aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules/BulletS/BSApiTemplate.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/BSApiTemplate.cs141
1 files changed, 81 insertions, 60 deletions
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSApiTemplate.cs b/OpenSim/Region/PhysicsModules/BulletS/BSApiTemplate.cs
index 7756b10..a288048 100644
--- a/OpenSim/Region/PhysicsModules/BulletS/BSApiTemplate.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSApiTemplate.cs
@@ -36,16 +36,16 @@ namespace OpenSim.Region.PhysicsModule.BulletS {
36 // Constraint type values as defined by Bullet 36 // Constraint type values as defined by Bullet
37public enum ConstraintType : int 37public enum ConstraintType : int
38{ 38{
39 POINT2POINT_CONSTRAINT_TYPE = 3, 39 POINT2POINT_CONSTRAINT_TYPE = 3,
40 HINGE_CONSTRAINT_TYPE, 40 HINGE_CONSTRAINT_TYPE,
41 CONETWIST_CONSTRAINT_TYPE, 41 CONETWIST_CONSTRAINT_TYPE,
42 D6_CONSTRAINT_TYPE, 42 D6_CONSTRAINT_TYPE,
43 SLIDER_CONSTRAINT_TYPE, 43 SLIDER_CONSTRAINT_TYPE,
44 CONTACT_CONSTRAINT_TYPE, 44 CONTACT_CONSTRAINT_TYPE,
45 D6_SPRING_CONSTRAINT_TYPE, 45 D6_SPRING_CONSTRAINT_TYPE,
46 GEAR_CONSTRAINT_TYPE, // added in Bullet 2.82 46 GEAR_CONSTRAINT_TYPE, // added in Bullet 2.82
47 FIXED_CONSTRAINT_TYPE, // added in Bullet 2.82 47 FIXED_CONSTRAINT_TYPE, // added in Bullet 2.82
48 MAX_CONSTRAINT_TYPE, // last type defined by Bullet 48 MAX_CONSTRAINT_TYPE, // last type defined by Bullet
49 // 49 //
50 BS_FIXED_CONSTRAINT_TYPE = 1234 // BulletSim constraint that is fixed and unmoving 50 BS_FIXED_CONSTRAINT_TYPE = 1234 // BulletSim constraint that is fixed and unmoving
51} 51}
@@ -54,25 +54,25 @@ public enum ConstraintType : int
54[StructLayout(LayoutKind.Sequential)] 54[StructLayout(LayoutKind.Sequential)]
55public struct ConvexHull 55public struct ConvexHull
56{ 56{
57 Vector3 Offset; 57 Vector3 Offset;
58 int VertexCount; 58 int VertexCount;
59 Vector3[] Vertices; 59 Vector3[] Vertices;
60} 60}
61public enum BSPhysicsShapeType 61public enum BSPhysicsShapeType
62{ 62{
63 SHAPE_UNKNOWN = 0, 63 SHAPE_UNKNOWN = 0,
64 SHAPE_CAPSULE = 1, 64 SHAPE_CAPSULE = 1,
65 SHAPE_BOX = 2, 65 SHAPE_BOX = 2,
66 SHAPE_CONE = 3, 66 SHAPE_CONE = 3,
67 SHAPE_CYLINDER = 4, 67 SHAPE_CYLINDER = 4,
68 SHAPE_SPHERE = 5, 68 SHAPE_SPHERE = 5,
69 SHAPE_MESH = 6, 69 SHAPE_MESH = 6,
70 SHAPE_HULL = 7, 70 SHAPE_HULL = 7,
71 // following defined by BulletSim 71 // following defined by BulletSim
72 SHAPE_GROUNDPLANE = 20, 72 SHAPE_GROUNDPLANE = 20,
73 SHAPE_TERRAIN = 21, 73 SHAPE_TERRAIN = 21,
74 SHAPE_COMPOUND = 22, 74 SHAPE_COMPOUND = 22,
75 SHAPE_HEIGHTMAP = 23, 75 SHAPE_HEIGHTMAP = 23,
76 SHAPE_AVATAR = 24, 76 SHAPE_AVATAR = 24,
77 SHAPE_CONVEXHULL= 25, 77 SHAPE_CONVEXHULL= 25,
78 SHAPE_GIMPACT = 26, 78 SHAPE_GIMPACT = 26,
@@ -121,6 +121,14 @@ public struct SweepHit
121 public float Fraction; 121 public float Fraction;
122 public Vector3 Normal; 122 public Vector3 Normal;
123 public Vector3 Point; 123 public Vector3 Point;
124
125 public bool hasHit()
126 {
127 float sum = Fraction
128 + Normal.X + Normal.Y + Normal.Z
129 + Point.X + Point.Y + Point.Z;
130 return (sum != 0) || (ID != 0);
131 }
124} 132}
125[StructLayout(LayoutKind.Sequential)] 133[StructLayout(LayoutKind.Sequential)]
126public struct RaycastHit 134public struct RaycastHit
@@ -128,6 +136,13 @@ public struct RaycastHit
128 public UInt32 ID; 136 public UInt32 ID;
129 public float Fraction; 137 public float Fraction;
130 public Vector3 Normal; 138 public Vector3 Normal;
139 public Vector3 Point;
140
141 public bool hasHit()
142 {
143 float sum = Normal.X + Normal.Y + Normal.Z + Point.X + Point.Y + Point.Z;
144 return (sum != 0);
145 }
131} 146}
132[StructLayout(LayoutKind.Sequential)] 147[StructLayout(LayoutKind.Sequential)]
133public struct CollisionDesc 148public struct CollisionDesc
@@ -180,16 +195,16 @@ public struct ConfigurationParameters
180 public float collisionMargin; 195 public float collisionMargin;
181 public float gravity; 196 public float gravity;
182 197
183 public float maxPersistantManifoldPoolSize; 198 public float maxPersistantManifoldPoolSize;
184 public float maxCollisionAlgorithmPoolSize; 199 public float maxCollisionAlgorithmPoolSize;
185 public float shouldDisableContactPoolDynamicAllocation; 200 public float shouldDisableContactPoolDynamicAllocation;
186 public float shouldForceUpdateAllAabbs; 201 public float shouldForceUpdateAllAabbs;
187 public float shouldRandomizeSolverOrder; 202 public float shouldRandomizeSolverOrder;
188 public float shouldSplitSimulationIslands; 203 public float shouldSplitSimulationIslands;
189 public float shouldEnableFrictionCaching; 204 public float shouldEnableFrictionCaching;
190 public float numberOfSolverIterations; 205 public float numberOfSolverIterations;
191 public float useSingleSidedMeshes; 206 public float useSingleSidedMeshes;
192 public float globalContactBreakingThreshold; 207 public float globalContactBreakingThreshold;
193 208
194 public float physicsLoggingFrames; 209 public float physicsLoggingFrames;
195 210
@@ -202,30 +217,30 @@ public struct ConfigurationParameters
202public struct HACDParams 217public struct HACDParams
203{ 218{
204 // usual default values 219 // usual default values
205 public float maxVerticesPerHull; // 100 220 public float maxVerticesPerHull; // 100
206 public float minClusters; // 2 221 public float minClusters; // 2
207 public float compacityWeight; // 0.1 222 public float compacityWeight; // 0.1
208 public float volumeWeight; // 0.0 223 public float volumeWeight; // 0.0
209 public float concavity; // 100 224 public float concavity; // 100
210 public float addExtraDistPoints; // false 225 public float addExtraDistPoints; // false
211 public float addNeighboursDistPoints; // false 226 public float addNeighboursDistPoints; // false
212 public float addFacesPoints; // false 227 public float addFacesPoints; // false
213 public float shouldAdjustCollisionMargin; // false 228 public float shouldAdjustCollisionMargin; // false
214 // VHACD 229 // VHACD
215 public float whichHACD; // zero if Bullet HACD, non-zero says VHACD 230 public float whichHACD; // zero if Bullet HACD, non-zero says VHACD
216 // http://kmamou.blogspot.ca/2014/12/v-hacd-20-parameters-description.html 231 // http://kmamou.blogspot.ca/2014/12/v-hacd-20-parameters-description.html
217 public float vHACDresolution; // 100,000 max number of voxels generated during voxelization stage 232 public float vHACDresolution; // 100,000 max number of voxels generated during voxelization stage
218 public float vHACDdepth; // 20 max number of clipping stages 233 public float vHACDdepth; // 20 max number of clipping stages
219 public float vHACDconcavity; // 0.0025 maximum concavity 234 public float vHACDconcavity; // 0.0025 maximum concavity
220 public float vHACDplaneDownsampling; // 4 granularity of search for best clipping plane 235 public float vHACDplaneDownsampling; // 4 granularity of search for best clipping plane
221 public float vHACDconvexHullDownsampling; // 4 precision of hull gen process 236 public float vHACDconvexHullDownsampling; // 4 precision of hull gen process
222 public float vHACDalpha; // 0.05 bias toward clipping along symmetry planes 237 public float vHACDalpha; // 0.05 bias toward clipping along symmetry planes
223 public float vHACDbeta; // 0.05 bias toward clipping along revolution axis 238 public float vHACDbeta; // 0.05 bias toward clipping along revolution axis
224 public float vHACDgamma; // 0.00125 max concavity when merging 239 public float vHACDgamma; // 0.00125 max concavity when merging
225 public float vHACDpca; // 0 on/off normalizing mesh before decomp 240 public float vHACDpca; // 0 on/off normalizing mesh before decomp
226 public float vHACDmode; // 0 0:voxel based, 1: tetrahedron based 241 public float vHACDmode; // 0 0:voxel based, 1: tetrahedron based
227 public float vHACDmaxNumVerticesPerCH; // 64 max triangles per convex hull 242 public float vHACDmaxNumVerticesPerCH; // 64 max triangles per convex hull
228 public float vHACDminVolumePerCH; // 0.0001 sampling of generated convex hulls 243 public float vHACDminVolumePerCH; // 0.0001 sampling of generated convex hulls
229} 244}
230 245
231// The states a bullet collision object can have 246// The states a bullet collision object can have
@@ -322,8 +337,8 @@ public abstract string BulletEngineVersion { get; protected set;}
322 337
323// Initialization and simulation 338// Initialization and simulation
324public abstract BulletWorld Initialize(Vector3 maxPosition, ConfigurationParameters parms, 339public abstract BulletWorld Initialize(Vector3 maxPosition, ConfigurationParameters parms,
325 int maxCollisions, ref CollisionDesc[] collisionArray, 340 int maxCollisions, ref CollisionDesc[] collisionArray,
326 int maxUpdates, ref EntityProperties[] updateArray 341 int maxUpdates, ref EntityProperties[] updateArray
327 ); 342 );
328 343
329public abstract int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, 344public abstract int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep,
@@ -398,7 +413,7 @@ public abstract void DestroyObject(BulletWorld sim, BulletBody obj);
398public abstract BulletShape CreateGroundPlaneShape(UInt32 id, float height, float collisionMargin); 413public abstract BulletShape CreateGroundPlaneShape(UInt32 id, float height, float collisionMargin);
399 414
400public abstract BulletShape CreateTerrainShape(UInt32 id, Vector3 size, float minHeight, float maxHeight, float[] heightMap, 415public abstract BulletShape CreateTerrainShape(UInt32 id, Vector3 size, float minHeight, float maxHeight, float[] heightMap,
401 float scaleFactor, float collisionMargin); 416 float scaleFactor, float collisionMargin);
402 417
403// ===================================================================================== 418// =====================================================================================
404// Constraint creation and helper routines 419// Constraint creation and helper routines
@@ -742,6 +757,12 @@ public abstract void SetMargin(BulletShape shape, float val);
742public abstract float GetMargin(BulletShape shape); 757public abstract float GetMargin(BulletShape shape);
743 758
744// ===================================================================================== 759// =====================================================================================
760// Raycast
761public abstract SweepHit ConvexSweepTest2(BulletWorld world, BulletBody obj, Vector3 from, Vector3 to, float margin);
762
763public abstract RaycastHit RayTest2(BulletWorld world, Vector3 from, Vector3 to, uint filterGroup, uint filterMask);
764
765// =====================================================================================
745// Debugging 766// Debugging
746public virtual void DumpRigidBody(BulletWorld sim, BulletBody collisionObject) { } 767public virtual void DumpRigidBody(BulletWorld sim, BulletBody collisionObject) { }
747 768