From 0553e9d9a20f8b3866fc56c5196e810941663d93 Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Mon, 10 Sep 2018 15:40:42 -0700 Subject: [PATCH] fix for issue #898 --- .../src/main/java/com/jme3/bullet/PhysicsSpace.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java b/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java index bfb0c4661..83d26e3aa 100644 --- a/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java +++ b/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java @@ -32,7 +32,6 @@ package com.jme3.bullet; import com.jme3.app.AppTask; -import com.jme3.asset.AssetManager; import com.jme3.bullet.collision.*; import com.jme3.bullet.collision.shapes.CollisionShape; import com.jme3.bullet.control.PhysicsControl; @@ -634,9 +633,15 @@ public class PhysicsSpace { logger.log(Level.FINE, "Adding RigidBody {0} to physics space.", node.getObjectId()); if (node instanceof PhysicsVehicle) { - logger.log(Level.FINE, "Adding vehicle constraint {0} to physics space.", Long.toHexString(((PhysicsVehicle) node).getVehicleId())); - physicsVehicles.put(((PhysicsVehicle) node).getVehicleId(), (PhysicsVehicle) node); - addVehicle(physicsSpaceId, ((PhysicsVehicle) node).getVehicleId()); + PhysicsVehicle vehicle = (PhysicsVehicle) node; + vehicle.createVehicle(this); + long vehicleId = vehicle.getVehicleId(); + assert vehicleId != 0L; + logger.log(Level.FINE, + "Adding vehicle constraint {0} to physics space.", + Long.toHexString(vehicleId)); + physicsVehicles.put(vehicleId, vehicle); + addVehicle(physicsSpaceId, vehicleId); } }