fix for issue #1126 (TestHoveringTank assertion failures)

accellbaker
Stephen Gold 6 years ago
parent 04f771f7f9
commit a4b22e4b37
  1. 13
      jme3-examples/src/main/java/jme3test/bullet/PhysicsHoverControl.java

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2018 jMonkeyEngine
* Copyright (c) 2009-2019 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -146,6 +146,7 @@ public class PhysicsHoverControl extends PhysicsVehicle implements PhysicsContro
Vector3f dir = getForwardVector(tempVect2).multLocal(1, 0, 1).normalizeLocal();
getLinearVelocity(tempVect3);
Vector3f linearVelocity = tempVect3.multLocal(1, 0, 1);
float groundSpeed = linearVelocity.length();
if (steeringValue != 0) {
if (rotationVelocity < 1 && rotationVelocity > -1) {
@ -164,16 +165,18 @@ public class PhysicsHoverControl extends PhysicsVehicle implements PhysicsContro
// if we are not going where we want to go.
// this will prevent "drifting" and thus improve control
// of the vehicle
float d = dir.dot(linearVelocity.normalize());
Vector3f counter = dir.project(linearVelocity).normalizeLocal().negateLocal().multLocal(1 - d);
applyForce(counter.multLocal(mass * 10), Vector3f.ZERO);
if (groundSpeed > FastMath.ZERO_TOLERANCE) {
float d = dir.dot(linearVelocity.normalize());
Vector3f counter = dir.project(linearVelocity).normalizeLocal().negateLocal().multLocal(1 - d);
applyForce(counter.multLocal(mass * 10), Vector3f.ZERO);
}
if (linearVelocity.length() < 30) {
applyForce(dir.multLocal(accelerationValue), Vector3f.ZERO);
}
} else {
// counter the acceleration value
if (linearVelocity.length() > FastMath.ZERO_TOLERANCE) {
if (groundSpeed > FastMath.ZERO_TOLERANCE) {
linearVelocity.normalizeLocal().negateLocal();
applyForce(linearVelocity.mult(mass * 10), Vector3f.ZERO);
}

Loading…
Cancel
Save