diff options
Diffstat (limited to '')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs) | 67 |
1 files changed, 16 insertions, 51 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs b/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs index 23ef052..683bc51 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs | |||
@@ -32,14 +32,10 @@ using OpenMetaverse; | |||
32 | namespace OpenSim.Region.Physics.BulletSPlugin | 32 | namespace OpenSim.Region.Physics.BulletSPlugin |
33 | { | 33 | { |
34 | 34 | ||
35 | public sealed class BSConstraint6Dof : BSConstraint | 35 | public class BS6DofConstraint : BSConstraint |
36 | { | 36 | { |
37 | private static string LogHeader = "[BULLETSIM 6DOF CONSTRAINT]"; | ||
38 | |||
39 | public override ConstraintType Type { get { return ConstraintType.D6_CONSTRAINT_TYPE; } } | ||
40 | |||
41 | // Create a btGeneric6DofConstraint | 37 | // Create a btGeneric6DofConstraint |
42 | public BSConstraint6Dof(BulletSim world, BulletBody obj1, BulletBody obj2, | 38 | public BS6DofConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, |
43 | Vector3 frame1, Quaternion frame1rot, | 39 | Vector3 frame1, Quaternion frame1rot, |
44 | Vector3 frame2, Quaternion frame2rot, | 40 | Vector3 frame2, Quaternion frame2rot, |
45 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | 41 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) |
@@ -48,52 +44,25 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
48 | m_body1 = obj1; | 44 | m_body1 = obj1; |
49 | m_body2 = obj2; | 45 | m_body2 = obj2; |
50 | m_constraint = new BulletConstraint( | 46 | m_constraint = new BulletConstraint( |
51 | BulletSimAPI.Create6DofConstraint2(m_world.ptr, m_body1.ptr, m_body2.ptr, | 47 | BulletSimAPI.Create6DofConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, |
52 | frame1, frame1rot, | 48 | frame1, frame1rot, |
53 | frame2, frame2rot, | 49 | frame2, frame2rot, |
54 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | 50 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); |
55 | m_enabled = true; | 51 | m_enabled = true; |
56 | world.physicsScene.DetailLog("{0},BS6DofConstraint,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", | ||
57 | BSScene.DetailLogZero, world.worldID, | ||
58 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | ||
59 | } | 52 | } |
60 | 53 | ||
61 | public BSConstraint6Dof(BulletSim world, BulletBody obj1, BulletBody obj2, | 54 | public BS6DofConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, |
62 | Vector3 joinPoint, | 55 | Vector3 joinPoint, |
63 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | 56 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) |
64 | { | 57 | { |
65 | m_world = world; | 58 | m_world = world; |
66 | m_body1 = obj1; | 59 | m_body1 = obj1; |
67 | m_body2 = obj2; | 60 | m_body2 = obj2; |
68 | if (obj1.ptr == IntPtr.Zero || obj2.ptr == IntPtr.Zero) | 61 | m_constraint = new BulletConstraint( |
69 | { | 62 | BulletSimAPI.Create6DofConstraintToPoint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, |
70 | world.physicsScene.DetailLog("{0},BS6DOFConstraint,badBodyPtr,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", | 63 | joinPoint, |
71 | BSScene.DetailLogZero, world.worldID, | 64 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); |
72 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | 65 | m_enabled = true; |
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")); | ||
75 | m_enabled = false; | ||
76 | } | ||
77 | else | ||
78 | { | ||
79 | m_constraint = new BulletConstraint( | ||
80 | BulletSimAPI.Create6DofConstraintToPoint2(m_world.ptr, m_body1.ptr, m_body2.ptr, | ||
81 | joinPoint, | ||
82 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | ||
83 | world.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"), | ||
85 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | ||
86 | if (m_constraint.ptr == IntPtr.Zero) | ||
87 | { | ||
88 | world.physicsScene.Logger.ErrorFormat("{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}", | ||
89 | LogHeader, obj1.ID, obj2.ID); | ||
90 | m_enabled = false; | ||
91 | } | ||
92 | else | ||
93 | { | ||
94 | m_enabled = true; | ||
95 | } | ||
96 | } | ||
97 | } | 66 | } |
98 | 67 | ||
99 | public bool SetFrames(Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot) | 68 | public bool SetFrames(Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot) |
@@ -101,7 +70,7 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
101 | bool ret = false; | 70 | bool ret = false; |
102 | if (m_enabled) | 71 | if (m_enabled) |
103 | { | 72 | { |
104 | BulletSimAPI.SetFrames2(m_constraint.ptr, frameA, frameArot, frameB, frameBrot); | 73 | BulletSimAPI.SetFrames2(m_constraint.Ptr, frameA, frameArot, frameB, frameBrot); |
105 | ret = true; | 74 | ret = true; |
106 | } | 75 | } |
107 | return ret; | 76 | return ret; |
@@ -112,9 +81,9 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
112 | bool ret = false; | 81 | bool ret = false; |
113 | if (m_enabled) | 82 | if (m_enabled) |
114 | { | 83 | { |
115 | BulletSimAPI.SetConstraintParam2(m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL); | 84 | BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL); |
116 | BulletSimAPI.SetConstraintParam2(m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL); | 85 | BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL); |
117 | BulletSimAPI.SetConstraintParam2(m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL); | 86 | BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL); |
118 | ret = true; | 87 | ret = true; |
119 | } | 88 | } |
120 | return ret; | 89 | return ret; |
@@ -125,7 +94,7 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
125 | bool ret = false; | 94 | bool ret = false; |
126 | float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; | 95 | float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; |
127 | if (m_enabled) | 96 | if (m_enabled) |
128 | ret = BulletSimAPI.UseFrameOffset2(m_constraint.ptr, onOff); | 97 | ret = BulletSimAPI.UseFrameOffset2(m_constraint.Ptr, onOff); |
129 | return ret; | 98 | return ret; |
130 | } | 99 | } |
131 | 100 | ||
@@ -134,11 +103,7 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
134 | bool ret = false; | 103 | bool ret = false; |
135 | float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; | 104 | float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; |
136 | if (m_enabled) | 105 | if (m_enabled) |
137 | { | 106 | ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.Ptr, onOff, targetVelocity, maxMotorForce); |
138 | ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.ptr, onOff, targetVelocity, maxMotorForce); | ||
139 | m_world.physicsScene.DetailLog("{0},BS6DOFConstraint,TransLimitMotor,enable={1},vel={2},maxForce={3}", | ||
140 | BSScene.DetailLogZero, enable, targetVelocity, maxMotorForce); | ||
141 | } | ||
142 | return ret; | 107 | return ret; |
143 | } | 108 | } |
144 | 109 | ||
@@ -146,7 +111,7 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
146 | { | 111 | { |
147 | bool ret = false; | 112 | bool ret = false; |
148 | if (m_enabled) | 113 | if (m_enabled) |
149 | ret = BulletSimAPI.SetBreakingImpulseThreshold2(m_constraint.ptr, threshold); | 114 | ret = BulletSimAPI.SetBreakingImpulseThreshold2(m_constraint.Ptr, threshold); |
150 | return ret; | 115 | return ret; |
151 | } | 116 | } |
152 | } | 117 | } |