Fix some IntelliSense messages
This commit is contained in:
parent
235178be3d
commit
e84746fab0
@ -4,12 +4,15 @@
|
|||||||
{
|
{
|
||||||
public static bool RemoveUnordered<T>(this List<T> list, T obj)
|
public static bool RemoveUnordered<T>(this List<T> list, T obj)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < list.Count; i++)
|
if (obj != null)
|
||||||
{
|
{
|
||||||
if (list[i].Equals(obj))
|
for (int i = 0; i < list.Count; i++)
|
||||||
{
|
{
|
||||||
list.RemoveUnorderedAt(i);
|
if (obj.Equals(list[i]))
|
||||||
return true;
|
{
|
||||||
|
list.RemoveUnorderedAt(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -17,7 +20,7 @@
|
|||||||
|
|
||||||
public static void RemoveUnorderedAt<T>(this List<T> list, int index)
|
public static void RemoveUnorderedAt<T>(this List<T> list, int index)
|
||||||
{
|
{
|
||||||
list[index] = list[list.Count - 1];
|
list[index] = list[^1];
|
||||||
list.RemoveAt(list.Count - 1);
|
list.RemoveAt(list.Count - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
Quadtree.cs
10
Quadtree.cs
@ -48,18 +48,18 @@ namespace Quadtree
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stack of vertex indices with their bounding boxes. It is reused for each query.
|
/// Stack of vertex indices with their bounding boxes. It is reused for each query.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Stack<QuadtreeQuery> _queryStack;
|
private readonly Stack<QuadtreeQuery> _queryStack;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stack of vertex indices. It is reused for each query.
|
/// Stack of vertex indices. It is reused for each query.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Stack<int> _vertexStack;
|
private readonly Stack<int> _vertexStack;
|
||||||
|
|
||||||
public Quadtree(int maxLeafSize, int maxTreeDepth)
|
public Quadtree(int maxLeafSize, int maxTreeDepth)
|
||||||
{
|
{
|
||||||
_maxLeafSize = maxLeafSize;
|
_maxLeafSize = maxLeafSize;
|
||||||
_maxTreeDepth = maxTreeDepth;
|
_maxTreeDepth = maxTreeDepth;
|
||||||
_vertices = new List<QuadtreeVertex>() { new QuadtreeVertex(-1, 0) };
|
_vertices = new List<QuadtreeVertex>() { new(-1, 0) };
|
||||||
_items = new List<QuadtreeItem<IWorldObject>>();
|
_items = new List<QuadtreeItem<IWorldObject>>();
|
||||||
_rootBoundingBox = new BoundingBox2(Vector2.Zero, Vector2.Zero);
|
_rootBoundingBox = new BoundingBox2(Vector2.Zero, Vector2.Zero);
|
||||||
_maxObjectRadius = 0f;
|
_maxObjectRadius = 0f;
|
||||||
@ -153,7 +153,7 @@ namespace Quadtree
|
|||||||
QuadtreeQuery query = _queryStack.Pop();
|
QuadtreeQuery query = _queryStack.Pop();
|
||||||
|
|
||||||
int childIndex = _vertices[query.VertexIndex].FirstChildIndex;
|
int childIndex = _vertices[query.VertexIndex].FirstChildIndex;
|
||||||
BoundingBox2 halfBounds = new BoundingBox2(query.VertexBounds.Center, query.VertexBounds.Max);
|
BoundingBox2 halfBounds = new(query.VertexBounds.Center, query.VertexBounds.Max);
|
||||||
Vector2 halfSize = halfBounds.Size;
|
Vector2 halfSize = halfBounds.Size;
|
||||||
QueryProcessChildVertex(inflatedBox, box, childIndex++, halfBounds, resultList, _queryStack);
|
QueryProcessChildVertex(inflatedBox, box, childIndex++, halfBounds, resultList, _queryStack);
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ namespace Quadtree
|
|||||||
private void ExpandRoot(Vector2 position)
|
private void ExpandRoot(Vector2 position)
|
||||||
{
|
{
|
||||||
// Finds the new index for the old root vertex and expands the bounds.
|
// Finds the new index for the old root vertex and expands the bounds.
|
||||||
QuadtreeVertex newRoot = new QuadtreeVertex(_vertices.Count, -1);
|
QuadtreeVertex newRoot = new(_vertices.Count, -1);
|
||||||
int oldRootIndex = _vertices.Count;
|
int oldRootIndex = _vertices.Count;
|
||||||
if (position.X > _rootBoundingBox.Max.X)
|
if (position.X > _rootBoundingBox.Max.X)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user