private void executeRayCast(Vector3 position, Vector3 end, RayResultCallback callback) {
raycastReport.reset();
world.rayTest(position, end, callback);
raycastReport.hit = callback.hasHit();
if (raycastReport.hit) {
float length = position.dst(end);
raycastReport.hitDistance = length * callback.getClosestHitFraction();
if (callback instanceof ClosestRayResultCallback) {
ClosestRayResultCallback cb = (ClosestRayResultCallback) callback;
Vector3 normal = tmp;
cb.getHitNormalWorld(tmp);
raycastReport.hitNormal.set(normal.x, normal.y, normal.z);
}
}
}
private static void setCallbackRayPositions(ClosestRayResultCallback cb, Vector3 from, Vector3 to) {
cb.setRayFromWorld(from);
cb.setRayToWorld(to);
}