/** Returns {@code true} if both linear and angular components of this steering acceleration are zero; {@code false} otherwise. */ public boolean isZero () { return angular == 0 && linear.isZero(); }
@Override protected SteeringAcceleration<T> calculateRealSteering (SteeringAcceleration<T> steering) { // Check for a zero direction, and return no steering if so if (owner.getLinearVelocity().isZero(getActualLimiter().getZeroLinearSpeedThreshold())) return steering.setZero(); // Calculate the orientation based on the velocity of the owner float orientation = owner.vectorToAngle(owner.getLinearVelocity()); // Delegate to ReachOrientation return reachOrientation(steering, orientation); }
protected SteeringAcceleration<T> face (SteeringAcceleration<T> steering, T targetPosition) { // Get the direction to target T toTarget = steering.linear.set(targetPosition).sub(owner.getPosition()); // Check for a zero direction, and return no steering if so if (toTarget.isZero(getActualLimiter().getZeroLinearSpeedThreshold())) return steering.setZero(); // Calculate the orientation to face the target float orientation = owner.vectorToAngle(toTarget); // Delegate to ReachOrientation return reachOrientation(steering, orientation); }
/** Returns {@code true} if both linear and angular components of this steering acceleration are zero; {@code false} otherwise. */ public boolean isZero () { return angular == 0 && linear.isZero(); }
@Override protected SteeringAcceleration<T> calculateRealSteering (SteeringAcceleration<T> steering) { // Predictive or non-predictive behavior? T location = (predictionTime == 0) ? // Use the current position of the owner owner.getPosition() : // Calculate the predicted future position of the owner. We're reusing steering.linear here. steering.linear.set(owner.getPosition()).mulAdd(owner.getLinearVelocity(), predictionTime); // Retrieve the flow vector at the specified location T flowVector = flowField.lookup(location); // Clear both linear and angular components steering.setZero(); if (flowVector != null && !flowVector.isZero()) { Limiter actualLimiter = getActualLimiter(); // Calculate linear acceleration steering.linear.mulAdd(flowVector, actualLimiter.getMaxLinearSpeed()).sub(owner.getLinearVelocity()) .limit(actualLimiter.getMaxLinearAcceleration()); } // Output steering return steering; }
@Override protected SteeringAcceleration<T> calculateRealSteering (SteeringAcceleration<T> steering) { // Check for a zero direction, and return no steering if so if (owner.getLinearVelocity().isZero(getActualLimiter().getZeroLinearSpeedThreshold())) return steering.setZero(); // Calculate the orientation based on the velocity of the owner float orientation = owner.vectorToAngle(owner.getLinearVelocity()); // Delegate to ReachOrientation return reachOrientation(steering, orientation); }
protected SteeringAcceleration<T> face (SteeringAcceleration<T> steering, T targetPosition) { // Get the direction to target T toTarget = steering.linear.set(targetPosition).sub(owner.getPosition()); // Check for a zero direction, and return no steering if so if (toTarget.isZero(getActualLimiter().getZeroLinearSpeedThreshold())) return steering.setZero(); // Calculate the orientation to face the target float orientation = owner.vectorToAngle(toTarget); // Delegate to ReachOrientation return reachOrientation(steering, orientation); }
@Override protected SteeringAcceleration<T> calculateRealSteering (SteeringAcceleration<T> steering) { // Predictive or non-predictive behavior? T location = (predictionTime == 0) ? // Use the current position of the owner owner.getPosition() : // Calculate the predicted future position of the owner. We're reusing steering.linear here. steering.linear.set(owner.getPosition()).mulAdd(owner.getLinearVelocity(), predictionTime); // Retrieve the flow vector at the specified location T flowVector = flowField.lookup(location); // Clear both linear and angular components steering.setZero(); if (flowVector != null && !flowVector.isZero()) { Limiter actualLimiter = getActualLimiter(); // Calculate linear acceleration steering.linear.mulAdd(flowVector, actualLimiter.getMaxLinearSpeed()).sub(owner.getLinearVelocity()) .limit(actualLimiter.getMaxLinearAcceleration()); } // Output steering return steering; }