Search in sources :

Example 66 with Stack

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();
    }
}
Also used : CollisionObject(com.bulletphysics.collision.dispatch.CollisionObject) Transform(com.bulletphysics.linearmath.Transform) TypedConstraint(com.bulletphysics.dynamics.constraintsolver.TypedConstraint) ManifoldPoint(com.bulletphysics.collision.narrowphase.ManifoldPoint) Stack(com.bulletphysics.util.Stack)

Example 67 with Stack

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;
}
Also used : Vector3f(javax.vecmath.Vector3f) Stack(com.bulletphysics.util.Stack)

Example 68 with Stack

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();
}
Also used : Matrix3f(javax.vecmath.Matrix3f) Stack(com.bulletphysics.util.Stack)

Example 69 with Stack

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();
}
Also used : Vector3f(javax.vecmath.Vector3f) Stack(com.bulletphysics.util.Stack)

Example 70 with Stack

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();
        }
    }
}
Also used : Vector3f(javax.vecmath.Vector3f) Stack(com.bulletphysics.util.Stack) StaticAlloc(com.bulletphysics.util.StaticAlloc)

Aggregations

Stack (com.bulletphysics.util.Stack)252 Vector3f (javax.vecmath.Vector3f)197 Transform (com.bulletphysics.linearmath.Transform)65 Matrix3f (javax.vecmath.Matrix3f)23 ManifoldPoint (com.bulletphysics.collision.narrowphase.ManifoldPoint)15 AABB (com.bulletphysics.extras.gimpact.BoxCollision.AABB)15 StaticAlloc (com.bulletphysics.util.StaticAlloc)12 CollisionObject (com.bulletphysics.collision.dispatch.CollisionObject)10 CollisionShape (com.bulletphysics.collision.shapes.CollisionShape)10 TypedConstraint (com.bulletphysics.dynamics.constraintsolver.TypedConstraint)10 Vector4f (javax.vecmath.Vector4f)8 CompoundShape (com.bulletphysics.collision.shapes.CompoundShape)6 ConcaveShape (com.bulletphysics.collision.shapes.ConcaveShape)5 SphereShape (com.bulletphysics.collision.shapes.SphereShape)5 RigidBody (com.bulletphysics.dynamics.RigidBody)5 Quat4f (javax.vecmath.Quat4f)5 ConvexShape (com.bulletphysics.collision.shapes.ConvexShape)4 ObjectArrayList (com.bulletphysics.util.ObjectArrayList)4 PersistentManifold (com.bulletphysics.collision.narrowphase.PersistentManifold)3 VoronoiSimplexSolver (com.bulletphysics.collision.narrowphase.VoronoiSimplexSolver)3