diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 89 |
1 files changed, 70 insertions, 19 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 95bdc7b..b2947c6 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -70,18 +70,17 @@ public class BSPrim : BSPhysObject | |||
70 | private int CrossingFailures { get; set; } | 70 | private int CrossingFailures { get; set; } |
71 | 71 | ||
72 | // Keep a handle to the vehicle actor so it is easy to set parameters on same. | 72 | // Keep a handle to the vehicle actor so it is easy to set parameters on same. |
73 | public BSDynamics VehicleActor; | ||
74 | public const string VehicleActorName = "BasicVehicle"; | 73 | public const string VehicleActorName = "BasicVehicle"; |
75 | 74 | ||
76 | // Parameters for the hover actor | 75 | // Parameters for the hover actor |
77 | public const string HoverActorName = "HoverActor"; | 76 | public const string HoverActorName = "BSPrim.HoverActor"; |
78 | // Parameters for the axis lock actor | 77 | // Parameters for the axis lock actor |
79 | public const String LockedAxisActorName = "BSPrim.LockedAxis"; | 78 | public const String LockedAxisActorName = "BSPrim.LockedAxis"; |
80 | // Parameters for the move to target actor | 79 | // Parameters for the move to target actor |
81 | public const string MoveToTargetActorName = "MoveToTargetActor"; | 80 | public const string MoveToTargetActorName = "BSPrim.MoveToTargetActor"; |
82 | // Parameters for the setForce and setTorque actors | 81 | // Parameters for the setForce and setTorque actors |
83 | public const string SetForceActorName = "SetForceActor"; | 82 | public const string SetForceActorName = "BSPrim.SetForceActor"; |
84 | public const string SetTorqueActorName = "SetTorqueActor"; | 83 | public const string SetTorqueActorName = "BSPrim.SetTorqueActor"; |
85 | 84 | ||
86 | public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, | 85 | public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, |
87 | OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) | 86 | OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) |
@@ -100,9 +99,8 @@ public class BSPrim : BSPhysObject | |||
100 | _isPhysical = pisPhysical; | 99 | _isPhysical = pisPhysical; |
101 | _isVolumeDetect = false; | 100 | _isVolumeDetect = false; |
102 | 101 | ||
103 | // We keep a handle to the vehicle actor so we can set vehicle parameters later. | 102 | // Add a dynamic vehicle to our set of actors that can move this prim. |
104 | VehicleActor = new BSDynamics(PhysScene, this, VehicleActorName); | 103 | PhysicalActors.Add(VehicleActorName, new BSDynamics(PhysScene, this, VehicleActorName)); |
105 | PhysicalActors.Add(VehicleActorName, VehicleActor); | ||
106 | 104 | ||
107 | _mass = CalculateMass(); | 105 | _mass = CalculateMass(); |
108 | 106 | ||
@@ -450,6 +448,9 @@ public class BSPrim : BSPhysObject | |||
450 | Gravity = ComputeGravity(Buoyancy); | 448 | Gravity = ComputeGravity(Buoyancy); |
451 | PhysScene.PE.SetGravity(PhysBody, Gravity); | 449 | PhysScene.PE.SetGravity(PhysBody, Gravity); |
452 | 450 | ||
451 | OMV.Vector3 currentScale = PhysScene.PE.GetLocalScaling(PhysShape.physShapeInfo); // DEBUG DEBUG | ||
452 | DetailLog("{0},BSPrim.UpdateMassProperties,currentScale{1},shape={2}", LocalID, currentScale, PhysShape.physShapeInfo); // DEBUG DEBUG | ||
453 | |||
453 | Inertia = PhysScene.PE.CalculateLocalInertia(PhysShape.physShapeInfo, physMass); | 454 | Inertia = PhysScene.PE.CalculateLocalInertia(PhysShape.physShapeInfo, physMass); |
454 | PhysScene.PE.SetMassProps(PhysBody, physMass, Inertia); | 455 | PhysScene.PE.SetMassProps(PhysBody, physMass, Inertia); |
455 | PhysScene.PE.UpdateInertiaTensor(PhysBody); | 456 | PhysScene.PE.UpdateInertiaTensor(PhysBody); |
@@ -502,9 +503,25 @@ public class BSPrim : BSPhysObject | |||
502 | } | 503 | } |
503 | } | 504 | } |
504 | 505 | ||
506 | // Find and return a handle to the current vehicle actor. | ||
507 | // Return 'null' if there is no vehicle actor. | ||
508 | public BSDynamics GetVehicleActor() | ||
509 | { | ||
510 | BSDynamics ret = null; | ||
511 | BSActor actor; | ||
512 | if (PhysicalActors.TryGetActor(VehicleActorName, out actor)) | ||
513 | { | ||
514 | ret = actor as BSDynamics; | ||
515 | } | ||
516 | return ret; | ||
517 | } | ||
505 | public override int VehicleType { | 518 | public override int VehicleType { |
506 | get { | 519 | get { |
507 | return (int)VehicleActor.Type; | 520 | int ret = (int)Vehicle.TYPE_NONE; |
521 | BSDynamics vehicleActor = GetVehicleActor(); | ||
522 | if (vehicleActor != null) | ||
523 | ret = (int)vehicleActor.Type; | ||
524 | return ret; | ||
508 | } | 525 | } |
509 | set { | 526 | set { |
510 | Vehicle type = (Vehicle)value; | 527 | Vehicle type = (Vehicle)value; |
@@ -515,8 +532,12 @@ public class BSPrim : BSPhysObject | |||
515 | // change all the parameters. Like a plane changing to CAR when on the | 532 | // change all the parameters. Like a plane changing to CAR when on the |
516 | // ground. In this case, don't want to zero motion. | 533 | // ground. In this case, don't want to zero motion. |
517 | // ZeroMotion(true /* inTaintTime */); | 534 | // ZeroMotion(true /* inTaintTime */); |
518 | VehicleActor.ProcessTypeChange(type); | 535 | BSDynamics vehicleActor = GetVehicleActor(); |
519 | ActivateIfPhysical(false); | 536 | if (vehicleActor != null) |
537 | { | ||
538 | vehicleActor.ProcessTypeChange(type); | ||
539 | ActivateIfPhysical(false); | ||
540 | } | ||
520 | }); | 541 | }); |
521 | } | 542 | } |
522 | } | 543 | } |
@@ -524,31 +545,47 @@ public class BSPrim : BSPhysObject | |||
524 | { | 545 | { |
525 | PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() | 546 | PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() |
526 | { | 547 | { |
527 | VehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); | 548 | BSDynamics vehicleActor = GetVehicleActor(); |
528 | ActivateIfPhysical(false); | 549 | if (vehicleActor != null) |
550 | { | ||
551 | vehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); | ||
552 | ActivateIfPhysical(false); | ||
553 | } | ||
529 | }); | 554 | }); |
530 | } | 555 | } |
531 | public override void VehicleVectorParam(int param, OMV.Vector3 value) | 556 | public override void VehicleVectorParam(int param, OMV.Vector3 value) |
532 | { | 557 | { |
533 | PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() | 558 | PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() |
534 | { | 559 | { |
535 | VehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); | 560 | BSDynamics vehicleActor = GetVehicleActor(); |
536 | ActivateIfPhysical(false); | 561 | if (vehicleActor != null) |
562 | { | ||
563 | vehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); | ||
564 | ActivateIfPhysical(false); | ||
565 | } | ||
537 | }); | 566 | }); |
538 | } | 567 | } |
539 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) | 568 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) |
540 | { | 569 | { |
541 | PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() | 570 | PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() |
542 | { | 571 | { |
543 | VehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); | 572 | BSDynamics vehicleActor = GetVehicleActor(); |
544 | ActivateIfPhysical(false); | 573 | if (vehicleActor != null) |
574 | { | ||
575 | vehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); | ||
576 | ActivateIfPhysical(false); | ||
577 | } | ||
545 | }); | 578 | }); |
546 | } | 579 | } |
547 | public override void VehicleFlags(int param, bool remove) | 580 | public override void VehicleFlags(int param, bool remove) |
548 | { | 581 | { |
549 | PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate() | 582 | PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate() |
550 | { | 583 | { |
551 | VehicleActor.ProcessVehicleFlags(param, remove); | 584 | BSDynamics vehicleActor = GetVehicleActor(); |
585 | if (vehicleActor != null) | ||
586 | { | ||
587 | vehicleActor.ProcessVehicleFlags(param, remove); | ||
588 | } | ||
552 | }); | 589 | }); |
553 | } | 590 | } |
554 | 591 | ||
@@ -1040,6 +1077,20 @@ public class BSPrim : BSPhysObject | |||
1040 | } | 1077 | } |
1041 | } | 1078 | } |
1042 | 1079 | ||
1080 | public override OMV.Vector3 PIDTarget | ||
1081 | { | ||
1082 | set | ||
1083 | { | ||
1084 | base.PIDTarget = value; | ||
1085 | BSActor actor; | ||
1086 | if (PhysicalActors.TryGetActor(MoveToTargetActorName, out actor)) | ||
1087 | { | ||
1088 | // if the actor exists, tell it to refresh its values. | ||
1089 | actor.Refresh(); | ||
1090 | } | ||
1091 | |||
1092 | } | ||
1093 | } | ||
1043 | // Used for llSetHoverHeight and maybe vehicle height | 1094 | // Used for llSetHoverHeight and maybe vehicle height |
1044 | // Hover Height will override MoveTo target's Z | 1095 | // Hover Height will override MoveTo target's Z |
1045 | public override bool PIDHoverActive { | 1096 | public override bool PIDHoverActive { |
@@ -1063,7 +1114,7 @@ public class BSPrim : BSPhysObject | |||
1063 | 1114 | ||
1064 | // Applying a force just adds this to the total force on the object. | 1115 | // Applying a force just adds this to the total force on the object. |
1065 | // This added force will only last the next simulation tick. | 1116 | // This added force will only last the next simulation tick. |
1066 | public void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { | 1117 | public override void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { |
1067 | // for an object, doesn't matter if force is a pushforce or not | 1118 | // for an object, doesn't matter if force is a pushforce or not |
1068 | if (IsPhysicallyActive) | 1119 | if (IsPhysicallyActive) |
1069 | { | 1120 | { |