public Quadtree(float x, float z, float width, float min) { this.x = x; this.z = z; this.width = width; this.min = min; this.level = 0; this.root = new QuadtreeNode(x, z, width, min); }
public QuadtreeNode find(float x, float z) { QuadtreeNode ret = null; if (isInside(x, z)) { if (lowerLeft != null) { ret = lowerLeft.find(x, z); if (ret != null) { return(ret); } } if (lowerRight != null) { ret = lowerRight.find(x, z); if (ret != null) { return(ret); } } if (upperLeft != null) { ret = upperLeft.find(x, z); if (ret != null) { return(ret); } } if (upperRight != null) { ret = upperRight.find(x, z); if (ret != null) { return(ret); } } if (ret == null) { return(this); } } return(ret); }
public void renderQuadtreeNode(QuadtreeNode qNode, int detail) { int width = (int)(qNode.Width / (patchSize * scale.X)); int iStart = (int)Math.Abs(qNode.X / (patchSize * scale.X)); int jStart = (int)Math.Abs(qNode.Z / (patchSize * scale.X)); for (int j = jStart; j < jStart + width; j++) { for (int i = iStart; i < iStart + width; i++) { if (m_Patches[i, j].isVisible()) { NumPatchesRendered++; m_Patches[i, j].render(detail); } } } }
public void renderQuadtree(QuadtreeNode root) { if (root.HasChildNodes && root.Level > 0) { renderQuadtree(root.LowerLeft); renderQuadtree(root.LowerRight); renderQuadtree(root.UpperLeft); renderQuadtree(root.UpperRight); } else { if (root.HasChildNodes) { renderQuadtreeNode(root, root.Level); } else { renderQuadtreeNode(root, root.Level + 1); } } }
public QuadtreeNode(float x, float z, float width, float min) { this.x = x; this.z = z; this.width = width; float helperWidth = width; this.min = min; //this.hasChildNodes = isInside(root.Pos.X, root.Pos.Z) || isNear(root.Pos.X, root.Pos.Z); while ((helperWidth = helperWidth / 2) >= min) { level++; } if (width > min) { float halfwidth = width / 2; lowerLeft = new QuadtreeNode(x, z, halfwidth, min); lowerRight = new QuadtreeNode(x + halfwidth, z, halfwidth, min); upperLeft = new QuadtreeNode(x, z - halfwidth, halfwidth, min); upperRight = new QuadtreeNode(x + halfwidth, z - halfwidth, halfwidth, min); } }