diff options
Diffstat (limited to 'OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs')
-rw-r--r-- | OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs | 283 |
1 files changed, 193 insertions, 90 deletions
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs index c04ff58..ebd2185 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs | |||
@@ -43,7 +43,8 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
43 | Unknown = 0, | 43 | Unknown = 0, |
44 | Agent = 1, | 44 | Agent = 1, |
45 | Prim = 2, | 45 | Prim = 2, |
46 | Ground = 3 | 46 | Ground = 3, |
47 | Water = 4 | ||
47 | } | 48 | } |
48 | 49 | ||
49 | public enum PIDHoverType | 50 | public enum PIDHoverType |
@@ -59,15 +60,41 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
59 | public Vector3 Position; | 60 | public Vector3 Position; |
60 | public Vector3 SurfaceNormal; | 61 | public Vector3 SurfaceNormal; |
61 | public float PenetrationDepth; | 62 | public float PenetrationDepth; |
63 | public float RelativeSpeed; | ||
64 | public bool CharacterFeet; | ||
62 | 65 | ||
63 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) | 66 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) |
64 | { | 67 | { |
65 | Position = position; | 68 | Position = position; |
66 | SurfaceNormal = surfaceNormal; | 69 | SurfaceNormal = surfaceNormal; |
67 | PenetrationDepth = penetrationDepth; | 70 | PenetrationDepth = penetrationDepth; |
71 | RelativeSpeed = 0f; // for now let this one be set explicity | ||
72 | CharacterFeet = true; // keep other plugins work as before | ||
73 | } | ||
74 | |||
75 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth, bool feet) | ||
76 | { | ||
77 | Position = position; | ||
78 | SurfaceNormal = surfaceNormal; | ||
79 | PenetrationDepth = penetrationDepth; | ||
80 | RelativeSpeed = 0f; // for now let this one be set explicity | ||
81 | CharacterFeet = feet; // keep other plugins work as before | ||
68 | } | 82 | } |
69 | } | 83 | } |
70 | 84 | ||
85 | public struct ContactData | ||
86 | { | ||
87 | public float mu; | ||
88 | public float bounce; | ||
89 | public bool softcolide; | ||
90 | |||
91 | public ContactData(float _mu, float _bounce, bool _softcolide) | ||
92 | { | ||
93 | mu = _mu; | ||
94 | bounce = _bounce; | ||
95 | softcolide = _softcolide; | ||
96 | } | ||
97 | } | ||
71 | /// <summary> | 98 | /// <summary> |
72 | /// Used to pass collision information to OnCollisionUpdate listeners. | 99 | /// Used to pass collision information to OnCollisionUpdate listeners. |
73 | /// </summary> | 100 | /// </summary> |
@@ -99,7 +126,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
99 | m_objCollisionList.Add(localID, contact); | 126 | m_objCollisionList.Add(localID, contact); |
100 | } | 127 | } |
101 | else | 128 | else |
102 | { | 129 | { |
103 | if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) | 130 | if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) |
104 | m_objCollisionList[localID] = contact; | 131 | m_objCollisionList[localID] = contact; |
105 | } | 132 | } |
@@ -142,11 +169,32 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
142 | { | 169 | { |
143 | get { return new NullPhysicsActor(); } | 170 | get { return new NullPhysicsActor(); } |
144 | } | 171 | } |
172 | |||
173 | public virtual bool Building { get; set; } | ||
174 | |||
175 | public virtual void getContactData(ref ContactData cdata) | ||
176 | { | ||
177 | cdata.mu = 0; | ||
178 | cdata.bounce = 0; | ||
179 | } | ||
145 | 180 | ||
146 | public abstract bool Stopped { get; } | 181 | public abstract bool Stopped { get; } |
147 | 182 | ||
148 | public abstract Vector3 Size { get; set; } | 183 | public abstract Vector3 Size { get; set; } |
149 | 184 | ||
185 | public virtual void setAvatarSize(Vector3 size, float feetOffset) | ||
186 | { | ||
187 | Size = size; | ||
188 | } | ||
189 | |||
190 | public virtual bool Phantom { get; set; } | ||
191 | |||
192 | public virtual bool IsVolumeDtc | ||
193 | { | ||
194 | get { return false; } | ||
195 | set { return; } | ||
196 | } | ||
197 | |||
150 | public virtual byte PhysicsShapeType { get; set; } | 198 | public virtual byte PhysicsShapeType { get; set; } |
151 | 199 | ||
152 | public abstract PrimitiveBaseShape Shape { set; } | 200 | public abstract PrimitiveBaseShape Shape { set; } |
@@ -169,7 +217,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
169 | /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or | 217 | /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or |
170 | /// water. This is not a problem due to the formatting of names given by prims and avatars. | 218 | /// water. This is not a problem due to the formatting of names given by prims and avatars. |
171 | /// </remarks> | 219 | /// </remarks> |
172 | public string Name { get; protected set; } | 220 | public string Name { get; set; } |
173 | 221 | ||
174 | /// <summary> | 222 | /// <summary> |
175 | /// This is being used by ODE joint code. | 223 | /// This is being used by ODE joint code. |
@@ -182,8 +230,8 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
182 | 230 | ||
183 | public abstract void delink(); | 231 | public abstract void delink(); |
184 | 232 | ||
185 | public abstract void LockAngularMotion(Vector3 axis); | 233 | public abstract void LockAngularMotion(byte axislocks); |
186 | 234 | ||
187 | public virtual void RequestPhysicsterseUpdate() | 235 | public virtual void RequestPhysicsterseUpdate() |
188 | { | 236 | { |
189 | // Make a temporary copy of the event to avoid possibility of | 237 | // Make a temporary copy of the event to avoid possibility of |
@@ -245,6 +293,56 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
245 | public abstract void VehicleRotationParam(int param, Quaternion rotation); | 293 | public abstract void VehicleRotationParam(int param, Quaternion rotation); |
246 | public abstract void VehicleFlags(int param, bool remove); | 294 | public abstract void VehicleFlags(int param, bool remove); |
247 | 295 | ||
296 | // This is an overridable version of SetVehicle() that works for all physics engines. | ||
297 | // This is VERY inefficient. It behoves any physics engine to override this and | ||
298 | // implement a more efficient setting of all the vehicle parameters. | ||
299 | public virtual void SetVehicle(object pvdata) | ||
300 | { | ||
301 | VehicleData vdata = (VehicleData)pvdata; | ||
302 | // vehicleActor.ProcessSetVehicle((VehicleData)vdata); | ||
303 | |||
304 | this.VehicleType = (int)vdata.m_type; | ||
305 | this.VehicleFlags(-1, false); // clears all flags | ||
306 | this.VehicleFlags((int)vdata.m_flags, false); | ||
307 | |||
308 | // Linear properties | ||
309 | this.VehicleVectorParam((int)Vehicle.LINEAR_MOTOR_DIRECTION, vdata.m_linearMotorDirection); | ||
310 | this.VehicleVectorParam((int)Vehicle.LINEAR_FRICTION_TIMESCALE, vdata.m_linearFrictionTimescale); | ||
311 | this.VehicleFloatParam((int)Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE, vdata.m_linearMotorDecayTimescale); | ||
312 | this.VehicleFloatParam((int)Vehicle.LINEAR_MOTOR_TIMESCALE, vdata.m_linearMotorTimescale); | ||
313 | this.VehicleVectorParam((int)Vehicle.LINEAR_MOTOR_OFFSET, vdata.m_linearMotorOffset); | ||
314 | |||
315 | //Angular properties | ||
316 | this.VehicleVectorParam((int)Vehicle.ANGULAR_MOTOR_DIRECTION, vdata.m_angularMotorDirection); | ||
317 | this.VehicleFloatParam((int)Vehicle.ANGULAR_MOTOR_TIMESCALE, vdata.m_angularMotorTimescale); | ||
318 | this.VehicleFloatParam((int)Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE, vdata.m_angularMotorDecayTimescale); | ||
319 | this.VehicleVectorParam((int)Vehicle.ANGULAR_FRICTION_TIMESCALE, vdata.m_angularFrictionTimescale); | ||
320 | |||
321 | //Deflection properties | ||
322 | this.VehicleFloatParam((int)Vehicle.ANGULAR_DEFLECTION_EFFICIENCY, vdata.m_angularDeflectionEfficiency); | ||
323 | this.VehicleFloatParam((int)Vehicle.ANGULAR_DEFLECTION_TIMESCALE, vdata.m_angularDeflectionTimescale); | ||
324 | this.VehicleFloatParam((int)Vehicle.LINEAR_DEFLECTION_EFFICIENCY, vdata.m_linearDeflectionEfficiency); | ||
325 | this.VehicleFloatParam((int)Vehicle.LINEAR_DEFLECTION_TIMESCALE, vdata.m_linearDeflectionTimescale); | ||
326 | |||
327 | //Banking properties | ||
328 | this.VehicleFloatParam((int)Vehicle.BANKING_EFFICIENCY, vdata.m_bankingEfficiency); | ||
329 | this.VehicleFloatParam((int)Vehicle.BANKING_MIX, vdata.m_bankingMix); | ||
330 | this.VehicleFloatParam((int)Vehicle.BANKING_TIMESCALE, vdata.m_bankingTimescale); | ||
331 | |||
332 | //Hover and Buoyancy properties | ||
333 | this.VehicleFloatParam((int)Vehicle.HOVER_HEIGHT, vdata.m_VhoverHeight); | ||
334 | this.VehicleFloatParam((int)Vehicle.HOVER_EFFICIENCY, vdata.m_VhoverEfficiency); | ||
335 | this.VehicleFloatParam((int)Vehicle.HOVER_TIMESCALE, vdata.m_VhoverTimescale); | ||
336 | this.VehicleFloatParam((int)Vehicle.BUOYANCY, vdata.m_VehicleBuoyancy); | ||
337 | |||
338 | //Attractor properties | ||
339 | this.VehicleFloatParam((int)Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, vdata.m_verticalAttractionEfficiency); | ||
340 | this.VehicleFloatParam((int)Vehicle.VERTICAL_ATTRACTION_TIMESCALE, vdata.m_verticalAttractionTimescale); | ||
341 | |||
342 | this.VehicleRotationParam((int)Vehicle.REFERENCE_FRAME, vdata.m_referenceFrame); | ||
343 | } | ||
344 | |||
345 | |||
248 | /// <summary> | 346 | /// <summary> |
249 | /// Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more | 347 | /// Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more |
250 | /// </summary> | 348 | /// </summary> |
@@ -253,6 +351,51 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
253 | public abstract Vector3 GeometricCenter { get; } | 351 | public abstract Vector3 GeometricCenter { get; } |
254 | public abstract Vector3 CenterOfMass { get; } | 352 | public abstract Vector3 CenterOfMass { get; } |
255 | 353 | ||
354 | public virtual Vector3 OOBsize | ||
355 | { | ||
356 | get | ||
357 | { | ||
358 | Vector3 s=Size; | ||
359 | s.X *=0.5f; | ||
360 | s.Y *=0.5f; | ||
361 | s.Z *=0.5f; | ||
362 | return s; | ||
363 | } | ||
364 | } | ||
365 | |||
366 | public virtual Vector3 OOBoffset | ||
367 | { | ||
368 | get | ||
369 | { | ||
370 | return Vector3.Zero; | ||
371 | } | ||
372 | } | ||
373 | |||
374 | public virtual float OOBRadiusSQ | ||
375 | { | ||
376 | get | ||
377 | { | ||
378 | return Size.LengthSquared() * 0.25f; // ((0.5^2) | ||
379 | } | ||
380 | } | ||
381 | |||
382 | |||
383 | public virtual float PhysicsCost | ||
384 | { | ||
385 | get | ||
386 | { | ||
387 | return 0.1f; | ||
388 | } | ||
389 | } | ||
390 | |||
391 | public virtual float StreamCost | ||
392 | { | ||
393 | get | ||
394 | { | ||
395 | return 1.0f; | ||
396 | } | ||
397 | } | ||
398 | |||
256 | /// <summary> | 399 | /// <summary> |
257 | /// The desired velocity of this actor. | 400 | /// The desired velocity of this actor. |
258 | /// </summary> | 401 | /// </summary> |
@@ -296,7 +439,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
296 | 439 | ||
297 | // Used for llSetHoverHeight and maybe vehicle height | 440 | // Used for llSetHoverHeight and maybe vehicle height |
298 | // Hover Height will override MoveTo target's Z | 441 | // Hover Height will override MoveTo target's Z |
299 | public abstract bool PIDHoverActive { set;} | 442 | public abstract bool PIDHoverActive {get; set;} |
300 | public abstract float PIDHoverHeight { set;} | 443 | public abstract float PIDHoverHeight { set;} |
301 | public abstract PIDHoverType PIDHoverType { set;} | 444 | public abstract PIDHoverType PIDHoverType { set;} |
302 | public abstract float PIDHoverTau { set;} | 445 | public abstract float PIDHoverTau { set;} |
@@ -314,6 +457,12 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
314 | public abstract void UnSubscribeEvents(); | 457 | public abstract void UnSubscribeEvents(); |
315 | public abstract bool SubscribedEvents(); | 458 | public abstract bool SubscribedEvents(); |
316 | 459 | ||
460 | public virtual void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { } | ||
461 | |||
462 | // Warning in a parent part it returns itself, not null | ||
463 | public virtual PhysicsActor ParentActor { get { return this; } } | ||
464 | |||
465 | |||
317 | // Extendable interface for new, physics engine specific operations | 466 | // Extendable interface for new, physics engine specific operations |
318 | public virtual object Extension(string pFunct, params object[] pParams) | 467 | public virtual object Extension(string pFunct, params object[] pParams) |
319 | { | 468 | { |
@@ -324,9 +473,11 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
324 | 473 | ||
325 | public class NullPhysicsActor : PhysicsActor | 474 | public class NullPhysicsActor : PhysicsActor |
326 | { | 475 | { |
476 | private ActorTypes m_actorType = ActorTypes.Unknown; | ||
477 | |||
327 | public override bool Stopped | 478 | public override bool Stopped |
328 | { | 479 | { |
329 | get{ return false; } | 480 | get{ return true; } |
330 | } | 481 | } |
331 | 482 | ||
332 | public override Vector3 Position | 483 | public override Vector3 Position |
@@ -343,6 +494,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
343 | 494 | ||
344 | public override uint LocalID | 495 | public override uint LocalID |
345 | { | 496 | { |
497 | get { return 0; } | ||
346 | set { return; } | 498 | set { return; } |
347 | } | 499 | } |
348 | 500 | ||
@@ -402,50 +554,17 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
402 | set { return; } | 554 | set { return; } |
403 | } | 555 | } |
404 | 556 | ||
405 | public override void VehicleFloatParam(int param, float value) | 557 | public override void VehicleFloatParam(int param, float value) {} |
406 | { | 558 | public override void VehicleVectorParam(int param, Vector3 value) { } |
407 | 559 | public override void VehicleRotationParam(int param, Quaternion rotation) { } | |
408 | } | 560 | public override void VehicleFlags(int param, bool remove) { } |
409 | 561 | public override void SetVolumeDetect(int param) {} | |
410 | public override void VehicleVectorParam(int param, Vector3 value) | 562 | public override void SetMaterial(int material) {} |
411 | { | 563 | public override Vector3 CenterOfMass { get { return Vector3.Zero; }} |
412 | |||
413 | } | ||
414 | |||
415 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
416 | { | ||
417 | |||
418 | } | ||
419 | 564 | ||
420 | public override void VehicleFlags(int param, bool remove) | 565 | public override Vector3 GeometricCenter { get { return Vector3.Zero; }} |
421 | { | ||
422 | |||
423 | } | ||
424 | |||
425 | public override void SetVolumeDetect(int param) | ||
426 | { | ||
427 | |||
428 | } | ||
429 | |||
430 | public override void SetMaterial(int material) | ||
431 | { | ||
432 | |||
433 | } | ||
434 | |||
435 | public override Vector3 CenterOfMass | ||
436 | { | ||
437 | get { return Vector3.Zero; } | ||
438 | } | ||
439 | |||
440 | public override Vector3 GeometricCenter | ||
441 | { | ||
442 | get { return Vector3.Zero; } | ||
443 | } | ||
444 | 566 | ||
445 | public override PrimitiveBaseShape Shape | 567 | public override PrimitiveBaseShape Shape { set { return; }} |
446 | { | ||
447 | set { return; } | ||
448 | } | ||
449 | 568 | ||
450 | public override Vector3 Velocity | 569 | public override Vector3 Velocity |
451 | { | 570 | { |
@@ -465,9 +584,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
465 | set { } | 584 | set { } |
466 | } | 585 | } |
467 | 586 | ||
468 | public override void CrossingFailure() | 587 | public override void CrossingFailure() {} |
469 | { | ||
470 | } | ||
471 | 588 | ||
472 | public override Quaternion Orientation | 589 | public override Quaternion Orientation |
473 | { | 590 | { |
@@ -507,8 +624,20 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
507 | 624 | ||
508 | public override int PhysicsActorType | 625 | public override int PhysicsActorType |
509 | { | 626 | { |
510 | get { return (int) ActorTypes.Unknown; } | 627 | get { return (int)m_actorType; } |
511 | set { return; } | 628 | set { |
629 | ActorTypes type = (ActorTypes)value; | ||
630 | switch (type) | ||
631 | { | ||
632 | case ActorTypes.Ground: | ||
633 | case ActorTypes.Water: | ||
634 | m_actorType = type; | ||
635 | break; | ||
636 | default: | ||
637 | m_actorType = ActorTypes.Unknown; | ||
638 | break; | ||
639 | } | ||
640 | } | ||
512 | } | 641 | } |
513 | 642 | ||
514 | public override bool Kinematic | 643 | public override bool Kinematic |
@@ -517,26 +646,11 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
517 | set { return; } | 646 | set { return; } |
518 | } | 647 | } |
519 | 648 | ||
520 | public override void link(PhysicsActor obj) | 649 | public override void link(PhysicsActor obj) { } |
521 | { | 650 | public override void delink() { } |
522 | } | 651 | public override void LockAngularMotion(byte axislocks) { } |
523 | 652 | public override void AddForce(Vector3 force, bool pushforce) { } | |
524 | public override void delink() | 653 | public override void AddAngularForce(Vector3 force, bool pushforce) { } |
525 | { | ||
526 | } | ||
527 | |||
528 | public override void LockAngularMotion(Vector3 axis) | ||
529 | { | ||
530 | } | ||
531 | |||
532 | public override void AddForce(Vector3 force, bool pushforce) | ||
533 | { | ||
534 | } | ||
535 | |||
536 | public override void AddAngularForce(Vector3 force, bool pushforce) | ||
537 | { | ||
538 | |||
539 | } | ||
540 | 654 | ||
541 | public override Vector3 RotationalVelocity | 655 | public override Vector3 RotationalVelocity |
542 | { | 656 | { |
@@ -555,7 +669,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
555 | public override float PIDTau { set { return; } } | 669 | public override float PIDTau { set { return; } } |
556 | 670 | ||
557 | public override float PIDHoverHeight { set { return; } } | 671 | public override float PIDHoverHeight { set { return; } } |
558 | public override bool PIDHoverActive { set { return; } } | 672 | public override bool PIDHoverActive {get {return false;} set { return; } } |
559 | public override PIDHoverType PIDHoverType { set { return; } } | 673 | public override PIDHoverType PIDHoverType { set { return; } } |
560 | public override float PIDHoverTau { set { return; } } | 674 | public override float PIDHoverTau { set { return; } } |
561 | 675 | ||
@@ -564,21 +678,10 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
564 | public override float APIDStrength { set { return; } } | 678 | public override float APIDStrength { set { return; } } |
565 | public override float APIDDamping { set { return; } } | 679 | public override float APIDDamping { set { return; } } |
566 | 680 | ||
567 | public override void SetMomentum(Vector3 momentum) | 681 | public override void SetMomentum(Vector3 momentum) { } |
568 | { | ||
569 | } | ||
570 | 682 | ||
571 | public override void SubscribeEvents(int ms) | 683 | public override void SubscribeEvents(int ms) { } |
572 | { | 684 | public override void UnSubscribeEvents() { } |
573 | 685 | public override bool SubscribedEvents() { return false; } | |
574 | } | ||
575 | public override void UnSubscribeEvents() | ||
576 | { | ||
577 | |||
578 | } | ||
579 | public override bool SubscribedEvents() | ||
580 | { | ||
581 | return false; | ||
582 | } | ||
583 | } | 686 | } |
584 | } | 687 | } |