- fix PhysicsVehicle initialization

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8477 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent 3ff2771a69
commit 0868244b9a
  1. 3
      engine/src/bullet/com/jme3/bullet/PhysicsSpace.java
  2. 23
      engine/src/bullet/com/jme3/bullet/objects/PhysicsVehicle.java
  3. 2
      engine/src/bullet/com/jme3/bullet/objects/VehicleWheel.java

@ -615,9 +615,7 @@ public class PhysicsSpace {
Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Adding RigidBody {0} to physics space.", node.getObjectId());
if (node instanceof PhysicsVehicle) {
Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Adding vehicle constraint {0} to physics space.", Long.toHexString(((PhysicsVehicle) node).getVehicleId()));
((PhysicsVehicle) node).createVehicle(this);
addVehicle(physicsSpaceId, ((PhysicsVehicle) node).getVehicleId());
// dynamicsWorld.addVehicle(((PhysicsVehicle) node).getVehicleId());
}
}
@ -625,7 +623,6 @@ public class PhysicsSpace {
if (node instanceof PhysicsVehicle) {
Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Removing vehicle constraint {0} from physics space.", Long.toHexString(((PhysicsVehicle) node).getVehicleId()));
removeVehicle(physicsSpaceId, ((PhysicsVehicle) node).getVehicleId());
// dynamicsWorld.removeVehicle(((PhysicsVehicle) node).getVehicleId());
}
Logger.getLogger(PhysicsSpace.class.getName()).log(Level.INFO, "Removing RigidBody {0} from physics space.", Long.toHexString(node.getObjectId()));
physicsNodes.remove(node.getObjectId());

@ -114,9 +114,7 @@ public class PhysicsVehicle extends PhysicsRigidBody {
tuning = new VehicleTuning();
}
motionState.setVehicle(this);
// if (physicsSpace != null) {
// createVehicle(physicsSpace);
// }
createVehicle(physicsSpace);
}
/**
@ -124,12 +122,6 @@ public class PhysicsVehicle extends PhysicsRigidBody {
*/
public void createVehicle(PhysicsSpace space) {
physicsSpace = space;
// try{
// if(5==5)
// throw new IllegalStateException("Who calls this!");
// }catch(Exception e){
// e.printStackTrace();
// }
if (space == null) {
return;
}
@ -137,7 +129,6 @@ public class PhysicsVehicle extends PhysicsRigidBody {
throw new IllegalStateException("Physics space is not initialized!");
}
if (rayCasterId != 0) {
space.removeCollisionObject(this);
Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Clearing RayCaster {0}", Long.toHexString(rayCasterId));
Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Clearing Vehicle {0}", Long.toHexString(vehicleId));
finalizeNative(rayCasterId, vehicleId);
@ -149,12 +140,6 @@ public class PhysicsVehicle extends PhysicsRigidBody {
setCoordinateSystem(vehicleId, 0, 1, 2);
for (VehicleWheel wheel : wheels) {
wheel.setWheelId(addWheel(vehicleId, wheel.getLocation(), wheel.getDirection(), wheel.getAxle(), wheel.getRestLength(), wheel.getRadius(), tuning, wheel.isFrontWheel()));
wheel.setFrictionSlip(tuning.frictionSlip);
wheel.setMaxSuspensionTravelCm(tuning.maxSuspensionTravelCm);
wheel.setSuspensionStiffness(tuning.suspensionStiffness);
wheel.setWheelsDampingCompression(tuning.suspensionCompression);
wheel.setWheelsDampingRelaxation(tuning.suspensionDamping);
wheel.setMaxSuspensionForce(tuning.maxSuspensionForce);
}
}
@ -198,9 +183,6 @@ public class PhysicsVehicle extends PhysicsRigidBody {
} else {
wheel = new VehicleWheel(spat, connectionPoint, direction, axle, suspensionRestLength, wheelRadius, isFrontWheel);
}
if (vehicleId != 0) {
wheel.setWheelId(addWheel(vehicleId, wheel.getLocation(), wheel.getDirection(), wheel.getAxle(), wheel.getRestLength(), wheel.getRadius(), tuning, wheel.isFrontWheel()));
}
wheel.setFrictionSlip(tuning.frictionSlip);
wheel.setMaxSuspensionTravelCm(tuning.maxSuspensionTravelCm);
wheel.setSuspensionStiffness(tuning.suspensionStiffness);
@ -208,6 +190,9 @@ public class PhysicsVehicle extends PhysicsRigidBody {
wheel.setWheelsDampingRelaxation(tuning.suspensionDamping);
wheel.setMaxSuspensionForce(tuning.maxSuspensionForce);
wheels.add(wheel);
if (vehicleId != 0) {
wheel.setWheelId(addWheel(vehicleId, wheel.getLocation(), wheel.getDirection(), wheel.getAxle(), wheel.getRestLength(), wheel.getRadius(), tuning, wheel.isFrontWheel()));
}
if (debugShape != null) {
updateDebugShape();
}

@ -418,7 +418,7 @@ public class VehicleWheel implements Savable {
protected void finalize() throws Throwable {
super.finalize();
Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Finalizing Wheel {0}", Long.toHexString(wheelId));
finalizeNative(wheelId);
// finalizeNative(wheelId);
}
private native void finalizeNative(long wheelId);

Loading…
Cancel
Save