use of com.bulletphysics.collision.dispatch.CollisionObject in project bdx by GoranM.
the class DiscreteDynamicsWorld method synchronizeMotionStates.
protected void synchronizeMotionStates() {
Stack stack = Stack.enter();
Transform interpolatedTransform = stack.allocTransform();
Transform tmpTrans = stack.allocTransform();
Vector3f tmpLinVel = stack.allocVector3f();
Vector3f tmpAngVel = stack.allocVector3f();
// todo: iterate over awake simulation islands!
for (int i = 0; i < collisionObjects.size(); i++) {
CollisionObject colObj = collisionObjects.getQuick(i);
RigidBody body = RigidBody.upcast(colObj);
if (body != null && body.getMotionState() != null && !body.isStaticOrKinematicObject()) {
// we need to call the update at least once, even for sleeping objects
// otherwise the 'graphics' transform never updates properly
// so todo: add 'dirty' flag
//if (body->getActivationState() != ISLAND_SLEEPING)
{
TransformUtil.integrateTransform(body.getInterpolationWorldTransform(tmpTrans), body.getInterpolationLinearVelocity(tmpLinVel), body.getInterpolationAngularVelocity(tmpAngVel), localTime * body.getHitFraction(), interpolatedTransform);
body.getMotionState().setWorldTransform(interpolatedTransform);
}
}
}
if (getDebugDrawer() != null && (getDebugDrawer().getDebugMode() & DebugDrawModes.DRAW_WIREFRAME) != 0) {
for (int i = 0; i < vehicles.size(); i++) {
for (int v = 0; v < vehicles.getQuick(i).getNumWheels(); v++) {
// synchronize the wheels with the (interpolated) chassis worldtransform
vehicles.getQuick(i).updateWheelTransform(v, true);
}
}
}
stack.leave();
}
use of com.bulletphysics.collision.dispatch.CollisionObject in project bdx by GoranM.
the class SimpleDynamicsWorld method integrateTransforms.
protected void integrateTransforms(float timeStep) {
Stack stack = Stack.enter();
Transform predictedTrans = stack.allocTransform();
for (int i = 0; i < collisionObjects.size(); i++) {
CollisionObject colObj = collisionObjects.getQuick(i);
RigidBody body = RigidBody.upcast(colObj);
if (body != null) {
if (body.isActive() && (!body.isStaticObject())) {
body.predictIntegratedTransform(timeStep, predictedTrans);
body.proceedToTransform(predictedTrans);
}
}
}
stack.leave();
}
use of com.bulletphysics.collision.dispatch.CollisionObject in project bdx by GoranM.
the class SimpleDynamicsWorld method synchronizeMotionStates.
public void synchronizeMotionStates() {
Stack stack = Stack.enter();
Transform tmpTrans = stack.allocTransform();
// todo: iterate over awake simulation islands!
for (int i = 0; i < collisionObjects.size(); i++) {
CollisionObject colObj = collisionObjects.getQuick(i);
RigidBody body = RigidBody.upcast(colObj);
if (body != null && body.getMotionState() != null) {
if (body.getActivationState() != CollisionObject.ISLAND_SLEEPING) {
body.getMotionState().setWorldTransform(body.getWorldTransform(tmpTrans));
}
}
}
stack.leave();
}
use of com.bulletphysics.collision.dispatch.CollisionObject in project bdx by GoranM.
the class SimpleDynamicsWorld method clearForces.
@Override
public void clearForces() {
// todo: iterate over awake simulation islands!
for (int i = 0; i < collisionObjects.size(); i++) {
CollisionObject colObj = collisionObjects.getQuick(i);
RigidBody body = RigidBody.upcast(colObj);
if (body != null) {
body.clearForces();
}
}
}
Aggregations