|
|
@ -70,6 +70,10 @@ public class BulletRigidBodyDebugControl extends AbstractPhysicsDebugControl { |
|
|
|
* geometry to visualize myShape (not null) |
|
|
|
* geometry to visualize myShape (not null) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected Spatial geom; |
|
|
|
protected Spatial geom; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* physics scale for which geom was generated |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
final private Vector3f oldScale = new Vector3f(); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Instantiate an enabled control to visualize the specified body. |
|
|
|
* Instantiate an enabled control to visualize the specified body. |
|
|
@ -81,7 +85,9 @@ public class BulletRigidBodyDebugControl extends AbstractPhysicsDebugControl { |
|
|
|
super(debugAppState); |
|
|
|
super(debugAppState); |
|
|
|
this.body = body; |
|
|
|
this.body = body; |
|
|
|
myShape = body.getCollisionShape(); |
|
|
|
myShape = body.getCollisionShape(); |
|
|
|
this.geom = DebugShapeFactory.getDebugShape(body.getCollisionShape()); |
|
|
|
oldScale.set(myShape.getScale()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.geom = DebugShapeFactory.getDebugShape(myShape); |
|
|
|
this.geom.setName(body.toString()); |
|
|
|
this.geom.setName(body.toString()); |
|
|
|
geom.setMaterial(debugAppState.DEBUG_BLUE); |
|
|
|
geom.setMaterial(debugAppState.DEBUG_BLUE); |
|
|
|
} |
|
|
|
} |
|
|
@ -114,10 +120,18 @@ public class BulletRigidBodyDebugControl extends AbstractPhysicsDebugControl { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void controlUpdate(float tpf) { |
|
|
|
protected void controlUpdate(float tpf) { |
|
|
|
if(myShape != body.getCollisionShape()){ |
|
|
|
CollisionShape newShape = body.getCollisionShape(); |
|
|
|
Node node = (Node) this.spatial; |
|
|
|
Vector3f newScale = newShape.getScale(); |
|
|
|
|
|
|
|
if (myShape != newShape || !oldScale.equals(newScale)) { |
|
|
|
|
|
|
|
myShape = newShape; |
|
|
|
|
|
|
|
oldScale.set(newScale); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Node node = (Node) spatial; |
|
|
|
node.detachChild(geom); |
|
|
|
node.detachChild(geom); |
|
|
|
geom = DebugShapeFactory.getDebugShape(body.getCollisionShape()); |
|
|
|
|
|
|
|
|
|
|
|
geom = DebugShapeFactory.getDebugShape(myShape); |
|
|
|
|
|
|
|
geom.setName(body.toString()); |
|
|
|
|
|
|
|
|
|
|
|
node.attachChild(geom); |
|
|
|
node.attachChild(geom); |
|
|
|
} |
|
|
|
} |
|
|
|
if(body.isActive()){ |
|
|
|
if(body.isActive()){ |
|
|
@ -125,8 +139,10 @@ public class BulletRigidBodyDebugControl extends AbstractPhysicsDebugControl { |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
geom.setMaterial(debugAppState.DEBUG_BLUE); |
|
|
|
geom.setMaterial(debugAppState.DEBUG_BLUE); |
|
|
|
} |
|
|
|
} |
|
|
|
applyPhysicsTransform(body.getPhysicsLocation(location), body.getPhysicsRotation(rotation)); |
|
|
|
|
|
|
|
geom.setLocalScale(body.getCollisionShape().getScale()); |
|
|
|
body.getPhysicsLocation(location); |
|
|
|
|
|
|
|
body.getPhysicsRotation(rotation); |
|
|
|
|
|
|
|
applyPhysicsTransform(location, rotation); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|