private GridSection[] CreateSubSections(Vector3 start) { var subSectionsX = Math.Max(this.subSectionsX, 1); var subSectionsZ = Math.Max(this.subSectionsZ, 1); var overLap = this.subSectionsCellOverlap * this.cellSize; var subSectionWidth = ((this.sizeX + ((subSectionsX - 1) * this.subSectionsCellOverlap)) * this.cellSize) / (subSectionsX * 1.0f); var subSectionDepth = ((this.sizeZ + ((subSectionsZ - 1) * this.subSectionsCellOverlap)) * this.cellSize) / (subSectionsZ * 1.0f); var subSectionCount = subSectionsX * subSectionsZ; var gridSections = new GridSection[subSectionCount]; int idx = 0; for (int i = 0; i < subSectionsX; i++) { for (int j = 0; j < subSectionsZ; j++) { var rect = new RectangleXZ( start.x + (subSectionWidth * i) - (overLap * i), start.z + (subSectionDepth * j) - (overLap * j), subSectionWidth, subSectionDepth); gridSections[idx++] = new GridSection(rect); } } return(gridSections); }
private GridSection[] CreateSubSections(Vector3 start) { var subSectionsX = Math.Max(this.subSectionsX, 1); var subSectionsZ = Math.Max(this.subSectionsZ, 1); var overLap = this.subSectionsCellOverlap * this.cellSize; var subSectionWidth = ((this.sizeX + ((subSectionsX - 1) * this.subSectionsCellOverlap)) * this.cellSize) / (subSectionsX * 1.0f); var subSectionDepth = ((this.sizeZ + ((subSectionsZ - 1) * this.subSectionsCellOverlap)) * this.cellSize) / (subSectionsZ * 1.0f); var subSectionCount = subSectionsX * subSectionsZ; var gridSections = new GridSection[subSectionCount]; int idx = 0; for (int i = 0; i < subSectionsX; i++) { for (int j = 0; j < subSectionsZ; j++) { var rect = new RectangleXZ( start.x + (subSectionWidth * i) - (overLap * i), start.z + (subSectionDepth * j) - (overLap * j), subSectionWidth, subSectionDepth); gridSections[idx++] = new GridSection(rect); } } return gridSections; }