use of com.bulletphysics.collision.dispatch.PairCachingGhostObject in project Terasology by MovingBlocks.
the class BulletPhysics method updateTrigger.
@Override
public // TODO: update if detectGroups changed
boolean updateTrigger(EntityRef entity) {
LocationComponent location = entity.getComponent(LocationComponent.class);
PairCachingGhostObject triggerObj = entityTriggers.get(entity);
if (location == null) {
logger.warn("Trying to update or create trigger of entity that has no LocationComponent?! Entity: {}", entity);
return false;
}
if (triggerObj != null) {
float scale = location.getWorldScale();
if (Math.abs(triggerObj.getCollisionShape().getLocalScaling(new Vector3f()).x - scale) > BulletGlobals.SIMD_EPSILON) {
discreteDynamicsWorld.removeCollisionObject(triggerObj);
newTrigger(entity);
} else {
Quat4f worldRotation = VecMath.to(location.getWorldRotation());
Vector3f worldPosition = VecMath.to(location.getWorldPosition());
triggerObj.setWorldTransform(new Transform(new Matrix4f(worldRotation, worldPosition, 1.0f)));
}
return true;
} else {
newTrigger(entity);
return false;
}
}
Aggregations