diff --git a/include/common.h b/include/common.h index 5792f51..5c57326 100644 --- a/include/common.h +++ b/include/common.h @@ -19,7 +19,7 @@ #define VERSION_X 0 #define VERSION_Y 0 #define VERSION_A 0 -#define VERSION_Z 7 +#define VERSION_Z 8 // Remember to bump "Z" basically every time you change the engine! // TRIPLEFOX THIS INCLUDES YOU // Z can only be 0 for official releases! diff --git a/pkg/base/common.lua b/pkg/base/common.lua index ddd0cc4..6314035 100644 --- a/pkg/base/common.lua +++ b/pkg/base/common.lua @@ -82,7 +82,7 @@ MODE_TILT_SLOWDOWN = false -- TODO! MODE_TILT_DOWN_NOCLIMB = false -- TODO! MODE_DRUNKCAM_VELOCITY = false -- keep this off unless you want to throw up -MODE_DRUNKCAM_LOCALTURN = true +MODE_DRUNKCAM_LOCALTURN = false -- this is the one you're looking for. MODE_DELAY_SPADE_DIG = 1.0 MODE_DELAY_SPADE_HIT = 0.25 diff --git a/pkg/base/obj_player.lua b/pkg/base/obj_player.lua index de6ba7b..20f6971 100644 --- a/pkg/base/obj_player.lua +++ b/pkg/base/obj_player.lua @@ -699,6 +699,7 @@ function new_player(settings) --print("polar",this.angx, this.angy) else + this.angx = this.angx + this.dangx this.angy = this.angy + this.dangy end this.dangx = 0 diff --git a/pkg/base/version.lua b/pkg/base/version.lua index 36f4e9d..5f60ac9 100644 --- a/pkg/base/version.lua +++ b/pkg/base/version.lua @@ -35,4 +35,5 @@ VERSION_BUGS = { {intro=4, fix=5, msg="Dedicated server build was broken"}, {intro=5, fix=6, msg="CRASHES ON CHANNEL WRAPAROUND - PLEASE UPDATE TO 0.0-6!"}, {intro=nil, fix=7, msg="Camera roll / camera_point_sky not implemented - drunken cam will not roll properly"}, +{intro=nil, fix=8, msg="Renderer uses double-rect approximation of cube instead of using trapezia"}, } diff --git a/pkg/iceball/pmfedit/main_client.lua b/pkg/iceball/pmfedit/main_client.lua index d96b741..3da7dad 100644 --- a/pkg/iceball/pmfedit/main_client.lua +++ b/pkg/iceball/pmfedit/main_client.lua @@ -57,7 +57,9 @@ pmfedit_z = 0 pmfedit_size = 16 pmfedit_data = {} pmfedit_model = common.model_new(1) -pmfedit_model, pmfedit_model_bone = common.model_bone_new(pmfedit_model) +pmfedit_idx = 1 +pmfedit_model_bone = {} +pmfedit_model, pmfedit_model_bone[pmfedit_idx] = common.model_bone_new(pmfedit_model) pmfedit_data[#pmfedit_data+1] = {x=0,y=0,z=0,r=0,g=0,b=0,radius=1} pmfedit_ry = 0 pmfedit_rx = 0 @@ -110,7 +112,7 @@ function client.hook_tick(sec_current, sec_delta) g=math.sin(sec_current)*127+128, b=math.sin(sec_current+2*math.pi/3)*127+128, radius=pmfedit_size} - common.model_bone_set(pmfedit_model, pmfedit_model_bone, "edit", pmfedit_data) + common.model_bone_set(pmfedit_model, pmfedit_model_bone[pmfedit_idx], "edit", pmfedit_data) return 0.005 end @@ -213,9 +215,9 @@ function client.hook_key(key, state) if xpmf then common.model_free(pmfedit_model) -- YECCH! Forgot this line! pmfedit_model = xpmf - pmfedit_model_bone = 0 + pmfedit_model_bone[pmfedit_idx] = 0 local bname - bname, pmfedit_data = common.model_bone_get(pmfedit_model, pmfedit_model_bone) + bname, pmfedit_data = common.model_bone_get(pmfedit_model, pmfedit_model_bone[pmfedit_idx]) pmfedit_data[#pmfedit_data+1] = {} print("loaded!") else @@ -225,8 +227,8 @@ function client.hook_key(key, state) local xpt = pmfedit_data[#pmfedit_data] pmfedit_data[#pmfedit_data] = nil local bname, blah - bname, blah = common.model_bone_get(pmfedit_model, pmfedit_model_bone) - common.model_bone_set(pmfedit_model, pmfedit_model_bone, bname, pmfedit_data) + bname, blah = common.model_bone_get(pmfedit_model, pmfedit_model_bone[pmfedit_idx]) + common.model_bone_set(pmfedit_model, pmfedit_model_bone[pmfedit_idx], bname, pmfedit_data) if common.model_save_pmf(pmfedit_model, PMFEDIT_FNAME) then print("saved!") else @@ -250,7 +252,7 @@ function client.hook_render() ,pmfedit_rx ,pmfedit_ry2)) - client.model_render_bone_local(pmfedit_model, pmfedit_model_bone, + client.model_render_bone_local(pmfedit_model, pmfedit_model_bone[pmfedit_idx], 0,0,1, pmfedit_ry,pmfedit_rx,pmfedit_ry2, 0.7) @@ -261,9 +263,9 @@ if preload then if xpmf then common.model_free(pmfedit_model) -- YECCH! Forgot this line! pmfedit_model = xpmf - pmfedit_model_bone = 0 + pmfedit_model_bone[pmfedit_idx] = 0 local bname - bname, pmfedit_data = common.model_bone_get(pmfedit_model, pmfedit_model_bone) + bname, pmfedit_data = common.model_bone_get(pmfedit_model, pmfedit_model_bone[pmfedit_idx]) pmfedit_data[#pmfedit_data+1] = {} print("loaded!") else diff --git a/src/render.c b/src/render.c index 8c6e828..5e94a86 100644 --- a/src/render.c +++ b/src/render.c @@ -495,11 +495,147 @@ void render_vxl_rect_ftb_fast(uint32_t *ccolor, float *cdepth, int x1, int y1, i #endif } +void render_vxl_cube_htrap(uint32_t *ccolor, float *cdepth, + int x1a, int x1b, int y1, int x2a, int x2b, int y2, uint32_t color, float depth) +{ + // dropout + if(x1b <= 0 && x2b <= 0) + return; + if(x1a >= cubemap_size && x2a >= cubemap_size) + return; + if(y2 <= 0) + return; + if(y1 >= cubemap_size) + return; + if(x1a >= x1b || x2a >= x2b) + return; + if(y1 >= y2) + return; + + // calc gradients + int m_x1a = (((x2a-x1a)<<16)+0x8000)/(y2-y1); + int m_x1b = (((x2b-x1b)<<16)+0x8000)/(y2-y1); + int sub_x1a = 0; + int sub_x1b = 0; + + // Y clamp + // TODO: clamp y1 properly + if(y2 >= cubemap_size) + y2 = cubemap_size; + + // render + //uint32_t *cptr = &ccolor[(y1<= 0) + { + int rx1a = (x1a < 0 ? 0 : x1a); + int rx1b = (x1b >= cubemap_size ? cubemap_size : x1b); + + cptr = &ccolor[(y<>16); + x1b += (sub_x1b>>16); + sub_x1a &= 0xFFFF; + sub_x1b &= 0xFFFF; + } +} + +void render_vxl_cube_vtrap(uint32_t *ccolor, float *cdepth, + int x1, int y1a, int y1b, int x2, int y2a, int y2b, uint32_t color, float depth) +{ + // TODO: make this not so bloody horrible for the cache + + // dropout + if(y1b <= 0 && y2b <= 0) + return; + if(y1a >= cubemap_size && y2a >= cubemap_size) + return; + if(x2 <= 0) + return; + if(x1 >= cubemap_size) + return; + if(y1a >= y1b || y2a >= y2b) + return; + if(x1 >= x2) + return; + + // calc gradients + int m_y1a = ((y2a-y1a)<<16); + int m_y1b = ((y2b-y1b)<<16); + m_y1a /= (x2-x1); + m_y1b /= (x2-x1); + int sub_y1a = 0; + int sub_y1b = 0; + + // X clamp + // TODO: clamp x1 properly + // TODO: fix the leaks properly + x2++; y1b++; y2b++; + if(x2 >= cubemap_size) + x2 = cubemap_size; + + // render + //uint32_t *cptr = &ccolor[(y1<= 0) + { + int ry1a = (y1a < 0 ? 0 : y1a); + int ry1b = (y1b >= cubemap_size ? cubemap_size : y1b); + + cptr = &ccolor[(ry1a<>16); + y1b += (sub_y1b>>16); + sub_y1a &= 0xFFFF; + sub_y1b &= 0xFFFF; + } +} + void render_vxl_cube_sides(uint32_t *ccolor, float *cdepth, int x1, int y1, int x2, int y2, uint32_t color, float depth) { int hsize = (cubemap_size>>1); - if(depth > CUBESUX_MARKER) { int x3 = ((x1-hsize)*depth)/(depth+1.0f)+hsize; @@ -515,33 +651,32 @@ void render_vxl_cube_sides(uint32_t *ccolor, float *cdepth, int x1, int y1, int return; } - int x3 = ((x1-hsize)*depth)/(depth+0.5f)+hsize; - int y3 = ((y1-hsize)*depth)/(depth+0.5f)+hsize; - int x4 = ((x2-hsize)*depth)/(depth+0.5f)+hsize; - int y4 = ((y2-hsize)*depth)/(depth+0.5f)+hsize; + int x3 = ((x1-hsize)*depth)/(depth+1.0f)+hsize; + int y3 = ((y1-hsize)*depth)/(depth+1.0f)+hsize; + int x4 = ((x2-hsize)*depth)/(depth+1.0f)+hsize; + int y4 = ((y2-hsize)*depth)/(depth+1.0f)+hsize+1; render_vxl_rect_ftb_fast(ccolor, cdepth, x1, y1, x2, y2, color, depth); depth += 0.5f; - // TODO: replace these with trapezium drawing routines - if(x3 < x1) - render_vxl_rect_ftb_fast(ccolor, cdepth, - (int)x3, (int)y3, (int)x1, (int)y4, - color, depth); - else if(x2 < x4) - render_vxl_rect_ftb_fast(ccolor, cdepth, - (int)x2, (int)y3, (int)x4, (int)y4, - color, depth); - if(y3 < y1) - render_vxl_rect_ftb_fast(ccolor, cdepth, - (int)x3, (int)y3, (int)x4, (int)y1, - color, depth); + render_vxl_cube_htrap(ccolor, cdepth, + x3, x4, y3, x1, x2, y1, + color, depth+1.0f); else if(y2 < y4) - render_vxl_rect_ftb_fast(ccolor, cdepth, - (int)x3, (int)y2, (int)x4, (int)y4, - color, depth); + render_vxl_cube_htrap(ccolor, cdepth, + x1, x2, y2, x3, x4, y4, + color, depth+1.0f); + + if(x3 < x1) + render_vxl_cube_vtrap(ccolor, cdepth, + x3, y3, y4, x1, y1, y2, + color, depth+1.0f); + else if(x2 < x4) + render_vxl_cube_vtrap(ccolor, cdepth, + x2, y1, y2, x4, y3, y4, + color, depth+1.0f); } void render_vxl_cube(uint32_t *ccolor, float *cdepth, int x1, int y1, int x2, int y2, uint32_t color, float depth)