Ejemplo n.º 1
0
 public void Add(RHBoundingBox box)
 {
     if (box.minPoint == null)
     {
         return;
     }
     Add(box.minPoint);
     Add(box.maxPoint);
 }
Ejemplo n.º 2
0
        public bool IntersectsBox(RHBoundingBox box)
        {
            if (minPoint == null || box.minPoint == null)
            {
                return(false);
            }
            bool xOverlap = Overlap(minPoint.x, maxPoint.x, box.minPoint.x, box.maxPoint.x);
            bool yOverlap = Overlap(minPoint.y, maxPoint.y, box.minPoint.y, box.maxPoint.y);
            bool zOverlap = Overlap(minPoint.z, maxPoint.z, box.minPoint.z, box.maxPoint.z);

            return(xOverlap && yOverlap && zOverlap);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Convert the box range into bitpattern for a fast intersection test.
        ///
        /// </summary>
        /// <param name="box"></param>
        /// <returns></returns>
        public int RangeToBits(RHBoundingBox box)
        {
            double dx = (maxPoint.x - minPoint.x) / 10;
            double dy = (maxPoint.y - minPoint.y) / 10;
            double dz = (maxPoint.z - minPoint.z) / 10;
            int    p  = 0;
            int    i;
            double px  = minPoint.x;
            double px2 = px + dx;
            double vx  = box.minPoint.x;
            double vx2 = box.maxPoint.x;
            double py  = minPoint.y;
            double py2 = py + dy;
            double vy  = box.minPoint.y;
            double vy2 = box.maxPoint.y;
            double pz  = minPoint.z;
            double pz2 = pz + dz;
            double vz  = box.minPoint.z;
            double vz2 = box.maxPoint.z;

            for (i = 0; i < 10; i++)
            {
                if (Overlap(px, px2, vx, vx2))
                {
                    p |= 1 << i;
                }
                if (Overlap(py, py2, vy, vy2))
                {
                    p |= 1 << (10 + i);
                }
                if (Overlap(pz, pz2, vz, vz2))
                {
                    p |= 1 << (20 + i);
                }
                px   = px2;
                px2 += dx;
                py   = py2;
                py2 += dy;
                pz   = pz2;
                pz2 += dz;
            }
            return(p);
        }