Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

優化GenerateQuadTreeConnectedNode #3

Open
xwc2021 opened this issue Feb 26, 2022 · 0 comments
Open

優化GenerateQuadTreeConnectedNode #3

xwc2021 opened this issue Feb 26, 2022 · 0 comments

Comments

@xwc2021
Copy link
Owner

xwc2021 commented Feb 26, 2022

todo 那裡有點暴力

public void GenerateQuadTreeConnectedNode()

既然已經是quadTree,改成逐一測試每個Rect
就可以避免無謂的測試

doIt(node,rect,depth){
 
  if(depth >max_depth)
    return;

  if(NodeIsIntersectWithColliderRect(node,rect) | NodeIsContainColliderRectsVertex(node,rect)){

    // 有需要才Split
    if(childNode.count==0){ 
      node.SplitTo4();
    }

    // 往下遞迴
    foreach(childnode in childs)
       doIt(childnode,Rect,++depth)
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant