From caeba98e0385edebb344e6dbd024c01801a75fc4 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Wed, 10 May 2023 09:35:29 +0800 Subject: *misc --- marching/Assets/Scripts/Physics/Quadtree.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'marching/Assets/Scripts/Physics/Quadtree.cs') 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 /// 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 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> m_QuadtreeObjPool = new Queue>(); private static Queue m_QuadtreePool = new Queue(); @@ -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) -- cgit v1.1-26-g67d0