use of javax.vecmath.Vector3f in project bdx by GoranM.
the class DiscreteDynamicsWorld method integrateTransforms.
protected void integrateTransforms(float timeStep) {
BulletStats.pushProfile("integrateTransforms");
Stack stack = Stack.enter();
int sp = stack.getSp();
try {
Vector3f tmp = stack.allocVector3f();
Transform tmpTrans = stack.allocTransform();
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) {
body.setHitFraction(1f);
if (body.isActive() && (!body.isStaticOrKinematicObject())) {
body.predictIntegratedTransform(timeStep, predictedTrans);
tmp.sub(predictedTrans.origin, body.getWorldTransform(tmpTrans).origin);
float squareMotion = tmp.lengthSquared();
if (body.getCcdSquareMotionThreshold() != 0f && body.getCcdSquareMotionThreshold() < squareMotion) {
BulletStats.pushProfile("CCD motion clamping");
try {
if (body.getCollisionShape().isConvex()) {
BulletStats.gNumClampedCcdMotions++;
ClosestNotMeConvexResultCallback sweepResults = new ClosestNotMeConvexResultCallback(body, body.getWorldTransform(tmpTrans).origin, predictedTrans.origin, getBroadphase().getOverlappingPairCache(), getDispatcher());
//ConvexShape convexShape = (ConvexShape)body.getCollisionShape();
//btConvexShape* convexShape = static_cast<btConvexShape*>(body->getCollisionShape());
SphereShape tmpSphere = new SphereShape(body.getCcdSweptSphereRadius());
sweepResults.collisionFilterGroup = body.getBroadphaseProxy().collisionFilterGroup;
sweepResults.collisionFilterMask = body.getBroadphaseProxy().collisionFilterMask;
convexSweepTest(tmpSphere, body.getWorldTransform(tmpTrans), predictedTrans, sweepResults);
// JAVA NOTE: added closestHitFraction test to prevent objects being stuck
if (sweepResults.hasHit() && (sweepResults.closestHitFraction > 0.0001f)) {
body.setHitFraction(sweepResults.closestHitFraction);
body.predictIntegratedTransform(timeStep * body.getHitFraction(), predictedTrans);
body.setHitFraction(0f);
//System.out.printf("clamped integration to hit fraction = %f\n", sweepResults.closestHitFraction);
}
}
} finally {
BulletStats.popProfile();
}
}
body.proceedToTransform(predictedTrans);
}
}
}
} finally {
stack.leave(sp);
BulletStats.popProfile();
}
}
use of javax.vecmath.Vector3f 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 javax.vecmath.Vector3f 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 javax.vecmath.Vector3f 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();
}
}
}
use of javax.vecmath.Vector3f in project bdx by GoranM.
the class SimpleDynamicsWorld method updateAabbs.
@Override
public void updateAabbs() {
Stack stack = Stack.enter();
Transform tmpTrans = stack.allocTransform();
// Transform predictedTrans = stack.allocTransform();
Vector3f minAabb = stack.allocVector3f(), maxAabb = stack.allocVector3f();
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())) {
colObj.getCollisionShape().getAabb(colObj.getWorldTransform(tmpTrans), minAabb, maxAabb);
BroadphaseInterface bp = getBroadphase();
bp.setAabb(body.getBroadphaseHandle(), minAabb, maxAabb, dispatcher1);
}
}
}
stack.leave();
}
Aggregations