summaryrefslogtreecommitdiff
path: root/Thronefall/NGS.MeshFusionPro/BinaryTreeNode.cs
blob: 45585190d981d46506188fd4e5be6735a0744cb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using UnityEngine;

namespace NGS.MeshFusionPro;

public abstract class BinaryTreeNode<TData> : IBinaryTreeNode
{
	public BinaryTreeNode<TData> Left { get; private set; }

	public BinaryTreeNode<TData> Right { get; private set; }

	public bool IsLeaf { get; private set; }

	public bool HasChilds => Left != null;

	public Vector3 Center { get; private set; }

	public Vector3 Size { get; private set; }

	public Bounds Bounds { get; private set; }

	public BinaryTreeNode(Vector3 center, Vector3 size, bool isLeaf)
	{
		Center = center;
		Size = size;
		Bounds = new Bounds(center, size);
		IsLeaf = isLeaf;
	}

	public IBinaryTreeNode GetLeft()
	{
		return Left;
	}

	public IBinaryTreeNode GetRight()
	{
		return Right;
	}

	public void SetChilds(BinaryTreeNode<TData> left, BinaryTreeNode<TData> right)
	{
		Left = left;
		Right = right;
	}

	public abstract void Add(TData data);

	public abstract void Remove(TData data);
}