public FollowOrientation_Worker(FollowDirectionType direction, float value, bool isAccel = true, bool isSpring = false, GradientEntry[] gradient = null) { if (gradient != null && gradient.Length == 1) { throw new ArgumentException("Gradient must have at least two items if it is populated"); } Direction = direction; Value = value; IsAccel = isAccel; IsSpring = isSpring; if (gradient == null || gradient.Length == 0) { Gradient = null; } else { Gradient = gradient; } }
private static void GetDesiredVector(out Vector3 unit, out float length, FollowOrientation_Args e, FollowDirectionType direction) { switch (direction) { case FollowDirectionType.Drag_Velocity_Along: unit = e.AngVelocityAlongUnit; length = e.AngVelocityAlongLength; break; case FollowDirectionType.Drag_Velocity_AlongIfVelocityAway: unit = e.AngVelocityAlongUnit; length = Vector3.Dot(e.AngVelocityUnit, e.Rotation_Axis) < 0 ? e.AngVelocityAlongLength : 0f; break; case FollowDirectionType.Drag_Velocity_AlongIfVelocityToward: unit = e.AngVelocityAlongUnit; length = Vector3.Dot(e.AngVelocityUnit, e.Rotation_Axis) >= 0 ? e.AngVelocityAlongLength : 0f; break; case FollowDirectionType.Attract_Direction: unit = e.Rotation_Axis; length = e.Rotation_Angle; break; case FollowDirectionType.Drag_Velocity_Any: unit = e.AngVelocityUnit; length = e.AngVelocityLength; break; case FollowDirectionType.Drag_Velocity_Orth: unit = e.AngVelocityOrthUnit; length = e.AngVelocityOrthLength; break; default: throw new ApplicationException($"Unknown DirectionType: {direction}"); } }