engine/source/gamelib/spriteq.c
// Double sort code (sorts high and low simultaneously from 2 directions)
// Can't get much faster than this - I think
Double sort code (sorts high and low simultaneously from 2 directions)
Can't get much faster than this - I think
Double sort code ( sorts high and low simultaneously from 2 directions ) Can ' t get much faster than this - I think
static void spriteq_sort()
{
    int i, lidx, hidx, lz, hz, start, end, lsid, hsid;
    void *tempp;
    start = 0;
    end = spritequeue_len - 1;
    while(start < end)
    {
        lidx = end;
        hidx = start;
        lz = order[lidx]->z;
        hz = order[hidx]->z;
        lsid = order[lidx]->sortid;
        hsid = order[hidx]->sortid;
        for(i = start; i <= end; i++)
        {
            if(order[i]->z < lz || (order[i]->z == lz && order[i]->sortid < lsid))
            {
                lidx = i;
                lz = order[i]->z;
                lsid = order[i]->sortid;
            }
            if(order[i]->z > hz || (order[i]->z == hz && order[i]->sortid > hsid))
            {
                hidx = i;
                hz = order[i]->z;
                hsid = order[i]->sortid;
            }
        }
        if(hz == lz && hsid == lsid)
        {
            return;
        }
        tempp = order[start];
        order[start] = order[lidx];
        order[lidx] = tempp;
        if(hidx == start)
        {
            hidx = lidx;
        }
        tempp = order[end];
        order[end] = order[hidx];
        order[hidx] = tempp;
        ++start;
        --end;
    }
}
static void spriteq_sort ( ) { int i , lidx , hidx , lz , hz , start , end , lsid , hsid ; void * tempp ; start = 0 ; end = spritequeue_len - 1 ; while ( start < end ) { lidx = end ; hidx = start ; lz = order [ lidx ] -> z ; hz = order [ hidx ] -> z ; lsid = order [ lidx ] -> sortid ; hsid = order [ hidx ] -> sortid ; for ( i = start ; i <= end ; i ++ ) { if ( order [ i ] -> z < lz || ( order [ i ] -> z == lz && order [ i ] -> sortid < lsid ) ) { lidx = i ; lz = order [ i ] -> z ; lsid = order [ i ] -> sortid ; } if ( order [ i ] -> z > hz || ( order [ i ] -> z == hz && order [ i ] -> sortid > hsid ) ) { hidx = i ; hz = order [ i ] -> z ; hsid = order [ i ] -> sortid ; } } if ( hz == lz && hsid == lsid ) { return ; } tempp = order [ start ] ; order [ start ] = order [ lidx ] ; order [ lidx ] = tempp ; if ( hidx == start ) { hidx = lidx ; } tempp = order [ end ] ; order [ end ] = order [ hidx ] ; order [ hidx ] = tempp ; ++ start ; -- end ; } }
Double sort code (sorts high and low simultaneously from 2 directions)
Can't get much faster than this - I think
Double sort code ( sorts high and low simultaneously from 2 directions ) Can ' t get much faster than this - I think
// Search for lowest and highest Z coord // No need to sort equal values! // Exchange values (low) // Prevent confusion: // This value may already have been exchanged! // Exchange values (high)