Exemplo n.º 1
0
        /// <summary>
        /// Milder comparer than Cover, only parts need to be overlapping to return true
        /// </summary>
        public virtual bool Overlap(Region r)
        {
            if (r.MinX >= MaxX)
                return false;
            if (r.MinY >= MaxY)
                return false;
            if (r.MinZ >= MaxZ)
                return false;
            if (r.MaxX <= MinX)
                return false;
            if (r.MaxY <= MinY)
                return false;
            if (r.MaxZ <= MinZ)
                return false;
			
            return true;			
        }
Exemplo n.º 2
0
        /// <summary>
        /// true if r is completely within this
        /// </summary>
        public virtual bool Cover(Region r)
        {
            if (r.MinX < MinX)
                return false;
            if (r.MinY < MinY)
                return false;
            if (r.MinZ < MinZ)
                return false;
            if (r.MaxX > MaxX)
                return false;
            if (r.MaxY > MaxY)
                return false;
            if (r.MaxZ > MaxZ)
                return false;
			
            return true;			
        }
Exemplo n.º 3
0
        /// <summary>
        /// Return best matching parent region for our new region or return an interferring region if found
        /// Check for Cover to make sure the returning region is not crossing edges
        /// </summary>
        public static WorldRegion GetBaseRegion(List<WorldRegion> list, Region reg, Dimensions dimension)
        {
            foreach (WorldRegion r in list)
            {
                if ((int)dimension != r.Dimension)
                    continue;
                if (reg.Overlap(r) == false)
                    continue;   
                
                if (r.Cover(reg) == false)
                    return r; // we will catch this later
                        
                if (r.SubRegions == null) 
                    return r;

                WorldRegion w = GetBaseRegion(r.SubRegions, reg, dimension);
                        
                if (w == null)
                    return r;
                else
                    return w;
            }
            return null;
        }