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();
}
}
}
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;
}
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);
}
}
}
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);
}
}
}
}
}
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();
}
}
}
Aggregations