mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[qfvis] Make cluster reconstruction O(N)
For most (if not all) maps. The heapsort is needed only if the clustered leafs are not contiguous, but most bsp compilers output contiguous leaf clusters, so is just a bit of protection. The difference isn't really noticeable on a fast machine, but no point in doing more work than necessary.
This commit is contained in:
parent
b320c3352f
commit
9a93bf8d4a
1 changed files with 14 additions and 5 deletions
|
@ -260,15 +260,24 @@ static void
|
|||
reconstruct_clusters (void)
|
||||
{
|
||||
leafvis = malloc (num_leafs * sizeof (leafvis_t));
|
||||
int sorted = 1;
|
||||
num_clusters = 1;
|
||||
for (unsigned i = 0; i < num_leafs; i++) {
|
||||
leafvis[i].visoffs = bsp->leafs[i + 1].visofs;
|
||||
leafvis[i].leafnum = i;
|
||||
if (i > 0) {
|
||||
num_clusters += leafvis[i].visoffs != leafvis[i - 1].visoffs;
|
||||
if (leafvis[i].visoffs < leafvis[i - 1].visoffs) {
|
||||
sorted = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
heapsort (leafvis, num_leafs, sizeof (leafvis_t), leaf_compare);
|
||||
|
||||
num_clusters = 1;
|
||||
for (unsigned i = 1; i < num_leafs; i++) {
|
||||
num_clusters += leafvis[i].visoffs != leafvis[i - 1].visoffs;
|
||||
if (!sorted) {
|
||||
heapsort (leafvis, num_leafs, sizeof (leafvis_t), leaf_compare);
|
||||
num_clusters = 1;
|
||||
for (unsigned i = 1; i < num_leafs; i++) {
|
||||
num_clusters += leafvis[i].visoffs != leafvis[i - 1].visoffs;
|
||||
}
|
||||
}
|
||||
|
||||
leafcluster = malloc (num_leafs * sizeof (uint32_t));
|
||||
|
|
Loading…
Reference in a new issue