diff options
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs | 110 |
1 files changed, 103 insertions, 7 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs index 80218e7..c9d0909 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs | |||
@@ -83,7 +83,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
83 | private Vector3 m_linearFrictionTimescale = new Vector3(1000, 1000, 1000); | 83 | private Vector3 m_linearFrictionTimescale = new Vector3(1000, 1000, 1000); |
84 | private float m_linearMotorDecayTimescale = 120; | 84 | private float m_linearMotorDecayTimescale = 120; |
85 | private float m_linearMotorTimescale = 1000; | 85 | private float m_linearMotorTimescale = 1000; |
86 | private Vector3 m_lastLinearVelocityVector = Vector3.Zero; | ||
87 | private Vector3 m_linearMotorOffset = Vector3.Zero; | 86 | private Vector3 m_linearMotorOffset = Vector3.Zero; |
88 | 87 | ||
89 | //Angular properties | 88 | //Angular properties |
@@ -91,7 +90,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
91 | private float m_angularMotorTimescale = 1000; // motor angular velocity ramp up rate | 90 | private float m_angularMotorTimescale = 1000; // motor angular velocity ramp up rate |
92 | private float m_angularMotorDecayTimescale = 120; // motor angular velocity decay rate | 91 | private float m_angularMotorDecayTimescale = 120; // motor angular velocity decay rate |
93 | private Vector3 m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); // body angular velocity decay rate | 92 | private Vector3 m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); // body angular velocity decay rate |
94 | private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body | ||
95 | 93 | ||
96 | //Deflection properties | 94 | //Deflection properties |
97 | private float m_angularDeflectionEfficiency = 0; | 95 | private float m_angularDeflectionEfficiency = 0; |
@@ -102,7 +100,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
102 | //Banking properties | 100 | //Banking properties |
103 | private float m_bankingEfficiency = 0; | 101 | private float m_bankingEfficiency = 0; |
104 | private float m_bankingMix = 0; | 102 | private float m_bankingMix = 0; |
105 | private float m_bankingTimescale = 0; | 103 | private float m_bankingTimescale = 1000; |
106 | 104 | ||
107 | //Hover and Buoyancy properties | 105 | //Hover and Buoyancy properties |
108 | private float m_VhoverHeight = 0f; | 106 | private float m_VhoverHeight = 0f; |
@@ -117,9 +115,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
117 | private float m_verticalAttractionEfficiency = 1.0f; // damped | 115 | private float m_verticalAttractionEfficiency = 1.0f; // damped |
118 | private float m_verticalAttractionTimescale = 1000f; // Timescale > 300 means no vert attractor. | 116 | private float m_verticalAttractionTimescale = 1000f; // Timescale > 300 means no vert attractor. |
119 | 117 | ||
120 | // auxiliar | ||
121 | private Vector3 m_dir = Vector3.Zero; // velocity applied to body | ||
122 | 118 | ||
119 | // auxiliar | ||
123 | private float m_lmEfect = 0; // current linear motor eficiency | 120 | private float m_lmEfect = 0; // current linear motor eficiency |
124 | private float m_amEfect = 0; // current angular motor eficiency | 121 | private float m_amEfect = 0; // current angular motor eficiency |
125 | 122 | ||
@@ -130,6 +127,82 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
130 | _pParentScene = rootPrim._parent_scene; | 127 | _pParentScene = rootPrim._parent_scene; |
131 | } | 128 | } |
132 | 129 | ||
130 | |||
131 | public void DoSetVehicle(VehicleData vd) | ||
132 | { | ||
133 | |||
134 | float timestep = _pParentScene.ODE_STEPSIZE; | ||
135 | float invtimestep = 1.0f / timestep; | ||
136 | |||
137 | m_type = vd.m_type; | ||
138 | m_flags = vd.m_flags; | ||
139 | |||
140 | // Linear properties | ||
141 | m_linearMotorDirection = vd.m_linearMotorDirection; | ||
142 | |||
143 | m_linearFrictionTimescale = vd.m_linearFrictionTimescale; | ||
144 | if (m_linearFrictionTimescale.X < timestep) m_linearFrictionTimescale.X = timestep; | ||
145 | if (m_linearFrictionTimescale.Y < timestep) m_linearFrictionTimescale.Y = timestep; | ||
146 | if (m_linearFrictionTimescale.Z < timestep) m_linearFrictionTimescale.Z = timestep; | ||
147 | |||
148 | m_linearMotorDecayTimescale = vd.m_linearMotorDecayTimescale; | ||
149 | if (m_linearMotorDecayTimescale < 0.5f) m_linearMotorDecayTimescale = 0.5f; | ||
150 | m_linearMotorDecayTimescale *= invtimestep; | ||
151 | |||
152 | m_linearMotorTimescale = vd.m_linearMotorTimescale; | ||
153 | if (m_linearMotorTimescale < timestep) m_linearMotorTimescale = timestep; | ||
154 | |||
155 | m_linearMotorOffset = vd.m_linearMotorOffset; | ||
156 | |||
157 | //Angular properties | ||
158 | m_angularMotorDirection = vd.m_angularMotorDirection; | ||
159 | m_angularMotorTimescale = vd.m_angularMotorTimescale; | ||
160 | if (m_angularMotorTimescale < timestep) m_angularMotorTimescale = timestep; | ||
161 | |||
162 | m_angularMotorDecayTimescale = vd.m_angularMotorDecayTimescale; | ||
163 | if (m_angularMotorDecayTimescale < 0.5f) m_angularMotorDecayTimescale = 0.5f; | ||
164 | m_angularMotorDecayTimescale *= invtimestep; | ||
165 | |||
166 | m_angularFrictionTimescale = vd.m_angularFrictionTimescale; | ||
167 | if (m_angularFrictionTimescale.X < timestep) m_angularFrictionTimescale.X = timestep; | ||
168 | if (m_angularFrictionTimescale.Y < timestep) m_angularFrictionTimescale.Y = timestep; | ||
169 | if (m_angularFrictionTimescale.Z < timestep) m_angularFrictionTimescale.Z = timestep; | ||
170 | |||
171 | //Deflection properties | ||
172 | m_angularDeflectionEfficiency = vd.m_angularDeflectionEfficiency; | ||
173 | m_angularDeflectionTimescale = vd.m_angularDeflectionTimescale; | ||
174 | if (m_angularDeflectionTimescale < timestep) m_angularDeflectionTimescale = timestep; | ||
175 | |||
176 | m_linearDeflectionEfficiency = vd.m_linearDeflectionEfficiency; | ||
177 | m_linearDeflectionTimescale = vd.m_linearDeflectionTimescale; | ||
178 | if (m_linearDeflectionTimescale < timestep) m_linearDeflectionTimescale = timestep; | ||
179 | |||
180 | //Banking properties | ||
181 | m_bankingEfficiency = vd.m_bankingEfficiency; | ||
182 | m_bankingMix = vd.m_bankingMix; | ||
183 | m_bankingTimescale = vd.m_bankingTimescale; | ||
184 | if (m_bankingTimescale < timestep) m_bankingTimescale = timestep; | ||
185 | |||
186 | //Hover and Buoyancy properties | ||
187 | m_VhoverHeight = vd.m_VhoverHeight; | ||
188 | m_VhoverEfficiency = vd.m_VhoverEfficiency; | ||
189 | m_VhoverTimescale = vd.m_VhoverTimescale; | ||
190 | if (m_VhoverTimescale < timestep) m_VhoverTimescale = timestep; | ||
191 | |||
192 | m_VehicleBuoyancy = vd.m_VehicleBuoyancy; | ||
193 | |||
194 | //Attractor properties | ||
195 | m_verticalAttractionEfficiency = vd.m_verticalAttractionEfficiency; | ||
196 | m_verticalAttractionTimescale = vd.m_verticalAttractionTimescale; | ||
197 | if (m_verticalAttractionTimescale < timestep) m_verticalAttractionTimescale = timestep; | ||
198 | |||
199 | // Axis | ||
200 | m_referenceFrame = vd.m_referenceFrame; | ||
201 | |||
202 | m_lmEfect = 0; | ||
203 | m_amEfect = 0; | ||
204 | } | ||
205 | |||
133 | internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) | 206 | internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) |
134 | { | 207 | { |
135 | float len; | 208 | float len; |
@@ -231,6 +304,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
231 | if (len > 12.566f) | 304 | if (len > 12.566f) |
232 | m_angularMotorDirection *= (12.566f / len); | 305 | m_angularMotorDirection *= (12.566f / len); |
233 | m_amEfect = 1.0f; // turn it on | 306 | m_amEfect = 1.0f; // turn it on |
307 | if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) | ||
308 | && !rootPrim.m_isSelected && !rootPrim.m_disabled) | ||
309 | d.BodyEnable(rootPrim.Body); | ||
234 | break; | 310 | break; |
235 | case Vehicle.LINEAR_FRICTION_TIMESCALE: | 311 | case Vehicle.LINEAR_FRICTION_TIMESCALE: |
236 | if (pValue < timestep) pValue = timestep; | 312 | if (pValue < timestep) pValue = timestep; |
@@ -242,6 +318,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
242 | if (len > 30.0f) | 318 | if (len > 30.0f) |
243 | m_linearMotorDirection *= (30.0f / len); | 319 | m_linearMotorDirection *= (30.0f / len); |
244 | m_lmEfect = 1.0f; // turn it on | 320 | m_lmEfect = 1.0f; // turn it on |
321 | if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) | ||
322 | && !rootPrim.m_isSelected && !rootPrim.m_disabled) | ||
323 | d.BodyEnable(rootPrim.Body); | ||
245 | break; | 324 | break; |
246 | case Vehicle.LINEAR_MOTOR_OFFSET: | 325 | case Vehicle.LINEAR_MOTOR_OFFSET: |
247 | m_linearMotorOffset = new Vector3(pValue, pValue, pValue); | 326 | m_linearMotorOffset = new Vector3(pValue, pValue, pValue); |
@@ -273,6 +352,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
273 | if (len > 12.566f) | 352 | if (len > 12.566f) |
274 | m_angularMotorDirection *= (12.566f / len); | 353 | m_angularMotorDirection *= (12.566f / len); |
275 | m_amEfect = 1.0f; // turn it on | 354 | m_amEfect = 1.0f; // turn it on |
355 | if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) | ||
356 | && !rootPrim.m_isSelected && !rootPrim.m_disabled) | ||
357 | d.BodyEnable(rootPrim.Body); | ||
276 | break; | 358 | break; |
277 | case Vehicle.LINEAR_FRICTION_TIMESCALE: | 359 | case Vehicle.LINEAR_FRICTION_TIMESCALE: |
278 | if (pValue.X < timestep) pValue.X = timestep; | 360 | if (pValue.X < timestep) pValue.X = timestep; |
@@ -286,6 +368,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
286 | if (len > 30.0f) | 368 | if (len > 30.0f) |
287 | m_linearMotorDirection *= (30.0f / len); | 369 | m_linearMotorDirection *= (30.0f / len); |
288 | m_lmEfect = 1.0f; // turn it on | 370 | m_lmEfect = 1.0f; // turn it on |
371 | if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) | ||
372 | && !rootPrim.m_isSelected && !rootPrim.m_disabled) | ||
373 | d.BodyEnable(rootPrim.Body); | ||
289 | break; | 374 | break; |
290 | case Vehicle.LINEAR_MOTOR_OFFSET: | 375 | case Vehicle.LINEAR_MOTOR_OFFSET: |
291 | m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); | 376 | m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); |
@@ -347,12 +432,23 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
347 | m_linearFrictionTimescale = new Vector3(1000, 1000, 1000); | 432 | m_linearFrictionTimescale = new Vector3(1000, 1000, 1000); |
348 | m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); | 433 | m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); |
349 | m_linearMotorTimescale = 1000; | 434 | m_linearMotorTimescale = 1000; |
350 | m_linearMotorDecayTimescale = 120 * invtimestep; | 435 | m_linearMotorDecayTimescale = 120; |
351 | m_angularMotorTimescale = 1000; | 436 | m_angularMotorTimescale = 1000; |
352 | m_angularMotorDecayTimescale = 1000 * invtimestep; | 437 | m_angularMotorDecayTimescale = 1000; |
353 | m_VhoverHeight = 0; | 438 | m_VhoverHeight = 0; |
439 | m_VhoverEfficiency = 1; | ||
354 | m_VhoverTimescale = 1000; | 440 | m_VhoverTimescale = 1000; |
355 | m_VehicleBuoyancy = 0; | 441 | m_VehicleBuoyancy = 0; |
442 | m_linearDeflectionEfficiency = 0; | ||
443 | m_linearDeflectionTimescale = 1000; | ||
444 | m_angularDeflectionEfficiency = 0; | ||
445 | m_angularDeflectionTimescale = 1000; | ||
446 | m_bankingEfficiency = 0; | ||
447 | m_bankingMix = 1; | ||
448 | m_bankingTimescale = 1000; | ||
449 | m_verticalAttractionEfficiency = 0; | ||
450 | m_verticalAttractionTimescale = 1000; | ||
451 | |||
356 | m_flags = (VehicleFlag)0; | 452 | m_flags = (VehicleFlag)0; |
357 | break; | 453 | break; |
358 | 454 | ||