public float calculateAirborneTimeAndVelocity (T outVelocity, JumpDescriptor<T> jumpDescriptor, float maxLinearSpeed) {
		float g = gravityComponentHandler.getComponent(gravity);

		// Calculate the first jump time, see time of flight at http://hyperphysics.phy-astr.gsu.edu/hbase/traj.html
		// Notice that the equation has 2 solutions. We'd ideally like to achieve the jump in the fastest time
		// possible, so we want to use the smaller of the two values. However, this time value might give us
		// an impossible launch velocity (required speed greater than the max), so we need to check and
		// use the higher value if necessary.
		float sqrtTerm = (float)Math.sqrt(2f * g * gravityComponentHandler.getComponent(jumpDescriptor.delta)
			+ maxVerticalVelocity * maxVerticalVelocity);
		float time = (-maxVerticalVelocity + sqrtTerm) / g;
		if (DEBUG_ENABLED) GdxAI.getLogger().info("Jump", "1st jump time = " + time);

		// Check if we can use it
		if (!checkAirborneTimeAndCalculateVelocity(outVelocity, time, jumpDescriptor, maxLinearSpeed)) {
			// Otherwise try the other time
			time = (-maxVerticalVelocity - sqrtTerm) / g;
			if (DEBUG_ENABLED) GdxAI.getLogger().info("Jump", "2nd jump time = " + time);
			if (!checkAirborneTimeAndCalculateVelocity(outVelocity, time, jumpDescriptor, maxLinearSpeed)) {
				return -1f; // Unachievable jump
			}
		}
		return time; // Achievable jump
	}
public float calculateAirborneTimeAndVelocity ( T outVelocity , JumpDescriptor < T > jumpDescriptor , float maxLinearSpeed ) { float g = gravityComponentHandler . getComponent ( gravity ) ; float sqrtTerm = ( float ) Math . sqrt ( 2f * g * gravityComponentHandler . getComponent ( jumpDescriptor . delta ) + maxVerticalVelocity * maxVerticalVelocity ) ; float time = ( - maxVerticalVelocity + sqrtTerm ) / g ; if ( DEBUG_ENABLED ) GdxAI . getLogger ( ) . info ( "Jump" , "1st jump time = " + time ) ; if ( ! checkAirborneTimeAndCalculateVelocity ( outVelocity , time , jumpDescriptor , maxLinearSpeed ) ) { time = ( - maxVerticalVelocity - sqrtTerm ) / g ; if ( DEBUG_ENABLED ) GdxAI . getLogger ( ) . info ( "Jump" , "2nd jump time = " + time ) ; if ( ! checkAirborneTimeAndCalculateVelocity ( outVelocity , time , jumpDescriptor , maxLinearSpeed ) ) { return - 1f ; } } return time ; }
Returns the airborne time and sets the {@code outVelocity} vector to the airborne planar velocity required to achieve the
jump. If the jump is not achievable -1 is returned and the {@code outVelocity} vector remains unchanged.
<p>
Be aware that you should avoid using unlimited or very high max velocity, because this might produce a time of flight close
to 0. Actually, the motion equation for T has 2 solutions and Jump always try to use the fastest time.
@param outVelocity the output vector where the airborne planar velocity is calculated
@param jumpDescriptor the jump descriptor
@param maxLinearSpeed the maximum linear speed that can be used to achieve the jump
@return the time of flight or -1 if the jump is not achievable using the given max linear speed.