Search in sources :

Example 6 with AABB

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

the class GImpactMeshShape method calcLocalAABB.

@Override
protected void calcLocalAABB() {
    Stack stack = Stack.enter();
    AABB tmpAABB = stack.allocAABB();
    localAABB.invalidate();
    int i = mesh_parts.size();
    while ((i--) != 0) {
        mesh_parts.getQuick(i).updateBound();
        localAABB.merge(mesh_parts.getQuick(i).getLocalBox(tmpAABB));
    }
    stack.leave();
}
Also used : AABB(com.bulletphysics.extras.gimpact.BoxCollision.AABB) Stack(com.bulletphysics.util.Stack)

Example 7 with AABB

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

the class Stack method alloc.

public AABB alloc(AABB box) {
    AABB aabb = allocAABB();
    aabb.set(box);
    return aabb;
}
Also used : AABB(com.bulletphysics.extras.gimpact.BoxCollision.AABB)

Example 8 with AABB

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

the class GImpactBvh method boxQueryTrans.

/**
	 * Returns the indices of the primitives in the primitive_manager field.
	 */
public boolean boxQueryTrans(AABB box, Transform transform, IntArrayList collided_results) {
    Stack stack = Stack.enter();
    AABB transbox = stack.alloc(box);
    transbox.appy_transform(transform);
    boolean result = boxQuery(transbox, collided_results);
    stack.leave();
    return result;
}
Also used : AABB(com.bulletphysics.extras.gimpact.BoxCollision.AABB) Stack(com.bulletphysics.util.Stack)

Example 9 with AABB

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

the class GImpactBvh method boxQuery.

/**
	 * Returns the indices of the primitives in the primitive_manager field.
	 */
public boolean boxQuery(AABB box, IntArrayList collided_results) {
    int curIndex = 0;
    int numNodes = getNodeCount();
    Stack stack = Stack.enter();
    AABB bound = stack.allocAABB();
    while (curIndex < numNodes) {
        getNodeBound(curIndex, bound);
        // catch bugs in tree data
        boolean aabbOverlap = bound.has_collision(box);
        boolean isleafnode = isLeafNode(curIndex);
        if (isleafnode && aabbOverlap) {
            collided_results.add(getNodeData(curIndex));
        }
        if (aabbOverlap || isleafnode) {
            // next subnode
            curIndex++;
        } else {
            // skip node
            curIndex += getEscapeNodeIndex(curIndex);
        }
    }
    if (collided_results.size() > 0) {
        stack.leave();
        return true;
    }
    stack.leave();
    return false;
}
Also used : AABB(com.bulletphysics.extras.gimpact.BoxCollision.AABB) Stack(com.bulletphysics.util.Stack)

Example 10 with AABB

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

the class GImpactBvh method rayQuery.

/**
	 * Returns the indices of the primitives in the primitive_manager field.
	 */
public boolean rayQuery(Vector3f ray_dir, Vector3f ray_origin, IntArrayList collided_results) {
    int curIndex = 0;
    int numNodes = getNodeCount();
    Stack stack = Stack.enter();
    AABB bound = stack.allocAABB();
    while (curIndex < numNodes) {
        getNodeBound(curIndex, bound);
        // catch bugs in tree data
        boolean aabbOverlap = bound.collide_ray(ray_origin, ray_dir);
        boolean isleafnode = isLeafNode(curIndex);
        if (isleafnode && aabbOverlap) {
            collided_results.add(getNodeData(curIndex));
        }
        if (aabbOverlap || isleafnode) {
            // next subnode
            curIndex++;
        } else {
            // skip node
            curIndex += getEscapeNodeIndex(curIndex);
        }
    }
    if (collided_results.size() > 0) {
        stack.leave();
        return true;
    }
    stack.leave();
    return false;
}
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