diff options
Diffstat (limited to 'marching/Assets/Scripts/Physics/Quadtree.cs')
-rw-r--r-- | marching/Assets/Scripts/Physics/Quadtree.cs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/marching/Assets/Scripts/Physics/Quadtree.cs b/marching/Assets/Scripts/Physics/Quadtree.cs index f1237ab..9f8ecba 100644 --- a/marching/Assets/Scripts/Physics/Quadtree.cs +++ b/marching/Assets/Scripts/Physics/Quadtree.cs @@ -23,14 +23,16 @@ namespace mh /// </summary> public class Quadtree { - public const int kMaxObjectsPerBlock = 5; - public const int kMaxLevel = 6; + public const int kMaxObjectsPerBlock = 4; + public const int kMaxLevel = 5; 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 bool m_IsRoot; + public Vector4 bound { get { return m_Bounds; } } public float x { get { return m_Bounds.x; } } public float y { get { return m_Bounds.y; } } public float w { get { return m_Bounds.z; } } @@ -42,6 +44,8 @@ namespace mh public float top { get { return y + halfH; } } public float bottom { get { return y - halfH; } } + 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>(); @@ -84,12 +88,13 @@ namespace mh list = null; } - public Quadtree(int level, Vector4 bounds) + public Quadtree(int level, Vector4 bounds, bool isRoot = false) { m_Level = level; m_Bounds = bounds; m_SubTrees = new Quadtree[4]; m_Objects = QueryQuadtreeObjList(); + m_IsRoot = isRoot; } public void Rebound(Vector4 bounds) |