diff options
author | Robert Adams | 2013-01-20 09:33:13 -0800 |
---|---|---|
committer | Robert Adams | 2013-01-20 23:09:53 -0800 |
commit | 3b0df52d10c157cd2711d64ef9007d2afccbd468 (patch) | |
tree | ff548c66f9ee84933e33988ec21fb6712b6b82c1 /OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs | |
parent | This updates prebuild to remove BulletSimN, implements the BulletSim API in B... (diff) | |
download | opensim-SC_OLD-3b0df52d10c157cd2711d64ef9007d2afccbd468.zip opensim-SC_OLD-3b0df52d10c157cd2711d64ef9007d2afccbd468.tar.gz opensim-SC_OLD-3b0df52d10c157cd2711d64ef9007d2afccbd468.tar.bz2 opensim-SC_OLD-3b0df52d10c157cd2711d64ef9007d2afccbd468.tar.xz |
BulletSim: modify motors to return correction rather than current value
to better use them for incremental updates.
Modify prim and character to use the new motors.
Simplify the vehicle linear movement code to just update the velocity
directly or the basic movement.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs index 6d0db2e..82fd2d2 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs | |||
@@ -138,7 +138,8 @@ public class BSVMotor : BSMotor | |||
138 | CurrentValue = TargetValue = Vector3.Zero; | 138 | CurrentValue = TargetValue = Vector3.Zero; |
139 | } | 139 | } |
140 | 140 | ||
141 | // Compute the next step and return the new current value | 141 | // Compute the next step and return the new current value. |
142 | // Returns the correction needed to move 'current' to 'target'. | ||
142 | public virtual Vector3 Step(float timeStep) | 143 | public virtual Vector3 Step(float timeStep) |
143 | { | 144 | { |
144 | if (!Enabled) return TargetValue; | 145 | if (!Enabled) return TargetValue; |
@@ -150,7 +151,7 @@ public class BSVMotor : BSMotor | |||
150 | Vector3 error = TargetValue - CurrentValue; | 151 | Vector3 error = TargetValue - CurrentValue; |
151 | if (!ErrorIsZero(error)) | 152 | if (!ErrorIsZero(error)) |
152 | { | 153 | { |
153 | correction = Step(timeStep, error); | 154 | correction = StepError(timeStep, error); |
154 | 155 | ||
155 | CurrentValue += correction; | 156 | CurrentValue += correction; |
156 | 157 | ||
@@ -187,14 +188,20 @@ public class BSVMotor : BSMotor | |||
187 | else | 188 | else |
188 | { | 189 | { |
189 | // Difference between what we have and target is small. Motor is done. | 190 | // Difference between what we have and target is small. Motor is done. |
190 | CurrentValue = TargetValue; | 191 | CurrentValue = TargetValue = Vector3.Zero; |
191 | MDetailLog("{0}, BSVMotor.Step,zero,{1},origTgt={2},origCurr={3},ret={4}", | 192 | MDetailLog("{0}, BSVMotor.Step,zero,{1},origTgt={2},origCurr={3},ret={4}", |
192 | BSScene.DetailLogZero, UseName, origCurrVal, origTarget, CurrentValue); | 193 | BSScene.DetailLogZero, UseName, origCurrVal, origTarget, CurrentValue); |
193 | } | 194 | } |
194 | 195 | ||
195 | return CurrentValue; | 196 | return correction; |
197 | } | ||
198 | // version of step that sets the current value before doing the step | ||
199 | public virtual Vector3 Step(float timeStep, Vector3 current) | ||
200 | { | ||
201 | CurrentValue = current; | ||
202 | return Step(timeStep); | ||
196 | } | 203 | } |
197 | public virtual Vector3 Step(float timeStep, Vector3 error) | 204 | public virtual Vector3 StepError(float timeStep, Vector3 error) |
198 | { | 205 | { |
199 | if (!Enabled) return Vector3.Zero; | 206 | if (!Enabled) return Vector3.Zero; |
200 | 207 | ||
@@ -304,7 +311,7 @@ public class BSFMotor : BSMotor | |||
304 | float error = TargetValue - CurrentValue; | 311 | float error = TargetValue - CurrentValue; |
305 | if (!ErrorIsZero(error)) | 312 | if (!ErrorIsZero(error)) |
306 | { | 313 | { |
307 | correction = Step(timeStep, error); | 314 | correction = StepError(timeStep, error); |
308 | 315 | ||
309 | CurrentValue += correction; | 316 | CurrentValue += correction; |
310 | 317 | ||
@@ -347,7 +354,7 @@ public class BSFMotor : BSMotor | |||
347 | return CurrentValue; | 354 | return CurrentValue; |
348 | } | 355 | } |
349 | 356 | ||
350 | public virtual float Step(float timeStep, float error) | 357 | public virtual float StepError(float timeStep, float error) |
351 | { | 358 | { |
352 | if (!Enabled) return 0f; | 359 | if (!Enabled) return 0f; |
353 | 360 | ||
@@ -440,8 +447,8 @@ public class BSPIDVMotor : BSVMotor | |||
440 | } | 447 | } |
441 | } | 448 | } |
442 | 449 | ||
443 | // Ignore Current and Target Values and just advance the PID computation on this error. | 450 | // Advance the PID computation on this error. |
444 | public override Vector3 Step(float timeStep, Vector3 error) | 451 | public override Vector3 StepError(float timeStep, Vector3 error) |
445 | { | 452 | { |
446 | if (!Enabled) return Vector3.Zero; | 453 | if (!Enabled) return Vector3.Zero; |
447 | 454 | ||