diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 616 |
1 files changed, 233 insertions, 383 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 5a9f135..4ba2f62 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -54,17 +54,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
54 | { | 54 | { |
55 | public class BSDynamics | 55 | public class BSDynamics |
56 | { | 56 | { |
57 | private int frcount = 0; // Used to limit dynamics debug output to | 57 | private BSScene PhysicsScene { get; set; } |
58 | // every 100th frame | 58 | // the prim this dynamic controller belongs to |
59 | 59 | private BSPrim Prim { get; set; } | |
60 | private BSPrim m_prim; // the prim this dynamic controller belongs to | ||
61 | 60 | ||
62 | // Vehicle properties | 61 | // Vehicle properties |
63 | private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind | 62 | public Vehicle Type { get; set; } |
64 | public Vehicle Type | 63 | |
65 | { | ||
66 | get { return m_type; } | ||
67 | } | ||
68 | // private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier | 64 | // private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier |
69 | private VehicleFlag m_flags = (VehicleFlag) 0; // Boolean settings: | 65 | private VehicleFlag m_flags = (VehicleFlag) 0; // Boolean settings: |
70 | // HOVER_TERRAIN_ONLY | 66 | // HOVER_TERRAIN_ONLY |
@@ -74,13 +70,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
74 | // HOVER_UP_ONLY | 70 | // HOVER_UP_ONLY |
75 | // LIMIT_MOTOR_UP | 71 | // LIMIT_MOTOR_UP |
76 | // LIMIT_ROLL_ONLY | 72 | // LIMIT_ROLL_ONLY |
77 | private VehicleFlag m_Hoverflags = (VehicleFlag)0; | ||
78 | private Vector3 m_BlockingEndPoint = Vector3.Zero; | 73 | private Vector3 m_BlockingEndPoint = Vector3.Zero; |
79 | private Quaternion m_RollreferenceFrame = Quaternion.Identity; | 74 | private Quaternion m_RollreferenceFrame = Quaternion.Identity; |
80 | // Linear properties | 75 | // Linear properties |
81 | private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time | 76 | private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time |
82 | private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL | 77 | private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL |
83 | private Vector3 m_dir = Vector3.Zero; // velocity applied to body | 78 | private Vector3 m_newVelocity = Vector3.Zero; // velocity computed to be applied to body |
84 | private Vector3 m_linearFrictionTimescale = Vector3.Zero; | 79 | private Vector3 m_linearFrictionTimescale = Vector3.Zero; |
85 | private float m_linearMotorDecayTimescale = 0; | 80 | private float m_linearMotorDecayTimescale = 0; |
86 | private float m_linearMotorTimescale = 0; | 81 | private float m_linearMotorTimescale = 0; |
@@ -97,7 +92,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
97 | private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate | 92 | private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate |
98 | private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate | 93 | private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate |
99 | private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body | 94 | private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body |
100 | // private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body | 95 | private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body |
101 | 96 | ||
102 | //Deflection properties | 97 | //Deflection properties |
103 | // private float m_angularDeflectionEfficiency = 0; | 98 | // private float m_angularDeflectionEfficiency = 0; |
@@ -124,86 +119,74 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
124 | private float m_verticalAttractionEfficiency = 1.0f; // damped | 119 | private float m_verticalAttractionEfficiency = 1.0f; // damped |
125 | private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor. | 120 | private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor. |
126 | 121 | ||
127 | public BSDynamics(BSPrim myPrim) | 122 | public BSDynamics(BSScene myScene, BSPrim myPrim) |
123 | { | ||
124 | PhysicsScene = myScene; | ||
125 | Prim = myPrim; | ||
126 | Type = Vehicle.TYPE_NONE; | ||
127 | } | ||
128 | |||
129 | // Return 'true' if this vehicle is doing vehicle things | ||
130 | public bool IsActive | ||
128 | { | 131 | { |
129 | m_prim = myPrim; | 132 | get { return Type != Vehicle.TYPE_NONE; } |
130 | m_type = Vehicle.TYPE_NONE; | ||
131 | } | 133 | } |
132 | 134 | ||
133 | internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue, float timestep) | 135 | internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) |
134 | { | 136 | { |
135 | DetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue); | 137 | VDetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", Prim.LocalID, pParam, pValue); |
136 | switch (pParam) | 138 | switch (pParam) |
137 | { | 139 | { |
138 | case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: | 140 | case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: |
139 | if (pValue < 0.01f) pValue = 0.01f; | 141 | // m_angularDeflectionEfficiency = Math.Max(pValue, 0.01f); |
140 | // m_angularDeflectionEfficiency = pValue; | ||
141 | break; | 142 | break; |
142 | case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: | 143 | case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: |
143 | if (pValue < 0.01f) pValue = 0.01f; | 144 | // m_angularDeflectionTimescale = Math.Max(pValue, 0.01f); |
144 | // m_angularDeflectionTimescale = pValue; | ||
145 | break; | 145 | break; |
146 | case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE: | 146 | case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE: |
147 | if (pValue < 0.01f) pValue = 0.01f; | 147 | m_angularMotorDecayTimescale = Math.Max(pValue, 0.01f); |
148 | m_angularMotorDecayTimescale = pValue; | ||
149 | break; | 148 | break; |
150 | case Vehicle.ANGULAR_MOTOR_TIMESCALE: | 149 | case Vehicle.ANGULAR_MOTOR_TIMESCALE: |
151 | if (pValue < 0.01f) pValue = 0.01f; | 150 | m_angularMotorTimescale = Math.Max(pValue, 0.01f); |
152 | m_angularMotorTimescale = pValue; | ||
153 | break; | 151 | break; |
154 | case Vehicle.BANKING_EFFICIENCY: | 152 | case Vehicle.BANKING_EFFICIENCY: |
155 | if (pValue < 0.01f) pValue = 0.01f; | 153 | // m_bankingEfficiency = Math.Max(pValue, 0.01f); |
156 | // m_bankingEfficiency = pValue; | ||
157 | break; | 154 | break; |
158 | case Vehicle.BANKING_MIX: | 155 | case Vehicle.BANKING_MIX: |
159 | if (pValue < 0.01f) pValue = 0.01f; | 156 | // m_bankingMix = Math.Max(pValue, 0.01f); |
160 | // m_bankingMix = pValue; | ||
161 | break; | 157 | break; |
162 | case Vehicle.BANKING_TIMESCALE: | 158 | case Vehicle.BANKING_TIMESCALE: |
163 | if (pValue < 0.01f) pValue = 0.01f; | 159 | // m_bankingTimescale = Math.Max(pValue, 0.01f); |
164 | // m_bankingTimescale = pValue; | ||
165 | break; | 160 | break; |
166 | case Vehicle.BUOYANCY: | 161 | case Vehicle.BUOYANCY: |
167 | if (pValue < -1f) pValue = -1f; | 162 | m_VehicleBuoyancy = Math.Max(-1f, Math.Min(pValue, 1f)); |
168 | if (pValue > 1f) pValue = 1f; | ||
169 | m_VehicleBuoyancy = pValue; | ||
170 | break; | 163 | break; |
171 | // case Vehicle.HOVER_EFFICIENCY: | 164 | // case Vehicle.HOVER_EFFICIENCY: |
172 | // if (pValue < 0f) pValue = 0f; | 165 | // m_VhoverEfficiency = Math.Max(0f, Math.Min(pValue, 1f)); |
173 | // if (pValue > 1f) pValue = 1f; | ||
174 | // m_VhoverEfficiency = pValue; | ||
175 | // break; | 166 | // break; |
176 | case Vehicle.HOVER_HEIGHT: | 167 | case Vehicle.HOVER_HEIGHT: |
177 | m_VhoverHeight = pValue; | 168 | m_VhoverHeight = pValue; |
178 | break; | 169 | break; |
179 | case Vehicle.HOVER_TIMESCALE: | 170 | case Vehicle.HOVER_TIMESCALE: |
180 | if (pValue < 0.01f) pValue = 0.01f; | 171 | m_VhoverTimescale = Math.Max(pValue, 0.01f); |
181 | m_VhoverTimescale = pValue; | ||
182 | break; | 172 | break; |
183 | case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: | 173 | case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: |
184 | if (pValue < 0.01f) pValue = 0.01f; | 174 | // m_linearDeflectionEfficiency = Math.Max(pValue, 0.01f); |
185 | // m_linearDeflectionEfficiency = pValue; | ||
186 | break; | 175 | break; |
187 | case Vehicle.LINEAR_DEFLECTION_TIMESCALE: | 176 | case Vehicle.LINEAR_DEFLECTION_TIMESCALE: |
188 | if (pValue < 0.01f) pValue = 0.01f; | 177 | // m_linearDeflectionTimescale = Math.Max(pValue, 0.01f); |
189 | // m_linearDeflectionTimescale = pValue; | ||
190 | break; | 178 | break; |
191 | case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: | 179 | case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: |
192 | if (pValue < 0.01f) pValue = 0.01f; | 180 | m_linearMotorDecayTimescale = Math.Max(pValue, 0.01f); |
193 | m_linearMotorDecayTimescale = pValue; | ||
194 | break; | 181 | break; |
195 | case Vehicle.LINEAR_MOTOR_TIMESCALE: | 182 | case Vehicle.LINEAR_MOTOR_TIMESCALE: |
196 | if (pValue < 0.01f) pValue = 0.01f; | 183 | m_linearMotorTimescale = Math.Max(pValue, 0.01f); |
197 | m_linearMotorTimescale = pValue; | ||
198 | break; | 184 | break; |
199 | case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY: | 185 | case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY: |
200 | if (pValue < 0.1f) pValue = 0.1f; // Less goes unstable | 186 | m_verticalAttractionEfficiency = Math.Max(0.1f, Math.Min(pValue, 1f)); |
201 | if (pValue > 1.0f) pValue = 1.0f; | ||
202 | m_verticalAttractionEfficiency = pValue; | ||
203 | break; | 187 | break; |
204 | case Vehicle.VERTICAL_ATTRACTION_TIMESCALE: | 188 | case Vehicle.VERTICAL_ATTRACTION_TIMESCALE: |
205 | if (pValue < 0.01f) pValue = 0.01f; | 189 | m_verticalAttractionTimescale = Math.Max(pValue, 0.01f); |
206 | m_verticalAttractionTimescale = pValue; | ||
207 | break; | 190 | break; |
208 | 191 | ||
209 | // These are vector properties but the engine lets you use a single float value to | 192 | // These are vector properties but the engine lets you use a single float value to |
@@ -229,9 +212,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
229 | } | 212 | } |
230 | }//end ProcessFloatVehicleParam | 213 | }//end ProcessFloatVehicleParam |
231 | 214 | ||
232 | internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue, float timestep) | 215 | internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue) |
233 | { | 216 | { |
234 | DetailLog("{0},ProcessVectorVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue); | 217 | VDetailLog("{0},ProcessVectorVehicleParam,param={1},val={2}", Prim.LocalID, pParam, pValue); |
235 | switch (pParam) | 218 | switch (pParam) |
236 | { | 219 | { |
237 | case Vehicle.ANGULAR_FRICTION_TIMESCALE: | 220 | case Vehicle.ANGULAR_FRICTION_TIMESCALE: |
@@ -266,7 +249,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
266 | 249 | ||
267 | internal void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue) | 250 | internal void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue) |
268 | { | 251 | { |
269 | DetailLog("{0},ProcessRotationalVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue); | 252 | VDetailLog("{0},ProcessRotationalVehicleParam,param={1},val={2}", Prim.LocalID, pParam, pValue); |
270 | switch (pParam) | 253 | switch (pParam) |
271 | { | 254 | { |
272 | case Vehicle.REFERENCE_FRAME: | 255 | case Vehicle.REFERENCE_FRAME: |
@@ -280,166 +263,29 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
280 | 263 | ||
281 | internal void ProcessVehicleFlags(int pParam, bool remove) | 264 | internal void ProcessVehicleFlags(int pParam, bool remove) |
282 | { | 265 | { |
283 | DetailLog("{0},ProcessVehicleFlags,param={1},remove={2}", m_prim.LocalID, pParam, remove); | 266 | VDetailLog("{0},ProcessVehicleFlags,param={1},remove={2}", Prim.LocalID, pParam, remove); |
267 | VehicleFlag parm = (VehicleFlag)pParam; | ||
284 | if (remove) | 268 | if (remove) |
285 | { | 269 | { |
286 | if (pParam == -1) | 270 | if (pParam == -1) |
287 | { | 271 | { |
288 | m_flags = (VehicleFlag)0; | 272 | m_flags = (VehicleFlag)0; |
289 | m_Hoverflags = (VehicleFlag)0; | ||
290 | return; | ||
291 | } | ||
292 | if ((pParam & (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) == (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) | ||
293 | { | ||
294 | if ((m_Hoverflags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != (VehicleFlag)0) | ||
295 | m_Hoverflags &= ~(VehicleFlag.HOVER_GLOBAL_HEIGHT); | ||
296 | } | ||
297 | if ((pParam & (int)VehicleFlag.HOVER_TERRAIN_ONLY) == (int)VehicleFlag.HOVER_TERRAIN_ONLY) | ||
298 | { | ||
299 | if ((m_Hoverflags & VehicleFlag.HOVER_TERRAIN_ONLY) != (VehicleFlag)0) | ||
300 | m_Hoverflags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY); | ||
301 | } | ||
302 | if ((pParam & (int)VehicleFlag.HOVER_UP_ONLY) == (int)VehicleFlag.HOVER_UP_ONLY) | ||
303 | { | ||
304 | if ((m_Hoverflags & VehicleFlag.HOVER_UP_ONLY) != (VehicleFlag)0) | ||
305 | m_Hoverflags &= ~(VehicleFlag.HOVER_UP_ONLY); | ||
306 | } | ||
307 | if ((pParam & (int)VehicleFlag.HOVER_WATER_ONLY) == (int)VehicleFlag.HOVER_WATER_ONLY) | ||
308 | { | ||
309 | if ((m_Hoverflags & VehicleFlag.HOVER_WATER_ONLY) != (VehicleFlag)0) | ||
310 | m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY); | ||
311 | } | ||
312 | if ((pParam & (int)VehicleFlag.LIMIT_MOTOR_UP) == (int)VehicleFlag.LIMIT_MOTOR_UP) | ||
313 | { | ||
314 | if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != (VehicleFlag)0) | ||
315 | m_flags &= ~(VehicleFlag.LIMIT_MOTOR_UP); | ||
316 | } | ||
317 | if ((pParam & (int)VehicleFlag.LIMIT_ROLL_ONLY) == (int)VehicleFlag.LIMIT_ROLL_ONLY) | ||
318 | { | ||
319 | if ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) != (VehicleFlag)0) | ||
320 | m_flags &= ~(VehicleFlag.LIMIT_ROLL_ONLY); | ||
321 | } | ||
322 | if ((pParam & (int)VehicleFlag.MOUSELOOK_BANK) == (int)VehicleFlag.MOUSELOOK_BANK) | ||
323 | { | ||
324 | if ((m_flags & VehicleFlag.MOUSELOOK_BANK) != (VehicleFlag)0) | ||
325 | m_flags &= ~(VehicleFlag.MOUSELOOK_BANK); | ||
326 | } | ||
327 | if ((pParam & (int)VehicleFlag.MOUSELOOK_STEER) == (int)VehicleFlag.MOUSELOOK_STEER) | ||
328 | { | ||
329 | if ((m_flags & VehicleFlag.MOUSELOOK_STEER) != (VehicleFlag)0) | ||
330 | m_flags &= ~(VehicleFlag.MOUSELOOK_STEER); | ||
331 | } | 273 | } |
332 | if ((pParam & (int)VehicleFlag.NO_DEFLECTION_UP) == (int)VehicleFlag.NO_DEFLECTION_UP) | 274 | else |
333 | { | ||
334 | if ((m_flags & VehicleFlag.NO_DEFLECTION_UP) != (VehicleFlag)0) | ||
335 | m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP); | ||
336 | } | ||
337 | if ((pParam & (int)VehicleFlag.CAMERA_DECOUPLED) == (int)VehicleFlag.CAMERA_DECOUPLED) | ||
338 | { | ||
339 | if ((m_flags & VehicleFlag.CAMERA_DECOUPLED) != (VehicleFlag)0) | ||
340 | m_flags &= ~(VehicleFlag.CAMERA_DECOUPLED); | ||
341 | } | ||
342 | if ((pParam & (int)VehicleFlag.NO_X) == (int)VehicleFlag.NO_X) | ||
343 | { | ||
344 | if ((m_flags & VehicleFlag.NO_X) != (VehicleFlag)0) | ||
345 | m_flags &= ~(VehicleFlag.NO_X); | ||
346 | } | ||
347 | if ((pParam & (int)VehicleFlag.NO_Y) == (int)VehicleFlag.NO_Y) | ||
348 | { | ||
349 | if ((m_flags & VehicleFlag.NO_Y) != (VehicleFlag)0) | ||
350 | m_flags &= ~(VehicleFlag.NO_Y); | ||
351 | } | ||
352 | if ((pParam & (int)VehicleFlag.NO_Z) == (int)VehicleFlag.NO_Z) | ||
353 | { | ||
354 | if ((m_flags & VehicleFlag.NO_Z) != (VehicleFlag)0) | ||
355 | m_flags &= ~(VehicleFlag.NO_Z); | ||
356 | } | ||
357 | if ((pParam & (int)VehicleFlag.LOCK_HOVER_HEIGHT) == (int)VehicleFlag.LOCK_HOVER_HEIGHT) | ||
358 | { | ||
359 | if ((m_Hoverflags & VehicleFlag.LOCK_HOVER_HEIGHT) != (VehicleFlag)0) | ||
360 | m_Hoverflags &= ~(VehicleFlag.LOCK_HOVER_HEIGHT); | ||
361 | } | ||
362 | if ((pParam & (int)VehicleFlag.NO_DEFLECTION) == (int)VehicleFlag.NO_DEFLECTION) | ||
363 | { | ||
364 | if ((m_flags & VehicleFlag.NO_DEFLECTION) != (VehicleFlag)0) | ||
365 | m_flags &= ~(VehicleFlag.NO_DEFLECTION); | ||
366 | } | ||
367 | if ((pParam & (int)VehicleFlag.LOCK_ROTATION) == (int)VehicleFlag.LOCK_ROTATION) | ||
368 | { | 275 | { |
369 | if ((m_flags & VehicleFlag.LOCK_ROTATION) != (VehicleFlag)0) | 276 | m_flags &= ~parm; |
370 | m_flags &= ~(VehicleFlag.LOCK_ROTATION); | ||
371 | } | 277 | } |
372 | } | 278 | } |
373 | else | 279 | else { |
374 | { | 280 | m_flags |= parm; |
375 | if ((pParam & (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) == (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) | ||
376 | { | ||
377 | m_Hoverflags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT | m_flags); | ||
378 | } | ||
379 | if ((pParam & (int)VehicleFlag.HOVER_TERRAIN_ONLY) == (int)VehicleFlag.HOVER_TERRAIN_ONLY) | ||
380 | { | ||
381 | m_Hoverflags |= (VehicleFlag.HOVER_TERRAIN_ONLY | m_flags); | ||
382 | } | ||
383 | if ((pParam & (int)VehicleFlag.HOVER_UP_ONLY) == (int)VehicleFlag.HOVER_UP_ONLY) | ||
384 | { | ||
385 | m_Hoverflags |= (VehicleFlag.HOVER_UP_ONLY | m_flags); | ||
386 | } | ||
387 | if ((pParam & (int)VehicleFlag.HOVER_WATER_ONLY) == (int)VehicleFlag.HOVER_WATER_ONLY) | ||
388 | { | ||
389 | m_Hoverflags |= (VehicleFlag.HOVER_WATER_ONLY | m_flags); | ||
390 | } | ||
391 | if ((pParam & (int)VehicleFlag.LIMIT_MOTOR_UP) == (int)VehicleFlag.LIMIT_MOTOR_UP) | ||
392 | { | ||
393 | m_flags |= (VehicleFlag.LIMIT_MOTOR_UP | m_flags); | ||
394 | } | ||
395 | if ((pParam & (int)VehicleFlag.MOUSELOOK_BANK) == (int)VehicleFlag.MOUSELOOK_BANK) | ||
396 | { | ||
397 | m_flags |= (VehicleFlag.MOUSELOOK_BANK | m_flags); | ||
398 | } | ||
399 | if ((pParam & (int)VehicleFlag.MOUSELOOK_STEER) == (int)VehicleFlag.MOUSELOOK_STEER) | ||
400 | { | ||
401 | m_flags |= (VehicleFlag.MOUSELOOK_STEER | m_flags); | ||
402 | } | ||
403 | if ((pParam & (int)VehicleFlag.NO_DEFLECTION_UP) == (int)VehicleFlag.NO_DEFLECTION_UP) | ||
404 | { | ||
405 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | m_flags); | ||
406 | } | ||
407 | if ((pParam & (int)VehicleFlag.CAMERA_DECOUPLED) == (int)VehicleFlag.CAMERA_DECOUPLED) | ||
408 | { | ||
409 | m_flags |= (VehicleFlag.CAMERA_DECOUPLED | m_flags); | ||
410 | } | ||
411 | if ((pParam & (int)VehicleFlag.NO_X) == (int)VehicleFlag.NO_X) | ||
412 | { | ||
413 | m_flags |= (VehicleFlag.NO_X); | ||
414 | } | ||
415 | if ((pParam & (int)VehicleFlag.NO_Y) == (int)VehicleFlag.NO_Y) | ||
416 | { | ||
417 | m_flags |= (VehicleFlag.NO_Y); | ||
418 | } | ||
419 | if ((pParam & (int)VehicleFlag.NO_Z) == (int)VehicleFlag.NO_Z) | ||
420 | { | ||
421 | m_flags |= (VehicleFlag.NO_Z); | ||
422 | } | ||
423 | if ((pParam & (int)VehicleFlag.LOCK_HOVER_HEIGHT) == (int)VehicleFlag.LOCK_HOVER_HEIGHT) | ||
424 | { | ||
425 | m_Hoverflags |= (VehicleFlag.LOCK_HOVER_HEIGHT); | ||
426 | } | ||
427 | if ((pParam & (int)VehicleFlag.NO_DEFLECTION) == (int)VehicleFlag.NO_DEFLECTION) | ||
428 | { | ||
429 | m_flags |= (VehicleFlag.NO_DEFLECTION); | ||
430 | } | ||
431 | if ((pParam & (int)VehicleFlag.LOCK_ROTATION) == (int)VehicleFlag.LOCK_ROTATION) | ||
432 | { | ||
433 | m_flags |= (VehicleFlag.LOCK_ROTATION); | ||
434 | } | ||
435 | } | 281 | } |
436 | }//end ProcessVehicleFlags | 282 | }//end ProcessVehicleFlags |
437 | 283 | ||
438 | internal void ProcessTypeChange(Vehicle pType) | 284 | internal void ProcessTypeChange(Vehicle pType) |
439 | { | 285 | { |
440 | DetailLog("{0},ProcessTypeChange,type={1}", m_prim.LocalID, pType); | 286 | VDetailLog("{0},ProcessTypeChange,type={1}", Prim.LocalID, pType); |
441 | // Set Defaults For Type | 287 | // Set Defaults For Type |
442 | m_type = pType; | 288 | Type = pType; |
443 | switch (pType) | 289 | switch (pType) |
444 | { | 290 | { |
445 | case Vehicle.TYPE_NONE: | 291 | case Vehicle.TYPE_NONE: |
@@ -478,10 +324,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
478 | // m_bankingMix = 1; | 324 | // m_bankingMix = 1; |
479 | // m_bankingTimescale = 10; | 325 | // m_bankingTimescale = 10; |
480 | // m_referenceFrame = Quaternion.Identity; | 326 | // m_referenceFrame = Quaternion.Identity; |
481 | m_Hoverflags &= | 327 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); |
328 | m_flags &= | ||
482 | ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | | 329 | ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | |
483 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); | 330 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); |
484 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); | ||
485 | break; | 331 | break; |
486 | case Vehicle.TYPE_CAR: | 332 | case Vehicle.TYPE_CAR: |
487 | m_linearFrictionTimescale = new Vector3(100, 2, 1000); | 333 | m_linearFrictionTimescale = new Vector3(100, 2, 1000); |
@@ -506,10 +352,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
506 | // m_bankingMix = 1; | 352 | // m_bankingMix = 1; |
507 | // m_bankingTimescale = 1; | 353 | // m_bankingTimescale = 1; |
508 | // m_referenceFrame = Quaternion.Identity; | 354 | // m_referenceFrame = Quaternion.Identity; |
509 | m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); | 355 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP |
510 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | | 356 | | VehicleFlag.LIMIT_ROLL_ONLY |
511 | VehicleFlag.LIMIT_MOTOR_UP); | 357 | | VehicleFlag.LIMIT_MOTOR_UP); |
512 | m_Hoverflags |= (VehicleFlag.HOVER_UP_ONLY); | 358 | m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); |
359 | m_flags |= (VehicleFlag.HOVER_UP_ONLY); | ||
513 | break; | 360 | break; |
514 | case Vehicle.TYPE_BOAT: | 361 | case Vehicle.TYPE_BOAT: |
515 | m_linearFrictionTimescale = new Vector3(10, 3, 2); | 362 | m_linearFrictionTimescale = new Vector3(10, 3, 2); |
@@ -534,12 +381,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
534 | // m_bankingMix = 0.8f; | 381 | // m_bankingMix = 0.8f; |
535 | // m_bankingTimescale = 1; | 382 | // m_bankingTimescale = 1; |
536 | // m_referenceFrame = Quaternion.Identity; | 383 | // m_referenceFrame = Quaternion.Identity; |
537 | m_Hoverflags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | | 384 | m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY |
538 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); | 385 | | VehicleFlag.HOVER_GLOBAL_HEIGHT |
539 | m_flags &= ~(VehicleFlag.LIMIT_ROLL_ONLY); | 386 | | VehicleFlag.LIMIT_ROLL_ONLY |
540 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | | 387 | | VehicleFlag.HOVER_UP_ONLY); |
541 | VehicleFlag.LIMIT_MOTOR_UP); | 388 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP |
542 | m_Hoverflags |= (VehicleFlag.HOVER_WATER_ONLY); | 389 | | VehicleFlag.LIMIT_MOTOR_UP |
390 | | VehicleFlag.HOVER_WATER_ONLY); | ||
543 | break; | 391 | break; |
544 | case Vehicle.TYPE_AIRPLANE: | 392 | case Vehicle.TYPE_AIRPLANE: |
545 | m_linearFrictionTimescale = new Vector3(200, 10, 5); | 393 | m_linearFrictionTimescale = new Vector3(200, 10, 5); |
@@ -564,9 +412,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
564 | // m_bankingMix = 0.7f; | 412 | // m_bankingMix = 0.7f; |
565 | // m_bankingTimescale = 2; | 413 | // m_bankingTimescale = 2; |
566 | // m_referenceFrame = Quaternion.Identity; | 414 | // m_referenceFrame = Quaternion.Identity; |
567 | m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | | 415 | m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY |
568 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); | 416 | | VehicleFlag.HOVER_TERRAIN_ONLY |
569 | m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); | 417 | | VehicleFlag.HOVER_GLOBAL_HEIGHT |
418 | | VehicleFlag.HOVER_UP_ONLY | ||
419 | | VehicleFlag.NO_DEFLECTION_UP | ||
420 | | VehicleFlag.LIMIT_MOTOR_UP); | ||
570 | m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); | 421 | m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); |
571 | break; | 422 | break; |
572 | case Vehicle.TYPE_BALLOON: | 423 | case Vehicle.TYPE_BALLOON: |
@@ -592,50 +443,66 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
592 | // m_bankingMix = 0.7f; | 443 | // m_bankingMix = 0.7f; |
593 | // m_bankingTimescale = 5; | 444 | // m_bankingTimescale = 5; |
594 | // m_referenceFrame = Quaternion.Identity; | 445 | // m_referenceFrame = Quaternion.Identity; |
595 | m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | | 446 | m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY |
596 | VehicleFlag.HOVER_UP_ONLY); | 447 | | VehicleFlag.HOVER_TERRAIN_ONLY |
597 | m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); | 448 | | VehicleFlag.HOVER_UP_ONLY |
598 | m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); | 449 | | VehicleFlag.NO_DEFLECTION_UP |
599 | m_Hoverflags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT); | 450 | | VehicleFlag.LIMIT_MOTOR_UP); |
451 | m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY | ||
452 | | VehicleFlag.HOVER_GLOBAL_HEIGHT); | ||
600 | break; | 453 | break; |
601 | } | 454 | } |
602 | }//end SetDefaultsForType | 455 | }//end SetDefaultsForType |
603 | 456 | ||
604 | internal void Step(float pTimestep) | 457 | // Some of the properties of this prim may have changed. |
458 | // Do any updating needed for a vehicle | ||
459 | public void Refresh() | ||
605 | { | 460 | { |
606 | if (m_type == Vehicle.TYPE_NONE) return; | 461 | if (!IsActive) |
462 | return; | ||
463 | |||
464 | // Set the prim's inertia to zero. The vehicle code handles that and this | ||
465 | // removes the torque action introduced by Bullet. | ||
466 | Vector3 inertia = Vector3.Zero; | ||
467 | BulletSimAPI.SetMassProps2(Prim.BSBody.ptr, Prim.MassRaw, inertia); | ||
468 | BulletSimAPI.UpdateInertiaTensor2(Prim.BSBody.ptr); | ||
469 | } | ||
607 | 470 | ||
608 | frcount++; // used to limit debug comment output | 471 | // One step of the vehicle properties for the next 'pTimestep' seconds. |
609 | if (frcount > 100) | 472 | internal void Step(float pTimestep) |
610 | frcount = 0; | 473 | { |
474 | if (!IsActive) return; | ||
611 | 475 | ||
612 | MoveLinear(pTimestep); | 476 | MoveLinear(pTimestep); |
613 | MoveAngular(pTimestep); | 477 | MoveAngular(pTimestep); |
614 | LimitRotation(pTimestep); | 478 | LimitRotation(pTimestep); |
615 | 479 | ||
616 | DetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", | 480 | // remember the position so next step we can limit absolute movement effects |
617 | m_prim.LocalID, m_prim.Position, m_prim.Force, m_prim.Velocity, m_prim.RotationalVelocity); | 481 | m_lastPositionVector = Prim.ForcePosition; |
482 | |||
483 | VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", | ||
484 | Prim.LocalID, Prim.Position, Prim.Force, Prim.Velocity, Prim.RotationalVelocity); | ||
618 | }// end Step | 485 | }// end Step |
619 | 486 | ||
487 | // Apply the effect of the linear motor. | ||
488 | // Also does hover and float. | ||
620 | private void MoveLinear(float pTimestep) | 489 | private void MoveLinear(float pTimestep) |
621 | { | 490 | { |
622 | // requested m_linearMotorDirection is significant | 491 | // m_linearMotorDirection is the direction we are moving relative to the vehicle coordinates |
623 | // if (!m_linearMotorDirection.ApproxEquals(Vector3.Zero, 0.01f)) | 492 | // m_lastLinearVelocityVector is the speed we are moving in that direction |
624 | if (m_linearMotorDirection.LengthSquared() > 0.0001f) | 493 | if (m_linearMotorDirection.LengthSquared() > 0.001f) |
625 | { | 494 | { |
626 | Vector3 origDir = m_linearMotorDirection; | 495 | Vector3 origDir = m_linearMotorDirection; |
627 | Vector3 origVel = m_lastLinearVelocityVector; | 496 | Vector3 origVel = m_lastLinearVelocityVector; |
628 | 497 | ||
629 | // add drive to body | 498 | // add drive to body |
630 | // Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale/pTimestep); | 499 | // Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale / pTimestep); |
631 | Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale); | 500 | Vector3 addAmount = (m_linearMotorDirection - m_lastLinearVelocityVector)/(m_linearMotorTimescale / pTimestep); |
632 | // lastLinearVelocityVector is the current body velocity vector? | 501 | // lastLinearVelocityVector is the current body velocity vector |
633 | // RA: Not sure what the *10 is for. A correction for pTimestep? | 502 | // RA: Not sure what the *10 is for. A correction for pTimestep? |
634 | // m_lastLinearVelocityVector += (addAmount*10); | 503 | // m_lastLinearVelocityVector += (addAmount*10); |
635 | m_lastLinearVelocityVector += addAmount; | 504 | m_lastLinearVelocityVector += addAmount; |
636 | 505 | ||
637 | // This will work temporarily, but we really need to compare speed on an axis | ||
638 | // KF: Limit body velocity to applied velocity? | ||
639 | // Limit the velocity vector to less than the last set linear motor direction | 506 | // Limit the velocity vector to less than the last set linear motor direction |
640 | if (Math.Abs(m_lastLinearVelocityVector.X) > Math.Abs(m_linearMotorDirectionLASTSET.X)) | 507 | if (Math.Abs(m_lastLinearVelocityVector.X) > Math.Abs(m_linearMotorDirectionLASTSET.X)) |
641 | m_lastLinearVelocityVector.X = m_linearMotorDirectionLASTSET.X; | 508 | m_lastLinearVelocityVector.X = m_linearMotorDirectionLASTSET.X; |
@@ -644,124 +511,87 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
644 | if (Math.Abs(m_lastLinearVelocityVector.Z) > Math.Abs(m_linearMotorDirectionLASTSET.Z)) | 511 | if (Math.Abs(m_lastLinearVelocityVector.Z) > Math.Abs(m_linearMotorDirectionLASTSET.Z)) |
645 | m_lastLinearVelocityVector.Z = m_linearMotorDirectionLASTSET.Z; | 512 | m_lastLinearVelocityVector.Z = m_linearMotorDirectionLASTSET.Z; |
646 | 513 | ||
514 | /* | ||
647 | // decay applied velocity | 515 | // decay applied velocity |
648 | Vector3 decayfraction = ((Vector3.One/(m_linearMotorDecayTimescale/pTimestep))); | 516 | Vector3 decayfraction = Vector3.One/(m_linearMotorDecayTimescale / pTimestep); |
517 | // (RA: do not know where the 0.5f comes from) | ||
649 | m_linearMotorDirection -= m_linearMotorDirection * decayfraction * 0.5f; | 518 | m_linearMotorDirection -= m_linearMotorDirection * decayfraction * 0.5f; |
650 | |||
651 | /* | ||
652 | Vector3 addAmount = (m_linearMotorDirection - m_lastLinearVelocityVector)/m_linearMotorTimescale; | ||
653 | m_lastLinearVelocityVector += addAmount; | ||
654 | |||
655 | float decayfraction = (1.0f - 1.0f / m_linearMotorDecayTimescale); | ||
656 | m_linearMotorDirection *= decayfraction; | ||
657 | |||
658 | */ | 519 | */ |
520 | float keepfraction = 1.0f - (1.0f / (m_linearMotorDecayTimescale / pTimestep)); | ||
521 | m_linearMotorDirection *= keepfraction; | ||
659 | 522 | ||
660 | DetailLog("{0},MoveLinear,nonZero,origdir={1},origvel={2},add={3},decay={4},dir={5},vel={6}", | 523 | VDetailLog("{0},MoveLinear,nonZero,origdir={1},origvel={2},add={3},notDecay={4},dir={5},vel={6}", |
661 | m_prim.LocalID, origDir, origVel, addAmount, decayfraction, m_linearMotorDirection, m_lastLinearVelocityVector); | 524 | Prim.LocalID, origDir, origVel, addAmount, keepfraction, m_linearMotorDirection, m_lastLinearVelocityVector); |
662 | } | 525 | } |
663 | else | 526 | else |
664 | { | 527 | { |
665 | // if what remains of applied is small, zero it. | 528 | // if what remains of direction is very small, zero it. |
666 | // if (m_lastLinearVelocityVector.ApproxEquals(Vector3.Zero, 0.01f)) | ||
667 | // m_lastLinearVelocityVector = Vector3.Zero; | ||
668 | m_linearMotorDirection = Vector3.Zero; | 529 | m_linearMotorDirection = Vector3.Zero; |
669 | m_lastLinearVelocityVector = Vector3.Zero; | 530 | m_lastLinearVelocityVector = Vector3.Zero; |
531 | VDetailLog("{0},MoveLinear,zeroed", Prim.LocalID); | ||
670 | } | 532 | } |
671 | 533 | ||
672 | // convert requested object velocity to world-referenced vector | 534 | // convert requested object velocity to object relative vector |
673 | Quaternion rotq = m_prim.Orientation; | 535 | Quaternion rotq = Prim.ForceOrientation; |
674 | m_dir = m_lastLinearVelocityVector * rotq; | 536 | m_newVelocity = m_lastLinearVelocityVector * rotq; |
675 | 537 | ||
676 | // Add the various forces into m_dir which will be our new direction vector (velocity) | 538 | // Add the various forces into m_dir which will be our new direction vector (velocity) |
677 | 539 | ||
678 | // add Gravity and Buoyancy | 540 | // add Gravity and Buoyancy |
679 | // KF: So far I have found no good method to combine a script-requested | ||
680 | // .Z velocity and gravity. Therefore only 0g will used script-requested | ||
681 | // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only. | ||
682 | Vector3 grav = Vector3.Zero; | ||
683 | // There is some gravity, make a gravity force vector that is applied after object velocity. | 541 | // There is some gravity, make a gravity force vector that is applied after object velocity. |
684 | // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g; | 542 | // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g; |
685 | grav.Z = m_prim.Scene.DefaultGravity.Z * m_prim.Mass * (1f - m_VehicleBuoyancy); | 543 | Vector3 grav = Prim.PhysicsScene.DefaultGravity * (Prim.Mass * (1f - m_VehicleBuoyancy)); |
544 | |||
545 | /* | ||
546 | * RA: Not sure why one would do this | ||
686 | // Preserve the current Z velocity | 547 | // Preserve the current Z velocity |
687 | Vector3 vel_now = m_prim.Velocity; | 548 | Vector3 vel_now = m_prim.Velocity; |
688 | m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity | 549 | m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity |
550 | */ | ||
689 | 551 | ||
690 | Vector3 pos = m_prim.Position; | 552 | Vector3 pos = Prim.ForcePosition; |
691 | Vector3 posChange = pos; | ||
692 | // Vector3 accel = new Vector3(-(m_dir.X - m_lastLinearVelocityVector.X / 0.1f), -(m_dir.Y - m_lastLinearVelocityVector.Y / 0.1f), m_dir.Z - m_lastLinearVelocityVector.Z / 0.1f); | 553 | // Vector3 accel = new Vector3(-(m_dir.X - m_lastLinearVelocityVector.X / 0.1f), -(m_dir.Y - m_lastLinearVelocityVector.Y / 0.1f), m_dir.Z - m_lastLinearVelocityVector.Z / 0.1f); |
693 | double Zchange = Math.Abs(posChange.Z); | ||
694 | if (m_BlockingEndPoint != Vector3.Zero) | ||
695 | { | ||
696 | bool changed = false; | ||
697 | if (pos.X >= (m_BlockingEndPoint.X - (float)1)) | ||
698 | { | ||
699 | pos.X -= posChange.X + 1; | ||
700 | changed = true; | ||
701 | } | ||
702 | if (pos.Y >= (m_BlockingEndPoint.Y - (float)1)) | ||
703 | { | ||
704 | pos.Y -= posChange.Y + 1; | ||
705 | changed = true; | ||
706 | } | ||
707 | if (pos.Z >= (m_BlockingEndPoint.Z - (float)1)) | ||
708 | { | ||
709 | pos.Z -= posChange.Z + 1; | ||
710 | changed = true; | ||
711 | } | ||
712 | if (pos.X <= 0) | ||
713 | { | ||
714 | pos.X += posChange.X + 1; | ||
715 | changed = true; | ||
716 | } | ||
717 | if (pos.Y <= 0) | ||
718 | { | ||
719 | pos.Y += posChange.Y + 1; | ||
720 | changed = true; | ||
721 | } | ||
722 | if (changed) | ||
723 | { | ||
724 | m_prim.Position = pos; | ||
725 | DetailLog("{0},MoveLinear,blockingEndPoint,block={1},origPos={2},pos={3}", | ||
726 | m_prim.LocalID, m_BlockingEndPoint, posChange, pos); | ||
727 | } | ||
728 | } | ||
729 | 554 | ||
730 | // If below the terrain, move us above the ground a little. | 555 | // If below the terrain, move us above the ground a little. |
731 | if (pos.Z < m_prim.Scene.GetTerrainHeightAtXYZ(pos)) | 556 | float terrainHeight = Prim.PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos); |
557 | // Taking the rotated size doesn't work here because m_prim.Size is the size of the root prim and not the linkset. | ||
558 | // Need to add a m_prim.LinkSet.Size similar to m_prim.LinkSet.Mass. | ||
559 | // Vector3 rotatedSize = m_prim.Size * m_prim.ForceOrientation; | ||
560 | // if (rotatedSize.Z < terrainHeight) | ||
561 | if (pos.Z < terrainHeight) | ||
732 | { | 562 | { |
733 | pos.Z = m_prim.Scene.GetTerrainHeightAtXYZ(pos) + 2; | 563 | pos.Z = terrainHeight + 2; |
734 | m_prim.Position = pos; | 564 | Prim.ForcePosition = pos; |
735 | DetailLog("{0},MoveLinear,terrainHeight,pos={1}", m_prim.LocalID, pos); | 565 | VDetailLog("{0},MoveLinear,terrainHeight,terrainHeight={1},pos={2}", Prim.LocalID, terrainHeight, pos); |
736 | } | 566 | } |
737 | 567 | ||
738 | // Check if hovering | 568 | // Check if hovering |
739 | if ((m_Hoverflags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0) | 569 | if ((m_flags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0) |
740 | { | 570 | { |
741 | // We should hover, get the target height | 571 | // We should hover, get the target height |
742 | if ((m_Hoverflags & VehicleFlag.HOVER_WATER_ONLY) != 0) | 572 | if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) != 0) |
743 | { | 573 | { |
744 | m_VhoverTargetHeight = m_prim.Scene.GetWaterLevel() + m_VhoverHeight; | 574 | m_VhoverTargetHeight = Prim.PhysicsScene.GetWaterLevelAtXYZ(pos) + m_VhoverHeight; |
745 | } | 575 | } |
746 | if ((m_Hoverflags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0) | 576 | if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0) |
747 | { | 577 | { |
748 | m_VhoverTargetHeight = m_prim.Scene.GetTerrainHeightAtXY(pos.X, pos.Y) + m_VhoverHeight; | 578 | m_VhoverTargetHeight = terrainHeight + m_VhoverHeight; |
749 | } | 579 | } |
750 | if ((m_Hoverflags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != 0) | 580 | if ((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != 0) |
751 | { | 581 | { |
752 | m_VhoverTargetHeight = m_VhoverHeight; | 582 | m_VhoverTargetHeight = m_VhoverHeight; |
753 | } | 583 | } |
754 | 584 | ||
755 | if ((m_Hoverflags & VehicleFlag.HOVER_UP_ONLY) != 0) | 585 | if ((m_flags & VehicleFlag.HOVER_UP_ONLY) != 0) |
756 | { | 586 | { |
757 | // If body is aready heigher, use its height as target height | 587 | // If body is aready heigher, use its height as target height |
758 | if (pos.Z > m_VhoverTargetHeight) m_VhoverTargetHeight = pos.Z; | 588 | if (pos.Z > m_VhoverTargetHeight) m_VhoverTargetHeight = pos.Z; |
759 | } | 589 | } |
760 | if ((m_Hoverflags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0) | 590 | if ((m_flags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0) |
761 | { | 591 | { |
762 | if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2) | 592 | if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2) |
763 | { | 593 | { |
764 | m_prim.Position = pos; | 594 | Prim.ForcePosition = pos; |
765 | } | 595 | } |
766 | } | 596 | } |
767 | else | 597 | else |
@@ -770,85 +600,99 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
770 | // Replace Vertical speed with correction figure if significant | 600 | // Replace Vertical speed with correction figure if significant |
771 | if (Math.Abs(herr0) > 0.01f) | 601 | if (Math.Abs(herr0) > 0.01f) |
772 | { | 602 | { |
773 | m_dir.Z = -((herr0 * pTimestep * 50.0f) / m_VhoverTimescale); | 603 | m_newVelocity.Z = -((herr0 * pTimestep * 50.0f) / m_VhoverTimescale); |
774 | //KF: m_VhoverEfficiency is not yet implemented | 604 | //KF: m_VhoverEfficiency is not yet implemented |
775 | } | 605 | } |
776 | else | 606 | else |
777 | { | 607 | { |
778 | m_dir.Z = 0f; | 608 | m_newVelocity.Z = 0f; |
779 | } | 609 | } |
780 | } | 610 | } |
781 | 611 | ||
782 | DetailLog("{0},MoveLinear,hover,pos={1},dir={2},height={3},target={4}", m_prim.LocalID, pos, m_dir, m_VhoverHeight, m_VhoverTargetHeight); | 612 | VDetailLog("{0},MoveLinear,hover,pos={1},dir={2},height={3},target={4}", Prim.LocalID, pos, m_newVelocity, m_VhoverHeight, m_VhoverTargetHeight); |
613 | } | ||
783 | 614 | ||
784 | // m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped | 615 | Vector3 posChange = pos - m_lastPositionVector; |
785 | // m_VhoverTimescale = 0f; // time to acheive height | 616 | if (m_BlockingEndPoint != Vector3.Zero) |
786 | // pTimestep is time since last frame,in secs | 617 | { |
618 | bool changed = false; | ||
619 | if (pos.X >= (m_BlockingEndPoint.X - (float)1)) | ||
620 | { | ||
621 | pos.X -= posChange.X + 1; | ||
622 | changed = true; | ||
623 | } | ||
624 | if (pos.Y >= (m_BlockingEndPoint.Y - (float)1)) | ||
625 | { | ||
626 | pos.Y -= posChange.Y + 1; | ||
627 | changed = true; | ||
628 | } | ||
629 | if (pos.Z >= (m_BlockingEndPoint.Z - (float)1)) | ||
630 | { | ||
631 | pos.Z -= posChange.Z + 1; | ||
632 | changed = true; | ||
633 | } | ||
634 | if (pos.X <= 0) | ||
635 | { | ||
636 | pos.X += posChange.X + 1; | ||
637 | changed = true; | ||
638 | } | ||
639 | if (pos.Y <= 0) | ||
640 | { | ||
641 | pos.Y += posChange.Y + 1; | ||
642 | changed = true; | ||
643 | } | ||
644 | if (changed) | ||
645 | { | ||
646 | Prim.ForcePosition = pos; | ||
647 | VDetailLog("{0},MoveLinear,blockingEndPoint,block={1},origPos={2},pos={3}", | ||
648 | Prim.LocalID, m_BlockingEndPoint, posChange, pos); | ||
649 | } | ||
787 | } | 650 | } |
788 | 651 | ||
652 | // Limit absolute vertical change | ||
653 | float Zchange = Math.Abs(posChange.Z); | ||
789 | if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0) | 654 | if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0) |
790 | { | 655 | { |
791 | //Start Experimental Values | ||
792 | if (Zchange > .3) | 656 | if (Zchange > .3) |
793 | { | ||
794 | grav.Z = (float)(grav.Z * 3); | 657 | grav.Z = (float)(grav.Z * 3); |
795 | } | ||
796 | if (Zchange > .15) | 658 | if (Zchange > .15) |
797 | { | ||
798 | grav.Z = (float)(grav.Z * 2); | 659 | grav.Z = (float)(grav.Z * 2); |
799 | } | ||
800 | if (Zchange > .75) | 660 | if (Zchange > .75) |
801 | { | ||
802 | grav.Z = (float)(grav.Z * 1.5); | 661 | grav.Z = (float)(grav.Z * 1.5); |
803 | } | ||
804 | if (Zchange > .05) | 662 | if (Zchange > .05) |
805 | { | ||
806 | grav.Z = (float)(grav.Z * 1.25); | 663 | grav.Z = (float)(grav.Z * 1.25); |
807 | } | ||
808 | if (Zchange > .025) | 664 | if (Zchange > .025) |
809 | { | ||
810 | grav.Z = (float)(grav.Z * 1.125); | 665 | grav.Z = (float)(grav.Z * 1.125); |
811 | } | 666 | float postemp = (pos.Z - terrainHeight); |
812 | float terraintemp = m_prim.Scene.GetTerrainHeightAtXYZ(pos); | ||
813 | float postemp = (pos.Z - terraintemp); | ||
814 | if (postemp > 2.5f) | 667 | if (postemp > 2.5f) |
815 | { | ||
816 | grav.Z = (float)(grav.Z * 1.037125); | 668 | grav.Z = (float)(grav.Z * 1.037125); |
817 | } | 669 | VDetailLog("{0},MoveLinear,limitMotorUp,grav={1}", Prim.LocalID, grav); |
818 | DetailLog("{0},MoveLinear,limitMotorUp,grav={1}", m_prim.LocalID, grav); | ||
819 | //End Experimental Values | ||
820 | } | 670 | } |
671 | |||
672 | // If not changing some axis, reduce out velocity | ||
821 | if ((m_flags & (VehicleFlag.NO_X)) != 0) | 673 | if ((m_flags & (VehicleFlag.NO_X)) != 0) |
822 | { | 674 | m_newVelocity.X = 0; |
823 | m_dir.X = 0; | ||
824 | } | ||
825 | if ((m_flags & (VehicleFlag.NO_Y)) != 0) | 675 | if ((m_flags & (VehicleFlag.NO_Y)) != 0) |
826 | { | 676 | m_newVelocity.Y = 0; |
827 | m_dir.Y = 0; | ||
828 | } | ||
829 | if ((m_flags & (VehicleFlag.NO_Z)) != 0) | 677 | if ((m_flags & (VehicleFlag.NO_Z)) != 0) |
830 | { | 678 | m_newVelocity.Z = 0; |
831 | m_dir.Z = 0; | ||
832 | } | ||
833 | |||
834 | m_lastPositionVector = m_prim.Position; | ||
835 | 679 | ||
836 | // Apply velocity | 680 | // Apply velocity |
837 | m_prim.Velocity = m_dir; | 681 | Prim.Velocity = m_newVelocity; |
838 | // apply gravity force | 682 | // apply gravity force |
839 | // Why is this set here? The physics engine already does gravity. | 683 | // Why is this set here? The physics engine already does gravity. |
840 | // m_prim.AddForce(grav, false); | 684 | // m_prim.AddForce(grav, false); |
841 | // m_prim.Force = grav; | ||
842 | 685 | ||
843 | // Apply friction | 686 | // Apply friction |
844 | Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep); | 687 | Vector3 keepFraction = Vector3.One - (Vector3.One / (m_linearFrictionTimescale / pTimestep)); |
845 | m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount; | 688 | m_lastLinearVelocityVector *= keepFraction; |
846 | 689 | ||
847 | DetailLog("{0},MoveLinear,done,pos={1},vel={2},force={3},decay={4}", | 690 | VDetailLog("{0},MoveLinear,done,lmDir={1},lmVel={2},newVel={3},grav={4},1Mdecay={5}", |
848 | m_prim.LocalID, m_lastPositionVector, m_dir, grav, decayamount); | 691 | Prim.LocalID, m_linearMotorDirection, m_lastLinearVelocityVector, m_newVelocity, grav, keepFraction); |
849 | 692 | ||
850 | } // end MoveLinear() | 693 | } // end MoveLinear() |
851 | 694 | ||
695 | // Apply the effect of the angular motor. | ||
852 | private void MoveAngular(float pTimestep) | 696 | private void MoveAngular(float pTimestep) |
853 | { | 697 | { |
854 | // m_angularMotorDirection // angular velocity requested by LSL motor | 698 | // m_angularMotorDirection // angular velocity requested by LSL motor |
@@ -860,7 +704,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
860 | // m_lastAngularVelocity // what was last applied to body | 704 | // m_lastAngularVelocity // what was last applied to body |
861 | 705 | ||
862 | // Get what the body is doing, this includes 'external' influences | 706 | // Get what the body is doing, this includes 'external' influences |
863 | Vector3 angularVelocity = m_prim.RotationalVelocity; | 707 | Vector3 angularVelocity = Prim.RotationalVelocity; |
864 | 708 | ||
865 | if (m_angularMotorApply > 0) | 709 | if (m_angularMotorApply > 0) |
866 | { | 710 | { |
@@ -868,48 +712,58 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
868 | // a newly set velocity, this routine steps the value from the previous | 712 | // a newly set velocity, this routine steps the value from the previous |
869 | // value (m_angularMotorVelocity) to the requested value (m_angularMotorDirection). | 713 | // value (m_angularMotorVelocity) to the requested value (m_angularMotorDirection). |
870 | // There are m_angularMotorApply steps. | 714 | // There are m_angularMotorApply steps. |
871 | Vector3 origAngularVelocity = m_angularMotorVelocity; | 715 | Vector3 origVel = m_angularMotorVelocity; |
716 | Vector3 origDir = m_angularMotorDirection; | ||
717 | |||
872 | // ramp up to new value | 718 | // ramp up to new value |
873 | // current velocity += error / (time to get there / step interval) | 719 | // new velocity += error / ( time to get there / step interval) |
874 | // requested speed - last motor speed | 720 | // requested speed - last motor speed |
875 | m_angularMotorVelocity.X += (m_angularMotorDirection.X - m_angularMotorVelocity.X) / (m_angularMotorTimescale / pTimestep); | 721 | m_angularMotorVelocity.X += (m_angularMotorDirection.X - m_angularMotorVelocity.X) / (m_angularMotorTimescale / pTimestep); |
876 | m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep); | 722 | m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep); |
877 | m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep); | 723 | m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep); |
878 | 724 | ||
879 | DetailLog("{0},MoveAngular,angularMotorApply,apply={1},origvel={2},dir={3},vel={4}", | 725 | VDetailLog("{0},MoveAngular,angularMotorApply,apply={1},angTScale={2},timeStep={3},origvel={4},origDir={5},vel={6}", |
880 | m_prim.LocalID,m_angularMotorApply,origAngularVelocity, m_angularMotorDirection, m_angularMotorVelocity); | 726 | Prim.LocalID, m_angularMotorApply, m_angularMotorTimescale, pTimestep, origVel, origDir, m_angularMotorVelocity); |
881 | 727 | ||
882 | m_angularMotorApply--; // This is done so that if script request rate is less than phys frame rate the expected | 728 | m_angularMotorApply--; |
883 | // velocity may still be acheived. | ||
884 | } | 729 | } |
885 | else | 730 | else |
886 | { | 731 | { |
887 | // No motor recently applied, keep the body velocity | 732 | // No motor recently applied, keep the body velocity |
888 | // and decay the velocity | 733 | // and decay the velocity |
889 | m_angularMotorVelocity -= m_angularMotorVelocity / (m_angularMotorDecayTimescale / pTimestep); | 734 | m_angularMotorVelocity -= m_angularMotorVelocity / (m_angularMotorDecayTimescale / pTimestep); |
735 | if (m_angularMotorVelocity.LengthSquared() < 0.00001) | ||
736 | m_angularMotorVelocity = Vector3.Zero; | ||
890 | } // end motor section | 737 | } // end motor section |
891 | 738 | ||
892 | // Vertical attractor section | 739 | // Vertical attractor section |
893 | Vector3 vertattr = Vector3.Zero; | 740 | Vector3 vertattr = Vector3.Zero; |
894 | if (m_verticalAttractionTimescale < 300) | 741 | Vector3 deflection = Vector3.Zero; |
742 | Vector3 banking = Vector3.Zero; | ||
743 | |||
744 | if (m_verticalAttractionTimescale < 300 && m_lastAngularVelocity != Vector3.Zero) | ||
895 | { | 745 | { |
896 | float VAservo = 0.2f / (m_verticalAttractionTimescale * pTimestep); | 746 | float VAservo = 0.2f / (m_verticalAttractionTimescale / pTimestep); |
747 | VAservo *= (m_verticalAttractionEfficiency * m_verticalAttractionEfficiency); | ||
748 | |||
897 | // get present body rotation | 749 | // get present body rotation |
898 | Quaternion rotq = m_prim.Orientation; | 750 | Quaternion rotq = Prim.ForceOrientation; |
899 | // make a vector pointing up | 751 | // vector pointing up |
900 | Vector3 verterr = Vector3.Zero; | 752 | Vector3 verterr = Vector3.Zero; |
901 | verterr.Z = 1.0f; | 753 | verterr.Z = 1.0f; |
754 | |||
902 | // rotate it to Body Angle | 755 | // rotate it to Body Angle |
903 | verterr = verterr * rotq; | 756 | verterr = verterr * rotq; |
904 | // verterr.X and .Y are the World error ammounts. They are 0 when there is no error (Vehicle Body is 'vertical'), and .Z will be 1. | 757 | // verterr.X and .Y are the World error amounts. They are 0 when there is no error (Vehicle Body is 'vertical'), and .Z will be 1. |
905 | // As the body leans to its side |.X| will increase to 1 and .Z fall to 0. As body inverts |.X| will fall and .Z will go | 758 | // As the body leans to its side |.X| will increase to 1 and .Z fall to 0. As body inverts |.X| will fall and .Z will go |
906 | // negative. Similar for tilt and |.Y|. .X and .Y must be modulated to prevent a stable inverted body. | 759 | // negative. Similar for tilt and |.Y|. .X and .Y must be modulated to prevent a stable inverted body. |
760 | |||
761 | // Error is 0 (no error) to +/- 2 (max error) | ||
907 | if (verterr.Z < 0.0f) | 762 | if (verterr.Z < 0.0f) |
908 | { | 763 | { |
909 | verterr.X = 2.0f - verterr.X; | 764 | verterr.X = 2.0f - verterr.X; |
910 | verterr.Y = 2.0f - verterr.Y; | 765 | verterr.Y = 2.0f - verterr.Y; |
911 | } | 766 | } |
912 | // Error is 0 (no error) to +/- 2 (max error) | ||
913 | // scale it by VAservo | 767 | // scale it by VAservo |
914 | verterr = verterr * VAservo; | 768 | verterr = verterr * VAservo; |
915 | 769 | ||
@@ -924,12 +778,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
924 | vertattr.X += bounce * angularVelocity.X; | 778 | vertattr.X += bounce * angularVelocity.X; |
925 | vertattr.Y += bounce * angularVelocity.Y; | 779 | vertattr.Y += bounce * angularVelocity.Y; |
926 | 780 | ||
927 | DetailLog("{0},MoveAngular,verticalAttraction,verterr={1},bounce={2},vertattr={3}", | 781 | VDetailLog("{0},MoveAngular,verticalAttraction,verterr={1},bounce={2},vertattr={3}", |
928 | m_prim.LocalID, verterr, bounce, vertattr); | 782 | Prim.LocalID, verterr, bounce, vertattr); |
929 | 783 | ||
930 | } // else vertical attractor is off | 784 | } // else vertical attractor is off |
931 | 785 | ||
932 | // m_lastVertAttractor = vertattr; | 786 | m_lastVertAttractor = vertattr; |
933 | 787 | ||
934 | // Bank section tba | 788 | // Bank section tba |
935 | 789 | ||
@@ -937,18 +791,18 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
937 | 791 | ||
938 | // Sum velocities | 792 | // Sum velocities |
939 | m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // + bank + deflection | 793 | m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // + bank + deflection |
940 | 794 | ||
941 | if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0) | 795 | if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0) |
942 | { | 796 | { |
943 | m_lastAngularVelocity.X = 0; | 797 | m_lastAngularVelocity.X = 0; |
944 | m_lastAngularVelocity.Y = 0; | 798 | m_lastAngularVelocity.Y = 0; |
945 | DetailLog("{0},MoveAngular,noDeflectionUp,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity); | 799 | VDetailLog("{0},MoveAngular,noDeflectionUp,lastAngular={1}", Prim.LocalID, m_lastAngularVelocity); |
946 | } | 800 | } |
947 | 801 | ||
948 | if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) | 802 | if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) |
949 | { | 803 | { |
950 | m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero. | 804 | m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero. |
951 | DetailLog("{0},MoveAngular,zeroSmallValues,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity); | 805 | VDetailLog("{0},MoveAngular,zeroSmallValues,lastAngular={1}", Prim.LocalID, m_lastAngularVelocity); |
952 | } | 806 | } |
953 | 807 | ||
954 | // apply friction | 808 | // apply friction |
@@ -956,14 +810,14 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
956 | m_lastAngularVelocity -= m_lastAngularVelocity * decayamount; | 810 | m_lastAngularVelocity -= m_lastAngularVelocity * decayamount; |
957 | 811 | ||
958 | // Apply to the body | 812 | // Apply to the body |
959 | m_prim.RotationalVelocity = m_lastAngularVelocity; | 813 | Prim.RotationalVelocity = m_lastAngularVelocity; |
960 | 814 | ||
961 | DetailLog("{0},MoveAngular,done,decay={1},lastAngular={2}", m_prim.LocalID, decayamount, m_lastAngularVelocity); | 815 | VDetailLog("{0},MoveAngular,done,decay={1},lastAngular={2}", Prim.LocalID, decayamount, m_lastAngularVelocity); |
962 | } //end MoveAngular | 816 | } //end MoveAngular |
963 | 817 | ||
964 | internal void LimitRotation(float timestep) | 818 | internal void LimitRotation(float timestep) |
965 | { | 819 | { |
966 | Quaternion rotq = m_prim.Orientation; | 820 | Quaternion rotq = Prim.ForceOrientation; |
967 | Quaternion m_rot = rotq; | 821 | Quaternion m_rot = rotq; |
968 | bool changed = false; | 822 | bool changed = false; |
969 | if (m_RollreferenceFrame != Quaternion.Identity) | 823 | if (m_RollreferenceFrame != Quaternion.Identity) |
@@ -996,23 +850,19 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
996 | m_rot.Y = 0; | 850 | m_rot.Y = 0; |
997 | changed = true; | 851 | changed = true; |
998 | } | 852 | } |
999 | if ((m_flags & VehicleFlag.LOCK_ROTATION) != 0) | 853 | if (changed) |
1000 | { | 854 | { |
1001 | m_rot.X = 0; | 855 | Prim.ForceOrientation = m_rot; |
1002 | m_rot.Y = 0; | 856 | VDetailLog("{0},LimitRotation,done,orig={1},new={2}", Prim.LocalID, rotq, m_rot); |
1003 | changed = true; | ||
1004 | } | 857 | } |
1005 | if (changed) | ||
1006 | m_prim.Orientation = m_rot; | ||
1007 | 858 | ||
1008 | DetailLog("{0},LimitRotation,done,changed={1},orig={2},new={3}", m_prim.LocalID, changed, rotq, m_rot); | ||
1009 | } | 859 | } |
1010 | 860 | ||
1011 | // Invoke the detailed logger and output something if it's enabled. | 861 | // Invoke the detailed logger and output something if it's enabled. |
1012 | private void DetailLog(string msg, params Object[] args) | 862 | private void VDetailLog(string msg, params Object[] args) |
1013 | { | 863 | { |
1014 | if (m_prim.Scene.VehicleLoggingEnabled) | 864 | if (Prim.PhysicsScene.VehicleLoggingEnabled) |
1015 | m_prim.Scene.PhysicsLogging.Write(msg, args); | 865 | Prim.PhysicsScene.PhysicsLogging.Write(msg, args); |
1016 | } | 866 | } |
1017 | } | 867 | } |
1018 | } | 868 | } |