Exemple #1
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);
        }
Exemple #2
0
 protected Shape3D(ShapeTypes3D shapeType)
 {
     ShapeType   = shapeType;
     Orientation = quat.Identity;
 }