fix for issue #1126 (TestHoveringTank assertion failures)
This commit is contained in:
parent
ccfaeab9d4
commit
6efc25f5b2
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009-2012 jMonkeyEngine
|
* Copyright (c) 2009-2019 jMonkeyEngine
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -145,6 +145,7 @@ public class PhysicsHoverControl extends PhysicsVehicle implements PhysicsContro
|
|||||||
Vector3f dir = getForwardVector(tempVect2).multLocal(1, 0, 1).normalizeLocal();
|
Vector3f dir = getForwardVector(tempVect2).multLocal(1, 0, 1).normalizeLocal();
|
||||||
getLinearVelocity(tempVect3);
|
getLinearVelocity(tempVect3);
|
||||||
Vector3f linearVelocity = tempVect3.multLocal(1, 0, 1);
|
Vector3f linearVelocity = tempVect3.multLocal(1, 0, 1);
|
||||||
|
float groundSpeed = linearVelocity.length();
|
||||||
|
|
||||||
if (steeringValue != 0) {
|
if (steeringValue != 0) {
|
||||||
if (rotationVelocity < 1 && rotationVelocity > -1) {
|
if (rotationVelocity < 1 && rotationVelocity > -1) {
|
||||||
@ -163,16 +164,18 @@ public class PhysicsHoverControl extends PhysicsVehicle implements PhysicsContro
|
|||||||
// if we are not going where we want to go.
|
// if we are not going where we want to go.
|
||||||
// this will prevent "drifting" and thus improve control
|
// this will prevent "drifting" and thus improve control
|
||||||
// of the vehicle
|
// of the vehicle
|
||||||
float d = dir.dot(linearVelocity.normalize());
|
if (groundSpeed > FastMath.ZERO_TOLERANCE) {
|
||||||
Vector3f counter = dir.project(linearVelocity).normalizeLocal().negateLocal().multLocal(1 - d);
|
float d = dir.dot(linearVelocity.normalize());
|
||||||
applyForce(counter.multLocal(mass * 10), Vector3f.ZERO);
|
Vector3f counter = dir.project(linearVelocity).normalizeLocal().negateLocal().multLocal(1 - d);
|
||||||
|
applyForce(counter.multLocal(mass * 10), Vector3f.ZERO);
|
||||||
|
}
|
||||||
|
|
||||||
if (linearVelocity.length() < 30) {
|
if (linearVelocity.length() < 30) {
|
||||||
applyForce(dir.multLocal(accelerationValue), Vector3f.ZERO);
|
applyForce(dir.multLocal(accelerationValue), Vector3f.ZERO);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// counter the acceleration value
|
// counter the acceleration value
|
||||||
if (linearVelocity.length() > FastMath.ZERO_TOLERANCE) {
|
if (groundSpeed > FastMath.ZERO_TOLERANCE) {
|
||||||
linearVelocity.normalizeLocal().negateLocal();
|
linearVelocity.normalizeLocal().negateLocal();
|
||||||
applyForce(linearVelocity.mult(mass * 10), Vector3f.ZERO);
|
applyForce(linearVelocity.mult(mass * 10), Vector3f.ZERO);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user