Quadtree fetch fix.

This commit is contained in:
Steve 2016-04-09 17:39:24 +01:00
parent cb6ad171a7
commit 90d157411a
1 changed files with 17 additions and 22 deletions

View File

@ -220,9 +220,25 @@ Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore)
static void getAllEntsWithinNode(int x, int y, int w, int h, Entity *ignore, Quadtree *root)
{
Quadtree *node;
int index, i;
if (root->node[0])
{
index = getIndex(root, x, y, w, h);
if (index != -1)
{
getAllEntsWithinNode(x, y, w, h, ignore, root->node[index]);
}
else
{
for (i = 0 ; i < 4 ; i++)
{
getAllEntsWithinNode(x, y, w, h, ignore, root->node[i]);
}
}
}
for (i = 0 ; i < root->numEnts ; i++)
{
candidates[cIndex++] = root->ents[i];
@ -232,27 +248,6 @@ static void getAllEntsWithinNode(int x, int y, int w, int h, Entity *ignore, Qua
resizeCandidates();
}
}
index = getIndex(root, x, y, w, h);
if (root->node[0])
{
if (index != -1)
{
node = root->node[index];
getAllEntsWithinNode(node->x, node->y, node->w, node->h, ignore, node);
}
else
{
for (i = 0; i < 4; i++)
{
node = root->node[i];
getAllEntsWithinNode(node->x, node->y, node->w, node->h, ignore, node);
}
}
}
}
static void resizeCandidates(void)