private void CreateVisualizationForQuadRecursive(QuadTreeNode node) { var rectangle = new Rectangle { Stroke = Brushes.Black, StrokeThickness = 0.08, Width = node.Size, Height = node.Size, IsHitTestVisible = false }; this.canvasChildren.Add(rectangle); Canvas.SetLeft(rectangle, node.Position.X); Canvas.SetTop(rectangle, node.Position.Y); for (byte subNodeIndex = 0; subNodeIndex < 4; subNodeIndex++) { var subNode = node.GetSubNode((QuadTreeNode.SubNodeIndex)subNodeIndex); if (subNode != null) { this.CreateVisualizationForQuadRecursive(subNode); } } }
private void DestroySubNode(SubNodeIndex subNodeIndex) { switch (subNodeIndex) { case SubNodeIndex.BottomLeft: this.subNodeBottomLeft = null; break; case SubNodeIndex.BottomRight: this.subNodeBottomRight = null; break; case SubNodeIndex.TopLeft: this.subNodeTopLeft = null; break; case SubNodeIndex.TopRight: this.subNodeTopRight = null; break; default: throw new ArgumentOutOfRangeException(nameof(subNodeIndex), subNodeIndex, null); } }
private void CreateQuadTree() { this.quadTreeRoot = new QuadTreeNode(new Vector2Int(0, 0), CanvasSize); }