Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class BinarySpacePartition
- {
- public class Node
- {
- public Vector2 min;
- public Vector2 max;
- public Node left;
- public Node right;
- public void Split(int axis, float line)
- {
- left = new Node();
- right = new Node();
- if (axis == 0)
- {
- left.min.x = min.x;
- left.min.y = min.y;
- left.max.x = line;
- left.max.y = max.y;
- left.left = null;
- left.right = null;
- right.min.x = line;
- right.min.y = min.y;
- right.max.x = max.x;
- right.max.y = max.y;
- right.left = null;
- right.right = null;
- }
- else
- {
- left.min.x = min.x;
- left.min.y = min.y;
- left.max.x = max.x;
- left.max.y = line;
- left.left = null;
- left.right = null;
- right.min.x = min.x;
- right.min.y = line;
- right.max.x = max.x;
- right.max.y = max.y;
- right.left = null;
- right.right = null;
- }
- }
- }
- public Node root;
- public BinarySpacePartition()
- {
- root = new Node();
- root.min = new Vector2(-200.0f, -200.0f);
- root.max = new Vector2(200.0f, 200.0f);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement