Browse Source

ref_soft: extended bsp support

pull/2/head
mittorn 6 years ago
parent
commit
b2105a113c
  1. 18
      r_edge.c
  2. 40
      r_surf.c

18
r_edge.c

@ -821,8 +821,8 @@ void D_CalcGradients (msurface_t *pface)
mipscale = 1.0 / (float)(1 << miplevel); mipscale = 1.0 / (float)(1 << miplevel);
TransformVector (pface->texinfo->vecs[0], p_saxis); TransformVector (pface->info->lmvecs[0], p_saxis);
TransformVector (pface->texinfo->vecs[1], p_taxis); TransformVector (pface->info->lmvecs[1], p_taxis);
t = xscaleinv * mipscale; t = xscaleinv * mipscale;
d_sdivzstepu = p_saxis[0] * t; d_sdivzstepu = p_saxis[0] * t;
@ -841,11 +841,11 @@ void D_CalcGradients (msurface_t *pface)
t = 0x10000*mipscale; t = 0x10000*mipscale;
sadjust = ((fixed16_t)(DotProduct (p_temp1, p_saxis) * 0x10000 + 0.5)) - sadjust = ((fixed16_t)(DotProduct (p_temp1, p_saxis) * 0x10000 + 0.5)) -
((pface->texturemins[0] << 16) >> miplevel) ((pface->info->lightmapmins[0] << 16) >> miplevel)
+ pface->texinfo->vecs[0][3]*t; + pface->info->lmvecs[0][3]*t;
tadjust = ((fixed16_t)(DotProduct (p_temp1, p_taxis) * 0x10000 + 0.5)) - tadjust = ((fixed16_t)(DotProduct (p_temp1, p_taxis) * 0x10000 + 0.5)) -
((pface->texturemins[1] << 16) >> miplevel) ((pface->info->lightmapmins[1] << 16) >> miplevel)
+ pface->texinfo->vecs[1][3]*t; + pface->info->lmvecs[1][3]*t;
#if 1 #if 1
// PGM - changing flow speed for non-warping textures. // PGM - changing flow speed for non-warping textures.
if (pface->flags & SURF_CONVEYOR) if (pface->flags & SURF_CONVEYOR)
@ -861,8 +861,8 @@ void D_CalcGradients (msurface_t *pface)
// //
// -1 (-epsilon) so we never wander off the edge of the texture // -1 (-epsilon) so we never wander off the edge of the texture
// //
bbextents = ((pface->extents[0] << 16) >> miplevel) - 1; bbextents = ((pface->info->lightextents[0] << 16) >> miplevel) - 1;
bbextentt = ((pface->extents[1] << 16) >> miplevel) - 1; bbextentt = ((pface->info->lightextents[1] << 16) >> miplevel) - 1;
} }
@ -1149,6 +1149,8 @@ void D_SolidSurf (surf_t *s)
miplevel = 1; miplevel = 1;
else else
miplevel = D_MipLevelForScale(s->nearzi * scale_for_mip ); miplevel = D_MipLevelForScale(s->nearzi * scale_for_mip );
while( 1 << miplevel > gEngfuncs.Mod_SampleSizeForFace(pface))
miplevel--;
#else #else
{ {
float dot; float dot;

40
r_surf.c

@ -484,9 +484,17 @@ void R_DrawSurface (void)
pixel_t *pcolumndest; pixel_t *pcolumndest;
void (*pblockdrawer)(void); void (*pblockdrawer)(void);
image_t *mt; image_t *mt;
uint sample_size, sample_bits, sample_pot;
surfrowbytes = r_drawsurf.rowbytes; surfrowbytes = r_drawsurf.rowbytes;
sample_size = gEngfuncs.Mod_SampleSizeForFace( r_drawsurf.surf );
sample_bits = 0;
for( sample_pot = 1; sample_pot < sample_size; sample_pot <<= 1, sample_bits++ );
//printf("%d\n", sample_size );
mt = r_drawsurf.image; mt = r_drawsurf.image;
r_source = mt->pixels[r_drawsurf.surfmip]; r_source = mt->pixels[r_drawsurf.surfmip];
@ -496,8 +504,8 @@ void R_DrawSurface (void)
texwidth = mt->width >> r_drawsurf.surfmip; texwidth = mt->width >> r_drawsurf.surfmip;
blocksize = 16 >> r_drawsurf.surfmip; blocksize = sample_pot >> r_drawsurf.surfmip;
blockdivshift = 4 - r_drawsurf.surfmip; blockdivshift = sample_bits - r_drawsurf.surfmip;
blockdivmask = (1 << blockdivshift) - 1; blockdivmask = (1 << blockdivshift) - 1;
r_lightwidth = ( r_drawsurf.surf->info->lightextents[0] / gEngfuncs.Mod_SampleSizeForFace( r_drawsurf.surf ) ) + 1; r_lightwidth = ( r_drawsurf.surf->info->lightextents[0] / gEngfuncs.Mod_SampleSizeForFace( r_drawsurf.surf ) ) + 1;
@ -520,8 +528,10 @@ void R_DrawSurface (void)
r_sourcemax = r_source + (tmax * smax); r_sourcemax = r_source + (tmax * smax);
soffset = r_drawsurf.surf->texturemins[0]; //soffset = r_drawsurf.surf->texturemins[0];
basetoffset = r_drawsurf.surf->texturemins[1]; //basetoffset = r_drawsurf.surf->texturemins[1];
soffset = r_drawsurf.surf->info->lightmapmins[0];
basetoffset = r_drawsurf.surf->info->lightmapmins[1];
// << 16 components are to guarantee positive values for % // << 16 components are to guarantee positive values for %
soffset = ((soffset >> r_drawsurf.surfmip) + (smax << 16)) % smax; soffset = ((soffset >> r_drawsurf.surfmip) + (smax << 16)) % smax;
@ -580,14 +590,14 @@ void R_DrawSurfaceBlock8_mip0 (void)
lightleftstep = (r_lightptr[0] - lightleft) >> 4; lightleftstep = (r_lightptr[0] - lightleft) >> 4;
lightrightstep = (r_lightptr[1] - lightright) >> 4; lightrightstep = (r_lightptr[1] - lightright) >> 4;
for (i=0 ; i<16 ; i++) for (i=0 ; i<blocksize ; i++)
{ {
lighttemp = lightleft - lightright; lighttemp = lightleft - lightright;
lightstep = lighttemp >> 4; lightstep = lighttemp >> 4;
light = lightright; light = lightright;
for (b=15; b>=0; b--) for (b=blocksize - 1; b>=0; b--)
{ {
pix = psource[b]; pix = psource[b];
prowdest[b] = BLEND_LM(pix, light); prowdest[b] = BLEND_LM(pix, light);
@ -636,14 +646,14 @@ void R_DrawSurfaceBlock8_mip1 (void)
lightleftstep = (r_lightptr[0] - lightleft) >> 3; lightleftstep = (r_lightptr[0] - lightleft) >> 3;
lightrightstep = (r_lightptr[1] - lightright) >> 3; lightrightstep = (r_lightptr[1] - lightright) >> 3;
for (i=0 ; i<8 ; i++) for (i=0 ; i<blocksize ; i++)
{ {
lighttemp = lightleft - lightright; lighttemp = lightleft - lightright;
lightstep = lighttemp >> 3; lightstep = lighttemp >> 3;
light = lightright; light = lightright;
for (b=7; b>=0; b--) for (b=blocksize-1; b>=0; b--)
{ {
pix = psource[b]; pix = psource[b];
prowdest[b] = BLEND_LM(pix, light); prowdest[b] = BLEND_LM(pix, light);
@ -688,14 +698,14 @@ void R_DrawSurfaceBlock8_mip2 (void)
lightleftstep = (r_lightptr[0] - lightleft) >> 2; lightleftstep = (r_lightptr[0] - lightleft) >> 2;
lightrightstep = (r_lightptr[1] - lightright) >> 2; lightrightstep = (r_lightptr[1] - lightright) >> 2;
for (i=0 ; i<4 ; i++) for (i=0 ; i<blocksize ; i++)
{ {
lighttemp = lightleft - lightright; lighttemp = lightleft - lightright;
lightstep = lighttemp >> 2; lightstep = lighttemp >> 2;
light = lightright; light = lightright;
for (b=3; b>=0; b--) for (b=blocksize-1; b>=0; b--)
{ {
pix = psource[b]; pix = psource[b];
prowdest[b] = BLEND_LM(pix, light);; prowdest[b] = BLEND_LM(pix, light);;
@ -740,14 +750,14 @@ void R_DrawSurfaceBlock8_mip3 (void)
lightleftstep = (r_lightptr[0] - lightleft) >> 1; lightleftstep = (r_lightptr[0] - lightleft) >> 1;
lightrightstep = (r_lightptr[1] - lightright) >> 1; lightrightstep = (r_lightptr[1] - lightright) >> 1;
for (i=0 ; i<2 ; i++) for (i=0 ; i<blocksize ; i++)
{ {
lighttemp = lightleft - lightright; lighttemp = lightleft - lightright;
lightstep = lighttemp >> 1; lightstep = lighttemp >> 1;
light = lightright; light = lightright;
for (b=1; b>=0; b--) for (b=blocksize-1; b>=0; b--)
{ {
pix = psource[b]; pix = psource[b];
prowdest[b] = BLEND_LM(pix, light);; prowdest[b] = BLEND_LM(pix, light);;
@ -1184,9 +1194,11 @@ surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel)
// //
surfscale = 1.0 / (1<<miplevel); surfscale = 1.0 / (1<<miplevel);
r_drawsurf.surfmip = miplevel; r_drawsurf.surfmip = miplevel;
r_drawsurf.surfwidth = surface->extents[0] >> miplevel; r_drawsurf.surfwidth = surface->info->lightextents[0] >> miplevel;
//surface->extents[0] >> miplevel;
r_drawsurf.rowbytes = r_drawsurf.surfwidth; r_drawsurf.rowbytes = r_drawsurf.surfwidth;
r_drawsurf.surfheight = surface->extents[1] >> miplevel; r_drawsurf.surfheight = surface->info->lightextents[1] >> miplevel;
//surface->extents[1] >> miplevel;
// //

Loading…
Cancel
Save