Skip to content

Instantly share code, notes, and snippets.

@dpogue
Created December 28, 2010 08:59
Show Gist options
  • Save dpogue/757074 to your computer and use it in GitHub Desktop.
Save dpogue/757074 to your computer and use it in GitHub Desktop.
void plDrawableSpans::ISortSpace(std::vector<plSpaceBuilderNode*>& nodes, int axis) {
if (nodes.size() < 2)
// Already sorted
return;
hsRadixSort rad;
hsRadixSortElem* list = new hsRadixSortElem[nodes.size()];
hsRadixSortElem* head = list;
for (int i = 0; i < nodes.size(); i++) {
switch (axis) {
case 0:
list->fKey.fFloat = nodes[i]->fBounds.getCenter().X;
break;
case 1:
list->fKey.fFloat = nodes[i]->fBounds.getCenter().Y;
break;
case 2:
list->fKey.fFloat = nodes[i]->fBounds.getCenter().Z;
break;
}
list->fData = nodes[i];
list->fNext = ++list;
}
list = NULL;
head = rad.sort(head, hsRadixSort::kFloat);
for (int i = 0; i < nodes.size(); i++) {
nodes[i] = (plSpaceBuilderNode*)head[i].fData;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment