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;
}
Aggregations