mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 11:22:18 -04:00
alternative approach to stable vissprite sorting in Vanilla order (#1169)
This commit is contained in:
parent
5594e81de1
commit
3209e4e467
@ -901,7 +901,7 @@ static void msort(vissprite_t **s, vissprite_t **t, int n)
|
|||||||
msort(s1, t, n1);
|
msort(s1, t, n1);
|
||||||
msort(s2, t, n2);
|
msort(s2, t, n2);
|
||||||
|
|
||||||
while ((*s1)->scale > (*s2)->scale ?
|
while ((*s1)->scale >= (*s2)->scale ?
|
||||||
(*d++ = *s1++, --n1) : (*d++ = *s2++, --n2));
|
(*d++ = *s1++, --n1) : (*d++ = *s2++, --n2));
|
||||||
|
|
||||||
if (n2)
|
if (n2)
|
||||||
@ -917,12 +917,10 @@ static void msort(vissprite_t **s, vissprite_t **t, int n)
|
|||||||
for (i = 1; i < n; i++)
|
for (i = 1; i < n; i++)
|
||||||
{
|
{
|
||||||
vissprite_t *temp = s[i];
|
vissprite_t *temp = s[i];
|
||||||
// [FG] change '<' to '<=' here and below, so that vissprites with the same scale
|
if (s[i-1]->scale < temp->scale)
|
||||||
// are reordered, so that the object with the higher map index appears in front
|
|
||||||
if (s[i-1]->scale <= temp->scale)
|
|
||||||
{
|
{
|
||||||
int j = i;
|
int j = i;
|
||||||
while ((s[j] = s[j-1])->scale <= temp->scale && --j);
|
while ((s[j] = s[j-1])->scale < temp->scale && --j);
|
||||||
s[j] = temp;
|
s[j] = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -946,8 +944,12 @@ void R_SortVisSprites (void)
|
|||||||
* sizeof *vissprite_ptrs, PU_STATIC, 0);
|
* sizeof *vissprite_ptrs, PU_STATIC, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sprites of equal distance need to be sorted in inverse order.
|
||||||
|
// This is most easily achieved by filling the sort array
|
||||||
|
// backwards before the sort.
|
||||||
|
|
||||||
while (--i>=0)
|
while (--i>=0)
|
||||||
vissprite_ptrs[i] = vissprites+i;
|
vissprite_ptrs[num_vissprite-i-1] = vissprites+i;
|
||||||
|
|
||||||
// killough 9/22/98: replace qsort with merge sort, since the keys
|
// killough 9/22/98: replace qsort with merge sort, since the keys
|
||||||
// are roughly in order to begin with, due to BSP rendering.
|
// are roughly in order to begin with, due to BSP rendering.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user