aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs80
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs2
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs2
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs16
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs2
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSMotors.cs15
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSParam.cs6
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs1
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs89
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs5
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs6
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs32
12 files changed, 182 insertions, 74 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs
index 75ff24e..bdf4bc0 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs
@@ -50,7 +50,8 @@ public class BSActorMoveToTarget : BSActor
50 // BSActor.isActive 50 // BSActor.isActive
51 public override bool isActive 51 public override bool isActive
52 { 52 {
53 get { return Enabled; } 53 // MoveToTarget only works on physical prims
54 get { return Enabled && m_controllingPrim.IsPhysicallyActive; }
54 } 55 }
55 56
56 // Release any connections and resources used by the actor. 57 // Release any connections and resources used by the actor.
@@ -102,16 +103,28 @@ public class BSActorMoveToTarget : BSActor
102 // We're taking over after this. 103 // We're taking over after this.
103 m_controllingPrim.ZeroMotion(true); 104 m_controllingPrim.ZeroMotion(true);
104 105
105 m_targetMotor = new BSVMotor("BSActorMoveToTargget.Activate", 106 /* Someday use the PID controller
106 m_controllingPrim.MoveToTargetTau, // timeScale 107 m_targetMotor = new BSPIDVMotor("BSActorMoveToTarget-" + m_controllingPrim.LocalID.ToString());
107 BSMotor.Infinite, // decay time scale 108 m_targetMotor.TimeScale = m_controllingPrim.MoveToTargetTau;
108 1f // efficiency 109 m_targetMotor.Efficiency = 1f;
110 */
111 m_targetMotor = new BSVMotor("BSActorMoveToTarget-" + m_controllingPrim.LocalID.ToString(),
112 m_controllingPrim.MoveToTargetTau, // timeScale
113 BSMotor.Infinite, // decay time scale
114 1f // efficiency
109 ); 115 );
110 m_targetMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG so motor will output detail log messages. 116 m_targetMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG so motor will output detail log messages.
111 m_targetMotor.SetTarget(m_controllingPrim.MoveToTargetTarget); 117 m_targetMotor.SetTarget(m_controllingPrim.MoveToTargetTarget);
112 m_targetMotor.SetCurrent(m_controllingPrim.RawPosition); 118 m_targetMotor.SetCurrent(m_controllingPrim.RawPosition);
113 119
114 m_physicsScene.BeforeStep += Mover; 120 // m_physicsScene.BeforeStep += Mover;
121 m_physicsScene.BeforeStep += Mover2;
122 }
123 else
124 {
125 // If already allocated, make sure the target and other paramters are current
126 m_targetMotor.SetTarget(m_controllingPrim.MoveToTargetTarget);
127 m_targetMotor.SetCurrent(m_controllingPrim.RawPosition);
115 } 128 }
116 } 129 }
117 130
@@ -119,12 +132,16 @@ public class BSActorMoveToTarget : BSActor
119 { 132 {
120 if (m_targetMotor != null) 133 if (m_targetMotor != null)
121 { 134 {
122 m_physicsScene.BeforeStep -= Mover; 135 // m_physicsScene.BeforeStep -= Mover;
136 m_physicsScene.BeforeStep -= Mover2;
123 m_targetMotor = null; 137 m_targetMotor = null;
124 } 138 }
125 } 139 }
126 140
127 // Called just before the simulation step. Update the vertical position for hoverness. 141 // Origional mover that set the objects position to move to the target.
142 // The problem was that gravity would keep trying to push the object down so
143 // the overall downward velocity would increase to infinity.
144 // Called just before the simulation step.
128 private void Mover(float timeStep) 145 private void Mover(float timeStep)
129 { 146 {
130 // Don't do hovering while the object is selected. 147 // Don't do hovering while the object is selected.
@@ -142,6 +159,7 @@ public class BSActorMoveToTarget : BSActor
142 m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover,zeroMovement,movePos={1},pos={2},mass={3}", 159 m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover,zeroMovement,movePos={1},pos={2},mass={3}",
143 m_controllingPrim.LocalID, movePosition, m_controllingPrim.RawPosition, m_controllingPrim.Mass); 160 m_controllingPrim.LocalID, movePosition, m_controllingPrim.RawPosition, m_controllingPrim.Mass);
144 m_controllingPrim.ForcePosition = m_targetMotor.TargetValue; 161 m_controllingPrim.ForcePosition = m_targetMotor.TargetValue;
162 m_controllingPrim.ForceVelocity = OMV.Vector3.Zero;
145 // Setting the position does not cause the physics engine to generate a property update. Force it. 163 // Setting the position does not cause the physics engine to generate a property update. Force it.
146 m_physicsScene.PE.PushUpdate(m_controllingPrim.PhysBody); 164 m_physicsScene.PE.PushUpdate(m_controllingPrim.PhysBody);
147 } 165 }
@@ -151,7 +169,51 @@ public class BSActorMoveToTarget : BSActor
151 // Setting the position does not cause the physics engine to generate a property update. Force it. 169 // Setting the position does not cause the physics engine to generate a property update. Force it.
152 m_physicsScene.PE.PushUpdate(m_controllingPrim.PhysBody); 170 m_physicsScene.PE.PushUpdate(m_controllingPrim.PhysBody);
153 } 171 }
154 m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover,move,fromPos={1},movePos={2}", m_controllingPrim.LocalID, origPosition, movePosition); 172 m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover,move,fromPos={1},movePos={2}",
173 m_controllingPrim.LocalID, origPosition, movePosition);
174 }
175
176 // Version of mover that applies forces to move the physical object to the target.
177 // Also overcomes gravity so the object doesn't just drop to the ground.
178 // Called just before the simulation step.
179 private void Mover2(float timeStep)
180 {
181 // Don't do hovering while the object is selected.
182 if (!isActive)
183 return;
184
185 OMV.Vector3 origPosition = m_controllingPrim.RawPosition; // DEBUG DEBUG (for printout below)
186 OMV.Vector3 addedForce = OMV.Vector3.Zero;
187
188 // CorrectionVector is the movement vector required this step
189 OMV.Vector3 correctionVector = m_targetMotor.Step(timeStep, m_controllingPrim.RawPosition);
190
191 // If we are very close to our target, turn off the movement motor.
192 if (m_targetMotor.ErrorIsZero())
193 {
194 m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover3,zeroMovement,pos={1},mass={2}",
195 m_controllingPrim.LocalID, m_controllingPrim.RawPosition, m_controllingPrim.Mass);
196 m_controllingPrim.ForcePosition = m_targetMotor.TargetValue;
197 m_controllingPrim.ForceVelocity = OMV.Vector3.Zero;
198 // Setting the position does not cause the physics engine to generate a property update. Force it.
199 m_physicsScene.PE.PushUpdate(m_controllingPrim.PhysBody);
200 }
201 else
202 {
203 // First force to move us there -- the motor return a timestep scaled value.
204 addedForce = correctionVector / timeStep;
205 // Remove the existing velocity (only the moveToTarget force counts)
206 addedForce -= m_controllingPrim.RawVelocity;
207 // Overcome gravity.
208 addedForce -= m_controllingPrim.Gravity;
209
210 // Add enough force to overcome the mass of the object
211 addedForce *= m_controllingPrim.Mass;
212
213 m_controllingPrim.AddForce(addedForce, false /* pushForce */, true /* inTaintTime */);
214 }
215 m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover3,move,fromPos={1},addedForce={2}",
216 m_controllingPrim.LocalID, origPosition, addedForce);
155 } 217 }
156} 218}
157} 219}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 48f842e..5ef6992 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -626,7 +626,7 @@ public sealed class BSCharacter : BSPhysObject
626 OMV.Vector3 addForce = force / PhysScene.LastTimeStep; 626 OMV.Vector3 addForce = force / PhysScene.LastTimeStep;
627 AddForce(addForce, pushforce, false); 627 AddForce(addForce, pushforce, false);
628 } 628 }
629 private void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { 629 public override void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) {
630 if (force.IsFinite()) 630 if (force.IsFinite())
631 { 631 {
632 OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude); 632 OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 07e87d1..aa247dd 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -1276,7 +1276,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1276 1276
1277 VehicleAddForce(appliedGravity); 1277 VehicleAddForce(appliedGravity);
1278 1278
1279 VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},fudge={3},mass={4},appliedForce={3}", 1279 VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},fudge={3},mass={4},appliedForce={5}",
1280 ControllingPrim.LocalID, m_VehicleGravity, 1280 ControllingPrim.LocalID, m_VehicleGravity,
1281 ControllingPrim.IsColliding, BSParam.VehicleGroundGravityFudge, m_vehicleMass, appliedGravity); 1281 ControllingPrim.IsColliding, BSParam.VehicleGroundGravityFudge, m_vehicleMass, appliedGravity);
1282 } 1282 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index 76c2187..ad8e10f 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -33,14 +33,6 @@ using OMV = OpenMetaverse;
33namespace OpenSim.Region.Physics.BulletSPlugin 33namespace OpenSim.Region.Physics.BulletSPlugin
34{ 34{
35 35
36// A BSPrim can get individual information about its linkedness attached
37// to it through an instance of a subclass of LinksetInfo.
38// Each type of linkset will define the information needed for its type.
39public abstract class BSLinksetInfo
40{
41 public virtual void Clear() { }
42}
43
44public abstract class BSLinkset 36public abstract class BSLinkset
45{ 37{
46 // private static string LogHeader = "[BULLETSIM LINKSET]"; 38 // private static string LogHeader = "[BULLETSIM LINKSET]";
@@ -56,15 +48,15 @@ public abstract class BSLinkset
56 { 48 {
57 BSLinkset ret = null; 49 BSLinkset ret = null;
58 50
59 switch ((int)BSParam.LinksetImplementation) 51 switch (parent.LinksetType)
60 { 52 {
61 case (int)LinksetImplementation.Constraint: 53 case LinksetImplementation.Constraint:
62 ret = new BSLinksetConstraints(physScene, parent); 54 ret = new BSLinksetConstraints(physScene, parent);
63 break; 55 break;
64 case (int)LinksetImplementation.Compound: 56 case LinksetImplementation.Compound:
65 ret = new BSLinksetCompound(physScene, parent); 57 ret = new BSLinksetCompound(physScene, parent);
66 break; 58 break;
67 case (int)LinksetImplementation.Manual: 59 case LinksetImplementation.Manual:
68 // ret = new BSLinksetManual(physScene, parent); 60 // ret = new BSLinksetManual(physScene, parent);
69 break; 61 break;
70 default: 62 default:
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 350a5d1..308cf13 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -238,7 +238,6 @@ public sealed class BSLinksetCompound : BSLinkset
238 // there will already be a rebuild scheduled. 238 // there will already be a rebuild scheduled.
239 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild.schedulingRebuild,whichUpdated={1}", 239 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild.schedulingRebuild,whichUpdated={1}",
240 updated.LocalID, whichUpdated); 240 updated.LocalID, whichUpdated);
241 updated.LinksetInfo = null; // setting to 'null' causes relative position to be recomputed.
242 ScheduleRebuild(updated); 241 ScheduleRebuild(updated);
243 } 242 }
244 } 243 }
@@ -294,7 +293,6 @@ public sealed class BSLinksetCompound : BSLinkset
294 child.LocalID, child.PhysBody.AddrString); 293 child.LocalID, child.PhysBody.AddrString);
295 294
296 // Cause the child's body to be rebuilt and thus restored to normal operation 295 // Cause the child's body to be rebuilt and thus restored to normal operation
297 child.LinksetInfo = null;
298 child.ForceBodyShapeRebuild(false); 296 child.ForceBodyShapeRebuild(false);
299 297
300 if (!HasAnyChildren) 298 if (!HasAnyChildren)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
index ef662b5..1214703 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
@@ -144,7 +144,6 @@ public class BSVMotor : BSMotor
144 144
145 Vector3 correction = Vector3.Zero; 145 Vector3 correction = Vector3.Zero;
146 Vector3 error = TargetValue - CurrentValue; 146 Vector3 error = TargetValue - CurrentValue;
147 LastError = error;
148 if (!ErrorIsZero(error)) 147 if (!ErrorIsZero(error))
149 { 148 {
150 correction = StepError(timeStep, error); 149 correction = StepError(timeStep, error);
@@ -179,6 +178,7 @@ public class BSVMotor : BSMotor
179 MDetailLog("{0}, BSVMotor.Step,zero,{1},origTgt={2},origCurr={3},currTgt={4},currCurr={5}", 178 MDetailLog("{0}, BSVMotor.Step,zero,{1},origTgt={2},origCurr={3},currTgt={4},currCurr={5}",
180 BSScene.DetailLogZero, UseName, origCurrVal, origTarget, TargetValue, CurrentValue); 179 BSScene.DetailLogZero, UseName, origCurrVal, origTarget, TargetValue, CurrentValue);
181 } 180 }
181 LastError = error;
182 182
183 return correction; 183 return correction;
184 } 184 }
@@ -293,7 +293,6 @@ public class BSFMotor : BSMotor
293 293
294 float correction = 0f; 294 float correction = 0f;
295 float error = TargetValue - CurrentValue; 295 float error = TargetValue - CurrentValue;
296 LastError = error;
297 if (!ErrorIsZero(error)) 296 if (!ErrorIsZero(error))
298 { 297 {
299 correction = StepError(timeStep, error); 298 correction = StepError(timeStep, error);
@@ -328,6 +327,7 @@ public class BSFMotor : BSMotor
328 MDetailLog("{0}, BSFMotor.Step,zero,{1},origTgt={2},origCurr={3},ret={4}", 327 MDetailLog("{0}, BSFMotor.Step,zero,{1},origTgt={2},origCurr={3},ret={4}",
329 BSScene.DetailLogZero, UseName, origCurrVal, origTarget, CurrentValue); 328 BSScene.DetailLogZero, UseName, origCurrVal, origTarget, CurrentValue);
330 } 329 }
330 LastError = error;
331 331
332 return CurrentValue; 332 return CurrentValue;
333 } 333 }
@@ -363,7 +363,7 @@ public class BSFMotor : BSMotor
363 363
364// ============================================================================ 364// ============================================================================
365// ============================================================================ 365// ============================================================================
366// Proportional, Integral, Derivitive Motor 366// Proportional, Integral, Derivitive ("PID") Motor
367// Good description at http://www.answers.com/topic/pid-controller . Includes processes for choosing p, i and d factors. 367// Good description at http://www.answers.com/topic/pid-controller . Includes processes for choosing p, i and d factors.
368public class BSPIDVMotor : BSVMotor 368public class BSPIDVMotor : BSVMotor
369{ 369{
@@ -434,15 +434,14 @@ public class BSPIDVMotor : BSVMotor
434 434
435 // A simple derivitive is the rate of change from the last error. 435 // A simple derivitive is the rate of change from the last error.
436 Vector3 derivitive = (error - LastError) * timeStep; 436 Vector3 derivitive = (error - LastError) * timeStep;
437 LastError = error;
438 437
439 // Correction = (proportionOfPresentError + accumulationOfPastError + rateOfChangeOfError) 438 // Correction = (proportionOfPresentError + accumulationOfPastError + rateOfChangeOfError)
440 Vector3 ret = error * timeStep * proportionFactor * FactorMix.X 439 Vector3 ret = error / TimeScale * timeStep * proportionFactor * FactorMix.X
441 + RunningIntegration * integralFactor * FactorMix.Y 440 + RunningIntegration / TimeScale * integralFactor * FactorMix.Y
442 + derivitive * derivFactor * FactorMix.Z 441 + derivitive / TimeScale * derivFactor * FactorMix.Z
443 ; 442 ;
444 443
445 MDetailLog("{0},BSPIDVMotor.step,ts={1},err={2},runnInt={3},deriv={4},ret={5}", 444 MDetailLog("{0}, BSPIDVMotor.step,ts={1},err={2},runnInt={3},deriv={4},ret={5}",
446 BSScene.DetailLogZero, timeStep, error, RunningIntegration, derivitive, ret); 445 BSScene.DetailLogZero, timeStep, error, RunningIntegration, derivitive, ret);
447 446
448 return ret; 447 return ret;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
index 6437b04..d17c8e7 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
@@ -706,7 +706,7 @@ public static class BSParam
706 new ParameterDefn<float>("ResetBroadphasePool", "Setting this is any value resets the broadphase collision pool", 706 new ParameterDefn<float>("ResetBroadphasePool", "Setting this is any value resets the broadphase collision pool",
707 0f, 707 0f,
708 (s) => { return 0f; }, 708 (s) => { return 0f; },
709 (s,v) => { BSParam.ResetBroadphasePoolTainted(s, v); } ), 709 (s,v) => { BSParam.ResetBroadphasePoolTainted(s, v, false /* inTaintTime */); } ),
710 new ParameterDefn<float>("ResetConstraintSolver", "Setting this is any value resets the constraint solver", 710 new ParameterDefn<float>("ResetConstraintSolver", "Setting this is any value resets the constraint solver",
711 0f, 711 0f,
712 (s) => { return 0f; }, 712 (s) => { return 0f; },
@@ -792,10 +792,10 @@ public static class BSParam
792 // ===================================================================== 792 // =====================================================================
793 // There are parameters that, when set, cause things to happen in the physics engine. 793 // There are parameters that, when set, cause things to happen in the physics engine.
794 // This causes the broadphase collision cache to be cleared. 794 // This causes the broadphase collision cache to be cleared.
795 private static void ResetBroadphasePoolTainted(BSScene pPhysScene, float v) 795 private static void ResetBroadphasePoolTainted(BSScene pPhysScene, float v, bool inTaintTime)
796 { 796 {
797 BSScene physScene = pPhysScene; 797 BSScene physScene = pPhysScene;
798 physScene.TaintedObject("BSParam.ResetBroadphasePoolTainted", delegate() 798 physScene.TaintedObject(inTaintTime, "BSParam.ResetBroadphasePoolTainted", delegate()
799 { 799 {
800 physScene.PE.ResetBroadphasePool(physScene.World); 800 physScene.PE.ResetBroadphasePool(physScene.World);
801 }); 801 });
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index a4c5e08..a0d5c42 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -210,6 +210,7 @@ public abstract class BSPhysObject : PhysicsActor
210 AddAngularForce(force, pushforce, false); 210 AddAngularForce(force, pushforce, false);
211 } 211 }
212 public abstract void AddAngularForce(OMV.Vector3 force, bool pushforce, bool inTaintTime); 212 public abstract void AddAngularForce(OMV.Vector3 force, bool pushforce, bool inTaintTime);
213 public abstract void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime);
213 214
214 public abstract OMV.Vector3 ForceRotationalVelocity { get; set; } 215 public abstract OMV.Vector3 ForceRotationalVelocity { get; set; }
215 216
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 {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
index 235da78..87eed98 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
@@ -41,12 +41,15 @@ public class BSPrimLinkable : BSPrimDisplaced
41 // The index of this child prim. 41 // The index of this child prim.
42 public int LinksetChildIndex { get; set; } 42 public int LinksetChildIndex { get; set; }
43 43
44 public BSLinksetInfo LinksetInfo { get; set; } 44 public BSLinkset.LinksetImplementation LinksetType { get; set; }
45 45
46 public BSPrimLinkable(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, 46 public BSPrimLinkable(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
47 OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) 47 OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
48 : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical) 48 : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical)
49 { 49 {
50 // Default linkset implementation for this prim
51 LinksetType = (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation;
52
50 Linkset = BSLinkset.Factory(PhysScene, this); 53 Linkset = BSLinkset.Factory(PhysScene, this);
51 54
52 PhysScene.TaintedObject("BSPrimLinksetCompound.Refresh", delegate() 55 PhysScene.TaintedObject("BSPrimLinksetCompound.Refresh", delegate()
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index dec6b6f..1645c98 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -223,8 +223,8 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
223 // can be left in and every call doesn't have to check for null. 223 // can be left in and every call doesn't have to check for null.
224 if (m_physicsLoggingEnabled) 224 if (m_physicsLoggingEnabled)
225 { 225 {
226 PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes); 226 PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes, m_physicsLoggingDoFlush);
227 PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output error messages. 227 PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output its own error messages.
228 } 228 }
229 else 229 else
230 { 230 {
@@ -1106,8 +1106,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
1106 public void DetailLog(string msg, params Object[] args) 1106 public void DetailLog(string msg, params Object[] args)
1107 { 1107 {
1108 PhysicsLogging.Write(msg, args); 1108 PhysicsLogging.Write(msg, args);
1109 // Add the Flush() if debugging crashes. Gets all the messages written out.
1110 if (m_physicsLoggingDoFlush) PhysicsLogging.Flush();
1111 } 1109 }
1112 // Used to fill in the LocalID when there isn't one. It's the correct number of characters. 1110 // Used to fill in the LocalID when there isn't one. It's the correct number of characters.
1113 public const string DetailLogZero = "0000000000"; 1111 public const string DetailLogZero = "0000000000";
diff --git a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs
index b040e21..583c436 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs
@@ -114,21 +114,25 @@ public class BasicVehicles : OpenSimTestCase
114 // Instead the appropriate values are set and calls are made just the parts of the 114 // Instead the appropriate values are set and calls are made just the parts of the
115 // controller we want to exercise. Stepping the physics engine then applies 115 // controller we want to exercise. Stepping the physics engine then applies
116 // the actions of that one feature. 116 // the actions of that one feature.
117 TestVehicle.VehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency); 117 BSDynamics vehicleActor = TestVehicle.GetVehicleActor();
118 TestVehicle.VehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale); 118 if (vehicleActor != null)
119 TestVehicle.VehicleActor.enableAngularVerticalAttraction = true;
120
121 TestVehicle.IsPhysical = true;
122 PhysicsScene.ProcessTaints();
123
124 // Step the simulator a bunch of times and vertical attraction should orient the vehicle up
125 for (int ii = 0; ii < simSteps; ii++)
126 { 119 {
127 TestVehicle.VehicleActor.ForgetKnownVehicleProperties(); 120 vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency);
128 TestVehicle.VehicleActor.ComputeAngularVerticalAttraction(); 121 vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale);
129 TestVehicle.VehicleActor.PushKnownChanged(); 122 vehicleActor.enableAngularVerticalAttraction = true;
130 123
131 PhysicsScene.Simulate(simulationTimeStep); 124 TestVehicle.IsPhysical = true;
125 PhysicsScene.ProcessTaints();
126
127 // Step the simulator a bunch of times and vertical attraction should orient the vehicle up
128 for (int ii = 0; ii < simSteps; ii++)
129 {
130 vehicleActor.ForgetKnownVehicleProperties();
131 vehicleActor.ComputeAngularVerticalAttraction();
132 vehicleActor.PushKnownChanged();
133
134 PhysicsScene.Simulate(simulationTimeStep);
135 }
132 } 136 }
133 137
134 TestVehicle.IsPhysical = false; 138 TestVehicle.IsPhysical = false;