diff options
Diffstat (limited to '')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs index 23ef052..476a0e5 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs | |||
@@ -39,51 +39,50 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
39 | public override ConstraintType Type { get { return ConstraintType.D6_CONSTRAINT_TYPE; } } | 39 | public override ConstraintType Type { get { return ConstraintType.D6_CONSTRAINT_TYPE; } } |
40 | 40 | ||
41 | // Create a btGeneric6DofConstraint | 41 | // Create a btGeneric6DofConstraint |
42 | public BSConstraint6Dof(BulletSim world, BulletBody obj1, BulletBody obj2, | 42 | public BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2, |
43 | Vector3 frame1, Quaternion frame1rot, | 43 | Vector3 frame1, Quaternion frame1rot, |
44 | Vector3 frame2, Quaternion frame2rot, | 44 | Vector3 frame2, Quaternion frame2rot, |
45 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | 45 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) |
46 | : base(world) | ||
46 | { | 47 | { |
47 | m_world = world; | ||
48 | m_body1 = obj1; | 48 | m_body1 = obj1; |
49 | m_body2 = obj2; | 49 | m_body2 = obj2; |
50 | m_constraint = new BulletConstraint( | 50 | m_constraint = PhysicsScene.PE.Create6DofConstraint(m_world, m_body1, m_body2, |
51 | BulletSimAPI.Create6DofConstraint2(m_world.ptr, m_body1.ptr, m_body2.ptr, | ||
52 | frame1, frame1rot, | 51 | frame1, frame1rot, |
53 | frame2, frame2rot, | 52 | frame2, frame2rot, |
54 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | 53 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); |
55 | m_enabled = true; | 54 | m_enabled = true; |
56 | world.physicsScene.DetailLog("{0},BS6DofConstraint,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", | 55 | world.physicsScene.DetailLog("{0},BS6DofConstraint,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", |
57 | BSScene.DetailLogZero, world.worldID, | 56 | BSScene.DetailLogZero, world.worldID, |
58 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | 57 | obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); |
59 | } | 58 | } |
60 | 59 | ||
61 | public BSConstraint6Dof(BulletSim world, BulletBody obj1, BulletBody obj2, | 60 | // 6 Dof constraint based on a midpoint between the two constrained bodies |
61 | public BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2, | ||
62 | Vector3 joinPoint, | 62 | Vector3 joinPoint, |
63 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | 63 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) |
64 | : base(world) | ||
64 | { | 65 | { |
65 | m_world = world; | ||
66 | m_body1 = obj1; | 66 | m_body1 = obj1; |
67 | m_body2 = obj2; | 67 | m_body2 = obj2; |
68 | if (obj1.ptr == IntPtr.Zero || obj2.ptr == IntPtr.Zero) | 68 | if (!obj1.HasPhysicalBody || !obj2.HasPhysicalBody) |
69 | { | 69 | { |
70 | world.physicsScene.DetailLog("{0},BS6DOFConstraint,badBodyPtr,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", | 70 | world.physicsScene.DetailLog("{0},BS6DOFConstraint,badBodyPtr,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", |
71 | BSScene.DetailLogZero, world.worldID, | 71 | BSScene.DetailLogZero, world.worldID, |
72 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | 72 | obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); |
73 | world.physicsScene.Logger.ErrorFormat("{0} Attempt to build 6DOF constraint with missing bodies: wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", | 73 | world.physicsScene.Logger.ErrorFormat("{0} Attempt to build 6DOF constraint with missing bodies: wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", |
74 | LogHeader, world.worldID, obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | 74 | LogHeader, world.worldID, obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); |
75 | m_enabled = false; | 75 | m_enabled = false; |
76 | } | 76 | } |
77 | else | 77 | else |
78 | { | 78 | { |
79 | m_constraint = new BulletConstraint( | 79 | m_constraint = PhysicsScene.PE.Create6DofConstraintToPoint(m_world, m_body1, m_body2, |
80 | BulletSimAPI.Create6DofConstraintToPoint2(m_world.ptr, m_body1.ptr, m_body2.ptr, | ||
81 | joinPoint, | 80 | joinPoint, |
82 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | 81 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); |
83 | world.physicsScene.DetailLog("{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}", | 82 | PhysicsScene.DetailLog("{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}", |
84 | BSScene.DetailLogZero, world.worldID, m_constraint.ptr.ToString("X"), | 83 | BSScene.DetailLogZero, world.worldID, m_constraint.AddrString, |
85 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | 84 | obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); |
86 | if (m_constraint.ptr == IntPtr.Zero) | 85 | if (!m_constraint.HasPhysicalConstraint) |
87 | { | 86 | { |
88 | world.physicsScene.Logger.ErrorFormat("{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}", | 87 | world.physicsScene.Logger.ErrorFormat("{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}", |
89 | LogHeader, obj1.ID, obj2.ID); | 88 | LogHeader, obj1.ID, obj2.ID); |
@@ -96,12 +95,27 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
96 | } | 95 | } |
97 | } | 96 | } |
98 | 97 | ||
98 | // A 6 Dof constraint that is fixed in the world and constrained to a on-the-fly created static object | ||
99 | public BSConstraint6Dof(BulletWorld world, BulletBody obj1, Vector3 frameInBloc, Quaternion frameInBrot, | ||
100 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | ||
101 | : base(world) | ||
102 | { | ||
103 | m_body1 = obj1; | ||
104 | m_body2 = obj1; // Look out for confusion down the road | ||
105 | m_constraint = PhysicsScene.PE.Create6DofConstraintFixed(m_world, m_body1, | ||
106 | frameInBloc, frameInBrot, | ||
107 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); | ||
108 | m_enabled = true; | ||
109 | world.physicsScene.DetailLog("{0},BS6DofConstraint,createFixed,wID={1},rID={2},rBody={3}", | ||
110 | BSScene.DetailLogZero, world.worldID, obj1.ID, obj1.AddrString); | ||
111 | } | ||
112 | |||
99 | public bool SetFrames(Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot) | 113 | public bool SetFrames(Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot) |
100 | { | 114 | { |
101 | bool ret = false; | 115 | bool ret = false; |
102 | if (m_enabled) | 116 | if (m_enabled) |
103 | { | 117 | { |
104 | BulletSimAPI.SetFrames2(m_constraint.ptr, frameA, frameArot, frameB, frameBrot); | 118 | PhysicsScene.PE.SetFrames(m_constraint, frameA, frameArot, frameB, frameBrot); |
105 | ret = true; | 119 | ret = true; |
106 | } | 120 | } |
107 | return ret; | 121 | return ret; |
@@ -112,9 +126,9 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
112 | bool ret = false; | 126 | bool ret = false; |
113 | if (m_enabled) | 127 | if (m_enabled) |
114 | { | 128 | { |
115 | BulletSimAPI.SetConstraintParam2(m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL); | 129 | PhysicsScene.PE.SetConstraintParam(m_constraint, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL); |
116 | BulletSimAPI.SetConstraintParam2(m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL); | 130 | PhysicsScene.PE.SetConstraintParam(m_constraint, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL); |
117 | BulletSimAPI.SetConstraintParam2(m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL); | 131 | PhysicsScene.PE.SetConstraintParam(m_constraint, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL); |
118 | ret = true; | 132 | ret = true; |
119 | } | 133 | } |
120 | return ret; | 134 | return ret; |
@@ -125,7 +139,7 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
125 | bool ret = false; | 139 | bool ret = false; |
126 | float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; | 140 | float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; |
127 | if (m_enabled) | 141 | if (m_enabled) |
128 | ret = BulletSimAPI.UseFrameOffset2(m_constraint.ptr, onOff); | 142 | ret = PhysicsScene.PE.UseFrameOffset(m_constraint, onOff); |
129 | return ret; | 143 | return ret; |
130 | } | 144 | } |
131 | 145 | ||
@@ -135,7 +149,7 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
135 | float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; | 149 | float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; |
136 | if (m_enabled) | 150 | if (m_enabled) |
137 | { | 151 | { |
138 | ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.ptr, onOff, targetVelocity, maxMotorForce); | 152 | ret = PhysicsScene.PE.TranslationalLimitMotor(m_constraint, onOff, targetVelocity, maxMotorForce); |
139 | m_world.physicsScene.DetailLog("{0},BS6DOFConstraint,TransLimitMotor,enable={1},vel={2},maxForce={3}", | 153 | m_world.physicsScene.DetailLog("{0},BS6DOFConstraint,TransLimitMotor,enable={1},vel={2},maxForce={3}", |
140 | BSScene.DetailLogZero, enable, targetVelocity, maxMotorForce); | 154 | BSScene.DetailLogZero, enable, targetVelocity, maxMotorForce); |
141 | } | 155 | } |
@@ -146,7 +160,7 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
146 | { | 160 | { |
147 | bool ret = false; | 161 | bool ret = false; |
148 | if (m_enabled) | 162 | if (m_enabled) |
149 | ret = BulletSimAPI.SetBreakingImpulseThreshold2(m_constraint.ptr, threshold); | 163 | ret = PhysicsScene.PE.SetBreakingImpulseThreshold(m_constraint, threshold); |
150 | return ret; | 164 | return ret; |
151 | } | 165 | } |
152 | } | 166 | } |