aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
authorRobert Adams2012-11-27 05:23:50 -0800
committerRobert Adams2012-11-27 10:03:38 -0800
commit9e0db36c82da303a0d9c709b84b1c35879a39e86 (patch)
tree91262baddcdfca8b9d97026266bbfc3663183381 /OpenSim/Region/Physics
parentFix database service unit test failures by temporarily reverting BasicDataSer... (diff)
downloadopensim-SC_OLD-9e0db36c82da303a0d9c709b84b1c35879a39e86.zip
opensim-SC_OLD-9e0db36c82da303a0d9c709b84b1c35879a39e86.tar.gz
opensim-SC_OLD-9e0db36c82da303a0d9c709b84b1c35879a39e86.tar.bz2
opensim-SC_OLD-9e0db36c82da303a0d9c709b84b1c35879a39e86.tar.xz
BulletSim: add 'infinite' timescale that does not reduce motor target or friction.
Diffstat (limited to 'OpenSim/Region/Physics')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSMotors.cs37
1 files changed, 27 insertions, 10 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
index 480da2c..e91bfa8 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
@@ -7,6 +7,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
7{ 7{
8public abstract class BSMotor 8public abstract class BSMotor
9{ 9{
10 // Timescales and other things can be turned off by setting them to 'infinite'.
11 public const float Infinite = 10000f;
12 public readonly static Vector3 InfiniteVector = new Vector3(BSMotor.Infinite, BSMotor.Infinite, BSMotor.Infinite);
13
10 public BSMotor(string useName) 14 public BSMotor(string useName)
11 { 15 {
12 UseName = useName; 16 UseName = useName;
@@ -46,8 +50,9 @@ public class BSVMotor : BSMotor
46 public BSVMotor(string useName) 50 public BSVMotor(string useName)
47 : base(useName) 51 : base(useName)
48 { 52 {
49 TimeScale = TargetValueDecayTimeScale = Efficiency = 1f; 53 TimeScale = TargetValueDecayTimeScale = BSMotor.Infinite;
50 FrictionTimescale = Vector3.Zero; 54 Efficiency = 1f;
55 FrictionTimescale = BSMotor.InfiniteVector;
51 CurrentValue = TargetValue = Vector3.Zero; 56 CurrentValue = TargetValue = Vector3.Zero;
52 } 57 }
53 public BSVMotor(string useName, float timeScale, float decayTimeScale, Vector3 frictionTimeScale, float efficiency) 58 public BSVMotor(string useName, float timeScale, float decayTimeScale, Vector3 frictionTimeScale, float efficiency)
@@ -78,23 +83,35 @@ public class BSVMotor : BSMotor
78 // Addition = (desiredVector - currentAppliedVector) / secondsItShouldTakeToComplete 83 // Addition = (desiredVector - currentAppliedVector) / secondsItShouldTakeToComplete
79 Vector3 addAmount = (TargetValue - CurrentValue)/TimeScale * timeStep; 84 Vector3 addAmount = (TargetValue - CurrentValue)/TimeScale * timeStep;
80 CurrentValue += addAmount; 85 CurrentValue += addAmount;
86
81 returnCurrent = CurrentValue; 87 returnCurrent = CurrentValue;
82 88
83 // The desired value reduces to zero when also reduces the difference with current. 89 // The desired value reduces to zero which also reduces the difference with current.
84 float decayFactor = (1.0f / TargetValueDecayTimeScale) * timeStep; 90 // If the decay time is infinite, don't decay at all.
85 TargetValue *= (1f - decayFactor); 91 float decayFactor = 0f;
92 if (TargetValueDecayTimeScale != BSMotor.Infinite)
93 {
94 decayFactor = (1.0f / TargetValueDecayTimeScale) * timeStep;
95 TargetValue *= (1f - decayFactor);
96 }
86 97
87 Vector3 frictionFactor = Vector3.Zero; 98 Vector3 frictionFactor = Vector3.Zero;
88 frictionFactor = (Vector3.One / FrictionTimescale) * timeStep; 99 if (FrictionTimescale != BSMotor.InfiniteVector)
89 CurrentValue *= (Vector3.One - frictionFactor); 100 {
101 // frictionFactor = (Vector3.One / FrictionTimescale) * timeStep;
102 frictionFactor.X = FrictionTimescale.X == BSMotor.Infinite ? 0f : (1f / FrictionTimescale.X) * timeStep;
103 frictionFactor.Y = FrictionTimescale.Y == BSMotor.Infinite ? 0f : (1f / FrictionTimescale.Y) * timeStep;
104 frictionFactor.Z = FrictionTimescale.Z == BSMotor.Infinite ? 0f : (1f / FrictionTimescale.Z) * timeStep;
105 CurrentValue *= (Vector3.One - frictionFactor);
106 }
90 107
91 MDetailLog("{0},BSVMotor.Step,nonZero,{1},origTarget={2},origCurr={3},timeStep={4},timeScale={5},addAmnt={6},targetDecay={7},decayFact={8},fricTS={9},frictFact={10}", 108 MDetailLog("{0},BSVMotor.Step,nonZero,{1},origCurr={2},origTarget={3},timeStep={4},timeScale={5},addAmnt={6},targetDecay={7},decayFact={8},fricTS={9},frictFact={10}",
92 BSScene.DetailLogZero, UseName, origTarget, origCurrVal, 109 BSScene.DetailLogZero, UseName, origCurrVal, origTarget,
93 timeStep, TimeScale, addAmount, 110 timeStep, TimeScale, addAmount,
94 TargetValueDecayTimeScale, decayFactor, 111 TargetValueDecayTimeScale, decayFactor,
95 FrictionTimescale, frictionFactor); 112 FrictionTimescale, frictionFactor);
96 MDetailLog("{0},BSVMotor.Step,nonZero,{1},curr={2},target={3},add={4},decay={5},frict={6},ret={7}", 113 MDetailLog("{0},BSVMotor.Step,nonZero,{1},curr={2},target={3},add={4},decay={5},frict={6},ret={7}",
97 BSScene.DetailLogZero, UseName, TargetValue, CurrentValue, 114 BSScene.DetailLogZero, UseName, CurrentValue, TargetValue,
98 addAmount, decayFactor, frictionFactor, returnCurrent); 115 addAmount, decayFactor, frictionFactor, returnCurrent);
99 } 116 }
100 else 117 else