28 using System.Collections.Generic;
32 namespace OpenSim.
Region.PhysicsModule.BulletS
37 private static string LogHeader =
"[BULLETSIM 6DOF CONSTRAINT]";
39 public override ConstraintType Type {
get {
return ConstraintType.D6_CONSTRAINT_TYPE; } }
50 Vector3 frame1, Quaternion frame1rot,
51 Vector3 frame2, Quaternion frame2rot,
52 bool useLinearReferenceFrameA,
bool disableCollisionsBetweenLinkedBodies)
57 m_constraint = PhysicsScene.PE.Create6DofConstraint(m_world, m_body1, m_body2,
60 useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies);
62 PhysicsScene.DetailLog(
"{0},BS6DofConstraint,create,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
63 m_body1.ID, world.worldID,
64 obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
65 PhysicsScene.DetailLog(
"{0},BS6DofConstraint,create, f1Loc={1},f1Rot={2},f2Loc={3},f2Rot={4},usefA={5},disCol={6}",
66 m_body1.ID, frame1, frame1rot, frame2, frame2rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies);
72 bool useLinearReferenceFrameA,
bool disableCollisionsBetweenLinkedBodies)
79 world.physicsScene.DetailLog(
"{0},BS6DOFConstraint,badBodyPtr,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
80 BSScene.DetailLogZero, world.worldID,
81 obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
82 world.physicsScene.Logger.ErrorFormat(
"{0} Attempt to build 6DOF constraint with missing bodies: wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
83 LogHeader, world.worldID, obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
88 m_constraint = PhysicsScene.PE.Create6DofConstraintToPoint(m_world, m_body1, m_body2,
90 useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies);
92 PhysicsScene.DetailLog(
"{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}",
93 m_body1.ID, world.worldID, m_constraint.AddrString,
94 obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
96 if (!m_constraint.HasPhysicalConstraint)
98 world.physicsScene.Logger.ErrorFormat(
"{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}",
99 LogHeader, obj1.ID, obj2.ID);
111 bool useLinearReferenceFrameB,
bool disableCollisionsBetweenLinkedBodies)
116 m_constraint = PhysicsScene.PE.Create6DofConstraintFixed(m_world, m_body1,
117 frameInBloc, frameInBrot,
118 useLinearReferenceFrameB, disableCollisionsBetweenLinkedBodies);
120 PhysicsScene.DetailLog(
"{0},BS6DofConstraint,createFixed,wID={1},rID={2},rBody={3}",
121 m_body1.ID, world.worldID, obj1.ID, obj1.AddrString);
122 PhysicsScene.DetailLog(
"{0},BS6DofConstraint,createFixed, fBLoc={1},fBRot={2},usefA={3},disCol={4}",
123 m_body1.ID, frameInBloc, frameInBrot, useLinearReferenceFrameB, disableCollisionsBetweenLinkedBodies);
126 public bool SetFrames(Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot)
131 PhysicsScene.PE.SetFrames(m_constraint, frameA, frameArot, frameB, frameBrot);
142 PhysicsScene.PE.SetConstraintParam(m_constraint, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
143 PhysicsScene.PE.SetConstraintParam(m_constraint, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL);
144 PhysicsScene.PE.SetConstraintParam(m_constraint, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
153 float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse;
155 ret = PhysicsScene.PE.UseFrameOffset(m_constraint, onOff);
162 float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse;
165 ret = PhysicsScene.PE.TranslationalLimitMotor(m_constraint, onOff, targetVelocity, maxMotorForce);
166 m_world.physicsScene.DetailLog(
"{0},BS6DOFConstraint,TransLimitMotor,enable={1},vel={2},maxForce={3}",
167 BSScene.DetailLogZero, enable, targetVelocity, maxMotorForce);
176 ret = PhysicsScene.PE.SetBreakingImpulseThreshold(m_constraint, threshold);
BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2)
bool TranslationalLimitMotor(bool enable, float targetVelocity, float maxMotorForce)
BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2, Vector3 joinPoint, bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
virtual bool HasPhysicalBody
BSConstraint6Dof(BulletWorld world, BulletBody obj1, Vector3 frameInBloc, Quaternion frameInBrot, bool useLinearReferenceFrameB, bool disableCollisionsBetweenLinkedBodies)
bool SetCFMAndERP(float cfm, float erp)
bool UseFrameOffset(bool useOffset)
bool SetBreakingImpulseThreshold(float threshold)
BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2, Vector3 frame1, Quaternion frame1rot, Vector3 frame2, Quaternion frame2rot, bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
bool SetFrames(Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot)