Search in sources :

Example 11 with CollisionObject

use of com.bulletphysics.collision.dispatch.CollisionObject in project bdx by GoranM.

the class DiscreteDynamicsWorld method applyGravity.

/**
	 * Apply gravity, call this once per timestep.
	 */
public void applyGravity() {
    // 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.isActive()) {
            body.applyGravity();
        }
    }
}
Also used : CollisionObject(com.bulletphysics.collision.dispatch.CollisionObject) TypedConstraint(com.bulletphysics.dynamics.constraintsolver.TypedConstraint) ManifoldPoint(com.bulletphysics.collision.narrowphase.ManifoldPoint)

Example 12 with CollisionObject

use of com.bulletphysics.collision.dispatch.CollisionObject in project bdx by GoranM.

the class DiscreteDynamicsWorld method getConstraintIslandId.

private static int getConstraintIslandId(TypedConstraint lhs) {
    int islandId;
    CollisionObject rcolObj0 = lhs.getRigidBodyA();
    CollisionObject rcolObj1 = lhs.getRigidBodyB();
    islandId = rcolObj0.getIslandTag() >= 0 ? rcolObj0.getIslandTag() : rcolObj1.getIslandTag();
    return islandId;
}
Also used : CollisionObject(com.bulletphysics.collision.dispatch.CollisionObject) TypedConstraint(com.bulletphysics.dynamics.constraintsolver.TypedConstraint) ManifoldPoint(com.bulletphysics.collision.narrowphase.ManifoldPoint)

Example 13 with CollisionObject

use of com.bulletphysics.collision.dispatch.CollisionObject in project bdx by GoranM.

the class DiscreteDynamicsWorld method setGravity.

@Override
public void setGravity(Vector3f gravity) {
    this.gravity.set(gravity);
    for (int i = 0; i < collisionObjects.size(); i++) {
        CollisionObject colObj = collisionObjects.getQuick(i);
        RigidBody body = RigidBody.upcast(colObj);
        if (body != null) {
            body.setGravity(gravity);
        }
    }
}
Also used : CollisionObject(com.bulletphysics.collision.dispatch.CollisionObject) TypedConstraint(com.bulletphysics.dynamics.constraintsolver.TypedConstraint) ManifoldPoint(com.bulletphysics.collision.narrowphase.ManifoldPoint)

Example 14 with CollisionObject

use of com.bulletphysics.collision.dispatch.CollisionObject in project bdx by GoranM.

the class DiscreteDynamicsWorld method saveKinematicState.

protected void saveKinematicState(float timeStep) {
    for (int i = 0; i < collisionObjects.size(); i++) {
        CollisionObject colObj = collisionObjects.getQuick(i);
        RigidBody body = RigidBody.upcast(colObj);
        if (body != null) {
            //Transform predictedTrans = new Transform();
            if (body.getActivationState() != CollisionObject.ISLAND_SLEEPING) {
                if (body.isKinematicObject()) {
                    // to calculate velocities next frame
                    body.saveKinematicState(timeStep);
                }
            }
        }
    }
}
Also used : CollisionObject(com.bulletphysics.collision.dispatch.CollisionObject) TypedConstraint(com.bulletphysics.dynamics.constraintsolver.TypedConstraint) ManifoldPoint(com.bulletphysics.collision.narrowphase.ManifoldPoint)

Example 15 with CollisionObject

use of com.bulletphysics.collision.dispatch.CollisionObject in project bdx by GoranM.

the class DiscreteDynamicsWorld 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) TypedConstraint(com.bulletphysics.dynamics.constraintsolver.TypedConstraint) ManifoldPoint(com.bulletphysics.collision.narrowphase.ManifoldPoint)

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