Esempio n. 1
0
    public ((int x, int y, int z) min, (int x, int y, int z) max) GetMinAndMax(IVoxelOrientation orientation)
    {
        var(minA, maxA) = a.GetMinAndMax(orientation);
        var(minB, maxB) = b.GetMinAndMax(orientation);

        return(minA.Zip(minB, Math.Max), maxA.Zip(maxB, Math.Min));
    }
 public NavMeshGenerationSettings(
     IVoxelOrientation orientation,
     int maxClimbDistanceInVoxels,
     int maxFallDistanceInVoxels,
     int crouchHeightInVoxels,
     int standingHeightInVoxels)
 {
     this.orientation = orientation;
     this.maxClimbDistanceInVoxels = maxClimbDistanceInVoxels;
     this.maxFallDistanceInVoxels  = maxFallDistanceInVoxels;
     this.crouchHeightInVoxels     = crouchHeightInVoxels;
     this.standingHeightInVoxels   = standingHeightInVoxels;
 }
Esempio n. 3
0
    public ((int x, int y) min, (int x, int y) max) GetMinAndMax(IVoxelOrientation orientation, Func <Vector2, Vector3> vector2To3)
    {
        (int x, int y, int z)min = (int.MaxValue, int.MaxValue, int.MaxValue);
        (int x, int y, int z)max = (int.MinValue, int.MinValue, int.MinValue);

        for (float f = 0f; f < 360f; f += 90f)
        {
            Quaternion rot    = Quaternion.Euler(0f, 0f, f);
            Vector2    corner = (Vector2)(rot * size) + center;
            var        index  = orientation.GetVoxelIndexOfPoint(vector2To3(corner));

            min = min.Zip(index, Math.Min);
            max = max.Zip(index, Math.Max);
        }

        return((min.x, min.y), (max.x, max.y));
    }
Esempio n. 4
0
    public ((int x, int y, int z) min, (int x, int y, int z) max) GetMinAndMax(IVoxelOrientation orientation)
    {
        (int x, int y, int z)min = (int.MaxValue, int.MaxValue, int.MaxValue);
        (int x, int y, int z)max = (int.MinValue, int.MinValue, int.MinValue);

        Vector3 halfScale = scale / 2f;

        if (IsIgnoringAxis(IgnoreAxis.x))
        {
            min.x = int.MinValue;
            max.x = int.MaxValue;
        }
        if (IsIgnoringAxis(IgnoreAxis.y))
        {
            min.y = int.MinValue;
            max.y = int.MaxValue;
        }
        if (IsIgnoringAxis(IgnoreAxis.z))
        {
            min.z = int.MinValue;
            max.z = int.MaxValue;
        }

        // This for loop itterates through each corner
        for (int x = -1; x <= 1; x += 2)
        {
            for (int y = -1; y <= 1; y += 2)
            {
                for (int z = -1; z <= 1; z += 2)
                {
                    Vector3 pos   = (rotation * Vector3.Scale(halfScale, new Vector3(x, y, z))) + center;
                    var     index = orientation.GetVoxelIndexOfPoint(pos);
                    min = min.Zip(index, Math.Min);
                    max = max.Zip(index, Math.Max);
                }
            }
        }

        return(min, max);
    }
Esempio n. 5
0
    public static IEnumerable <(int x, int y)> GetVoxelsInBounds(this IVoxelBounds2 bounds, IVoxelOrientation orientation)
    {
        var(min, max) = bounds.GetMinAndMax(orientation);

        for (int x = min.x; x <= max.x; x++)
        {
            for (int y = min.y; y <= max.y; y++)
            {
                yield return(x, y);
            }
        }
    }
Esempio n. 6
0
 public ((int x, int y) min, (int x, int y) max) GetMinAndMax(IVoxelOrientation orientation) => GetMinAndMax(orientation, SideOn);