further fixes to render ordering
parent
3e8eef4200
commit
9dbb5a1566
|
@ -147,6 +147,7 @@ void insert_drawcmd_at(size_t index, const drawcmd_t* cmd) {
|
|||
drawcmd_t* insertpoint = g_drawdata + index;
|
||||
drawcmd_t* dest = insertpoint + 1;
|
||||
size_t size = (size_t)(g_drawdata_endptr - g_drawdata);
|
||||
++g_drawdata_endptr;
|
||||
if(size > index) {
|
||||
size_t count = (size - index);
|
||||
if(size > 0)
|
||||
|
@ -154,29 +155,36 @@ void insert_drawcmd_at(size_t index, const drawcmd_t* cmd) {
|
|||
memmove(dest, insertpoint, count*sizeof(drawcmd_t));
|
||||
}
|
||||
}
|
||||
++g_drawdata_endptr;
|
||||
memcpy(insertpoint, cmd, sizeof(drawcmd_t));
|
||||
insertpoint->ui = _render_mode == 1;
|
||||
}
|
||||
|
||||
void draw(const drawcmd_t* cmd) {
|
||||
if(g_drawdata_endptr == g_drawdata) {
|
||||
insert_drawcmd_at(0, cmd);
|
||||
}
|
||||
long top = (size_t)(g_drawdata_endptr - g_drawdata),
|
||||
bot = 0,
|
||||
med = 0;
|
||||
|
||||
int ui = _render_mode == 1;
|
||||
if(top != bot) {
|
||||
while(bot <= top) {
|
||||
med = floor((float)(top + bot) / 2);
|
||||
if(g_drawdata[med].ui < ui || g_drawdata[med].depth > cmd->depth) {
|
||||
if(g_drawdata[med].depth > cmd->depth) {
|
||||
bot = med+1;
|
||||
} else if(g_drawdata[med].ui > ui || g_drawdata[med].depth < cmd->depth) {
|
||||
} else if(g_drawdata[med].depth < cmd->depth) {
|
||||
top = med-1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
size_t count = (g_drawdata_endptr - g_drawdata);
|
||||
int diff = g_drawdata[med].depth - cmd->depth;
|
||||
while(diff > 0 && med < count) {
|
||||
med++;
|
||||
diff = g_drawdata[med].depth - cmd->depth;
|
||||
}
|
||||
insert_drawcmd_at(med, cmd);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ extern "C" {
|
|||
|
||||
typedef int depth_t;
|
||||
|
||||
extern int d_debug_next_frame;
|
||||
|
||||
typedef enum drawcmdtype_t {
|
||||
DRAWCMDTYPE_MIN = -1,
|
||||
DRAWCMDTYPE_SPRITE = 0,
|
||||
|
|
Loading…
Reference in New Issue