INNER CODE UNIT · C
axis
xonotic/darkplaces · bih.c:95
axis = (longestaxis + j) % 3;
// sort children into front and back lists
splitdist = (node->mins[axis] + node->maxs[axis]) * 0.5f;
front = 0;
back = 0;
for (i = 0;i < numchildren;i++)
{
child = bih->leafs + leaflist[i];
d = (child->mins[axis] + child->maxs[axis]) * 0.5f;
if (d < splitdist)
bih->leafsortscratch[back++] = leaflist[i];
else
leaflist[front++] = leaflist[i];
}
// now copy the back ones into the space made in the leaflist for them
if (back)
memcpy(leaflist + front, bih->leafsortscratch, back*sizeof(leaflist[0]));
// if both sides have some children, it's good enough for us.