Search in sources :

Example 16 with CollisionObject

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();
}
Also used : CollisionObject(com.bulletphysics.collision.dispatch.CollisionObject) Vector3f(javax.vecmath.Vector3f) Transform(com.bulletphysics.linearmath.Transform) TypedConstraint(com.bulletphysics.dynamics.constraintsolver.TypedConstraint) ManifoldPoint(com.bulletphysics.collision.narrowphase.ManifoldPoint) Stack(com.bulletphysics.util.Stack)

Example 17 with CollisionObject

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();
}
Also used : CollisionObject(com.bulletphysics.collision.dispatch.CollisionObject) Transform(com.bulletphysics.linearmath.Transform) Stack(com.bulletphysics.util.Stack)

Example 18 with CollisionObject

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();
}
Also used : CollisionObject(com.bulletphysics.collision.dispatch.CollisionObject) Transform(com.bulletphysics.linearmath.Transform) Stack(com.bulletphysics.util.Stack)

Example 19 with CollisionObject

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();
        }
    }
}
Also used : CollisionObject(com.bulletphysics.collision.dispatch.CollisionObject)

Aggregations

CollisionObject (com.bulletphysics.collision.dispatch.CollisionObject)19 ManifoldPoint (com.bulletphysics.collision.narrowphase.ManifoldPoint)12 TypedConstraint (com.bulletphysics.dynamics.constraintsolver.TypedConstraint)11 Stack (com.bulletphysics.util.Stack)10 Transform (com.bulletphysics.linearmath.Transform)9 Vector3f (javax.vecmath.Vector3f)6 PersistentManifold (com.bulletphysics.collision.narrowphase.PersistentManifold)2 PhysicsCollisionObject (com.jme3.bullet.collision.PhysicsCollisionObject)2 ContactAddedCallback (com.bulletphysics.ContactAddedCallback)1 ContactDestroyedCallback (com.bulletphysics.ContactDestroyedCallback)1 ContactProcessedCallback (com.bulletphysics.ContactProcessedCallback)1 BroadphaseInterface (com.bulletphysics.collision.broadphase.BroadphaseInterface)1 BroadphaseProxy (com.bulletphysics.collision.broadphase.BroadphaseProxy)1 OverlapFilterCallback (com.bulletphysics.collision.broadphase.OverlapFilterCallback)1 PairCachingGhostObject (com.bulletphysics.collision.dispatch.PairCachingGhostObject)1 SphereShape (com.bulletphysics.collision.shapes.SphereShape)1 RigidBody (com.bulletphysics.dynamics.RigidBody)1 PhysicsCollisionGroupListener (com.jme3.bullet.collision.PhysicsCollisionGroupListener)1 PhysicsJoint (com.jme3.bullet.joints.PhysicsJoint)1 PhysicsGhostObject (com.jme3.bullet.objects.PhysicsGhostObject)1