Esempio n. 1
0
        public static bool IsPositionInRange(FLOAT3 from, FLOAT3 target, float minRange, float maxRange)
        {
            var dir         = target - from;
            var distanceSqr = dir.sqrMagnitude;

            if (distanceSqr <= maxRange * maxRange &&
                distanceSqr >= minRange * minRange)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        public static FLOAT3 GetNearestPositionToTarget(FLOAT3 from, FLOAT3 target, float minRange, float maxRange)
        {
            var dir         = target - from;
            var distanceSqr = dir.sqrMagnitude;

            if (distanceSqr <= maxRange * maxRange &&
                distanceSqr >= minRange * minRange)
            {
                return(from);
            }

            var tRange = maxRange;

            if (distanceSqr < minRange * minRange)
            {
                tRange = minRange;
            }

            var ray = new UnityEngine.Ray(target, from - target);

            return(ray.GetPoint(tRange));
        }
Esempio n. 3
0
 public abstract bool ClampPosition(FLOAT3 worldPosition, Constraint constraint, out FLOAT3 position);
Esempio n. 4
0
 public abstract NodeInfo GetNearest(FLOAT3 worldPosition, Constraint constraint);
Esempio n. 5
0
 public NodeInfo GetNearest(FLOAT3 worldPosition)
 {
     return(this.GetNearest(worldPosition, Constraint.Default));
 }
Esempio n. 6
0
        public static FLOAT3 GetSpiralPointByIndex(FLOAT3 center, int index, float radius = 1f)
        {
            var offset = MathUtils.GetSpiralPointByIndex(UnityEngine.Vector2Int.zero, index);

            return(center + new FLOAT3(offset.x * radius, 0f, offset.y * radius));
        }
Esempio n. 7
0
 public static string ToStringDec(this FLOAT3 value)
 {
     return(value.x.ToStringDec() + "; " + value.y.ToStringDec() + "; " + value.z.ToStringDec());
 }
Esempio n. 8
0
 public static string ToFullString(this FLOAT3 vec)
 {
     return($"{vec.x};{vec.y};{vec.z}");
 }
Esempio n. 9
0
        public static UnityEngine.Vector3Int RotateBySector(this UnityEngine.Vector3Int vecUp, FLOAT3 dir)
        {
            var p = vecUp;
            var x = Mathf.Abs(dir.x);
            var z = Mathf.Abs(dir.z);

            if (dir.x >= 0f &&
                x >= z)
            {
                // right
                vecUp = vecUp.Rotate90();
            }
            else if (dir.z >= 0f &&
                     z >= x)
            {
                // up
            }
            else if (dir.z <= 0f &&
                     z >= x)
            {
                // down
                vecUp = vecUp.Rotate90();
                vecUp = vecUp.Rotate90();
            }
            else if (dir.x <= 0f &&
                     x >= z)
            {
                // left
                vecUp = vecUp.Rotate90();
                vecUp = vecUp.Rotate90();
                vecUp = vecUp.Rotate90();
            }

            return(vecUp);
        }