diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs | 207 |
1 files changed, 191 insertions, 16 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs index 8c6e7d6..231f0f8 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs | |||
@@ -75,11 +75,11 @@ private sealed class BulletBodyUnman : BulletBody | |||
75 | private sealed class BulletShapeUnman : BulletShape | 75 | private sealed class BulletShapeUnman : BulletShape |
76 | { | 76 | { |
77 | public IntPtr ptr; | 77 | public IntPtr ptr; |
78 | public BulletShapeUnman(IntPtr xx, BSPhysicsShapeType typ) | 78 | public BulletShapeUnman(IntPtr xx, BSPhysicsShapeType typ) |
79 | : base() | 79 | : base() |
80 | { | 80 | { |
81 | ptr = xx; | 81 | ptr = xx; |
82 | type = typ; | 82 | shapeType = typ; |
83 | } | 83 | } |
84 | public override bool HasPhysicalShape | 84 | public override bool HasPhysicalShape |
85 | { | 85 | { |
@@ -91,7 +91,7 @@ private sealed class BulletShapeUnman : BulletShape | |||
91 | } | 91 | } |
92 | public override BulletShape Clone() | 92 | public override BulletShape Clone() |
93 | { | 93 | { |
94 | return new BulletShapeUnman(ptr, type); | 94 | return new BulletShapeUnman(ptr, shapeType); |
95 | } | 95 | } |
96 | public override bool ReferenceSame(BulletShape other) | 96 | public override bool ReferenceSame(BulletShape other) |
97 | { | 97 | { |
@@ -166,7 +166,7 @@ public override BulletWorld Initialize(Vector3 maxPosition, ConfigurationParamet | |||
166 | 166 | ||
167 | // If Debug logging level, enable logging from the unmanaged code | 167 | // If Debug logging level, enable logging from the unmanaged code |
168 | m_DebugLogCallbackHandle = null; | 168 | m_DebugLogCallbackHandle = null; |
169 | if (BSScene.m_log.IsDebugEnabled || PhysicsScene.PhysicsLogging.Enabled) | 169 | if (BSScene.m_log.IsDebugEnabled && PhysicsScene.PhysicsLogging.Enabled) |
170 | { | 170 | { |
171 | BSScene.m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", BSScene.LogHeader); | 171 | BSScene.m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", BSScene.LogHeader); |
172 | if (PhysicsScene.PhysicsLogging.Enabled) | 172 | if (PhysicsScene.PhysicsLogging.Enabled) |
@@ -202,7 +202,7 @@ private void BulletLoggerPhysLog(string msg) | |||
202 | } | 202 | } |
203 | 203 | ||
204 | public override int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, | 204 | public override int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, |
205 | out int updatedEntityCount, out int collidersCount) | 205 | out int updatedEntityCount, out int collidersCount) |
206 | { | 206 | { |
207 | BulletWorldUnman worldu = world as BulletWorldUnman; | 207 | BulletWorldUnman worldu = world as BulletWorldUnman; |
208 | return BSAPICPP.PhysicsStep2(worldu.ptr, timeStep, maxSubSteps, fixedTimeStep, out updatedEntityCount, out collidersCount); | 208 | return BSAPICPP.PhysicsStep2(worldu.ptr, timeStep, maxSubSteps, fixedTimeStep, out updatedEntityCount, out collidersCount); |
@@ -212,6 +212,19 @@ public override void Shutdown(BulletWorld world) | |||
212 | { | 212 | { |
213 | BulletWorldUnman worldu = world as BulletWorldUnman; | 213 | BulletWorldUnman worldu = world as BulletWorldUnman; |
214 | BSAPICPP.Shutdown2(worldu.ptr); | 214 | BSAPICPP.Shutdown2(worldu.ptr); |
215 | |||
216 | if (m_paramsHandle.IsAllocated) | ||
217 | { | ||
218 | m_paramsHandle.Free(); | ||
219 | } | ||
220 | if (m_collisionArrayPinnedHandle.IsAllocated) | ||
221 | { | ||
222 | m_collisionArrayPinnedHandle.Free(); | ||
223 | } | ||
224 | if (m_updateArrayPinnedHandle.IsAllocated) | ||
225 | { | ||
226 | m_updateArrayPinnedHandle.Free(); | ||
227 | } | ||
215 | } | 228 | } |
216 | 229 | ||
217 | public override bool PushUpdate(BulletBody obj) | 230 | public override bool PushUpdate(BulletBody obj) |
@@ -242,19 +255,38 @@ public override BulletShape CreateHullShape(BulletWorld world, int hullCount, fl | |||
242 | { | 255 | { |
243 | BulletWorldUnman worldu = world as BulletWorldUnman; | 256 | BulletWorldUnman worldu = world as BulletWorldUnman; |
244 | return new BulletShapeUnman( | 257 | return new BulletShapeUnman( |
245 | BSAPICPP.CreateHullShape2(worldu.ptr, hullCount, hulls), | 258 | BSAPICPP.CreateHullShape2(worldu.ptr, hullCount, hulls), |
246 | BSPhysicsShapeType.SHAPE_HULL); | 259 | BSPhysicsShapeType.SHAPE_HULL); |
247 | } | 260 | } |
248 | 261 | ||
249 | public override BulletShape BuildHullShapeFromMesh(BulletWorld world, BulletShape meshShape) | 262 | public override BulletShape BuildHullShapeFromMesh(BulletWorld world, BulletShape meshShape, HACDParams parms) |
250 | { | 263 | { |
251 | BulletWorldUnman worldu = world as BulletWorldUnman; | 264 | BulletWorldUnman worldu = world as BulletWorldUnman; |
252 | BulletShapeUnman shapeu = meshShape as BulletShapeUnman; | 265 | BulletShapeUnman shapeu = meshShape as BulletShapeUnman; |
253 | return new BulletShapeUnman( | 266 | return new BulletShapeUnman( |
254 | BSAPICPP.BuildHullShapeFromMesh2(worldu.ptr, shapeu.ptr), | 267 | BSAPICPP.BuildHullShapeFromMesh2(worldu.ptr, shapeu.ptr, parms), |
255 | BSPhysicsShapeType.SHAPE_HULL); | 268 | BSPhysicsShapeType.SHAPE_HULL); |
256 | } | 269 | } |
257 | 270 | ||
271 | public override BulletShape BuildConvexHullShapeFromMesh(BulletWorld world, BulletShape meshShape) | ||
272 | { | ||
273 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
274 | BulletShapeUnman shapeu = meshShape as BulletShapeUnman; | ||
275 | return new BulletShapeUnman( | ||
276 | BSAPICPP.BuildConvexHullShapeFromMesh2(worldu.ptr, shapeu.ptr), | ||
277 | BSPhysicsShapeType.SHAPE_CONVEXHULL); | ||
278 | } | ||
279 | |||
280 | public override BulletShape CreateConvexHullShape(BulletWorld world, | ||
281 | int indicesCount, int[] indices, | ||
282 | int verticesCount, float[] vertices) | ||
283 | { | ||
284 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
285 | return new BulletShapeUnman( | ||
286 | BSAPICPP.CreateConvexHullShape2(worldu.ptr, indicesCount, indices, verticesCount, vertices), | ||
287 | BSPhysicsShapeType.SHAPE_CONVEXHULL); | ||
288 | } | ||
289 | |||
258 | public override BulletShape BuildNativeShape(BulletWorld world, ShapeData shapeData) | 290 | public override BulletShape BuildNativeShape(BulletWorld world, ShapeData shapeData) |
259 | { | 291 | { |
260 | BulletWorldUnman worldu = world as BulletWorldUnman; | 292 | BulletWorldUnman worldu = world as BulletWorldUnman; |
@@ -273,7 +305,7 @@ public override void SetShapeCollisionMargin(BulletShape shape, float margin) | |||
273 | { | 305 | { |
274 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | 306 | BulletShapeUnman shapeu = shape as BulletShapeUnman; |
275 | if (shapeu != null && shapeu.HasPhysicalShape) | 307 | if (shapeu != null && shapeu.HasPhysicalShape) |
276 | BSAPICPP.SetShapeCollisionMargin2(shapeu.ptr, margin); | 308 | BSAPICPP.SetShapeCollisionMargin(shapeu.ptr, margin); |
277 | } | 309 | } |
278 | 310 | ||
279 | public override BulletShape BuildCapsuleShape(BulletWorld world, float radius, float height, Vector3 scale) | 311 | public override BulletShape BuildCapsuleShape(BulletWorld world, float radius, float height, Vector3 scale) |
@@ -327,6 +359,12 @@ public override void RemoveChildShapeFromCompoundShape(BulletShape shape, Bullet | |||
327 | BSAPICPP.RemoveChildShapeFromCompoundShape2(shapeu.ptr, removeShapeu.ptr); | 359 | BSAPICPP.RemoveChildShapeFromCompoundShape2(shapeu.ptr, removeShapeu.ptr); |
328 | } | 360 | } |
329 | 361 | ||
362 | public override void UpdateChildTransform(BulletShape pShape, int childIndex, Vector3 pos, Quaternion rot, bool shouldRecalculateLocalAabb) | ||
363 | { | ||
364 | BulletShapeUnman shapeu = pShape as BulletShapeUnman; | ||
365 | BSAPICPP.UpdateChildTransform2(shapeu.ptr, childIndex, pos, rot, shouldRecalculateLocalAabb); | ||
366 | } | ||
367 | |||
330 | public override void RecalculateCompoundShapeLocalAabb(BulletShape shape) | 368 | public override void RecalculateCompoundShapeLocalAabb(BulletShape shape) |
331 | { | 369 | { |
332 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | 370 | BulletShapeUnman shapeu = shape as BulletShapeUnman; |
@@ -337,7 +375,7 @@ public override BulletShape DuplicateCollisionShape(BulletWorld world, BulletSha | |||
337 | { | 375 | { |
338 | BulletWorldUnman worldu = world as BulletWorldUnman; | 376 | BulletWorldUnman worldu = world as BulletWorldUnman; |
339 | BulletShapeUnman srcShapeu = srcShape as BulletShapeUnman; | 377 | BulletShapeUnman srcShapeu = srcShape as BulletShapeUnman; |
340 | return new BulletShapeUnman(BSAPICPP.DuplicateCollisionShape2(worldu.ptr, srcShapeu.ptr, id), srcShape.type); | 378 | return new BulletShapeUnman(BSAPICPP.DuplicateCollisionShape2(worldu.ptr, srcShapeu.ptr, id), srcShape.shapeType); |
341 | } | 379 | } |
342 | 380 | ||
343 | public override bool DeleteCollisionShape(BulletWorld world, BulletShape shape) | 381 | public override bool DeleteCollisionShape(BulletWorld world, BulletShape shape) |
@@ -419,6 +457,28 @@ public override BulletConstraint Create6DofConstraintToPoint(BulletWorld world, | |||
419 | joinPoint, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | 457 | joinPoint, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); |
420 | } | 458 | } |
421 | 459 | ||
460 | public override BulletConstraint Create6DofConstraintFixed(BulletWorld world, BulletBody obj1, | ||
461 | Vector3 frameInBloc, Quaternion frameInBrot, | ||
462 | bool useLinearReferenceFrameB, bool disableCollisionsBetweenLinkedBodies) | ||
463 | { | ||
464 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
465 | BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman; | ||
466 | return new BulletConstraintUnman(BSAPICPP.Create6DofConstraintFixed2(worldu.ptr, bodyu1.ptr, | ||
467 | frameInBloc, frameInBrot, useLinearReferenceFrameB, disableCollisionsBetweenLinkedBodies)); | ||
468 | } | ||
469 | |||
470 | public override BulletConstraint Create6DofSpringConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2, | ||
471 | Vector3 frame1loc, Quaternion frame1rot, | ||
472 | Vector3 frame2loc, Quaternion frame2rot, | ||
473 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | ||
474 | { | ||
475 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
476 | BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman; | ||
477 | BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman; | ||
478 | return new BulletConstraintUnman(BSAPICPP.Create6DofSpringConstraint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr, frame1loc, frame1rot, | ||
479 | frame2loc, frame2rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | ||
480 | } | ||
481 | |||
422 | public override BulletConstraint CreateHingeConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2, | 482 | public override BulletConstraint CreateHingeConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2, |
423 | Vector3 pivotinA, Vector3 pivotinB, | 483 | Vector3 pivotinA, Vector3 pivotinB, |
424 | Vector3 axisInA, Vector3 axisInB, | 484 | Vector3 axisInA, Vector3 axisInB, |
@@ -431,6 +491,52 @@ public override BulletConstraint CreateHingeConstraint(BulletWorld world, Bullet | |||
431 | pivotinA, pivotinB, axisInA, axisInB, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | 491 | pivotinA, pivotinB, axisInA, axisInB, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); |
432 | } | 492 | } |
433 | 493 | ||
494 | public override BulletConstraint CreateSliderConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2, | ||
495 | Vector3 frame1loc, Quaternion frame1rot, | ||
496 | Vector3 frame2loc, Quaternion frame2rot, | ||
497 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | ||
498 | { | ||
499 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
500 | BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman; | ||
501 | BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman; | ||
502 | return new BulletConstraintUnman(BSAPICPP.CreateSliderConstraint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr, frame1loc, frame1rot, | ||
503 | frame2loc, frame2rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | ||
504 | } | ||
505 | |||
506 | public override BulletConstraint CreateConeTwistConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2, | ||
507 | Vector3 frame1loc, Quaternion frame1rot, | ||
508 | Vector3 frame2loc, Quaternion frame2rot, | ||
509 | bool disableCollisionsBetweenLinkedBodies) | ||
510 | { | ||
511 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
512 | BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman; | ||
513 | BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman; | ||
514 | return new BulletConstraintUnman(BSAPICPP.CreateConeTwistConstraint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr, frame1loc, frame1rot, | ||
515 | frame2loc, frame2rot, disableCollisionsBetweenLinkedBodies)); | ||
516 | } | ||
517 | |||
518 | public override BulletConstraint CreateGearConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2, | ||
519 | Vector3 axisInA, Vector3 axisInB, | ||
520 | float ratio, bool disableCollisionsBetweenLinkedBodies) | ||
521 | { | ||
522 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
523 | BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman; | ||
524 | BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman; | ||
525 | return new BulletConstraintUnman(BSAPICPP.CreateGearConstraint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr, axisInA, axisInB, | ||
526 | ratio, disableCollisionsBetweenLinkedBodies)); | ||
527 | } | ||
528 | |||
529 | public override BulletConstraint CreatePoint2PointConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2, | ||
530 | Vector3 pivotInA, Vector3 pivotInB, | ||
531 | bool disableCollisionsBetweenLinkedBodies) | ||
532 | { | ||
533 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
534 | BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman; | ||
535 | BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman; | ||
536 | return new BulletConstraintUnman(BSAPICPP.CreatePoint2PointConstraint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr, pivotInA, pivotInB, | ||
537 | disableCollisionsBetweenLinkedBodies)); | ||
538 | } | ||
539 | |||
434 | public override void SetConstraintEnable(BulletConstraint constrain, float numericTrueFalse) | 540 | public override void SetConstraintEnable(BulletConstraint constrain, float numericTrueFalse) |
435 | { | 541 | { |
436 | BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; | 542 | BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; |
@@ -530,12 +636,12 @@ public override void SetForceUpdateAllAabbs(BulletWorld world, bool force) | |||
530 | // btDynamicsWorld entries | 636 | // btDynamicsWorld entries |
531 | public override bool AddObjectToWorld(BulletWorld world, BulletBody obj) | 637 | public override bool AddObjectToWorld(BulletWorld world, BulletBody obj) |
532 | { | 638 | { |
533 | // Bullet resets several variables when an object is added to the world. | ||
534 | // Gravity is reset to world default depending on the static/dynamic | ||
535 | // type. Of course, the collision flags in the broadphase proxy are initialized to default. | ||
536 | BulletWorldUnman worldu = world as BulletWorldUnman; | 639 | BulletWorldUnman worldu = world as BulletWorldUnman; |
537 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | 640 | BulletBodyUnman bodyu = obj as BulletBodyUnman; |
538 | 641 | ||
642 | // Bullet resets several variables when an object is added to the world. | ||
643 | // Gravity is reset to world default depending on the static/dynamic | ||
644 | // type. Of course, the collision flags in the broadphase proxy are initialized to default. | ||
539 | Vector3 origGrav = BSAPICPP.GetGravity2(bodyu.ptr); | 645 | Vector3 origGrav = BSAPICPP.GetGravity2(bodyu.ptr); |
540 | 646 | ||
541 | bool ret = BSAPICPP.AddObjectToWorld2(worldu.ptr, bodyu.ptr); | 647 | bool ret = BSAPICPP.AddObjectToWorld2(worldu.ptr, bodyu.ptr); |
@@ -921,6 +1027,7 @@ public override void SetCenterOfMassByPosRot(BulletBody obj, Vector3 pos, Quater | |||
921 | } | 1027 | } |
922 | 1028 | ||
923 | // Add a force to the object as if its mass is one. | 1029 | // Add a force to the object as if its mass is one. |
1030 | // Deep down in Bullet: m_totalForce += force*m_linearFactor; | ||
924 | public override void ApplyCentralForce(BulletBody obj, Vector3 force) | 1031 | public override void ApplyCentralForce(BulletBody obj, Vector3 force) |
925 | { | 1032 | { |
926 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | 1033 | BulletBodyUnman bodyu = obj as BulletBodyUnman; |
@@ -964,6 +1071,7 @@ public override void SetSleepingThresholds(BulletBody obj, float lin_threshold, | |||
964 | BSAPICPP.SetSleepingThresholds2(bodyu.ptr, lin_threshold, ang_threshold); | 1071 | BSAPICPP.SetSleepingThresholds2(bodyu.ptr, lin_threshold, ang_threshold); |
965 | } | 1072 | } |
966 | 1073 | ||
1074 | // Deep down in Bullet: m_totalTorque += torque*m_angularFactor; | ||
967 | public override void ApplyTorque(BulletBody obj, Vector3 torque) | 1075 | public override void ApplyTorque(BulletBody obj, Vector3 torque) |
968 | { | 1076 | { |
969 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | 1077 | BulletBodyUnman bodyu = obj as BulletBodyUnman; |
@@ -971,6 +1079,8 @@ public override void ApplyTorque(BulletBody obj, Vector3 torque) | |||
971 | } | 1079 | } |
972 | 1080 | ||
973 | // Apply force at the given point. Will add torque to the object. | 1081 | // Apply force at the given point. Will add torque to the object. |
1082 | // Deep down in Bullet: applyCentralForce(force); | ||
1083 | // applyTorque(rel_pos.cross(force*m_linearFactor)); | ||
974 | public override void ApplyForce(BulletBody obj, Vector3 force, Vector3 pos) | 1084 | public override void ApplyForce(BulletBody obj, Vector3 force, Vector3 pos) |
975 | { | 1085 | { |
976 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | 1086 | BulletBodyUnman bodyu = obj as BulletBodyUnman; |
@@ -978,6 +1088,7 @@ public override void ApplyForce(BulletBody obj, Vector3 force, Vector3 pos) | |||
978 | } | 1088 | } |
979 | 1089 | ||
980 | // Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass. | 1090 | // Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass. |
1091 | // Deep down in Bullet: m_linearVelocity += impulse *m_linearFactor * m_inverseMass; | ||
981 | public override void ApplyCentralImpulse(BulletBody obj, Vector3 imp) | 1092 | public override void ApplyCentralImpulse(BulletBody obj, Vector3 imp) |
982 | { | 1093 | { |
983 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | 1094 | BulletBodyUnman bodyu = obj as BulletBodyUnman; |
@@ -985,6 +1096,7 @@ public override void ApplyCentralImpulse(BulletBody obj, Vector3 imp) | |||
985 | } | 1096 | } |
986 | 1097 | ||
987 | // Apply impulse to the object's torque. Force is scaled by object's mass. | 1098 | // Apply impulse to the object's torque. Force is scaled by object's mass. |
1099 | // Deep down in Bullet: m_angularVelocity += m_invInertiaTensorWorld * torque * m_angularFactor; | ||
988 | public override void ApplyTorqueImpulse(BulletBody obj, Vector3 imp) | 1100 | public override void ApplyTorqueImpulse(BulletBody obj, Vector3 imp) |
989 | { | 1101 | { |
990 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | 1102 | BulletBodyUnman bodyu = obj as BulletBodyUnman; |
@@ -992,6 +1104,8 @@ public override void ApplyTorqueImpulse(BulletBody obj, Vector3 imp) | |||
992 | } | 1104 | } |
993 | 1105 | ||
994 | // Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces. | 1106 | // Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces. |
1107 | // Deep down in Bullet: applyCentralImpulse(impulse); | ||
1108 | // applyTorqueImpulse(rel_pos.cross(impulse*m_linearFactor)); | ||
995 | public override void ApplyImpulse(BulletBody obj, Vector3 imp, Vector3 pos) | 1109 | public override void ApplyImpulse(BulletBody obj, Vector3 imp, Vector3 pos) |
996 | { | 1110 | { |
997 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | 1111 | BulletBodyUnman bodyu = obj as BulletBodyUnman; |
@@ -1259,6 +1373,16 @@ public override void DumpPhysicsStatistics(BulletWorld world) | |||
1259 | BulletWorldUnman worldu = world as BulletWorldUnman; | 1373 | BulletWorldUnman worldu = world as BulletWorldUnman; |
1260 | BSAPICPP.DumpPhysicsStatistics2(worldu.ptr); | 1374 | BSAPICPP.DumpPhysicsStatistics2(worldu.ptr); |
1261 | } | 1375 | } |
1376 | public override void ResetBroadphasePool(BulletWorld world) | ||
1377 | { | ||
1378 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
1379 | BSAPICPP.ResetBroadphasePool(worldu.ptr); | ||
1380 | } | ||
1381 | public override void ResetConstraintSolver(BulletWorld world) | ||
1382 | { | ||
1383 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
1384 | BSAPICPP.ResetConstraintSolver(worldu.ptr); | ||
1385 | } | ||
1262 | 1386 | ||
1263 | // ===================================================================================== | 1387 | // ===================================================================================== |
1264 | // ===================================================================================== | 1388 | // ===================================================================================== |
@@ -1306,7 +1430,15 @@ public static extern IntPtr CreateHullShape2(IntPtr world, | |||
1306 | int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls); | 1430 | int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls); |
1307 | 1431 | ||
1308 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1432 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
1309 | public static extern IntPtr BuildHullShapeFromMesh2(IntPtr world, IntPtr meshShape); | 1433 | public static extern IntPtr BuildHullShapeFromMesh2(IntPtr world, IntPtr meshShape, HACDParams parms); |
1434 | |||
1435 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1436 | public static extern IntPtr BuildConvexHullShapeFromMesh2(IntPtr world, IntPtr meshShape); | ||
1437 | |||
1438 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1439 | public static extern IntPtr CreateConvexHullShape2(IntPtr world, | ||
1440 | int indicesCount, [MarshalAs(UnmanagedType.LPArray)] int[] indices, | ||
1441 | int verticesCount, [MarshalAs(UnmanagedType.LPArray)] float[] vertices ); | ||
1310 | 1442 | ||
1311 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1443 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
1312 | public static extern IntPtr BuildNativeShape2(IntPtr world, ShapeData shapeData); | 1444 | public static extern IntPtr BuildNativeShape2(IntPtr world, ShapeData shapeData); |
@@ -1315,7 +1447,7 @@ public static extern IntPtr BuildNativeShape2(IntPtr world, ShapeData shapeData) | |||
1315 | public static extern bool IsNativeShape2(IntPtr shape); | 1447 | public static extern bool IsNativeShape2(IntPtr shape); |
1316 | 1448 | ||
1317 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1449 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
1318 | public static extern void SetShapeCollisionMargin2(IntPtr shape, float margin); | 1450 | public static extern void SetShapeCollisionMargin(IntPtr shape, float margin); |
1319 | 1451 | ||
1320 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1452 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
1321 | public static extern IntPtr BuildCapsuleShape2(IntPtr world, float radius, float height, Vector3 scale); | 1453 | public static extern IntPtr BuildCapsuleShape2(IntPtr world, float radius, float height, Vector3 scale); |
@@ -1339,6 +1471,9 @@ public static extern IntPtr RemoveChildShapeFromCompoundShapeIndex2(IntPtr cShap | |||
1339 | public static extern void RemoveChildShapeFromCompoundShape2(IntPtr cShape, IntPtr removeShape); | 1471 | public static extern void RemoveChildShapeFromCompoundShape2(IntPtr cShape, IntPtr removeShape); |
1340 | 1472 | ||
1341 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1473 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
1474 | public static extern void UpdateChildTransform2(IntPtr pShape, int childIndex, Vector3 pos, Quaternion rot, bool shouldRecalculateLocalAabb); | ||
1475 | |||
1476 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1342 | public static extern void RecalculateCompoundShapeLocalAabb2(IntPtr cShape); | 1477 | public static extern void RecalculateCompoundShapeLocalAabb2(IntPtr cShape); |
1343 | 1478 | ||
1344 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1479 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
@@ -1368,7 +1503,7 @@ public static extern void DestroyObject2(IntPtr sim, IntPtr obj); | |||
1368 | public static extern IntPtr CreateGroundPlaneShape2(uint id, float height, float collisionMargin); | 1503 | public static extern IntPtr CreateGroundPlaneShape2(uint id, float height, float collisionMargin); |
1369 | 1504 | ||
1370 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1505 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
1371 | public static extern IntPtr CreateTerrainShape2(uint id, Vector3 size, float minHeight, float maxHeight, | 1506 | public static extern IntPtr CreateTerrainShape2(uint id, Vector3 size, float minHeight, float maxHeight, |
1372 | [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, | 1507 | [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, |
1373 | float scaleFactor, float collisionMargin); | 1508 | float scaleFactor, float collisionMargin); |
1374 | 1509 | ||
@@ -1386,12 +1521,46 @@ public static extern IntPtr Create6DofConstraintToPoint2(IntPtr world, IntPtr ob | |||
1386 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); | 1521 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); |
1387 | 1522 | ||
1388 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1523 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
1524 | public static extern IntPtr Create6DofConstraintFixed2(IntPtr world, IntPtr obj1, | ||
1525 | Vector3 frameInBloc, Quaternion frameInBrot, | ||
1526 | bool useLinearReferenceFrameB, bool disableCollisionsBetweenLinkedBodies); | ||
1527 | |||
1528 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1529 | public static extern IntPtr Create6DofSpringConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2, | ||
1530 | Vector3 frame1loc, Quaternion frame1rot, | ||
1531 | Vector3 frame2loc, Quaternion frame2rot, | ||
1532 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); | ||
1533 | |||
1534 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1389 | public static extern IntPtr CreateHingeConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2, | 1535 | public static extern IntPtr CreateHingeConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2, |
1390 | Vector3 pivotinA, Vector3 pivotinB, | 1536 | Vector3 pivotinA, Vector3 pivotinB, |
1391 | Vector3 axisInA, Vector3 axisInB, | 1537 | Vector3 axisInA, Vector3 axisInB, |
1392 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); | 1538 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); |
1393 | 1539 | ||
1394 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1540 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
1541 | public static extern IntPtr CreateSliderConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2, | ||
1542 | Vector3 frameInAloc, Quaternion frameInArot, | ||
1543 | Vector3 frameInBloc, Quaternion frameInBrot, | ||
1544 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); | ||
1545 | |||
1546 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1547 | public static extern IntPtr CreateConeTwistConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2, | ||
1548 | Vector3 frameInAloc, Quaternion frameInArot, | ||
1549 | Vector3 frameInBloc, Quaternion frameInBrot, | ||
1550 | bool disableCollisionsBetweenLinkedBodies); | ||
1551 | |||
1552 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1553 | public static extern IntPtr CreateGearConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2, | ||
1554 | Vector3 axisInA, Vector3 axisInB, | ||
1555 | float ratio, bool disableCollisionsBetweenLinkedBodies); | ||
1556 | |||
1557 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1558 | public static extern IntPtr CreatePoint2PointConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2, | ||
1559 | Vector3 pivotInA, Vector3 pivotInB, | ||
1560 | bool disableCollisionsBetweenLinkedBodies); | ||
1561 | |||
1562 | |||
1563 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1395 | public static extern void SetConstraintEnable2(IntPtr constrain, float numericTrueFalse); | 1564 | public static extern void SetConstraintEnable2(IntPtr constrain, float numericTrueFalse); |
1396 | 1565 | ||
1397 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1566 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
@@ -1832,6 +2001,12 @@ public static extern void DumpAllInfo2(IntPtr sim); | |||
1832 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 2001 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
1833 | public static extern void DumpPhysicsStatistics2(IntPtr sim); | 2002 | public static extern void DumpPhysicsStatistics2(IntPtr sim); |
1834 | 2003 | ||
2004 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
2005 | public static extern void ResetBroadphasePool(IntPtr sim); | ||
2006 | |||
2007 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
2008 | public static extern void ResetConstraintSolver(IntPtr sim); | ||
2009 | |||
1835 | } | 2010 | } |
1836 | 2011 | ||
1837 | } | 2012 | } |