public void PrepareLineEntities(QTreeNode node) { this.GetLineEntities(node.GetRectangle()); if (node.GetNumberOfChildren() > 0) { foreach (QTreeNode nodeChild in node.GetChildren()) { this.PrepareLineEntities(nodeChild); } } }
public void AddEntity(Entity entity, QTreeNode node) { if (!entity.Collidable) { return; } Vector2 entityPosition = entity.GetProjectedPosition(); if (!entity.GetRectangle(entityPosition).Intersects(node.GetRectangle())) { return; } if (node.GetNumberOfChildren() == 0) { if (node.GetNumberOfEntities() < this.MaxEntitiesPerNode) { node.AddEntity(entity); } else { node.Divide(); foreach (Entity childEntity in node.GetEntities()) { childEntity.EmptyQTreeNodes(); foreach (QTreeNode childNode in node.GetChildren()) { this.AddEntity(childEntity, childNode); } } node.EmptyEntities(); foreach (QTreeNode childNode in node.GetChildren()) { this.AddEntity(entity, childNode); } } } else { foreach (QTreeNode childNode in node.GetChildren()) { this.AddEntity(entity, childNode); } } }