[0.0-8] OH LOOK THEY'RE FINALLY CUBES (also fixed non-drunken cam I broke)

This commit is contained in:
Ben Russell (300178622) 2013-01-08 18:06:57 +13:00
parent a2da76b7d3
commit 2ff476d8fa
6 changed files with 171 additions and 32 deletions

View File

@ -19,7 +19,7 @@
#define VERSION_X 0 #define VERSION_X 0
#define VERSION_Y 0 #define VERSION_Y 0
#define VERSION_A 0 #define VERSION_A 0
#define VERSION_Z 7 #define VERSION_Z 8
// Remember to bump "Z" basically every time you change the engine! // Remember to bump "Z" basically every time you change the engine!
// TRIPLEFOX THIS INCLUDES YOU // TRIPLEFOX THIS INCLUDES YOU
// Z can only be 0 for official releases! // Z can only be 0 for official releases!

View File

@ -82,7 +82,7 @@ MODE_TILT_SLOWDOWN = false -- TODO!
MODE_TILT_DOWN_NOCLIMB = false -- TODO! MODE_TILT_DOWN_NOCLIMB = false -- TODO!
MODE_DRUNKCAM_VELOCITY = false -- keep this off unless you want to throw up 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_DIG = 1.0
MODE_DELAY_SPADE_HIT = 0.25 MODE_DELAY_SPADE_HIT = 0.25

View File

@ -699,6 +699,7 @@ function new_player(settings)
--print("polar",this.angx, this.angy) --print("polar",this.angx, this.angy)
else else
this.angx = this.angx + this.dangx
this.angy = this.angy + this.dangy this.angy = this.angy + this.dangy
end end
this.dangx = 0 this.dangx = 0

View File

@ -35,4 +35,5 @@ VERSION_BUGS = {
{intro=4, fix=5, msg="Dedicated server build was broken"}, {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=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=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"},
} }

View File

@ -57,7 +57,9 @@ pmfedit_z = 0
pmfedit_size = 16 pmfedit_size = 16
pmfedit_data = {} pmfedit_data = {}
pmfedit_model = common.model_new(1) 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_data[#pmfedit_data+1] = {x=0,y=0,z=0,r=0,g=0,b=0,radius=1}
pmfedit_ry = 0 pmfedit_ry = 0
pmfedit_rx = 0 pmfedit_rx = 0
@ -110,7 +112,7 @@ function client.hook_tick(sec_current, sec_delta)
g=math.sin(sec_current)*127+128, g=math.sin(sec_current)*127+128,
b=math.sin(sec_current+2*math.pi/3)*127+128, b=math.sin(sec_current+2*math.pi/3)*127+128,
radius=pmfedit_size} 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 return 0.005
end end
@ -213,9 +215,9 @@ function client.hook_key(key, state)
if xpmf then if xpmf then
common.model_free(pmfedit_model) -- YECCH! Forgot this line! common.model_free(pmfedit_model) -- YECCH! Forgot this line!
pmfedit_model = xpmf pmfedit_model = xpmf
pmfedit_model_bone = 0 pmfedit_model_bone[pmfedit_idx] = 0
local bname 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] = {} pmfedit_data[#pmfedit_data+1] = {}
print("loaded!") print("loaded!")
else else
@ -225,8 +227,8 @@ function client.hook_key(key, state)
local xpt = pmfedit_data[#pmfedit_data] local xpt = pmfedit_data[#pmfedit_data]
pmfedit_data[#pmfedit_data] = nil pmfedit_data[#pmfedit_data] = nil
local bname, blah local bname, blah
bname, blah = common.model_bone_get(pmfedit_model, pmfedit_model_bone) bname, blah = common.model_bone_get(pmfedit_model, pmfedit_model_bone[pmfedit_idx])
common.model_bone_set(pmfedit_model, pmfedit_model_bone, bname, pmfedit_data) common.model_bone_set(pmfedit_model, pmfedit_model_bone[pmfedit_idx], bname, pmfedit_data)
if common.model_save_pmf(pmfedit_model, PMFEDIT_FNAME) then if common.model_save_pmf(pmfedit_model, PMFEDIT_FNAME) then
print("saved!") print("saved!")
else else
@ -250,7 +252,7 @@ function client.hook_render()
,pmfedit_rx ,pmfedit_rx
,pmfedit_ry2)) ,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, 0,0,1,
pmfedit_ry,pmfedit_rx,pmfedit_ry2, pmfedit_ry,pmfedit_rx,pmfedit_ry2,
0.7) 0.7)
@ -261,9 +263,9 @@ if preload then
if xpmf then if xpmf then
common.model_free(pmfedit_model) -- YECCH! Forgot this line! common.model_free(pmfedit_model) -- YECCH! Forgot this line!
pmfedit_model = xpmf pmfedit_model = xpmf
pmfedit_model_bone = 0 pmfedit_model_bone[pmfedit_idx] = 0
local bname 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] = {} pmfedit_data[#pmfedit_data+1] = {}
print("loaded!") print("loaded!")
else else

View File

@ -495,11 +495,147 @@ void render_vxl_rect_ftb_fast(uint32_t *ccolor, float *cdepth, int x1, int y1, i
#endif #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<<cubemap_shift)+x1a];
//float *dptr = &cdepth[(y1<<cubemap_shift)+x1a];
uint32_t *cptr = ccolor;
float *dptr = cdepth;
int x,y;
for(y = y1; y < y2; y++)
{
if(y >= 0)
{
int rx1a = (x1a < 0 ? 0 : x1a);
int rx1b = (x1b >= cubemap_size ? cubemap_size : x1b);
cptr = &ccolor[(y<<cubemap_shift)+rx1a];
dptr = &cdepth[(y<<cubemap_shift)+rx1a];
for(x = rx1a; x < rx1b; x++)
{
if(*cptr == fog_color)
{
*cptr = color;
*dptr = depth;
}
cptr++;
dptr++;
}
}
sub_x1a += m_x1a;
sub_x1b += m_x1b;
x1a += (sub_x1a>>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<<cubemap_shift)+x1a];
//float *dptr = &cdepth[(y1<<cubemap_shift)+x1a];
uint32_t *cptr = ccolor;
float *dptr = cdepth;
int pitch = cubemap_size;
int x,y;
for(x = x1; x < x2; x++)
{
if(x >= 0)
{
int ry1a = (y1a < 0 ? 0 : y1a);
int ry1b = (y1b >= cubemap_size ? cubemap_size : y1b);
cptr = &ccolor[(ry1a<<cubemap_shift)+x];
dptr = &cdepth[(ry1a<<cubemap_shift)+x];
for(y = ry1a; y < ry1b; y++)
{
if(*cptr == fog_color)
{
*cptr = color;
*dptr = depth;
}
cptr += pitch;
dptr += pitch;
}
}
sub_y1a += m_y1a;
sub_y1b += m_y1b;
y1a += (sub_y1a>>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) 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); int hsize = (cubemap_size>>1);
if(depth > CUBESUX_MARKER) if(depth > CUBESUX_MARKER)
{ {
int x3 = ((x1-hsize)*depth)/(depth+1.0f)+hsize; 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; return;
} }
int x3 = ((x1-hsize)*depth)/(depth+0.5f)+hsize; int x3 = ((x1-hsize)*depth)/(depth+1.0f)+hsize;
int y3 = ((y1-hsize)*depth)/(depth+0.5f)+hsize; int y3 = ((y1-hsize)*depth)/(depth+1.0f)+hsize;
int x4 = ((x2-hsize)*depth)/(depth+0.5f)+hsize; int x4 = ((x2-hsize)*depth)/(depth+1.0f)+hsize;
int y4 = ((y2-hsize)*depth)/(depth+0.5f)+hsize; int y4 = ((y2-hsize)*depth)/(depth+1.0f)+hsize+1;
render_vxl_rect_ftb_fast(ccolor, cdepth, x1, y1, x2, y2, color, depth); render_vxl_rect_ftb_fast(ccolor, cdepth, x1, y1, x2, y2, color, depth);
depth += 0.5f; 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) if(y3 < y1)
render_vxl_rect_ftb_fast(ccolor, cdepth, render_vxl_cube_htrap(ccolor, cdepth,
(int)x3, (int)y3, (int)x4, (int)y1, x3, x4, y3, x1, x2, y1,
color, depth); color, depth+1.0f);
else if(y2 < y4) else if(y2 < y4)
render_vxl_rect_ftb_fast(ccolor, cdepth, render_vxl_cube_htrap(ccolor, cdepth,
(int)x3, (int)y2, (int)x4, (int)y4, x1, x2, y2, x3, x4, y4,
color, depth); 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) void render_vxl_cube(uint32_t *ccolor, float *cdepth, int x1, int y1, int x2, int y2, uint32_t color, float depth)