Search in sources :

Example 11 with AABB

use of com.bulletphysics.extras.gimpact.BoxCollision.AABB in project bdx by GoranM.

the class GImpactBvh method refit.

// stackless refit
protected void refit() {
    Stack stack = Stack.enter();
    AABB leafbox = stack.allocAABB();
    AABB bound = stack.allocAABB();
    AABB temp_box = stack.allocAABB();
    int nodecount = getNodeCount();
    while ((nodecount--) != 0) {
        if (isLeafNode(nodecount)) {
            primitive_manager.get_primitive_box(getNodeData(nodecount), leafbox);
            setNodeBound(nodecount, leafbox);
        } else {
            //const BT_BVH_TREE_NODE * nodepointer = get_node_pointer(nodecount);
            //get left bound
            bound.invalidate();
            int child_node = getLeftNode(nodecount);
            if (child_node != 0) {
                getNodeBound(child_node, temp_box);
                bound.merge(temp_box);
            }
            child_node = getRightNode(nodecount);
            if (child_node != 0) {
                getNodeBound(child_node, temp_box);
                bound.merge(temp_box);
            }
            setNodeBound(nodecount, bound);
        }
    }
    stack.leave();
}
Also used : AABB(com.bulletphysics.extras.gimpact.BoxCollision.AABB) Stack(com.bulletphysics.util.Stack)

Example 12 with AABB

use of com.bulletphysics.extras.gimpact.BoxCollision.AABB in project bdx by GoranM.

the class GImpactCollisionAlgorithm method gimpact_vs_shape_find_pairs.

protected void gimpact_vs_shape_find_pairs(Transform trans0, Transform trans1, GImpactShapeInterface shape0, CollisionShape shape1, IntArrayList collided_primitives) {
    Stack stack = Stack.enter();
    AABB boxshape = stack.allocAABB();
    if (shape0.hasBoxSet()) {
        Transform trans1to0 = stack.allocTransform();
        trans1to0.inverse(trans0);
        trans1to0.mul(trans1);
        shape1.getAabb(trans1to0, boxshape.min, boxshape.max);
        shape0.getBoxSet().boxQuery(boxshape, collided_primitives);
    } else {
        shape1.getAabb(trans1, boxshape.min, boxshape.max);
        AABB boxshape0 = stack.allocAABB();
        int i = shape0.getNumChildShapes();
        while ((i--) != 0) {
            shape0.getChildAabb(i, trans0, boxshape0.min, boxshape0.max);
            if (boxshape.has_collision(boxshape0)) {
                collided_primitives.add(i);
            }
        }
    }
    stack.leave();
}
Also used : Transform(com.bulletphysics.linearmath.Transform) AABB(com.bulletphysics.extras.gimpact.BoxCollision.AABB) Stack(com.bulletphysics.util.Stack)

Example 13 with AABB

use of com.bulletphysics.extras.gimpact.BoxCollision.AABB in project bdx by GoranM.

the class GImpactMeshShapePart method processAllTriangles.

@Override
public void processAllTriangles(TriangleCallback callback, Vector3f aabbMin, Vector3f aabbMax) {
    Stack stack = Stack.enter();
    lockChildShapes();
    AABB box = stack.allocAABB();
    box.min.set(aabbMin);
    box.max.set(aabbMax);
    collided.clear();
    box_set.boxQuery(box, collided);
    if (collided.size() == 0) {
        unlockChildShapes();
        return;
    }
    int part = getPart();
    PrimitiveTriangle triangle = stack.allocPrimitiveTriangle();
    int i = collided.size();
    while ((i--) != 0) {
        getPrimitiveTriangle(collided.get(i), triangle);
        callback.processTriangle(triangle.vertices, part, collided.get(i));
    }
    unlockChildShapes();
    stack.leave();
}
Also used : AABB(com.bulletphysics.extras.gimpact.BoxCollision.AABB) Stack(com.bulletphysics.util.Stack)

Example 14 with AABB

use of com.bulletphysics.extras.gimpact.BoxCollision.AABB in project bdx by GoranM.

the class GImpactShapeInterface method getAabb.

/**
	 * If the Bounding box is not updated, then this class attemps to calculate it.<p>
     * Calls updateBound() for update the box set.
     */
@Override
public void getAabb(Transform t, Vector3f aabbMin, Vector3f aabbMax) {
    Stack stack = Stack.enter();
    AABB transformedbox = stack.alloc(localAABB);
    transformedbox.appy_transform(t);
    aabbMin.set(transformedbox.min);
    aabbMax.set(transformedbox.max);
    stack.leave();
}
Also used : AABB(com.bulletphysics.extras.gimpact.BoxCollision.AABB) Stack(com.bulletphysics.util.Stack)

Example 15 with AABB

use of com.bulletphysics.extras.gimpact.BoxCollision.AABB in project bdx by GoranM.

the class GImpactShapeInterface method getChildAabb.

/**
	 * Retrieves the bound from a child.
	 */
public void getChildAabb(int child_index, Transform t, Vector3f aabbMin, Vector3f aabbMax) {
    Stack stack = Stack.enter();
    AABB child_aabb = stack.allocAABB();
    getPrimitiveManager().get_primitive_box(child_index, child_aabb);
    child_aabb.appy_transform(t);
    aabbMin.set(child_aabb.min);
    aabbMax.set(child_aabb.max);
    stack.leave();
}
Also used : AABB(com.bulletphysics.extras.gimpact.BoxCollision.AABB) Stack(com.bulletphysics.util.Stack)

Aggregations

AABB (com.bulletphysics.extras.gimpact.BoxCollision.AABB)17 Stack (com.bulletphysics.util.Stack)15 Transform (com.bulletphysics.linearmath.Transform)2 Vector3f (javax.vecmath.Vector3f)2 StaticPlaneShape (com.bulletphysics.collision.shapes.StaticPlaneShape)1 Vector4f (javax.vecmath.Vector4f)1