Initial commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
|
||||
namespace EvilSatellites.Quadtree
|
||||
{
|
||||
public class Quadtree<T> where T : Positional
|
||||
{
|
||||
public Vector3 Dimensions { get; set; }
|
||||
public int MaxLevels;
|
||||
public int MaxObjects;
|
||||
public QuadtreeNode<T> Root;
|
||||
public Quadtree(Vector3 dimensions, int maxLevels, int maxObjects)
|
||||
{
|
||||
Dimensions = dimensions;
|
||||
this.MaxLevels = maxLevels;
|
||||
this.MaxObjects = maxObjects;
|
||||
this.Root = new QuadtreeNode<T>(new Vector3(0, 0, 0), Dimensions, MaxLevels, MaxObjects, 0);
|
||||
}
|
||||
|
||||
public void Add(T obj)
|
||||
{
|
||||
Root.Add(obj);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
this.Root = new QuadtreeNode<T>(new Vector3(0, 0, 0), Dimensions, MaxLevels, MaxObjects, 0);
|
||||
}
|
||||
|
||||
public List<T> Find(Vector3 Position, Vector3 dimensions)
|
||||
{
|
||||
return Root.Find(Position, dimensions);
|
||||
}
|
||||
|
||||
public List<T> Find(Vector3 Position)
|
||||
{
|
||||
return Root.Find(Position, new Vector3(1, 1, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user