com.badlogic.gdx.physics.bullet.collision.ClosestRayResultCallback Java Examples

The following examples show how to use com.badlogic.gdx.physics.bullet.collision.ClosestRayResultCallback. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Physics.java    From gdx-proto with Apache License 2.0 5 votes vote down vote up
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);
		}
	}
}
 
Example #2
Source File: Physics.java    From gdx-proto with Apache License 2.0 4 votes vote down vote up
private static void setCallbackRayPositions(ClosestRayResultCallback cb, Vector3 from, Vector3 to) {
	cb.setRayFromWorld(from);
	cb.setRayToWorld(to);
}