Java源码示例:com.badlogic.gdx.physics.bullet.collision.ClosestRayResultCallback

示例1
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);
		}
	}
}
 
示例2
private static void setCallbackRayPositions(ClosestRayResultCallback cb, Vector3 from, Vector3 to) {
	cb.setRayFromWorld(from);
	cb.setRayToWorld(to);
}