use of com.bulletphysics.util.Stack in project bdx by GoranM.
the class RigidBody method updateDeactivation.
public void updateDeactivation(float timeStep) {
if ((getActivationState() == ISLAND_SLEEPING) || (getActivationState() == DISABLE_DEACTIVATION)) {
return;
}
Stack stack = Stack.enter();
if ((getLinearVelocity(stack.allocVector3f()).lengthSquared() < linearSleepingThreshold * linearSleepingThreshold) && (getAngularVelocity(stack.allocVector3f()).lengthSquared() < angularSleepingThreshold * angularSleepingThreshold)) {
deactivationTime += timeStep;
} else {
deactivationTime = 0f;
setActivationState(0);
}
stack.leave();
}
use of com.bulletphysics.util.Stack in project bdx by GoranM.
the class SimpleDynamicsWorld method predictUnconstraintMotion.
protected void predictUnconstraintMotion(float timeStep) {
Stack stack = Stack.enter();
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.isStaticObject()) {
if (body.isActive()) {
body.applyGravity();
body.integrateVelocities(timeStep);
body.applyDamping(timeStep);
body.predictIntegratedTransform(timeStep, body.getInterpolationWorldTransform(tmpTrans));
}
}
}
}
stack.leave();
}
use of com.bulletphysics.util.Stack 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();
}
use of com.bulletphysics.util.Stack in project bdx by GoranM.
the class KinematicCharacterController method stepDown.
protected void stepDown(CollisionWorld collisionWorld, float dt) {
Stack stack = Stack.enter();
Transform start = stack.allocTransform();
Transform end = stack.allocTransform();
// phase 3: down
float additionalDownStep = (wasOnGround) ? stepHeight : 0.0f;
Vector3f step_drop = stack.allocVector3f();
step_drop.scale(currentStepOffset + additionalDownStep, upAxisDirection[upAxis]);
float downVelocity = (additionalDownStep == 0.0f && verticalVelocity < 0.0f ? -verticalVelocity : 0.0f) * dt;
Vector3f gravity_drop = stack.allocVector3f();
gravity_drop.scale(downVelocity, upAxisDirection[upAxis]);
targetPosition.sub(step_drop);
targetPosition.sub(gravity_drop);
start.setIdentity();
end.setIdentity();
start.origin.set(currentPosition);
end.origin.set(targetPosition);
KinematicClosestNotMeConvexResultCallback callback = new KinematicClosestNotMeConvexResultCallback(ghostObject, upAxisDirection[upAxis], maxSlopeCosine);
callback.collisionFilterGroup = getGhostObject().getBroadphaseHandle().collisionFilterGroup;
callback.collisionFilterMask = getGhostObject().getBroadphaseHandle().collisionFilterMask;
if (useGhostObjectSweepTest) {
ghostObject.convexSweepTest(convexShape, start, end, callback, collisionWorld.getDispatchInfo().allowedCcdPenetration);
} else {
collisionWorld.convexSweepTest(convexShape, start, end, callback);
}
if (callback.hasHit()) {
// we dropped a fraction of the height -> hit floor
currentPosition.interpolate(currentPosition, targetPosition, callback.closestHitFraction);
verticalVelocity = 0.0f;
verticalOffset = 0.0f;
} else {
// we dropped the full height
currentPosition.set(targetPosition);
}
stack.leave();
}
use of com.bulletphysics.util.Stack in project bdx by GoranM.
the class KinematicCharacterController method preStep.
public void preStep(CollisionWorld collisionWorld) {
int numPenetrationLoops = 0;
touchingContact = false;
while (recoverFromPenetration(collisionWorld)) {
numPenetrationLoops++;
touchingContact = true;
if (numPenetrationLoops > 4) {
//printf("character could not recover from penetration = %d\n", numPenetrationLoops);
break;
}
}
Stack stack = Stack.enter();
currentPosition.set(ghostObject.getWorldTransform(stack.allocTransform()).origin);
targetPosition.set(currentPosition);
//printf("m_targetPosition=%f,%f,%f\n",m_targetPosition[0],m_targetPosition[1],m_targetPosition[2]);
stack.leave();
}
Aggregations