use of com.bulletphysics.collision.dispatch.CollisionWorld.ClosestRayResultCallback in project bdx by GoranM.
the class DefaultVehicleRaycaster method castRay.
public Object castRay(Vector3f from, Vector3f to, VehicleRaycasterResult result) {
//RayResultCallback& resultCallback;
ClosestRayResultCallback rayCallback = new ClosestRayResultCallback(from, to);
dynamicsWorld.rayTest(from, to, rayCallback);
if (rayCallback.hasHit()) {
RigidBody body = RigidBody.upcast(rayCallback.collisionObject);
if (body != null && body.hasContactResponse()) {
result.hitPointInWorld.set(rayCallback.hitPointWorld);
result.hitNormalInWorld.set(rayCallback.hitNormalWorld);
result.hitNormalInWorld.normalize();
result.distFraction = rayCallback.closestHitFraction;
return body;
}
}
return null;
}
Aggregations