Search in sources :

Example 1 with GhostObject

use of com.bulletphysics.collision.dispatch.GhostObject in project Terasology by MovingBlocks.

the class BulletPhysics method scanArea.

@Override
public List<EntityRef> scanArea(AABB area, Iterable<CollisionGroup> collisionFilter) {
    // TODO: Add the aabbTest method from newer versions of bullet to TeraBullet, use that instead
    BoxShape shape = new BoxShape(VecMath.to(area.getExtents()));
    GhostObject scanObject = createCollider(VecMath.to(area.getCenter()), shape, CollisionFilterGroups.SENSOR_TRIGGER, combineGroups(collisionFilter), CollisionFlags.NO_CONTACT_RESPONSE);
    // This in particular is overkill
    broadphase.calculateOverlappingPairs(dispatcher);
    List<EntityRef> result = Lists.newArrayList();
    for (int i = 0; i < scanObject.getNumOverlappingObjects(); ++i) {
        CollisionObject other = scanObject.getOverlappingObject(i);
        Object userObj = other.getUserPointer();
        if (userObj instanceof EntityRef) {
            result.add((EntityRef) userObj);
        }
    }
    removeCollider(scanObject);
    return result;
}
Also used : CollisionObject(com.bulletphysics.collision.dispatch.CollisionObject) GhostObject(com.bulletphysics.collision.dispatch.GhostObject) PairCachingGhostObject(com.bulletphysics.collision.dispatch.PairCachingGhostObject) GhostObject(com.bulletphysics.collision.dispatch.GhostObject) PairCachingGhostObject(com.bulletphysics.collision.dispatch.PairCachingGhostObject) CollisionObject(com.bulletphysics.collision.dispatch.CollisionObject) EntityRef(org.terasology.entitySystem.entity.EntityRef) ManifoldPoint(com.bulletphysics.collision.narrowphase.ManifoldPoint) BoxShape(com.bulletphysics.collision.shapes.BoxShape)

Aggregations

CollisionObject (com.bulletphysics.collision.dispatch.CollisionObject)1 GhostObject (com.bulletphysics.collision.dispatch.GhostObject)1 PairCachingGhostObject (com.bulletphysics.collision.dispatch.PairCachingGhostObject)1 ManifoldPoint (com.bulletphysics.collision.narrowphase.ManifoldPoint)1 BoxShape (com.bulletphysics.collision.shapes.BoxShape)1 EntityRef (org.terasology.entitySystem.entity.EntityRef)1