Пример #1
0
        private static bool Overlaps(Line3D line, Shape3D other)
        {
            switch (other.ShapeType)
            {
            case ShapeTypes3D.Line: return(Overlaps(line, (Line3D)other));

            case ShapeTypes3D.Sphere: return(Overlaps(line, (Sphere)other));
            }

            return(false);
        }
Пример #2
0
        private static bool Overlaps(Cylinder cylinder, Shape3D other)
        {
            switch (other.ShapeType)
            {
            case ShapeTypes3D.Cylinder: return(Overlaps(cylinder, (Cylinder)other));

            case ShapeTypes3D.Line: return(Overlaps(cylinder, (Line3D)other));

            case ShapeTypes3D.Sphere: return(Overlaps(cylinder, (Sphere)other));
            }

            return(false);
        }
Пример #3
0
        private static bool Overlaps(Box box, Shape3D other)
        {
            switch (other.Type)
            {
            case ShapeTypes3D.Box: return(Overlaps(box, (Box)other));

            case ShapeTypes3D.Capsule: return(Overlaps(box, (Capsule3D)other));

            case ShapeTypes3D.Cylinder: return(Overlaps(box, (Cylinder)other));

            case ShapeTypes3D.Line: return(Overlaps(box, (Line3D)other));

            case ShapeTypes3D.Sphere: return(Overlaps(box, (Sphere)other));
            }

            return(false);
        }
Пример #4
0
        private static bool Overlaps(FlatShape3D flatShape, Shape3D other)
        {
            var flat = flatShape.FlatShape;

            // This means that the flat shape was never assigned (meaning there's definitely no overlap).
            if (flat == null)
            {
                return(false);
            }

            // TODO: Finish this implementation.
            switch (flat.Type)
            {
            }

            return(false);
        }
Пример #5
0
        public static bool Overlaps(Shape3D shape1, Shape3D shape2)
        {
            ShapeTypes3D type1 = shape1.ShapeType;
            ShapeTypes3D type2 = shape2.ShapeType;

            bool isPoint1 = type1 == ShapeTypes3D.Point;
            bool isPoint2 = type2 == ShapeTypes3D.Point;

            if (isPoint1)
            {
                var p1 = shape1.Position;

                return(isPoint2 ? p1 == shape2.Position : shape2.Contains(p1));
            }

            if (isPoint2)
            {
                return(shape1.Contains(shape2.Position));
            }

            if ((int)type1 > (int)type2)
            {
                var temp1 = shape1;
                shape1 = shape2;
                shape2 = temp1;

                type1 = type2;
            }

            switch (type1)
            {
            case ShapeTypes3D.Box: return(Overlaps((Box)shape1, shape2));

            case ShapeTypes3D.Cylinder: return(Overlaps((Cylinder)shape1, shape2));

            case ShapeTypes3D.Line: return(Overlaps((Line3D)shape1, shape2));

            case ShapeTypes3D.Sphere: return(Overlaps((Sphere)shape1, (Sphere)shape2));
            }

            return(false);
        }
Пример #6
0
        public static bool Overlaps(Shape3D shape1, Shape3D shape2)
        {
            var type1 = shape1.Type;
            var type2 = shape2.Type;

            if (type1 == ShapeTypes3D.Point)
            {
                return(shape2.Contains(shape1.Position, Coordinates.Absolute));
            }

            if (type2 == ShapeTypes3D.Point)
            {
                return(shape1.Contains(shape2.Position, Coordinates.Absolute));
            }

            if ((int)type1 > (int)type2)
            {
                var temp1 = shape1;
                shape1 = shape2;
                shape2 = temp1;
                type1  = type2;
            }

            switch (type1)
            {
            case ShapeTypes3D.Box: return(Overlaps((Box)shape1, shape2));

            case ShapeTypes3D.Capsule: return(Overlaps((Capsule3D)shape1, shape2));

            case ShapeTypes3D.Cylinder: return(Overlaps((Cylinder)shape1, shape2));

            case ShapeTypes3D.Flat: return(Overlaps((FlatShape3D)shape1, shape2));

            case ShapeTypes3D.Line: return(Overlaps((Line3D)shape1, shape2));

            case ShapeTypes3D.Sphere: return(Overlaps((Sphere)shape1, (Sphere)shape2));
            }

            return(false);
        }