fixed bad condition causing incorrect ordering on ui

pull/1/head
Sara 2023-04-10 13:27:12 +02:00
parent 307732dd05
commit c9c5cf4935
1 changed files with 8 additions and 6 deletions

View File

@ -141,12 +141,14 @@ void insert_drawcmd_at(size_t index, const drawcmd_t* cmd) {
drawcmd_t* insertpoint = g_drawdata + index; drawcmd_t* insertpoint = g_drawdata + index;
drawcmd_t* dest = insertpoint + 1; drawcmd_t* dest = insertpoint + 1;
size_t size = (size_t)(g_drawdata_endptr - g_drawdata); size_t size = (size_t)(g_drawdata_endptr - g_drawdata);
size_t count = (size - index); if(size > index) {
++g_drawdata_endptr; size_t count = (size - index);
if(size > 0) if(size > 0)
{ {
memmove(dest, insertpoint, count*sizeof(drawcmd_t)); memmove(dest, insertpoint, count*sizeof(drawcmd_t));
}
} }
++g_drawdata_endptr;
memcpy(insertpoint, cmd, sizeof(drawcmd_t)); memcpy(insertpoint, cmd, sizeof(drawcmd_t));
insertpoint->ui = _render_mode == 1; insertpoint->ui = _render_mode == 1;
} }
@ -162,7 +164,7 @@ void draw(const drawcmd_t* cmd) {
med = floor((float)(top + bot) / 2); med = floor((float)(top + bot) / 2);
if(g_drawdata[med].ui < ui || g_drawdata[med].depth > cmd->depth) { if(g_drawdata[med].ui < ui || g_drawdata[med].depth > cmd->depth) {
bot = med+1; bot = med+1;
} else if(g_drawdata[med].ui >= ui || g_drawdata[med].depth < cmd->depth) { } else if(g_drawdata[med].ui > ui || g_drawdata[med].depth < cmd->depth) {
top = med-1; top = med-1;
} else { } else {
break; break;