aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSMotors.cs26
1 files changed, 19 insertions, 7 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
index 82fd2d2..9501e2d 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
@@ -149,6 +149,7 @@ public class BSVMotor : BSMotor
149 149
150 Vector3 correction = Vector3.Zero; 150 Vector3 correction = Vector3.Zero;
151 Vector3 error = TargetValue - CurrentValue; 151 Vector3 error = TargetValue - CurrentValue;
152 LastError = error;
152 if (!ErrorIsZero(error)) 153 if (!ErrorIsZero(error))
153 { 154 {
154 correction = StepError(timeStep, error); 155 correction = StepError(timeStep, error);
@@ -188,9 +189,15 @@ public class BSVMotor : BSMotor
188 else 189 else
189 { 190 {
190 // Difference between what we have and target is small. Motor is done. 191 // Difference between what we have and target is small. Motor is done.
191 CurrentValue = TargetValue = Vector3.Zero; 192 if (TargetValue.ApproxEquals(Vector3.Zero, ErrorZeroThreshold))
192 MDetailLog("{0}, BSVMotor.Step,zero,{1},origTgt={2},origCurr={3},ret={4}", 193 {
193 BSScene.DetailLogZero, UseName, origCurrVal, origTarget, CurrentValue); 194 // The target can step down to nearly zero but not get there. If close to zero
195 // it is really zero.
196 TargetValue = Vector3.Zero;
197 }
198 CurrentValue = TargetValue;
199 MDetailLog("{0}, BSVMotor.Step,zero,{1},origTgt={2},origCurr={3},currTgt={4},currCurr={5}",
200 BSScene.DetailLogZero, UseName, origCurrVal, origTarget, TargetValue, CurrentValue);
194 } 201 }
195 202
196 return correction; 203 return correction;
@@ -205,9 +212,8 @@ public class BSVMotor : BSMotor
205 { 212 {
206 if (!Enabled) return Vector3.Zero; 213 if (!Enabled) return Vector3.Zero;
207 214
208 LastError = error;
209 Vector3 returnCorrection = Vector3.Zero; 215 Vector3 returnCorrection = Vector3.Zero;
210 if (!ErrorIsZero()) 216 if (!ErrorIsZero(error))
211 { 217 {
212 // correction = error / secondsItShouldTakeToCorrect 218 // correction = error / secondsItShouldTakeToCorrect
213 Vector3 correctionAmount; 219 Vector3 correctionAmount;
@@ -309,6 +315,7 @@ public class BSFMotor : BSMotor
309 315
310 float correction = 0f; 316 float correction = 0f;
311 float error = TargetValue - CurrentValue; 317 float error = TargetValue - CurrentValue;
318 LastError = error;
312 if (!ErrorIsZero(error)) 319 if (!ErrorIsZero(error))
313 { 320 {
314 correction = StepError(timeStep, error); 321 correction = StepError(timeStep, error);
@@ -346,6 +353,12 @@ public class BSFMotor : BSMotor
346 else 353 else
347 { 354 {
348 // Difference between what we have and target is small. Motor is done. 355 // Difference between what we have and target is small. Motor is done.
356 if (Util.InRange<float>(TargetValue, -ErrorZeroThreshold, ErrorZeroThreshold))
357 {
358 // The target can step down to nearly zero but not get there. If close to zero
359 // it is really zero.
360 TargetValue = 0f;
361 }
349 CurrentValue = TargetValue; 362 CurrentValue = TargetValue;
350 MDetailLog("{0}, BSFMotor.Step,zero,{1},origTgt={2},origCurr={3},ret={4}", 363 MDetailLog("{0}, BSFMotor.Step,zero,{1},origTgt={2},origCurr={3},ret={4}",
351 BSScene.DetailLogZero, UseName, origCurrVal, origTarget, CurrentValue); 364 BSScene.DetailLogZero, UseName, origCurrVal, origTarget, CurrentValue);
@@ -358,9 +371,8 @@ public class BSFMotor : BSMotor
358 { 371 {
359 if (!Enabled) return 0f; 372 if (!Enabled) return 0f;
360 373
361 LastError = error;
362 float returnCorrection = 0f; 374 float returnCorrection = 0f;
363 if (!ErrorIsZero()) 375 if (!ErrorIsZero(error))
364 { 376 {
365 // correction = error / secondsItShouldTakeToCorrect 377 // correction = error / secondsItShouldTakeToCorrect
366 float correctionAmount; 378 float correctionAmount;