Quadtree fetch fix.
This commit is contained in:
parent
cb6ad171a7
commit
90d157411a
|
@ -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)
|
static void getAllEntsWithinNode(int x, int y, int w, int h, Entity *ignore, Quadtree *root)
|
||||||
{
|
{
|
||||||
Quadtree *node;
|
|
||||||
int index, i;
|
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++)
|
for (i = 0 ; i < root->numEnts ; i++)
|
||||||
{
|
{
|
||||||
candidates[cIndex++] = root->ents[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();
|
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)
|
static void resizeCandidates(void)
|
||||||
|
|
Loading…
Reference in New Issue