Search in sources :

Example 1 with CollisionAlgorithm

use of com.bulletphysics.collision.broadphase.CollisionAlgorithm in project bdx by GoranM.

the class GImpactCollisionAlgorithm method shape_vs_shape_collision.

protected void shape_vs_shape_collision(CollisionObject body0, CollisionObject body1, CollisionShape shape0, CollisionShape shape1) {
    CollisionShape tmpShape0 = body0.getCollisionShape();
    CollisionShape tmpShape1 = body1.getCollisionShape();
    body0.internalSetTemporaryCollisionShape(shape0);
    body1.internalSetTemporaryCollisionShape(shape1);
    {
        CollisionAlgorithm algor = newAlgorithm(body0, body1);
        // post :	checkManifold is called
        resultOut.setShapeIdentifiers(part0, triface0, part1, triface1);
        algor.processCollision(body0, body1, dispatchInfo, resultOut);
        //algor.destroy();
        dispatcher.freeCollisionAlgorithm(algor);
    }
    body0.internalSetTemporaryCollisionShape(tmpShape0);
    body1.internalSetTemporaryCollisionShape(tmpShape1);
}
Also used : CollisionShape(com.bulletphysics.collision.shapes.CollisionShape) CollisionAlgorithm(com.bulletphysics.collision.broadphase.CollisionAlgorithm)

Example 2 with CollisionAlgorithm

use of com.bulletphysics.collision.broadphase.CollisionAlgorithm in project bdx by GoranM.

the class GImpactCollisionAlgorithm method newAlgorithm.

/**
	 * Call before process collision.
	 */
protected CollisionAlgorithm newAlgorithm(CollisionObject body0, CollisionObject body1) {
    checkManifold(body0, body1);
    CollisionAlgorithm convex_algorithm = dispatcher.findAlgorithm(body0, body1, getLastManifold());
    return convex_algorithm;
}
Also used : CollisionAlgorithm(com.bulletphysics.collision.broadphase.CollisionAlgorithm)

Example 3 with CollisionAlgorithm

use of com.bulletphysics.collision.broadphase.CollisionAlgorithm in project bdx by GoranM.

the class CollisionDispatcher method findAlgorithm.

@Override
public CollisionAlgorithm findAlgorithm(CollisionObject body0, CollisionObject body1, PersistentManifold sharedManifold) {
    CollisionAlgorithmConstructionInfo ci = tmpCI;
    ci.dispatcher1 = this;
    ci.manifold = sharedManifold;
    CollisionAlgorithmCreateFunc createFunc = doubleDispatch[body0.getCollisionShape().getShapeType().ordinal()][body1.getCollisionShape().getShapeType().ordinal()];
    CollisionAlgorithm algo = createFunc.createCollisionAlgorithm(ci, body0, body1);
    algo.internalSetCreateFunc(createFunc);
    return algo;
}
Also used : CollisionAlgorithm(com.bulletphysics.collision.broadphase.CollisionAlgorithm) CollisionAlgorithmConstructionInfo(com.bulletphysics.collision.broadphase.CollisionAlgorithmConstructionInfo)

Example 4 with CollisionAlgorithm

use of com.bulletphysics.collision.broadphase.CollisionAlgorithm in project bdx by GoranM.

the class ConvexTriangleCallback method processTriangle.

public void processTriangle(Vector3f[] triangle, int partId, int triangleIndex) {
    // just for debugging purposes
    //printf("triangle %d",m_triangleCount++);
    // aabb filter is already applied!	
    ci.dispatcher1 = dispatcher;
    CollisionObject ob = (CollisionObject) triBody;
    // debug drawing of the overlapping triangles
    if (dispatchInfoPtr != null && dispatchInfoPtr.debugDraw != null && dispatchInfoPtr.debugDraw.getDebugMode() > 0) {
        Stack stack = Stack.enter();
        Vector3f color = stack.allocVector3f();
        color.set(255, 255, 0);
        Transform tr = ob.getWorldTransform(stack.allocTransform());
        Vector3f tmp1 = stack.allocVector3f();
        Vector3f tmp2 = stack.allocVector3f();
        tmp1.set(triangle[0]);
        tr.transform(tmp1);
        tmp2.set(triangle[1]);
        tr.transform(tmp2);
        dispatchInfoPtr.debugDraw.drawLine(tmp1, tmp2, color);
        tmp1.set(triangle[1]);
        tr.transform(tmp1);
        tmp2.set(triangle[2]);
        tr.transform(tmp2);
        dispatchInfoPtr.debugDraw.drawLine(tmp1, tmp2, color);
        tmp1.set(triangle[2]);
        tr.transform(tmp1);
        tmp2.set(triangle[0]);
        tr.transform(tmp2);
        dispatchInfoPtr.debugDraw.drawLine(tmp1, tmp2, color);
        //btVector3 center = triangle[0] + triangle[1]+triangle[2];
        //center *= btScalar(0.333333);
        //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(center),color);
        //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(center),color);
        //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(center),color);
        stack.leave();
    }
    if (convexBody.getCollisionShape().isConvex()) {
        tm.init(triangle[0], triangle[1], triangle[2]);
        tm.setMargin(collisionMarginTriangle);
        CollisionShape tmpShape = ob.getCollisionShape();
        ob.internalSetTemporaryCollisionShape(tm);
        CollisionAlgorithm colAlgo = ci.dispatcher1.findAlgorithm(convexBody, triBody, manifoldPtr);
        // this should use the btDispatcher, so the actual registered algorithm is used
        //		btConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexBody,m_triBody);
        resultOut.setShapeIdentifiers(-1, -1, partId, triangleIndex);
        //cvxcvxalgo.setShapeIdentifiers(-1,-1,partId,triangleIndex);
        //cvxcvxalgo.processCollision(m_convexBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
        colAlgo.processCollision(convexBody, triBody, dispatchInfoPtr, resultOut);
        //colAlgo.destroy();
        ci.dispatcher1.freeCollisionAlgorithm(colAlgo);
        ob.internalSetTemporaryCollisionShape(tmpShape);
    }
}
Also used : CollisionShape(com.bulletphysics.collision.shapes.CollisionShape) CollisionAlgorithm(com.bulletphysics.collision.broadphase.CollisionAlgorithm) Vector3f(javax.vecmath.Vector3f) Transform(com.bulletphysics.linearmath.Transform) Stack(com.bulletphysics.util.Stack)

Aggregations

CollisionAlgorithm (com.bulletphysics.collision.broadphase.CollisionAlgorithm)4 CollisionShape (com.bulletphysics.collision.shapes.CollisionShape)2 CollisionAlgorithmConstructionInfo (com.bulletphysics.collision.broadphase.CollisionAlgorithmConstructionInfo)1 Transform (com.bulletphysics.linearmath.Transform)1 Stack (com.bulletphysics.util.Stack)1 Vector3f (javax.vecmath.Vector3f)1