Пример #1
0
 public static CSGVector2 operator +(CSGVector2 a, CSGVector2 b)
 {
     List<CSGShape> intersec = new List<CSGShape>();
     var aOnly = CSGGeometry.VectorSetSubtract(a.shapes, b.shapes, intersec);
     var bOnly = CSGGeometry.VectorSetSubtract(b.shapes, a.shapes);
     intersec.AddRange(aOnly);
     intersec.AddRange(bOnly);
     CSGVector2 output = new CSGVector2(intersec);
     if (AutoRemoveZeros)
         output.RemoveZeros();
     return output;
 }
Пример #2
0
        public static CSGVector3 operator +(CSGVector3 a, CSGVector3 b)
        {
            //This operation works via set subtraction
            //aOnly = a - b
            //bOnly = b - a
            //intersec = a - aOnly
            List <CSGBlock> intersec = new List <CSGBlock>();
            var             aOnly    = CSGGeometry.VectorSetSubtract(a.blocks, b.blocks, intersec);
            var             bOnly    = CSGGeometry.VectorSetSubtract(b.blocks, a.blocks);

            //aOnly and bOnly are merged with intersec to create a new vector
            intersec.AddRange(aOnly);
            intersec.AddRange(bOnly);
            CSGVector3 output = new CSGVector3(intersec);

            //Remove zeroes is processeced, if required
            if (AutoRemoveZeros)
            {
                output.RemoveZeros();
            }

            //the vector is returned
            return(output);
        }