use of com.bulletphysics.util.Stack in project bdx by GoranM.
the class DiscreteDynamicsWorld method predictUnconstraintMotion.
protected void predictUnconstraintMotion(float timeStep) {
BulletStats.pushProfile("predictUnconstraintMotion");
Stack stack = Stack.enter();
int sp = stack.getSp();
try {
Transform tmpTrans = 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.isStaticOrKinematicObject()) {
if (body.isActive()) {
body.integrateVelocities(timeStep);
// damping
body.applyDamping(timeStep);
body.predictIntegratedTransform(timeStep, body.getInterpolationWorldTransform(tmpTrans));
}
}
}
}
} finally {
stack.leave(sp);
BulletStats.popProfile();
}
}
use of com.bulletphysics.util.Stack in project bdx by GoranM.
the class RigidBody method computeImpulseDenominator.
public float computeImpulseDenominator(Vector3f pos, Vector3f normal) {
Stack stack = Stack.enter();
Vector3f r0 = stack.allocVector3f();
r0.sub(pos, getCenterOfMassPosition(stack.allocVector3f()));
Vector3f c0 = stack.allocVector3f();
c0.cross(r0, normal);
Vector3f tmp = stack.allocVector3f();
MatrixUtil.transposeTransform(tmp, c0, getInvInertiaTensorWorld(stack.allocMatrix3f()));
Vector3f vec = stack.allocVector3f();
vec.cross(tmp, r0);
float result = inverseMass + normal.dot(vec);
stack.leave();
return result;
}
use of com.bulletphysics.util.Stack in project bdx by GoranM.
the class RigidBody method updateInertiaTensor.
public void updateInertiaTensor() {
Stack stack = Stack.enter();
Matrix3f mat1 = stack.allocMatrix3f();
MatrixUtil.scale(mat1, worldTransform.basis, invInertiaLocal);
Matrix3f mat2 = stack.alloc(worldTransform.basis);
mat2.transpose();
invInertiaTensorWorld.mul(mat1, mat2);
stack.leave();
}
use of com.bulletphysics.util.Stack in project bdx by GoranM.
the class RigidBody method applyForce.
public void applyForce(Vector3f force, Vector3f rel_pos) {
Stack stack = Stack.enter();
applyCentralForce(force);
Vector3f tmp = stack.allocVector3f();
tmp.cross(rel_pos, force);
tmp.scale(angularFactor);
applyTorque(tmp);
stack.leave();
}
use of com.bulletphysics.util.Stack in project bdx by GoranM.
the class RigidBody method applyImpulse.
@StaticAlloc
public void applyImpulse(Vector3f impulse, Vector3f rel_pos) {
if (inverseMass != 0f) {
applyCentralImpulse(impulse);
if (angularFactor != 0f) {
Stack stack = Stack.enter();
Vector3f tmp = stack.allocVector3f();
tmp.cross(rel_pos, impulse);
tmp.scale(angularFactor);
applyTorqueImpulse(tmp);
stack.leave();
}
}
}
Aggregations