28 using System.Collections.Generic;
30 using System.Runtime.InteropServices;
33 using OpenSim.Framework;
38 using BulletXNA.LinearMath;
39 using BulletXNA.BulletCollision;
40 using BulletXNA.BulletDynamics;
41 using BulletXNA.BulletCollision.CollisionDispatch;
43 namespace OpenSim.
Region.PhysicsModule.BulletS
49 public DiscreteDynamicsWorld world;
50 public BulletWorldXNA(uint
id,
BSScene physScene, DiscreteDynamicsWorld xx)
57 private sealed
class BulletBodyXNA :
BulletBody
59 public CollisionObject body;
60 public RigidBody rigidBody {
get {
return RigidBody.Upcast(body); } }
62 public BulletBodyXNA(uint
id, CollisionObject xx)
67 public override bool HasPhysicalBody
69 get {
return body != null; }
71 public override void Clear()
75 public override string AddrString
77 get {
return "XNARigidBody"; }
83 public CollisionShape shape;
90 public override bool HasPhysicalShape
92 get {
return shape != null; }
94 public override void Clear()
100 return new BulletShapeXNA(shape, shapeType);
102 public override bool ReferenceSame(
BulletShape other)
104 BulletShapeXNA otheru = other as BulletShapeXNA;
105 return (otheru != null) && (this.shape == otheru.shape);
108 public override string AddrString
110 get {
return "XNACollisionShape"; }
115 public TypedConstraint constrain;
116 public BulletConstraintXNA(TypedConstraint xx) : base()
121 public override void Clear()
125 public override bool HasPhysicalConstraint {
get {
return constrain != null; } }
128 public override string AddrString
130 get {
return "XNAConstraint"; }
133 internal int m_maxCollisions;
135 internal int LastCollisionDesc = 0;
136 internal int m_maxUpdatesPerFrame;
137 internal int LastEntityProperty = 0;
140 internal Dictionary<uint, GhostObject> specialCollisionObjects;
142 private static int m_collisionsThisFrame;
143 private BSScene PhysicsScene {
get; set; }
145 public override string BulletEngineName {
get {
return "BulletXNA"; } }
146 public override string BulletEngineVersion {
get;
protected set; }
150 PhysicsScene = physScene;
160 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
161 RigidBody body = ((BulletBodyXNA)pBody).rigidBody;
162 CollisionObject collisionObject = ((BulletBodyXNA)pBody).body;
164 world.RemoveRigidBody(body);
165 else if (collisionObject != null)
166 world.RemoveCollisionObject(collisionObject);
174 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
175 RigidBody body = ((BulletBodyXNA)pBody).rigidBody;
176 CollisionObject collisionObject = ((BulletBodyXNA)pBody).body;
177 if (body != null && collisionObject != null && collisionObject.GetBroadphaseHandle() != null)
179 world.RemoveCollisionObject(collisionObject);
180 world.AddCollisionObject(collisionObject);
187 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
188 TypedConstraint constraint = (pConstraint as BulletConstraintXNA).constrain;
189 world.AddConstraint(constraint, pDisableCollisionsBetweenLinkedObjects);
197 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
198 TypedConstraint constraint = (pConstraint as BulletConstraintXNA).constrain;
199 world.RemoveConstraint(constraint);
205 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
206 collisionObject.SetRestitution(pRestitution);
211 CollisionShape shape = (pShape as BulletShapeXNA).shape;
212 return (
int)shape.GetShapeType();
216 CollisionShape shape = (pShape as BulletShapeXNA).shape;
217 shape.SetMargin(pMargin);
222 CollisionShape shape = (pShape as BulletShapeXNA).shape;
223 return shape.GetMargin();
228 CollisionShape shape = (pShape as BulletShapeXNA).shape;
229 IndexedVector3 vec =
new IndexedVector3(pScale.X, pScale.Y, pScale.Z);
230 shape.SetLocalScaling(ref vec);
236 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
237 collisionObject.SetContactProcessingThreshold(contactprocessingthreshold);
242 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
243 collisionObject.SetCcdMotionThreshold(pccdMotionThreashold);
248 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
249 collisionObject.SetCcdSweptSphereRadius(pCcdSweptSphereRadius);
254 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
255 body.SetAngularFactor(
new IndexedVector3(pAngularFactor.X, pAngularFactor.Y, pAngularFactor.Z));
260 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
262 existingcollisionFlags |= pcollisionFlags;
269 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
270 CollisionObject cbody = (pBody as BulletBodyXNA).body;
271 RigidBody rbody = cbody as RigidBody;
276 IndexedMatrix origPos = cbody.GetWorldTransform();
279 IndexedVector3 origGrav = rbody.GetGravity();
280 world.AddRigidBody(rbody);
281 rbody.SetGravity(origGrav);
285 world.AddCollisionObject(cbody);
287 cbody.SetWorldTransform(origPos);
289 pBody.ApplyCollisionMask(pWorld.physicsScene);
298 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
304 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
305 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
306 world.UpdateSingleAabb(collisionObject);
310 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
314 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
315 return world.GetForceUpdateAllAabbs();
320 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
321 world.SetForceUpdateAllAabbs(pForce);
326 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
327 collisionObject.GetBroadphaseHandle().m_collisionFilterGroup = (BulletXNA.BulletCollision.CollisionFilterGroups) pGroup;
328 collisionObject.GetBroadphaseHandle().m_collisionFilterGroup = (BulletXNA.BulletCollision.CollisionFilterGroups) pGroup;
329 if ((uint) collisionObject.GetBroadphaseHandle().m_collisionFilterGroup == 0)
336 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
337 IndexedVector3 zeroVector =
new IndexedVector3(0, 0, 0);
338 collisionObject.SetInterpolationLinearVelocity(ref zeroVector);
339 collisionObject.SetInterpolationAngularVelocity(ref zeroVector);
340 IndexedMatrix bodytransform = collisionObject.GetWorldTransform();
342 collisionObject.SetInterpolationWorldTransform(ref bodytransform);
344 if (collisionObject is RigidBody)
346 RigidBody rigidbody = collisionObject as RigidBody;
347 rigidbody.SetLinearVelocity(zeroVector);
348 rigidbody.SetAngularVelocity(zeroVector);
349 rigidbody.ClearForces();
355 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
356 IndexedVector3 vec =
new IndexedVector3(pVector3.X, pVector3.Y, pVector3.Z);
357 collisionObject.SetInterpolationAngularVelocity(ref vec);
362 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
363 IndexedVector3 vec =
new IndexedVector3(pVector3.X, pVector3.Y, pVector3.Z);
364 body.SetAngularVelocity(ref vec);
368 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
369 IndexedVector3 iv3 = body.GetTotalForce();
370 return new Vector3(iv3.X, iv3.Y, iv3.Z);
374 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
375 IndexedVector3 iv3 = body.GetTotalTorque();
376 return new Vector3(iv3.X, iv3.Y, iv3.Z);
380 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
381 IndexedVector3 iv3 = body.GetInvInertiaDiagLocal();
382 return new Vector3(iv3.X, iv3.Y, iv3.Z);
386 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
387 IndexedVector3 iv3 =
new IndexedVector3(inert.X, inert.Y, inert.Z);
388 body.SetInvInertiaDiagLocal(ref iv3);
392 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
393 IndexedVector3 forceiv3 =
new IndexedVector3(force.X, force.Y, force.Z);
394 IndexedVector3 posiv3 =
new IndexedVector3(pos.X, pos.Y, pos.Z);
395 body.ApplyForce(ref forceiv3, ref posiv3);
399 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
400 IndexedVector3 impiv3 =
new IndexedVector3(imp.X, imp.Y, imp.Z);
401 IndexedVector3 posiv3 =
new IndexedVector3(pos.X, pos.Y, pos.Z);
402 body.ApplyImpulse(ref impiv3, ref posiv3);
407 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
413 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
414 IndexedVector3 vposition =
new IndexedVector3(_position.X, _position.Y, _position.Z);
415 IndexedQuaternion vquaternion =
new IndexedQuaternion(_orientation.X, _orientation.Y, _orientation.Z,
417 IndexedMatrix mat = IndexedMatrix.CreateFromQuaternion(vquaternion);
418 mat._origin = vposition;
419 collisionObject.SetWorldTransform(mat);
425 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
426 IndexedVector3 pos = collisionObject.GetInterpolationWorldTransform()._origin;
427 return new Vector3(pos.X, pos.Y, pos.Z);
432 CollisionShape shape = (pShape as BulletShapeXNA).shape;
433 IndexedVector3 inertia = IndexedVector3.Zero;
434 shape.CalculateLocalInertia(pphysMass, out inertia);
435 return new Vector3(inertia.X, inertia.Y, inertia.Z);
440 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
443 IndexedVector3 inertia =
new IndexedVector3(plocalInertia.X, plocalInertia.Y, plocalInertia.Z);
444 body.SetMassProps(pphysMass, inertia);
451 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
452 IndexedVector3 force =
new IndexedVector3(_force.X, _force.Y, _force.Z);
453 body.SetTotalForce(ref force);
458 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
459 collisionObject.SetFriction(_currentFriction);
464 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
465 IndexedVector3 velocity =
new IndexedVector3(_velocity.X, _velocity.Y, _velocity.Z);
466 body.SetLinearVelocity(velocity);
471 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
472 collisionObject.Activate(pforceactivation);
478 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
479 IndexedQuaternion mat = collisionObject.GetInterpolationWorldTransform().GetRotation();
480 return new Quaternion(mat.X, mat.Y, mat.Z, mat.W);
485 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
487 existingcollisionFlags &= ~pcollisionFlags;
494 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
495 return collisionObject.GetCcdSquareMotionThreshold();
500 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
501 return collisionObject.GetCcdSweptSphereRadius();
507 CollisionObject shape = (pCollisionObject as BulletBodyXNA).body;
508 return (IntPtr)shape.GetUserPointer();
513 CollisionObject shape = (pCollisionObject as BulletBodyXNA).body;
514 shape.SetUserPointer(val);
519 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
522 IndexedVector3 gravity =
new IndexedVector3(pGravity.X, pGravity.Y, pGravity.Z);
523 body.SetGravity(gravity);
529 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
530 TypedConstraint constraint = (pConstraint as BulletConstraintXNA).constrain;
531 world.RemoveConstraint(constraint);
537 Generic6DofConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofConstraint;
538 IndexedVector3 lowlimit =
new IndexedVector3(low.X, low.Y, low.Z);
539 IndexedVector3 highlimit =
new IndexedVector3(high.X, high.Y, high.Z);
540 constraint.SetLinearLowerLimit(lowlimit);
541 constraint.SetLinearUpperLimit(highlimit);
547 Generic6DofConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofConstraint;
548 IndexedVector3 lowlimit =
new IndexedVector3(low.X, low.Y, low.Z);
549 IndexedVector3 highlimit =
new IndexedVector3(high.X, high.Y, high.Z);
550 constraint.SetAngularLowerLimit(lowlimit);
551 constraint.SetAngularUpperLimit(highlimit);
557 Generic6DofConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofConstraint;
558 constraint.SetOverrideNumSolverIterations((int)cnt);
563 Generic6DofConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofConstraint;
564 constraint.CalculateTransforms();
570 Generic6DofConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofConstraint;
571 constraint.SetEnabled((p_2 == 0) ?
false :
true);
576 Vector3 pframe1, Quaternion pframe1rot, Vector3 pframe2, Quaternion pframe2rot,
577 bool puseLinearReferenceFrameA,
bool pdisableCollisionsBetweenLinkedBodies)
580 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
581 RigidBody body1 = (pBody1 as BulletBodyXNA).rigidBody;
582 RigidBody body2 = (pBody2 as BulletBodyXNA).rigidBody;
583 IndexedVector3 frame1v =
new IndexedVector3(pframe1.X, pframe1.Y, pframe1.Z);
584 IndexedQuaternion frame1rot =
new IndexedQuaternion(pframe1rot.X, pframe1rot.Y, pframe1rot.Z, pframe1rot.W);
585 IndexedMatrix frame1 = IndexedMatrix.CreateFromQuaternion(frame1rot);
586 frame1._origin = frame1v;
588 IndexedVector3 frame2v =
new IndexedVector3(pframe2.X, pframe2.Y, pframe2.Z);
589 IndexedQuaternion frame2rot =
new IndexedQuaternion(pframe2rot.X, pframe2rot.Y, pframe2rot.Z, pframe2rot.W);
590 IndexedMatrix frame2 = IndexedMatrix.CreateFromQuaternion(frame2rot);
591 frame2._origin = frame1v;
593 Generic6DofConstraint consttr =
new Generic6DofConstraint(body1, body2, ref frame1, ref frame2,
594 puseLinearReferenceFrameA);
595 consttr.CalculateTransforms();
596 world.AddConstraint(consttr,pdisableCollisionsBetweenLinkedBodies);
598 return new BulletConstraintXNA(consttr);
602 Vector3 pframe1, Quaternion pframe1rot,
603 bool pUseLinearReferenceFrameB,
bool pdisableCollisionsBetweenLinkedBodies)
605 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
606 RigidBody body1 = (pBody1 as BulletBodyXNA).rigidBody;
607 IndexedVector3 frame1v =
new IndexedVector3(pframe1.X, pframe1.Y, pframe1.Z);
608 IndexedQuaternion frame1rot =
new IndexedQuaternion(pframe1rot.X, pframe1rot.Y, pframe1rot.Z, pframe1rot.W);
609 IndexedMatrix frame1 = IndexedMatrix.CreateFromQuaternion(frame1rot);
610 frame1._origin = frame1v;
612 Generic6DofConstraint consttr =
new Generic6DofConstraint(body1, ref frame1, pUseLinearReferenceFrameB);
613 consttr.CalculateTransforms();
614 world.AddConstraint(consttr,pdisableCollisionsBetweenLinkedBodies);
616 return new BulletConstraintXNA(consttr);
631 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
632 RigidBody body1 = (pBody1 as BulletBodyXNA).rigidBody;
633 RigidBody body2 = (pBody2 as BulletBodyXNA).rigidBody;
634 IndexedMatrix frame1 =
new IndexedMatrix(IndexedBasisMatrix.Identity,
new IndexedVector3(0, 0, 0));
635 IndexedMatrix frame2 =
new IndexedMatrix(IndexedBasisMatrix.Identity,
new IndexedVector3(0, 0, 0));
637 IndexedVector3 joinPoint =
new IndexedVector3(pjoinPoint.X, pjoinPoint.Y, pjoinPoint.Z);
638 IndexedMatrix mat = IndexedMatrix.Identity;
639 mat._origin =
new IndexedVector3(pjoinPoint.X, pjoinPoint.Y, pjoinPoint.Z);
640 frame1._origin = body1.GetWorldTransform().Inverse()*joinPoint;
641 frame2._origin = body2.GetWorldTransform().Inverse()*joinPoint;
643 Generic6DofConstraint consttr =
new Generic6DofConstraint(body1, body2, ref frame1, ref frame2, puseLinearReferenceFrameA);
644 consttr.CalculateTransforms();
645 world.AddConstraint(consttr, pdisableCollisionsBetweenLinkedBodies);
647 return new BulletConstraintXNA(consttr);
650 public override bool SetFrames(
BulletConstraint pConstraint, Vector3 pframe1, Quaternion pframe1rot, Vector3 pframe2, Quaternion pframe2rot)
652 Generic6DofConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofConstraint;
653 IndexedVector3 frame1v =
new IndexedVector3(pframe1.X, pframe1.Y, pframe1.Z);
654 IndexedQuaternion frame1rot =
new IndexedQuaternion(pframe1rot.X, pframe1rot.Y, pframe1rot.Z, pframe1rot.W);
655 IndexedMatrix frame1 = IndexedMatrix.CreateFromQuaternion(frame1rot);
656 frame1._origin = frame1v;
658 IndexedVector3 frame2v =
new IndexedVector3(pframe2.X, pframe2.Y, pframe2.Z);
659 IndexedQuaternion frame2rot =
new IndexedQuaternion(pframe2rot.X, pframe2rot.Y, pframe2rot.Z, pframe2rot.W);
660 IndexedMatrix frame2 = IndexedMatrix.CreateFromQuaternion(frame2rot);
661 frame2._origin = frame2v;
662 constraint.SetFrames(ref frame1, ref frame2);
668 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
669 IndexedVector3 iv3 = body.GetLinearVelocity();
670 return new Vector3(iv3.X, iv3.Y, iv3.Z);
674 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
675 IndexedVector3 iv3 = body.GetAngularVelocity();
676 return new Vector3(iv3.X, iv3.Y, iv3.Z);
680 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
681 IndexedVector3 posiv3 =
new IndexedVector3(pos.X, pos.Y, pos.Z);
682 IndexedVector3 iv3 = body.GetVelocityInLocalPoint(ref posiv3);
683 return new Vector3(iv3.X, iv3.Y, iv3.Z);
687 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
688 collisionObject.Translate(
new IndexedVector3(trans.X,trans.Y,trans.Z));
692 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
693 body.UpdateDeactivation(timeStep);
698 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
699 return body.WantsSleeping();
704 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
705 body.SetAngularFactor(factor);
710 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
711 IndexedVector3 iv3 = body.GetAngularFactor();
712 return new Vector3(iv3.X, iv3.Y, iv3.Z);
717 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
718 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
719 return world.IsInWorld(collisionObject);
724 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
725 TypedConstraint constrain = (pConstraint as BulletConstraintXNA).constrain;
726 body.AddConstraintRef(constrain);
731 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
732 TypedConstraint constrain = (pConstraint as BulletConstraintXNA).constrain;
733 body.RemoveConstraintRef(constrain);
738 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
739 return new BulletConstraintXNA(body.GetConstraintRef(index));
744 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
745 return body.GetNumConstraintRefs();
750 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
751 IndexedVector3 velocity =
new IndexedVector3(VehicleVelocity.X, VehicleVelocity.Y, VehicleVelocity.Z);
752 collisionObject.SetInterpolationLinearVelocity(ref velocity);
757 Generic6DofConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofConstraint;
758 constraint.SetUseFrameOffset((onOff == 0) ?
false :
true);
764 Generic6DofConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofConstraint;
765 constraint.SetBreakingImpulseThreshold(threshold);
770 HingeConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as HingeConstraint;
771 if (softness == HINGE_NOT_SPECIFIED)
772 constraint.SetLimit(low, high);
774 constraint.SetLimit(low, high, softness, bias, relaxation);
779 Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint;
780 constraint.EnableSpring(index, (numericTrueFalse == 0f ?
false :
true));
786 Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint;
787 if (index == SPRING_NOT_SPECIFIED)
789 constraint.SetEquilibriumPoint();
793 if (equilibriumPoint == SPRING_NOT_SPECIFIED)
794 constraint.SetEquilibriumPoint(index);
796 constraint.SetEquilibriumPoint(index, equilibriumPoint);
803 Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint;
804 constraint.SetStiffness(index, stiffness);
810 Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint;
811 constraint.SetDamping(index, damping);
817 SliderConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as SliderConstraint;
820 case SLIDER_LOWER_LIMIT:
824 constraint.SetLowerLinLimit(val);
827 constraint.SetLowerAngLimit(val);
831 case SLIDER_UPPER_LIMIT:
835 constraint.SetUpperLinLimit(val);
838 constraint.SetUpperAngLimit(val);
847 SliderConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as SliderConstraint;
848 switch (softRestDamp)
850 case SLIDER_SET_SOFTNESS:
853 case SLIDER_SET_DIRECTION:
856 case SLIDER_LINEAR: constraint.SetSoftnessDirLin(val);
break;
857 case SLIDER_ANGULAR: constraint.SetSoftnessDirAng(val);
break;
860 case SLIDER_SET_LIMIT:
863 case SLIDER_LINEAR: constraint.SetSoftnessLimLin(val);
break;
864 case SLIDER_ANGULAR: constraint.SetSoftnessLimAng(val);
break;
867 case SLIDER_SET_ORTHO:
870 case SLIDER_LINEAR: constraint.SetSoftnessOrthoLin(val);
break;
871 case SLIDER_ANGULAR: constraint.SetSoftnessOrthoAng(val);
break;
876 case SLIDER_SET_RESTITUTION:
879 case SLIDER_SET_DIRECTION:
882 case SLIDER_LINEAR: constraint.SetRestitutionDirLin(val);
break;
883 case SLIDER_ANGULAR: constraint.SetRestitutionDirAng(val);
break;
886 case SLIDER_SET_LIMIT:
889 case SLIDER_LINEAR: constraint.SetRestitutionLimLin(val);
break;
890 case SLIDER_ANGULAR: constraint.SetRestitutionLimAng(val);
break;
893 case SLIDER_SET_ORTHO:
896 case SLIDER_LINEAR: constraint.SetRestitutionOrthoLin(val);
break;
897 case SLIDER_ANGULAR: constraint.SetRestitutionOrthoAng(val);
break;
902 case SLIDER_SET_DAMPING:
905 case SLIDER_SET_DIRECTION:
908 case SLIDER_LINEAR: constraint.SetDampingDirLin(val);
break;
909 case SLIDER_ANGULAR: constraint.SetDampingDirAng(val);
break;
912 case SLIDER_SET_LIMIT:
915 case SLIDER_LINEAR: constraint.SetDampingLimLin(val);
break;
916 case SLIDER_ANGULAR: constraint.SetDampingLimAng(val);
break;
919 case SLIDER_SET_ORTHO:
922 case SLIDER_LINEAR: constraint.SetDampingOrthoLin(val);
break;
923 case SLIDER_ANGULAR: constraint.SetDampingOrthoAng(val);
break;
933 SliderConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as SliderConstraint;
937 constraint.SetPoweredLinMotor(numericTrueFalse == 0.0 ?
false :
true);
940 constraint.SetPoweredAngMotor(numericTrueFalse == 0.0 ?
false :
true);
947 SliderConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as SliderConstraint;
950 case SLIDER_MOTOR_VELOCITY:
954 constraint.SetTargetLinMotorVelocity(val);
957 constraint.SetTargetAngMotorVelocity(val);
961 case SLIDER_MAX_MOTOR_FORCE:
965 constraint.SetMaxLinMotorForce(val);
968 constraint.SetMaxAngMotorForce(val);
979 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
980 float lineardamping = body.GetLinearDamping();
981 body.SetDamping(lineardamping, angularDamping);
987 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
989 body.UpdateInertiaTensor();
994 CompoundShape shape = (pCompoundShape as BulletShapeXNA).shape as CompoundShape;
995 shape.RecalculateLocalAabb();
1001 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
1002 uint flags = (uint)collisionObject.GetCollisionFlags();
1008 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1009 body.SetDamping(pLinear, pAngular);
1014 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
1015 collisionObject.SetDeactivationTime(pDeactivationTime);
1020 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1021 body.SetSleepingThresholds(plinearSleepingThreshold, pangularSleepingThreshold);
1026 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
1033 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1034 body.ApplyGravity();
1039 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1040 IndexedVector3 gravity = body.GetGravity();
1041 return new Vector3(gravity.X, gravity.Y, gravity.Z);
1046 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1047 float angularDamping = body.GetAngularDamping();
1048 body.SetDamping(lin_damping, angularDamping);
1053 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1054 return body.GetLinearDamping();
1059 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1060 return body.GetAngularDamping();
1065 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1066 return body.GetLinearSleepingThreshold();
1071 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1072 body.ApplyDamping(timeStep);
1077 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1078 IndexedVector3 linearFactor = body.GetLinearFactor();
1079 return new Vector3(linearFactor.X, linearFactor.Y, linearFactor.Z);
1084 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1085 body.SetLinearFactor(
new IndexedVector3(factor.X, factor.Y, factor.Z));
1090 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1091 IndexedQuaternion quat =
new IndexedQuaternion(rot.X, rot.Y, rot.Z,rot.W);
1092 IndexedMatrix mat = IndexedMatrix.CreateFromQuaternion(quat);
1093 mat._origin =
new IndexedVector3(pos.X, pos.Y, pos.Z);
1094 body.SetCenterOfMassTransform( ref mat);
1101 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1102 IndexedVector3 fSum =
new IndexedVector3(pfSum.X, pfSum.Y, pfSum.Z);
1103 body.ApplyCentralForce(ref fSum);
1107 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1108 IndexedVector3 fSum =
new IndexedVector3(pfSum.X, pfSum.Y, pfSum.Z);
1109 body.ApplyCentralImpulse(ref fSum);
1113 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1114 IndexedVector3 fSum =
new IndexedVector3(pfSum.X, pfSum.Y, pfSum.Z);
1115 body.ApplyTorque(ref fSum);
1119 RigidBody body = (pBody as BulletBodyXNA).rigidBody;
1120 IndexedVector3 fSum =
new IndexedVector3(pfSum.X, pfSum.Y, pfSum.Z);
1121 body.ApplyTorqueImpulse(ref fSum);
1126 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1127 CollisionObject co = (pBody as BulletBodyXNA).rigidBody;
1128 RigidBody bo = co as RigidBody;
1132 if (world.IsInWorld(co))
1134 world.RemoveCollisionObject(co);
1140 if (world.IsInWorld(bo))
1142 world.RemoveRigidBody(bo);
1147 if (co.GetUserPointer() != null)
1149 uint localId = (uint) co.GetUserPointer();
1150 if (specialCollisionObjects.ContainsKey(localId))
1152 specialCollisionObjects.Remove(localId);
1161 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1167 CollisionShape shape1 = (pShape as BulletShapeXNA).shape;
1170 BulletShapeXNA shape2 =
new BulletShapeXNA(shape1, BSShapeTypeFromBroadPhaseNativeType(shape1.GetShapeType()));
1184 CollisionWorld world = (pWorld as BulletWorldXNA).world;
1186 IndexedMatrix.CreateFromQuaternion(
new IndexedQuaternion(pRawOrientation.X, pRawOrientation.Y,
1187 pRawOrientation.Z, pRawOrientation.W));
1188 mat._origin =
new IndexedVector3(pRawPosition.X, pRawPosition.Y, pRawPosition.Z);
1189 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1193 RigidBody body =
new RigidBody(0,motionState,shape,IndexedVector3.Zero);
1194 RigidBodyConstructionInfo constructionInfo =
new RigidBodyConstructionInfo(0, motionState, shape, IndexedVector3.Zero)
1216 body.SetUserPointer(pLocalID);
1218 return new BulletBodyXNA(pLocalID, body);
1226 IndexedMatrix.CreateFromQuaternion(
new IndexedQuaternion(pRawOrientation.X, pRawOrientation.Y,
1227 pRawOrientation.Z, pRawOrientation.W));
1228 mat._origin =
new IndexedVector3(pRawPosition.X, pRawPosition.Y, pRawPosition.Z);
1230 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1233 RigidBody body =
new RigidBody(0,
new DefaultMotionState( mat, IndexedMatrix.Identity), shape, IndexedVector3.Zero);
1234 body.SetWorldTransform(mat);
1235 body.SetUserPointer(pLocalID);
1236 return new BulletBodyXNA(pLocalID, body);
1241 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
1250 return Vector3.Zero;
1257 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
1258 return collisionObject.IsStaticObject();
1263 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
1264 return collisionObject.IsKinematicObject();
1268 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
1269 return collisionObject.IsStaticOrKinematicObject();
1273 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
1274 return collisionObject.HasContactResponse();
1288 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
1289 collisionObject.SetHitFraction(pHitFraction);
1294 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1295 IndexedVector3 scale =
new IndexedVector3(pScale.X, pScale.Y, pScale.Z);
1296 CapsuleShapeZ capsuleShapeZ =
new CapsuleShapeZ(pRadius, pHeight);
1297 capsuleShapeZ.SetMargin(world.WorldSettings.Params.collisionMargin);
1298 capsuleShapeZ.SetLocalScaling(ref scale);
1309 UpdatedObjects = updateArray;
1310 UpdatedCollisions = collisionArray;
1313 configparms[0] = parms;
1314 Vector3 worldExtent = maxPosition;
1315 m_maxCollisions = maxCollisions;
1316 m_maxUpdatesPerFrame = maxUpdates;
1317 specialCollisionObjects =
new Dictionary<uint, GhostObject>();
1319 return new BulletWorldXNA(1, PhysicsScene,
BSAPIXNA.Initialize2(worldExtent, configparms, maxCollisions, ref collisionArray, maxUpdates, ref updateArray, null));
1322 private static DiscreteDynamicsWorld Initialize2(Vector3 worldExtent,
1324 int mMaxCollisionsPerFrame, ref
CollisionDesc[] collisionArray,
1326 object mDebugLogCallbackHandle)
1328 CollisionWorld.WorldData.ParamData p =
new CollisionWorld.WorldData.ParamData();
1330 p.angularDamping = BSParam.AngularDamping;
1331 p.defaultFriction = o[0].defaultFriction;
1332 p.defaultFriction = o[0].defaultFriction;
1333 p.defaultDensity = o[0].defaultDensity;
1334 p.defaultRestitution = o[0].defaultRestitution;
1335 p.collisionMargin = o[0].collisionMargin;
1336 p.gravity = o[0].gravity;
1338 p.linearDamping = BSParam.LinearDamping;
1339 p.angularDamping = BSParam.AngularDamping;
1340 p.deactivationTime = BSParam.DeactivationTime;
1341 p.linearSleepingThreshold = BSParam.LinearSleepingThreshold;
1342 p.angularSleepingThreshold = BSParam.AngularSleepingThreshold;
1343 p.ccdMotionThreshold = BSParam.CcdMotionThreshold;
1344 p.ccdSweptSphereRadius = BSParam.CcdSweptSphereRadius;
1345 p.contactProcessingThreshold = BSParam.ContactProcessingThreshold;
1347 p.terrainImplementation = BSParam.TerrainImplementation;
1348 p.terrainFriction = BSParam.TerrainFriction;
1350 p.terrainHitFraction = BSParam.TerrainHitFraction;
1351 p.terrainRestitution = BSParam.TerrainRestitution;
1352 p.terrainCollisionMargin = BSParam.TerrainCollisionMargin;
1354 p.avatarFriction = BSParam.AvatarFriction;
1355 p.avatarStandingFriction = BSParam.AvatarStandingFriction;
1356 p.avatarDensity = BSParam.AvatarDensity;
1357 p.avatarRestitution = BSParam.AvatarRestitution;
1358 p.avatarCapsuleWidth = BSParam.AvatarCapsuleWidth;
1359 p.avatarCapsuleDepth = BSParam.AvatarCapsuleDepth;
1360 p.avatarCapsuleHeight = BSParam.AvatarCapsuleHeight;
1361 p.avatarContactProcessingThreshold = BSParam.AvatarContactProcessingThreshold;
1363 p.vehicleAngularDamping = BSParam.VehicleAngularDamping;
1365 p.maxPersistantManifoldPoolSize = o[0].maxPersistantManifoldPoolSize;
1366 p.maxCollisionAlgorithmPoolSize = o[0].maxCollisionAlgorithmPoolSize;
1367 p.shouldDisableContactPoolDynamicAllocation = o[0].shouldDisableContactPoolDynamicAllocation;
1368 p.shouldForceUpdateAllAabbs = o[0].shouldForceUpdateAllAabbs;
1369 p.shouldRandomizeSolverOrder = o[0].shouldRandomizeSolverOrder;
1370 p.shouldSplitSimulationIslands = o[0].shouldSplitSimulationIslands;
1371 p.shouldEnableFrictionCaching = o[0].shouldEnableFrictionCaching;
1372 p.numberOfSolverIterations = o[0].numberOfSolverIterations;
1374 p.linksetImplementation = BSParam.LinksetImplementation;
1375 p.linkConstraintUseFrameOffset = BSParam.NumericBool(BSParam.LinkConstraintUseFrameOffset);
1376 p.linkConstraintEnableTransMotor = BSParam.NumericBool(BSParam.LinkConstraintEnableTransMotor);
1377 p.linkConstraintTransMotorMaxVel = BSParam.LinkConstraintTransMotorMaxVel;
1378 p.linkConstraintTransMotorMaxForce = BSParam.LinkConstraintTransMotorMaxForce;
1379 p.linkConstraintERP = BSParam.LinkConstraintERP;
1380 p.linkConstraintCFM = BSParam.LinkConstraintCFM;
1381 p.linkConstraintSolverIterations = BSParam.LinkConstraintSolverIterations;
1382 p.physicsLoggingFrames = o[0].physicsLoggingFrames;
1383 DefaultCollisionConstructionInfo ccci =
new DefaultCollisionConstructionInfo();
1385 DefaultCollisionConfiguration cci =
new DefaultCollisionConfiguration();
1386 CollisionDispatcher m_dispatcher =
new CollisionDispatcher(cci);
1389 if (p.maxPersistantManifoldPoolSize > 0)
1390 cci.m_persistentManifoldPoolSize = (int)p.maxPersistantManifoldPoolSize;
1391 if (p.shouldDisableContactPoolDynamicAllocation !=0)
1392 m_dispatcher.SetDispatcherFlags(DispatcherFlags.CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION);
1395 DbvtBroadphase m_broadphase =
new DbvtBroadphase();
1400 m_broadphase.GetOverlappingPairCache().SetInternalGhostPairCallback(
new GhostPairCallback());
1402 SequentialImpulseConstraintSolver m_solver =
new SequentialImpulseConstraintSolver();
1404 DiscreteDynamicsWorld world =
new DiscreteDynamicsWorld(m_dispatcher, m_broadphase, m_solver, cci);
1406 world.LastCollisionDesc = 0;
1407 world.LastEntityProperty = 0;
1409 world.WorldSettings.Params = p;
1410 world.SetForceUpdateAllAabbs(p.shouldForceUpdateAllAabbs != 0);
1411 world.GetSolverInfo().m_solverMode = SolverMode.SOLVER_USE_WARMSTARTING | SolverMode.SOLVER_SIMD;
1412 if (p.shouldRandomizeSolverOrder != 0)
1413 world.GetSolverInfo().m_solverMode |= SolverMode.SOLVER_RANDMIZE_ORDER;
1415 world.GetSimulationIslandManager().SetSplitIslands(p.shouldSplitSimulationIslands != 0);
1418 if (p.shouldEnableFrictionCaching != 0)
1419 world.GetSolverInfo().m_solverMode |= SolverMode.SOLVER_ENABLE_FRICTION_DIRECTION_CACHING;
1421 if (p.numberOfSolverIterations > 0)
1422 world.GetSolverInfo().m_numIterations = (
int) p.numberOfSolverIterations;
1425 world.GetSolverInfo().m_damping = world.WorldSettings.Params.linearDamping;
1426 world.GetSolverInfo().m_restitution = world.WorldSettings.Params.defaultRestitution;
1427 world.GetSolverInfo().m_globalCfm = 0.0f;
1428 world.GetSolverInfo().m_tau = 0.6f;
1429 world.GetSolverInfo().m_friction = 0.3f;
1430 world.GetSolverInfo().m_maxErrorReduction = 20f;
1431 world.GetSolverInfo().m_numIterations = 10;
1432 world.GetSolverInfo().m_erp = 0.2f;
1433 world.GetSolverInfo().m_erp2 = 0.1f;
1434 world.GetSolverInfo().m_sor = 1.0f;
1435 world.GetSolverInfo().m_splitImpulse = false;
1436 world.GetSolverInfo().m_splitImpulsePenetrationThreshold = -0.02f;
1437 world.GetSolverInfo().m_linearSlop = 0.0f;
1438 world.GetSolverInfo().m_warmstartingFactor = 0.85f;
1439 world.GetSolverInfo().m_restingContactRestitutionThreshold = 2;
1440 world.SetForceUpdateAllAabbs(true);
1443 world.SetGravity(new IndexedVector3(0,0,p.gravity));
1446 BulletGlobals.VoronoiSimplexSolverPool.SetPoolingEnabled(false);
1447 BulletGlobals.SubSimplexConvexCastPool.SetPoolingEnabled(false);
1448 BulletGlobals.ManifoldPointPool.SetPoolingEnabled(false);
1449 BulletGlobals.CastResultPool.SetPoolingEnabled(false);
1450 BulletGlobals.SphereShapePool.SetPoolingEnabled(false);
1451 BulletGlobals.DbvtNodePool.SetPoolingEnabled(false);
1452 BulletGlobals.SingleRayCallbackPool.SetPoolingEnabled(false);
1453 BulletGlobals.SubSimplexClosestResultPool.SetPoolingEnabled(false);
1454 BulletGlobals.GjkPairDetectorPool.SetPoolingEnabled(false);
1455 BulletGlobals.DbvtTreeColliderPool.SetPoolingEnabled(false);
1456 BulletGlobals.SingleSweepCallbackPool.SetPoolingEnabled(false);
1457 BulletGlobals.BroadphaseRayTesterPool.SetPoolingEnabled(false);
1458 BulletGlobals.ClosestNotMeConvexResultCallbackPool.SetPoolingEnabled(false);
1459 BulletGlobals.GjkEpaPenetrationDepthSolverPool.SetPoolingEnabled(false);
1460 BulletGlobals.ContinuousConvexCollisionPool.SetPoolingEnabled(false);
1461 BulletGlobals.DbvtStackDataBlockPool.SetPoolingEnabled(false);
1463 BulletGlobals.BoxBoxCollisionAlgorithmPool.SetPoolingEnabled(false);
1464 BulletGlobals.CompoundCollisionAlgorithmPool.SetPoolingEnabled(false);
1465 BulletGlobals.ConvexConcaveCollisionAlgorithmPool.SetPoolingEnabled(false);
1466 BulletGlobals.ConvexConvexAlgorithmPool.SetPoolingEnabled(false);
1467 BulletGlobals.ConvexPlaneAlgorithmPool.SetPoolingEnabled(false);
1468 BulletGlobals.SphereBoxCollisionAlgorithmPool.SetPoolingEnabled(false);
1469 BulletGlobals.SphereSphereCollisionAlgorithmPool.SetPoolingEnabled(false);
1470 BulletGlobals.SphereTriangleCollisionAlgorithmPool.SetPoolingEnabled(false);
1471 BulletGlobals.GImpactCollisionAlgorithmPool.SetPoolingEnabled(false);
1472 BulletGlobals.GjkEpaSolver2MinkowskiDiffPool.SetPoolingEnabled(false);
1473 BulletGlobals.PersistentManifoldPool.SetPoolingEnabled(false);
1474 BulletGlobals.ManifoldResultPool.SetPoolingEnabled(false);
1475 BulletGlobals.GJKPool.SetPoolingEnabled(false);
1476 BulletGlobals.GIM_ShapeRetrieverPool.SetPoolingEnabled(false);
1477 BulletGlobals.TriangleShapePool.SetPoolingEnabled(false);
1478 BulletGlobals.SphereTriangleDetectorPool.SetPoolingEnabled(false);
1479 BulletGlobals.CompoundLeafCallbackPool.SetPoolingEnabled(false);
1480 BulletGlobals.GjkConvexCastPool.SetPoolingEnabled(false);
1481 BulletGlobals.LocalTriangleSphereCastCallbackPool.SetPoolingEnabled(false);
1482 BulletGlobals.BridgeTriangleRaycastCallbackPool.SetPoolingEnabled(false);
1483 BulletGlobals.BridgeTriangleConcaveRaycastCallbackPool.SetPoolingEnabled(false);
1484 BulletGlobals.BridgeTriangleConvexcastCallbackPool.SetPoolingEnabled(false);
1485 BulletGlobals.MyNodeOverlapCallbackPool.SetPoolingEnabled(false);
1486 BulletGlobals.ClosestRayResultCallbackPool.SetPoolingEnabled(false);
1487 BulletGlobals.DebugDrawcallbackPool.SetPoolingEnabled(false);
1494 Generic6DofConstraint constrain = (pConstraint as BulletConstraintXNA).constrain as Generic6DofConstraint;
1517 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
1518 RigidBody rb = collisionObject as RigidBody;
1524 IndexedMatrix wt = IndexedMatrix.Identity;
1525 sms.GetWorldTransform(out wt);
1526 sms.SetWorldTransform(ref wt,
true);
1536 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1537 return shape.GetAngularMotionDisc();
1541 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1542 return shape.GetContactBreakingThreshold(defaultFactor);
1546 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1547 return shape.IsCompound();
1551 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1552 return shape.IsSoftBody();
1556 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1557 return shape.IsPolyhedral();
1561 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1562 return shape.IsConvex2d();
1566 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1567 return shape.IsConvex();
1571 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1572 return shape.IsNonMoving();
1576 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1577 return shape.IsConcave();
1581 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1582 return shape.IsInfinite();
1586 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1588 switch (shape.GetShapeType())
1590 case BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE:
1591 case BroadphaseNativeTypes.CONE_SHAPE_PROXYTYPE:
1592 case BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE:
1593 case BroadphaseNativeTypes.CYLINDER_SHAPE_PROXYTYPE:
1605 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1606 shape.SetMargin(pMargin);
1612 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1613 IndexedMatrix bodyTransform =
new IndexedMatrix();
1614 bodyTransform._origin =
new IndexedVector3(pRawPosition.X, pRawPosition.Y, pRawPosition.Z);
1615 bodyTransform.SetRotation(
new IndexedQuaternion(pRawOrientation.X,pRawOrientation.Y,pRawOrientation.Z,pRawOrientation.W));
1616 GhostObject gObj =
new PairCachingGhostObject();
1617 gObj.SetWorldTransform(bodyTransform);
1618 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1619 gObj.SetCollisionShape(shape);
1620 gObj.SetUserPointer(pLocalID);
1622 if (specialCollisionObjects.ContainsKey(pLocalID))
1623 specialCollisionObjects[pLocalID] = gObj;
1625 specialCollisionObjects.Add(pLocalID, gObj);
1628 return new BulletBodyXNA(pLocalID, gObj);
1633 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1634 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
1637 collisionObject.SetCollisionShape(
new EmptyShape());
1641 CollisionShape shape = (pShape as BulletShapeXNA).shape;
1642 collisionObject.SetCollisionShape(shape);
1647 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
1648 CollisionShape shape = collisionObject.GetCollisionShape();
1649 return new BulletShapeXNA(shape, BSShapeTypeFromBroadPhaseNativeType(shape.GetShapeType()));
1655 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1656 CollisionShape shape = null;
1657 switch (pShapeData.
Type)
1659 case BSPhysicsShapeType.SHAPE_BOX:
1660 shape =
new BoxShape(
new IndexedVector3(0.5f,0.5f,0.5f));
1662 case BSPhysicsShapeType.SHAPE_CONE:
1663 shape =
new ConeShapeZ(0.5f, 1.0f);
1665 case BSPhysicsShapeType.SHAPE_CYLINDER:
1666 shape =
new CylinderShapeZ(
new IndexedVector3(0.5f, 0.5f, 0.5f));
1668 case BSPhysicsShapeType.SHAPE_SPHERE:
1669 shape =
new SphereShape(0.5f);
1675 IndexedVector3 scaling =
new IndexedVector3(pShapeData.
Scale.X, pShapeData.
Scale.Y, pShapeData.
Scale.Z);
1676 shape.SetMargin(world.WorldSettings.Params.collisionMargin);
1677 shape.SetLocalScaling(ref scaling);
1680 return new BulletShapeXNA(shape, pShapeData.
Type);
1685 return new BulletShapeXNA(
new CompoundShape(enableDynamicAabbTree),
BSPhysicsShapeType.SHAPE_COMPOUND);
1690 CompoundShape compoundshape = (pCompoundShape as BulletShapeXNA).shape as CompoundShape;
1691 return compoundshape.GetNumChildShapes();
1696 IndexedMatrix relativeTransform =
new IndexedMatrix();
1697 CompoundShape compoundshape = (pCShape as BulletShapeXNA).shape as CompoundShape;
1698 CollisionShape addshape = (paddShape as BulletShapeXNA).shape;
1700 relativeTransform._origin =
new IndexedVector3(displacementPos.X, displacementPos.Y, displacementPos.Z);
1701 relativeTransform.SetRotation(
new IndexedQuaternion(displacementRot.X,displacementRot.Y,displacementRot.Z,displacementRot.W));
1702 compoundshape.AddChildShape(ref relativeTransform, addshape);
1708 CompoundShape compoundshape = (pCShape as BulletShapeXNA).shape as CompoundShape;
1709 CollisionShape ret = null;
1710 ret = compoundshape.GetChildShape(pii);
1711 compoundshape.RemoveChildShapeByIndex(pii);
1712 return new BulletShapeXNA(ret, BSShapeTypeFromBroadPhaseNativeType(ret.GetShapeType()));
1719 CompoundShape compoundShape = (cShape as BulletShapeXNA).shape as CompoundShape;
1720 CollisionShape shape = compoundShape.GetChildShape(indx);
1721 BulletShape retShape =
new BulletShapeXNA(shape, BSShapeTypeFromBroadPhaseNativeType(shape.GetShapeType()));
1732 case BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE:
1733 ret = BSPhysicsShapeType.SHAPE_BOX;
1735 case BroadphaseNativeTypes.TRIANGLE_SHAPE_PROXYTYPE:
1736 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1739 case BroadphaseNativeTypes.TETRAHEDRAL_SHAPE_PROXYTYPE:
1740 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1742 case BroadphaseNativeTypes.CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE:
1743 ret = BSPhysicsShapeType.SHAPE_CONVEXHULL;
1745 case BroadphaseNativeTypes.CONVEX_HULL_SHAPE_PROXYTYPE:
1746 ret = BSPhysicsShapeType.SHAPE_HULL;
1748 case BroadphaseNativeTypes.CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE:
1749 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1751 case BroadphaseNativeTypes.CUSTOM_POLYHEDRAL_SHAPE_TYPE:
1752 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1755 case BroadphaseNativeTypes.IMPLICIT_CONVEX_SHAPES_START_HERE:
1756 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1758 case BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE:
1759 ret = BSPhysicsShapeType.SHAPE_SPHERE;
1761 case BroadphaseNativeTypes.MULTI_SPHERE_SHAPE_PROXYTYPE:
1762 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1764 case BroadphaseNativeTypes.CAPSULE_SHAPE_PROXYTYPE:
1765 ret = BSPhysicsShapeType.SHAPE_CAPSULE;
1767 case BroadphaseNativeTypes.CONE_SHAPE_PROXYTYPE:
1768 ret = BSPhysicsShapeType.SHAPE_CONE;
1770 case BroadphaseNativeTypes.CONVEX_SHAPE_PROXYTYPE:
1771 ret = BSPhysicsShapeType.SHAPE_CONVEXHULL;
1773 case BroadphaseNativeTypes.CYLINDER_SHAPE_PROXYTYPE:
1774 ret = BSPhysicsShapeType.SHAPE_CYLINDER;
1776 case BroadphaseNativeTypes.UNIFORM_SCALING_SHAPE_PROXYTYPE:
1777 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1779 case BroadphaseNativeTypes.MINKOWSKI_SUM_SHAPE_PROXYTYPE:
1780 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1782 case BroadphaseNativeTypes.MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE:
1783 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1785 case BroadphaseNativeTypes.BOX_2D_SHAPE_PROXYTYPE:
1786 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1788 case BroadphaseNativeTypes.CONVEX_2D_SHAPE_PROXYTYPE:
1789 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1791 case BroadphaseNativeTypes.CUSTOM_CONVEX_SHAPE_TYPE:
1792 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1795 case BroadphaseNativeTypes.CONCAVE_SHAPES_START_HERE:
1796 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1799 case BroadphaseNativeTypes.TRIANGLE_MESH_SHAPE_PROXYTYPE:
1800 ret = BSPhysicsShapeType.SHAPE_MESH;
1802 case BroadphaseNativeTypes.SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE:
1803 ret = BSPhysicsShapeType.SHAPE_MESH;
1806 case BroadphaseNativeTypes.FAST_CONCAVE_MESH_PROXYTYPE:
1807 ret = BSPhysicsShapeType.SHAPE_MESH;
1810 case BroadphaseNativeTypes.TERRAIN_SHAPE_PROXYTYPE:
1811 ret = BSPhysicsShapeType.SHAPE_HEIGHTMAP;
1814 case BroadphaseNativeTypes.GIMPACT_SHAPE_PROXYTYPE:
1815 ret = BSPhysicsShapeType.SHAPE_GIMPACT;
1818 case BroadphaseNativeTypes.MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE:
1819 ret = BSPhysicsShapeType.SHAPE_MESH;
1822 case BroadphaseNativeTypes.EMPTY_SHAPE_PROXYTYPE:
1823 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1825 case BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE:
1826 ret = BSPhysicsShapeType.SHAPE_GROUNDPLANE;
1828 case BroadphaseNativeTypes.CUSTOM_CONCAVE_SHAPE_TYPE:
1829 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1831 case BroadphaseNativeTypes.CONCAVE_SHAPES_END_HERE:
1832 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1835 case BroadphaseNativeTypes.COMPOUND_SHAPE_PROXYTYPE:
1836 ret = BSPhysicsShapeType.SHAPE_COMPOUND;
1839 case BroadphaseNativeTypes.SOFTBODY_SHAPE_PROXYTYPE:
1840 ret = BSPhysicsShapeType.SHAPE_MESH;
1842 case BroadphaseNativeTypes.HFFLUID_SHAPE_PROXYTYPE:
1843 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1845 case BroadphaseNativeTypes.HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE:
1846 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1848 case BroadphaseNativeTypes.INVALID_SHAPE_PROXYTYPE:
1849 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1860 StaticPlaneShape m_planeshape =
new StaticPlaneShape(
new IndexedVector3(0,0,1),(
int)pheight );
1861 m_planeshape.SetMargin(pcollisionMargin);
1862 m_planeshape.SetUserPointer(pLocalId);
1867 Vector3 pframe1, Quaternion pframe1rot, Vector3 pframe2, Quaternion pframe2rot,
1868 bool puseLinearReferenceFrameA,
bool pdisableCollisionsBetweenLinkedBodies)
1871 Generic6DofSpringConstraint constrain = null;
1872 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1873 RigidBody body1 = (pBody1 as BulletBodyXNA).rigidBody;
1874 RigidBody body2 = (pBody2 as BulletBodyXNA).rigidBody;
1875 if (body1 != null && body2 != null)
1877 IndexedVector3 frame1v =
new IndexedVector3(pframe1.X, pframe1.Y, pframe1.Z);
1878 IndexedQuaternion frame1rot =
new IndexedQuaternion(pframe1rot.X, pframe1rot.Y, pframe1rot.Z, pframe1rot.W);
1879 IndexedMatrix frame1 = IndexedMatrix.CreateFromQuaternion(frame1rot);
1880 frame1._origin = frame1v;
1882 IndexedVector3 frame2v =
new IndexedVector3(pframe2.X, pframe2.Y, pframe2.Z);
1883 IndexedQuaternion frame2rot =
new IndexedQuaternion(pframe2rot.X, pframe2rot.Y, pframe2rot.Z, pframe2rot.W);
1884 IndexedMatrix frame2 = IndexedMatrix.CreateFromQuaternion(frame2rot);
1885 frame2._origin = frame1v;
1887 constrain =
new Generic6DofSpringConstraint(body1, body2, ref frame1, ref frame2, puseLinearReferenceFrameA);
1888 world.AddConstraint(constrain, pdisableCollisionsBetweenLinkedBodies);
1890 constrain.CalculateTransforms();
1893 return new BulletConstraintXNA(constrain);
1897 Vector3 ppivotInA, Vector3 ppivotInB, Vector3 paxisInA, Vector3 paxisInB,
1898 bool puseLinearReferenceFrameA,
bool pdisableCollisionsBetweenLinkedBodies)
1900 HingeConstraint constrain = null;
1901 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1902 RigidBody rb1 = (pBody1 as BulletBodyXNA).rigidBody;
1903 RigidBody rb2 = (pBody2 as BulletBodyXNA).rigidBody;
1904 if (rb1 != null && rb2 != null)
1906 IndexedVector3 pivotInA =
new IndexedVector3(ppivotInA.X, ppivotInA.Y, ppivotInA.Z);
1907 IndexedVector3 pivotInB =
new IndexedVector3(ppivotInB.X, ppivotInB.Y, ppivotInB.Z);
1908 IndexedVector3 axisInA =
new IndexedVector3(paxisInA.X, paxisInA.Y, paxisInA.Z);
1909 IndexedVector3 axisInB =
new IndexedVector3(paxisInB.X, paxisInB.Y, paxisInB.Z);
1910 constrain =
new HingeConstraint(rb1, rb2, ref pivotInA, ref pivotInB, ref axisInA, ref axisInB, puseLinearReferenceFrameA);
1911 world.AddConstraint(constrain, pdisableCollisionsBetweenLinkedBodies);
1913 return new BulletConstraintXNA(constrain);
1917 Vector3 pframe1, Quaternion pframe1rot,
1918 Vector3 pframe2, Quaternion pframe2rot,
1919 bool puseLinearReferenceFrameA,
bool pdisableCollisionsBetweenLinkedBodies)
1921 SliderConstraint constrain = null;
1922 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1923 RigidBody rb1 = (pBody1 as BulletBodyXNA).rigidBody;
1924 RigidBody rb2 = (pBody2 as BulletBodyXNA).rigidBody;
1925 if (rb1 != null && rb2 != null)
1927 IndexedVector3 frame1v =
new IndexedVector3(pframe1.X, pframe1.Y, pframe1.Z);
1928 IndexedQuaternion frame1rot =
new IndexedQuaternion(pframe1rot.X, pframe1rot.Y, pframe1rot.Z, pframe1rot.W);
1929 IndexedMatrix frame1 = IndexedMatrix.CreateFromQuaternion(frame1rot);
1930 frame1._origin = frame1v;
1932 IndexedVector3 frame2v =
new IndexedVector3(pframe2.X, pframe2.Y, pframe2.Z);
1933 IndexedQuaternion frame2rot =
new IndexedQuaternion(pframe2rot.X, pframe2rot.Y, pframe2rot.Z, pframe2rot.W);
1934 IndexedMatrix frame2 = IndexedMatrix.CreateFromQuaternion(frame2rot);
1935 frame2._origin = frame1v;
1937 constrain =
new SliderConstraint(rb1, rb2, ref frame1, ref frame2, puseLinearReferenceFrameA);
1938 world.AddConstraint(constrain, pdisableCollisionsBetweenLinkedBodies);
1940 return new BulletConstraintXNA(constrain);
1944 Vector3 pframe1, Quaternion pframe1rot,
1945 Vector3 pframe2, Quaternion pframe2rot,
1946 bool pdisableCollisionsBetweenLinkedBodies)
1948 ConeTwistConstraint constrain = null;
1949 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1950 RigidBody rb1 = (pBody1 as BulletBodyXNA).rigidBody;
1951 RigidBody rb2 = (pBody2 as BulletBodyXNA).rigidBody;
1952 if (rb1 != null && rb2 != null)
1954 IndexedVector3 frame1v =
new IndexedVector3(pframe1.X, pframe1.Y, pframe1.Z);
1955 IndexedQuaternion frame1rot =
new IndexedQuaternion(pframe1rot.X, pframe1rot.Y, pframe1rot.Z, pframe1rot.W);
1956 IndexedMatrix frame1 = IndexedMatrix.CreateFromQuaternion(frame1rot);
1957 frame1._origin = frame1v;
1959 IndexedVector3 frame2v =
new IndexedVector3(pframe2.X, pframe2.Y, pframe2.Z);
1960 IndexedQuaternion frame2rot =
new IndexedQuaternion(pframe2rot.X, pframe2rot.Y, pframe2rot.Z, pframe2rot.W);
1961 IndexedMatrix frame2 = IndexedMatrix.CreateFromQuaternion(frame2rot);
1962 frame2._origin = frame1v;
1964 constrain =
new ConeTwistConstraint(rb1, rb2, ref frame1, ref frame2);
1965 world.AddConstraint(constrain, pdisableCollisionsBetweenLinkedBodies);
1967 return new BulletConstraintXNA(constrain);
1971 Vector3 paxisInA, Vector3 paxisInB,
1972 float pratio,
bool pdisableCollisionsBetweenLinkedBodies)
1974 Generic6DofConstraint constrain = null;
1988 return new BulletConstraintXNA(constrain);
1992 Vector3 ppivotInA, Vector3 ppivotInB,
1993 bool pdisableCollisionsBetweenLinkedBodies)
1995 Point2PointConstraint constrain = null;
1996 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1997 RigidBody rb1 = (pBody1 as BulletBodyXNA).rigidBody;
1998 RigidBody rb2 = (pBody2 as BulletBodyXNA).rigidBody;
1999 if (rb1 != null && rb2 != null)
2001 IndexedVector3 pivotInA =
new IndexedVector3(ppivotInA.X, ppivotInA.Y, ppivotInA.Z);
2002 IndexedVector3 pivotInB =
new IndexedVector3(ppivotInB.X, ppivotInB.Y, ppivotInB.Z);
2003 constrain =
new Point2PointConstraint(rb1, rb2, ref pivotInA, ref pivotInB);
2004 world.AddConstraint(constrain, pdisableCollisionsBetweenLinkedBodies);
2006 return new BulletConstraintXNA(constrain);
2011 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
2012 CompoundShape compoundshape =
new CompoundShape(
false);
2014 compoundshape.SetMargin(world.WorldSettings.Params.collisionMargin);
2017 for (
int i = 0; i < pHullCount; i++)
2019 int vertexCount = (int) pConvHulls[ii];
2021 IndexedVector3 centroid =
new IndexedVector3(pConvHulls[ii + 1], pConvHulls[ii + 2], pConvHulls[ii + 3]);
2022 IndexedMatrix childTrans = IndexedMatrix.Identity;
2023 childTrans._origin = centroid;
2025 List<IndexedVector3> virts =
new List<IndexedVector3>();
2026 int ender = ((ii + 4) + (vertexCount*3));
2027 for (
int iii = ii + 4; iii < ender; iii+=3)
2030 virts.Add(
new IndexedVector3(pConvHulls[iii], pConvHulls[iii + 1], pConvHulls[iii +2]));
2032 ConvexHullShape convexShape =
new ConvexHullShape(virts, vertexCount);
2033 convexShape.SetMargin(world.WorldSettings.Params.collisionMargin);
2034 compoundshape.AddChildShape(ref childTrans, convexShape);
2035 ii += (vertexCount*3 + 4);
2060 for (
int iter = 0; iter < pVerticesCount; iter++)
2062 if (verticesAsFloats[iter] > 0 && verticesAsFloats[iter] < 0.0001) verticesAsFloats[iter] = 0;
2063 if (verticesAsFloats[iter] < 0 && verticesAsFloats[iter] > -0.0001) verticesAsFloats[iter] = 0;
2066 ObjectArray<int> indicesarr =
new ObjectArray<int>(indices);
2067 ObjectArray<float> vertices =
new ObjectArray<float>(verticesAsFloats);
2068 DumpRaw(indicesarr,vertices,pIndicesCount,pVerticesCount);
2069 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
2070 IndexedMesh mesh =
new IndexedMesh();
2071 mesh.m_indexType = PHY_ScalarType.PHY_INTEGER;
2072 mesh.m_numTriangles = pIndicesCount/3;
2073 mesh.m_numVertices = pVerticesCount;
2074 mesh.m_triangleIndexBase = indicesarr;
2075 mesh.m_vertexBase = vertices;
2076 mesh.m_vertexStride = 3;
2077 mesh.m_vertexType = PHY_ScalarType.PHY_FLOAT;
2078 mesh.m_triangleIndexStride = 3;
2080 TriangleIndexVertexArray tribuilder =
new TriangleIndexVertexArray();
2081 tribuilder.AddIndexedMesh(mesh, PHY_ScalarType.PHY_INTEGER);
2082 BvhTriangleMeshShape meshShape =
new BvhTriangleMeshShape(tribuilder,
true,
true);
2083 meshShape.SetMargin(world.WorldSettings.Params.collisionMargin);
2093 public static void DumpRaw(ObjectArray<int>indices, ObjectArray<float> vertices,
int pIndicesCount,
int pVerticesCount )
2096 String fileName =
"objTest3.raw";
2097 String completePath = System.IO.Path.Combine(Util.configDir(), fileName);
2098 StreamWriter sw =
new StreamWriter(completePath);
2099 IndexedMesh mesh =
new IndexedMesh();
2101 mesh.m_indexType = PHY_ScalarType.PHY_INTEGER;
2102 mesh.m_numTriangles = pIndicesCount / 3;
2103 mesh.m_numVertices = pVerticesCount;
2104 mesh.m_triangleIndexBase = indices;
2105 mesh.m_vertexBase = vertices;
2106 mesh.m_vertexStride = 3;
2107 mesh.m_vertexType = PHY_ScalarType.PHY_FLOAT;
2108 mesh.m_triangleIndexStride = 3;
2110 TriangleIndexVertexArray tribuilder =
new TriangleIndexVertexArray();
2111 tribuilder.AddIndexedMesh(mesh, PHY_ScalarType.PHY_INTEGER);
2115 for (
int i = 0; i < pVerticesCount; i++)
2118 string s = vertices[indices[i * 3]].ToString(
"0.0000");
2119 s +=
" " + vertices[indices[i * 3 + 1]].ToString(
"0.0000");
2120 s +=
" " + vertices[indices[i * 3 + 2]].ToString(
"0.0000");
2127 public static void DumpRaw(
int[] indices,
float[] vertices,
int pIndicesCount,
int pVerticesCount)
2130 String fileName =
"objTest6.raw";
2131 String completePath = System.IO.Path.Combine(Util.configDir(), fileName);
2132 StreamWriter sw =
new StreamWriter(completePath);
2133 IndexedMesh mesh =
new IndexedMesh();
2135 mesh.m_indexType = PHY_ScalarType.PHY_INTEGER;
2136 mesh.m_numTriangles = pIndicesCount / 3;
2137 mesh.m_numVertices = pVerticesCount;
2138 mesh.m_triangleIndexBase = indices;
2139 mesh.m_vertexBase = vertices;
2140 mesh.m_vertexStride = 3;
2141 mesh.m_vertexType = PHY_ScalarType.PHY_FLOAT;
2142 mesh.m_triangleIndexStride = 3;
2144 TriangleIndexVertexArray tribuilder =
new TriangleIndexVertexArray();
2145 tribuilder.AddIndexedMesh(mesh, PHY_ScalarType.PHY_INTEGER);
2148 sw.WriteLine(
"Indices");
2149 sw.WriteLine(string.Format(
"int[] indices = new int[{0}];",pIndicesCount));
2150 for (
int iter = 0; iter < indices.Length; iter++)
2152 sw.WriteLine(string.Format(
"indices[{0}]={1};",iter,indices[iter]));
2154 sw.WriteLine(
"VerticesFloats");
2155 sw.WriteLine(string.Format(
"float[] vertices = new float[{0}];", pVerticesCount));
2156 for (
int iter = 0; iter < vertices.Length; iter++)
2158 sw.WriteLine(string.Format(
"Vertices[{0}]={1};", iter, vertices[iter].ToString(
"0.0000")));
2175 float scaleFactor,
float collisionMargin)
2177 const int upAxis = 2;
2178 HeightfieldTerrainShape terrainShape =
new HeightfieldTerrainShape((
int)size.X, (
int)size.Y,
2179 heightMap, scaleFactor,
2180 minHeight, maxHeight, upAxis,
2182 terrainShape.SetMargin(collisionMargin);
2183 terrainShape.SetUseDiamondSubdivision(
true);
2184 terrainShape.SetUserPointer(id);
2190 TypedConstraint tconstrain = (pConstraint as BulletConstraintXNA).constrain;
2191 bool onOff = ponOff != 0;
2194 switch (tconstrain.GetConstraintType())
2196 case TypedConstraintType.D6_CONSTRAINT_TYPE:
2197 Generic6DofConstraint constrain = tconstrain as Generic6DofConstraint;
2198 constrain.GetTranslationalLimitMotor().m_enableMotor[0] = onOff;
2199 constrain.GetTranslationalLimitMotor().m_targetVelocity[0] = targetVelocity;
2200 constrain.GetTranslationalLimitMotor().m_maxMotorForce[0] = maxMotorForce;
2211 out
int updatedEntityCount, out
int collidersCount)
2214 updatedEntityCount = 0;
2218 int ret = PhysicsStep2(world,timeStep,maxSubSteps,fixedTimeStep,out updatedEntityCount,out world.
physicsScene.m_updateArray, out collidersCount, out world.
physicsScene.m_collisionArray);
2223 private int PhysicsStep2(
BulletWorld pWorld,
float timeStep,
int m_maxSubSteps,
float m_fixedTimeStep,
2227 int epic = PhysicsStepint(pWorld, timeStep, m_maxSubSteps, m_fixedTimeStep, out updatedEntityCount, out updatedEntities,
2228 out collidersCount, out colliders, m_maxCollisions, m_maxUpdatesPerFrame);
2232 private int PhysicsStepint(BulletWorld pWorld,
float timeStep,
int m_maxSubSteps,
float m_fixedTimeStep, out
int updatedEntityCount,
2233 out EntityProperties[] updatedEntities, out
int collidersCount, out CollisionDesc[] colliders,
int maxCollisions,
int maxUpdates)
2235 int numSimSteps = 0;
2236 Array.Clear(UpdatedObjects, 0, UpdatedObjects.Length);
2237 Array.Clear(UpdatedCollisions, 0, UpdatedCollisions.Length);
2238 LastEntityProperty=0;
2245 LastCollisionDesc=0;
2247 updatedEntityCount = 0;
2251 if (pWorld is BulletWorldXNA)
2253 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
2255 world.LastCollisionDesc = 0;
2256 world.LastEntityProperty = 0;
2257 numSimSteps = world.StepSimulation(timeStep, m_maxSubSteps, m_fixedTimeStep);
2259 PersistentManifold contactManifold;
2260 CollisionObject objA;
2261 CollisionObject objB;
2262 ManifoldPoint manifoldPoint;
2263 PairCachingGhostObject pairCachingGhostObject;
2265 m_collisionsThisFrame = 0;
2266 int numManifolds = world.GetDispatcher().GetNumManifolds();
2267 for (
int j = 0; j < numManifolds; j++)
2269 contactManifold = world.GetDispatcher().GetManifoldByIndexInternal(j);
2270 int numContacts = contactManifold.GetNumContacts();
2271 if (numContacts == 0)
2274 objA = contactManifold.GetBody0() as CollisionObject;
2275 objB = contactManifold.GetBody1() as CollisionObject;
2277 manifoldPoint = contactManifold.GetContactPoint(0);
2281 RecordCollision(
this, objA, objB, manifoldPoint.GetPositionWorldOnB(), -manifoldPoint.m_normalWorldOnB, manifoldPoint.GetDistance());
2282 m_collisionsThisFrame ++;
2283 if (m_collisionsThisFrame >= 9999999)
2289 foreach (GhostObject ghostObject
in specialCollisionObjects.Values)
2291 pairCachingGhostObject = ghostObject as PairCachingGhostObject;
2292 if (pairCachingGhostObject != null)
2294 RecordGhostCollisions(pairCachingGhostObject);
2300 updatedEntityCount = LastEntityProperty;
2301 updatedEntities = UpdatedObjects;
2303 collidersCount = LastCollisionDesc;
2304 colliders = UpdatedCollisions;
2317 updatedEntities =
new EntityProperties[0];
2320 colliders =
new CollisionDesc[0];
2327 IOverlappingPairCache cache = obj.GetOverlappingPairCache();
2328 ObjectArray<BroadphasePair> pairs = cache.GetOverlappingPairArray();
2330 DiscreteDynamicsWorld world = (PhysicsScene.World as BulletWorldXNA).world;
2331 PersistentManifoldArray manifoldArray =
new PersistentManifoldArray();
2332 BroadphasePair collisionPair;
2333 PersistentManifold contactManifold;
2335 CollisionObject objA;
2336 CollisionObject objB;
2340 int numPairs = pairs.Count;
2342 for (
int i = 0; i < numPairs; i++)
2344 manifoldArray.Clear();
2345 if (LastCollisionDesc < UpdatedCollisions.Length)
2347 collisionPair = world.GetPairCache().FindPair(pairs[i].m_pProxy0, pairs[i].m_pProxy1);
2348 if (collisionPair == null)
2351 collisionPair.m_algorithm.GetAllContactManifolds(manifoldArray);
2352 for (
int j = 0; j < manifoldArray.Count; j++)
2354 contactManifold = manifoldArray[j];
2355 int numContacts = contactManifold.GetNumContacts();
2356 objA = contactManifold.GetBody0() as CollisionObject;
2357 objB = contactManifold.GetBody1() as CollisionObject;
2358 for (
int p = 0; p < numContacts; p++)
2360 pt = contactManifold.GetContactPoint(p);
2361 if (pt.GetDistance() < 0.0f)
2363 RecordCollision(
this, objA, objB, pt.GetPositionWorldOnA(), -pt.m_normalWorldOnB,pt.GetDistance());
2371 private static void RecordCollision(
BSAPIXNA world, CollisionObject objA, CollisionObject objB, IndexedVector3 contact, IndexedVector3 norm,
float penetration)
2374 IndexedVector3 contactNormal = norm;
2375 if ((objA.GetCollisionFlags() & BulletXNA.BulletCollision.CollisionFlags.BS_WANTS_COLLISIONS) == 0 &&
2376 (objB.GetCollisionFlags() & BulletXNA.BulletCollision.CollisionFlags.BS_WANTS_COLLISIONS) == 0)
2380 uint idA = (uint)objA.GetUserPointer();
2381 uint idB = (uint)objB.GetUserPointer();
2387 contactNormal = -contactNormal;
2392 CollisionDesc cDesc =
new CollisionDesc()
2396 point =
new Vector3(contact.X,contact.Y,contact.Z),
2397 normal =
new Vector3(contactNormal.X,contactNormal.Y,contactNormal.Z),
2398 penetration = penetration
2401 if (world.LastCollisionDesc < world.UpdatedCollisions.Length)
2402 world.UpdatedCollisions[world.LastCollisionDesc++] = (cDesc);
2403 m_collisionsThisFrame++;
2407 private static EntityProperties GetDebugProperties(BulletWorld pWorld, BulletBody pCollisionObject)
2409 EntityProperties ent =
new EntityProperties();
2410 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
2411 CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
2412 IndexedMatrix transform = collisionObject.GetWorldTransform();
2413 IndexedVector3 LinearVelocity = collisionObject.GetInterpolationLinearVelocity();
2414 IndexedVector3
AngularVelocity = collisionObject.GetInterpolationAngularVelocity();
2415 IndexedQuaternion
rotation = transform.GetRotation();
2416 ent.Acceleration = Vector3.Zero;
2417 ent.ID = (uint)collisionObject.GetUserPointer();
2418 ent.Position =
new Vector3(transform._origin.X,transform._origin.Y,transform._origin.Z);
2419 ent.Rotation =
new Quaternion(rotation.X,rotation.Y,rotation.Z,rotation.W);
2420 ent.Velocity =
new Vector3(LinearVelocity.X, LinearVelocity.Y, LinearVelocity.Z);
2421 ent.RotationalVelocity =
new Vector3(AngularVelocity.X, AngularVelocity.Y, AngularVelocity.Z);
2430 CollisionShape shape = (pShape as BulletShapeXNA).shape;
2431 IndexedVector3 scale = shape.GetLocalScaling();
2432 return new Vector3(scale.X,scale.Y,scale.Z);
2437 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
2442 CollisionObject AvoidBody = (NotMe as BulletBodyXNA).body;
2444 IndexedVector3 rOrigin =
new IndexedVector3(_RayOrigin.X, _RayOrigin.Y, _RayOrigin.Z);
2445 IndexedVector3 rEnd =
new IndexedVector3(_RayOrigin.X, _RayOrigin.Y, _RayOrigin.Z - pRayHeight);
2447 ClosestNotMeRayResultCallback rayCallback =
2448 new ClosestNotMeRayResultCallback(rOrigin, rEnd, AvoidBody)
2451 world.RayTest(ref rOrigin, ref rEnd, rayCallback);
2452 if (rayCallback.HasHit())
2454 IndexedVector3 hitLocation = rayCallback.m_hitPointWorld;
2456 return rayCallback.HasHit();
2472 private IndexedMatrix m_xform;
2478 const float POSITION_TOLERANCE = 0.05f;
2479 const float VELOCITY_TOLERANCE = 0.001f;
2480 const float ROTATION_TOLERANCE = 0.01f;
2481 const float ANGULARVELOCITY_TOLERANCE = 0.01f;
2485 IndexedQuaternion OrientationQuaterion = starTransform.GetRotation();
2489 Position =
new Vector3(starTransform._origin.X, starTransform._origin.Y,starTransform._origin.Z),
2490 Rotation =
new Quaternion(OrientationQuaterion.X,OrientationQuaterion.Y,OrientationQuaterion.Z,OrientationQuaterion.W)
2495 Position =
new Vector3(starTransform._origin.X, starTransform._origin.Y, starTransform._origin.Z),
2496 Rotation =
new Quaternion(OrientationQuaterion.X, OrientationQuaterion.Y, OrientationQuaterion.Z, OrientationQuaterion.W)
2499 m_xform = starTransform;
2504 worldTrans = m_xform;
2509 SetWorldTransform(ref worldTrans);
2514 SetWorldTransform(ref worldTrans,
false);
2518 m_xform = worldTrans;
2520 IndexedQuaternion OrientationQuaternion = m_xform.GetRotation();
2521 IndexedVector3 LinearVelocityVector = Rigidbody.GetLinearVelocity();
2522 IndexedVector3 AngularVelocityVector = Rigidbody.GetAngularVelocity();
2523 m_properties.Position =
new Vector3(m_xform._origin.X, m_xform._origin.Y, m_xform._origin.Z);
2524 m_properties.Rotation =
new Quaternion(OrientationQuaternion.X, OrientationQuaternion.Y,
2525 OrientationQuaternion.Z, OrientationQuaternion.W);
2531 m_properties.Velocity =
new Vector3(LinearVelocityVector.X, LinearVelocityVector.Y, LinearVelocityVector.Z);
2532 m_properties.RotationalVelocity =
new Vector3(AngularVelocityVector.X, AngularVelocityVector.Y, AngularVelocityVector.Z);
2536 || !AlmostEqual(ref m_lastProperties.Position, ref m_properties.Position, POSITION_TOLERANCE)
2537 || !AlmostEqual(ref m_properties.Rotation, ref m_lastProperties.Rotation, ROTATION_TOLERANCE)
2541 || ((m_properties.Velocity == ZeroVect && m_properties.RotationalVelocity == ZeroVect)
2543 (m_properties.Velocity != m_lastProperties.Velocity ||
2544 m_properties.RotationalVelocity != m_lastProperties.RotationalVelocity))
2546 || !AlmostEqual(ref m_properties.Velocity, ref m_lastProperties.Velocity, VELOCITY_TOLERANCE)
2548 !AlmostEqual(ref m_properties.RotationalVelocity, ref m_lastProperties.RotationalVelocity,
2549 ANGULARVELOCITY_TOLERANCE)
2555 m_lastProperties = m_properties;
2556 if (m_world.LastEntityProperty < m_world.UpdatedObjects.Length)
2557 m_world.UpdatedObjects[m_world.LastEntityProperty++]=(m_properties);
2570 internal static bool AlmostEqual(ref Vector3 v1, ref Vector3 v2,
float nEpsilon)
2573 (((v1.X - nEpsilon) < v2.X) && (v2.X < (v1.X + nEpsilon))) &&
2574 (((v1.Y - nEpsilon) < v2.Y) && (v2.Y < (v1.Y + nEpsilon))) &&
2575 (((v1.Z - nEpsilon) < v2.Z) && (v2.Z < (v1.Z + nEpsilon)));
2578 internal static bool AlmostEqual(ref Quaternion v1, ref Quaternion v2,
float nEpsilon)
2581 (((v1.X - nEpsilon) < v2.X) && (v2.X < (v1.X + nEpsilon))) &&
2582 (((v1.Y - nEpsilon) < v2.Y) && (v2.Y < (v1.Y + nEpsilon))) &&
2583 (((v1.Z - nEpsilon) < v2.Z) && (v2.Z < (v1.Z + nEpsilon))) &&
2584 (((v1.W - nEpsilon) < v2.W) && (v2.W < (v1.W + nEpsilon)));
override bool UpdateParameter(BulletWorld world, uint localID, String parm, float value)
override BulletConstraint CreatePoint2PointConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2, Vector3 ppivotInA, Vector3 ppivotInB, bool pdisableCollisionsBetweenLinkedBodies)
override Vector3 GetLinearVelocity(BulletBody pBody)
override void SetForceUpdateAllAabbs(BulletWorld pWorld, bool pForce)
override float GetLinearDamping(BulletBody pBody)
void RecordGhostCollisions(PairCachingGhostObject obj)
override bool IsStaticObject(BulletBody pCollisionObject)
override bool RemoveConstraintFromWorld(BulletWorld pWorld, BulletConstraint pConstraint)
override void RemoveConstraintRef(BulletBody pBody, BulletConstraint pConstraint)
override bool HasContactResponse(BulletBody pCollisionObject)
override void SetAngularVelocity(BulletBody pBody, Vector3 pVector3)
override bool UseFrameOffset(BulletConstraint pConstraint, float onOff)
override Vector3 GetGravity(BulletBody pBody)
override BulletShape GetCollisionShape(BulletBody pCollisionObject)
override void ApplyTorque(BulletBody pBody, Vector3 pfSum)
override BulletShape CreateGImpactShape(BulletWorld pWorld, int pIndicesCount, int[] indices, int pVerticesCount, float[] verticesAsFloats)
override void SetLocalScaling(BulletShape pShape, Vector3 pScale)
override float GetContactBreakingThreshold(BulletShape pShape, float defaultFactor)
override BulletShape BuildConvexHullShapeFromMesh(BulletWorld world, BulletShape meshShape)
override void UpdateInertiaTensor(BulletBody pBody)
override bool SliderMotor(BulletConstraint pConstraint, int forceVel, int linAng, float val)
override void SetCollisionShape(BulletWorld pWorld, BulletBody pCollisionObject, BulletShape pShape)
override void SetLinearDamping(BulletBody pBody, float lin_damping)
override bool DestroyConstraint(BulletWorld pWorld, BulletConstraint pConstraint)
override void SetCcdMotionThreshold(BulletBody pCollisionObject, float pccdMotionThreashold)
override int GetNumConstraintRefs(BulletBody pBody)
override float GetDeactivationTime(BulletBody pBody)
override CollisionObjectTypes GetBodyType(BulletBody pCollisionObject)
override bool IsConcave(BulletShape pShape)
override BulletConstraint Create6DofSpringConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2, Vector3 pframe1, Quaternion pframe1rot, Vector3 pframe2, Quaternion pframe2rot, bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies)
override Vector3 CalculateLocalInertia(BulletShape pShape, float pphysMass)
override BulletShape BuildCapsuleShape(BulletWorld pWorld, float pRadius, float pHeight, Vector3 pScale)
override bool IsNonMoving(BulletShape pShape)
override bool AddObjectToWorld(BulletWorld pWorld, BulletBody pBody)
override float GetAngularMotionDisc(BulletShape pShape)
override void GetWorldTransform(out IndexedMatrix worldTrans)
override void UpdateChildTransform(BulletShape pShape, int childIndex, Vector3 pos, Quaternion rot, bool shouldRecalculateLocalAabb)
SimMotionState(BSAPIXNA pWorld, uint id, IndexedMatrix starTransform, object frameUpdates)
static void DumpRaw(int[] indices, float[] vertices, int pIndicesCount, int pVerticesCount)
void SetWorldTransform(ref IndexedMatrix worldTrans, bool force)
override CollisionFlags GetCollisionFlags(BulletBody pCollisionObject)
override void ClearForces(BulletBody pBody)
override Vector3 GetVelocityInLocalPoint(BulletBody pBody, Vector3 pos)
override BulletShape CreateHullShape(BulletWorld pWorld, int pHullCount, float[] pConvHulls)
override void ApplyCentralForce(BulletBody pBody, Vector3 pfSum)
override bool SpringEnable(BulletConstraint pConstraint, int index, float numericTrueFalse)
override void ClearAllForces(BulletBody pCollisionObject)
override BulletBody CreateBodyFromShape(BulletWorld pWorld, BulletShape pShape, uint pLocalID, Vector3 pRawPosition, Quaternion pRawOrientation)
override bool SetCollisionGroupMask(BulletBody pCollisionObject, uint pGroup, uint pMask)
override float GetContactProcessingThreshold(BulletBody pBody)
override void SetContactProcessingThreshold(BulletBody pCollisionObject, float contactprocessingthreshold)
override void SetActivationState(BulletBody pBody, int state)
override float GetHitFraction(BulletBody pBody)
override int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, out int updatedEntityCount, out int collidersCount)
override BulletBody CreateBodyWithDefaultMotionState(BulletShape pShape, uint pLocalID, Vector3 pRawPosition, Quaternion pRawOrientation)
override void SetShapeCollisionMargin(BulletShape pShape, float pMargin)
override void UpdateDeactivation(BulletBody pBody, float timeStep)
override bool SpringSetStiffness(BulletConstraint pConstraint, int index, float stiffness)
override BulletConstraint Create6DofConstraintFixed(BulletWorld pWorld, BulletBody pBody1, Vector3 pframe1, Quaternion pframe1rot, bool pUseLinearReferenceFrameB, bool pdisableCollisionsBetweenLinkedBodies)
override BulletShape CreateGroundPlaneShape(uint pLocalId, float pheight, float pcollisionMargin)
bool RayCastGround(BulletWorld pWorld, Vector3 _RayOrigin, float pRayHeight, BulletBody NotMe)
override void SetDeactivationTime(BulletBody pCollisionObject, float pDeactivationTime)
override BulletConstraint CreateSliderConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2, Vector3 pframe1, Quaternion pframe1rot, Vector3 pframe2, Quaternion pframe2rot, bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies)
override void SetConstraintNumSolverIterations(BulletConstraint pConstraint, float cnt)
override void SetHitFraction(BulletBody pCollisionObject, float pHitFraction)
override float GetCcdSweptSphereRadius(BulletBody pCollisionObject)
override bool IsInfinite(BulletShape pShape)
override void SetLinearFactor(BulletBody pBody, Vector3 factor)
override bool CalculateTransforms(BulletConstraint pConstraint)
override bool IsNativeShape(BulletShape pShape)
override bool IsPolyhedral(BulletShape pShape)
override void SetFriction(BulletBody pCollisionObject, float _currentFriction)
override CollisionFlags AddToCollisionFlags(BulletBody pCollisionObject, CollisionFlags pcollisionFlags)
override bool SetLinearLimits(BulletConstraint pConstraint, Vector3 low, Vector3 high)
override void DestroyObject(BulletWorld pWorld, BulletBody pBody)
override void Activate(BulletBody pCollisionObject, bool pforceactivation)
override BulletConstraint GetConstraintRef(BulletBody pBody, int index)
static void DumpRaw(ObjectArray< int >indices, ObjectArray< float > vertices, int pIndicesCount, int pVerticesCount)
override void SetDamping(BulletBody pBody, float pLinear, float pAngular)
override BulletShape BuildHullShapeFromMesh(BulletWorld world, BulletShape meshShape, HACDParams parms)
override bool SetBreakingImpulseThreshold(BulletConstraint pConstraint, float threshold)
override bool IsKinematicObject(BulletBody pCollisionObject)
override void SetSleepingThresholds(BulletBody pBody, float plinearSleepingThreshold, float pangularSleepingThreshold)
override void Shutdown(BulletWorld pWorld)
override BulletWorld Initialize(Vector3 maxPosition, ConfigurationParameters parms, int maxCollisions, ref CollisionDesc[] collisionArray, int maxUpdates, ref EntityProperties[] updateArray)
override void SetMassProps(BulletBody pBody, float pphysMass, Vector3 plocalInertia)
override int GetNumberOfCompoundChildren(BulletShape pCompoundShape)
override bool SetAngularLimits(BulletConstraint pConstraint, Vector3 low, Vector3 high)
override BulletConstraint CreateGearConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2, Vector3 paxisInA, Vector3 paxisInB, float pratio, bool pdisableCollisionsBetweenLinkedBodies)
override void SetUserPointer(BulletBody pCollisionObject, IntPtr val)
override bool SpringSetDamping(BulletConstraint pConstraint, int index, float damping)
override bool HingeSetLimits(BulletConstraint pConstraint, float low, float high, float softness, float bias, float relaxation)
override Vector3 SetAnisotripicFriction(BulletConstraint pconstrain, Vector3 frict)
override bool WantsSleeping(BulletBody pBody)
override Vector3 GetLocalScaling(BulletShape pShape)
override BulletShape BuildNativeShape(BulletWorld pWorld, ShapeData pShapeData)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion rotation
override BulletConstraint Create6DofConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2, Vector3 pframe1, Quaternion pframe1rot, Vector3 pframe2, Quaternion pframe2rot, bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies)
override bool IsStaticOrKinematicObject(BulletBody pCollisionObject)
override void AddConstraintRef(BulletBody pBody, BulletConstraint pConstraint)
override Vector3 GetInvInertiaDiagLocal(BulletBody pBody)
override void SetAngularDamping(BulletBody pBody, float angularDamping)
override BulletConstraint Create6DofConstraintToPoint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2, Vector3 pjoinPoint, bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies)
override void AddChildShapeToCompoundShape(BulletShape pCShape, BulletShape paddShape, Vector3 displacementPos, Quaternion displacementRot)
override BulletShape GetChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx)
override Vector3 GetAngularVelocity(BulletBody pBody)
override void ForceActivationState(BulletBody pCollisionObject, ActivationState pActivationState)
override float GetLinearSleepingThreshold(BulletBody pBody)
virtual bool HasPhysicalBody
override bool SliderSet(BulletConstraint pConstraint, int softRestDamp, int dirLimOrtho, int linAng, float val)
override Vector3 GetAnisotripicFriction(BulletConstraint pconstrain)
override void SetMargin(BulletShape pShape, float pMargin)
override void SetObjectForce(BulletBody pBody, Vector3 _force)
override BulletConstraint CreateHingeConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2, Vector3 ppivotInA, Vector3 ppivotInB, Vector3 paxisInA, Vector3 paxisInB, bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies)
override CollisionFlags SetCollisionFlags(BulletBody pCollisionObject, CollisionFlags collisionFlags)
override Quaternion GetOrientation(BulletBody pCollisionObject)
override bool PushUpdate(BulletBody pCollisionObject)
override BulletShape RemoveChildShapeFromCompoundShapeIndex(BulletShape pCShape, int pii)
override bool SliderSetLimits(BulletConstraint pConstraint, int lowerUpper, int linAng, float val)
override bool IsInWorld(BulletWorld pWorld, BulletBody pCollisionObject)
override void ApplyDamping(BulletBody pBody, float timeStep)
override void SetConstraintEnable(BulletConstraint pConstraint, float p_2)
override BulletBody CreateGhostFromShape(BulletWorld pWorld, BulletShape pShape, uint pLocalID, Vector3 pRawPosition, Quaternion pRawOrientation)
override void SetGravity(BulletBody pBody, Vector3 pGravity)
override bool SetFrames(BulletConstraint pConstraint, Vector3 pframe1, Quaternion pframe1rot, Vector3 pframe2, Quaternion pframe2rot)
override void SetRestitution(BulletBody pCollisionObject, float pRestitution)
override void UpdateSingleAabb(BulletWorld pWorld, BulletBody pCollisionObject)
override void SetWorldTransform(ref IndexedMatrix worldTrans)
override bool SliderMotorEnable(BulletConstraint pConstraint, int linAng, float numericTrueFalse)
override BulletShape CreateTerrainShape(uint id, Vector3 size, float minHeight, float maxHeight, float[] heightMap, float scaleFactor, float collisionMargin)
override void ApplyForce(BulletBody pBody, Vector3 force, Vector3 pos)
override bool IsConvex(BulletShape pShape)
override Vector3 GetTotalTorque(BulletBody pBody)
override float GetAngularDamping(BulletBody pBody)
override BulletConstraint CreateConeTwistConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2, Vector3 pframe1, Quaternion pframe1rot, Vector3 pframe2, Quaternion pframe2rot, bool pdisableCollisionsBetweenLinkedBodies)
override BulletShape CreateCompoundShape(BulletWorld pWorld, bool enableDynamicAabbTree)
override bool IsCompound(BulletShape pShape)
override int GetActivationState(BulletBody pBody)
override bool TranslationalLimitMotor(BulletConstraint pConstraint, float ponOff, float targetVelocity, float maxMotorForce)
override bool DeleteCollisionShape(BulletWorld pWorld, BulletShape pShape)
override float GetFriction(BulletBody pBody)
override Vector3 GetAngularFactor(BulletBody pBody)
override bool AddConstraintToWorld(BulletWorld pWorld, BulletConstraint pConstraint, bool pDisableCollisionsBetweenLinkedObjects)
override BulletShape CreateMeshShape(BulletWorld pWorld, int pIndicesCount, int[] indices, int pVerticesCount, float[] verticesAsFloats)
override void SetAngularFactorV(BulletBody pBody, Vector3 pAngularFactor)
override bool IsSoftBody(BulletShape pShape)
override bool SpringSetEquilibriumPoint(BulletConstraint pConstraint, int index, float equilibriumPoint)
BSAPIXNA(string paramName, BSScene physScene)
override void SetRigidBody(RigidBody body)
override void ApplyTorqueImpulse(BulletBody pBody, Vector3 pfSum)
override bool ClearCollisionProxyCache(BulletWorld pWorld, BulletBody pBody)
override void ApplyCentralImpulse(BulletBody pBody, Vector3 pfSum)
override void SetLinearVelocity(BulletBody pBody, Vector3 _velocity)
override float GetRestitution(BulletBody pBody)
override bool GetForceUpdateAllAabbs(BulletWorld pWorld)
override void ApplyImpulse(BulletBody pBody, Vector3 imp, Vector3 pos)
override float GetMargin(BulletShape pShape)
override int GetShapeType(BulletShape pShape)
override BulletShape DuplicateCollisionShape(BulletWorld pWorld, BulletShape pShape, uint id)
override CollisionFlags RemoveFromCollisionFlags(BulletBody pCollisionObject, CollisionFlags pcollisionFlags)
override IntPtr GetUserPointer(BulletBody pCollisionObject)
override void RemoveChildShapeFromCompoundShape(BulletShape cShape, BulletShape removeShape)
override void Translate(BulletBody pCollisionObject, Vector3 trans)
override Vector3 GetLinearFactor(BulletBody pBody)
override Vector3 GetPosition(BulletBody pCollisionObject)
override void RecalculateCompoundShapeLocalAabb(BulletShape pCompoundShape)
override void SetCenterOfMassByPosRot(BulletBody pBody, Vector3 pos, Quaternion rot)
override float GetCcdMotionThreshold(BulletBody pCollisionObject)
override void SetAngularFactor(BulletBody pBody, float factor)
override void SetInvInertiaDiagLocal(BulletBody pBody, Vector3 inert)
override Vector3 GetTotalForce(BulletBody pBody)
override void SetTranslation(BulletBody pCollisionObject, Vector3 _position, Quaternion _orientation)
override void UpdateAabbs(BulletWorld pWorld)
override void SetInterpolationAngularVelocity(BulletBody pCollisionObject, Vector3 pVector3)
override BulletShape CreateConvexHullShape(BulletWorld pWorld, int pIndicesCount, int[] indices, int pVerticesCount, float[] verticesAsFloats)
override bool IsConvex2d(BulletShape pShape)
override void SetCcdSweptSphereRadius(BulletBody pCollisionObject, float pCcdSweptSphereRadius)
override bool IsActive(BulletBody pBody)
override void SetInterpolationLinearVelocity(BulletBody pCollisionObject, Vector3 VehicleVelocity)
override void SetWorldTransform(IndexedMatrix worldTrans)
BSPhysicsShapeType BSShapeTypeFromBroadPhaseNativeType(BroadphaseNativeTypes pin)
override void ApplyGravity(BulletBody pBody)
override bool RemoveObjectFromWorld(BulletWorld pWorld, BulletBody pBody)
override void SetInterpolationVelocity(BulletBody pBody, Vector3 linearVel, Vector3 angularVel)
override bool HasAnisotripicFriction(BulletConstraint pconstrain)