summaryrefslogtreecommitdiff
path: root/marching/Assets/Scripts/Physics/Quadtree.cs
diff options
context:
space:
mode:
Diffstat (limited to 'marching/Assets/Scripts/Physics/Quadtree.cs')
-rw-r--r--marching/Assets/Scripts/Physics/Quadtree.cs12
1 files changed, 10 insertions, 2 deletions
diff --git a/marching/Assets/Scripts/Physics/Quadtree.cs b/marching/Assets/Scripts/Physics/Quadtree.cs
index 9f8ecba..a012d26 100644
--- a/marching/Assets/Scripts/Physics/Quadtree.cs
+++ b/marching/Assets/Scripts/Physics/Quadtree.cs
@@ -29,7 +29,7 @@ namespace mh
private int m_Level;
private Vector4 m_Bounds; // x,y,z,w => posx,posy,width,height
private Quadtree[] m_SubTrees; // 从右上角开始逆时针索引
- private List<IQuadTreeObject> m_Objects; // 当前层能容纳,但任何一个子树都无法容纳的对象
+ private List<IQuadTreeObject> m_Objects; // 非叶节点的为0
private bool m_IsRoot;
public Vector4 bound { get { return m_Bounds; } }
@@ -47,7 +47,6 @@ namespace mh
public bool isRoot { get { return m_IsRoot; } }
private static Queue<List<IQuadTreeObject>> m_QuadtreeObjPool = new Queue<List<IQuadTreeObject>>();
-
private static Queue<Quadtree> m_QuadtreePool = new Queue<Quadtree>();
private Quadtree QueryQuadtree(int level, Vector4 bounds)
@@ -97,8 +96,17 @@ namespace mh
m_IsRoot = isRoot;
}
+ /// <summary>
+ /// 更改边界,只适用于最外层的tree
+ /// </summary>
+ /// <param name="bounds"></param>
public void Rebound(Vector4 bounds)
{
+ if(!m_IsRoot)
+ {
+ Debug.LogError("Quadtree.Rebound()只能运用于最外层");
+ return;
+ }
m_Bounds = bounds;
}