Allow smaller flat sizes

With mobj scale, smaller flats are pretty reasonable to want to use. Fixes a visual bug in Endless Mine.
This commit is contained in:
Sally Coolatta 2022-09-23 15:25:42 -04:00
parent 2890ce500a
commit e202f244b9
5 changed files with 83 additions and 112 deletions

View file

@ -31,6 +31,7 @@
#include "../p_local.h" // stplyr
#include "../g_game.h" // players
#include "../k_hud.h"
#include "../r_plane.h" // R_FlatDimensionsFromLumpSize
#include <fcntl.h>
#include "../i_video.h" // for rendermode != render_glide
@ -482,42 +483,17 @@ void HWR_DrawPic(INT32 x, INT32 y, lumpnum_t lumpnum)
// --------------------------------------------------------------------------
void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum)
{
FOutVector v[4];
double dflatsize;
INT32 flatflag;
const size_t len = W_LumpLength(flatlumpnum);
switch (len)
{
case 4194304: // 2048x2048 lump
dflatsize = 2048.0f;
flatflag = 2047;
break;
case 1048576: // 1024x1024 lump
dflatsize = 1024.0f;
flatflag = 1023;
break;
case 262144:// 512x512 lump
dflatsize = 512.0f;
flatflag = 511;
break;
case 65536: // 256x256 lump
dflatsize = 256.0f;
flatflag = 255;
break;
case 16384: // 128x128 lump
dflatsize = 128.0f;
flatflag = 127;
break;
case 1024: // 32x32 lump
dflatsize = 32.0f;
flatflag = 31;
break;
default: // 64x64 lump
dflatsize = 64.0f;
flatflag = 63;
break;
}
size_t sflatsize;
double dflatsize;
INT32 flatflag;
FOutVector v[4];
sflatsize = R_FlatDimensionsFromLumpSize(len);
dflatsize = (double)sflatsize;
flatflag = sflatsize - 1;
// 3--2
// | /|

View file

@ -46,6 +46,7 @@
// SRB2Kart
#include "../k_kart.h" // HITLAGJITTERS
#include "../r_fps.h"
#include "../r_plane.h" // R_FlatDimensionsFromLumpSize
#ifdef NEWCLIP
#include "hw_clip.h"
@ -393,31 +394,9 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
if (levelflat->type == LEVELFLAT_FLAT)
{
size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
switch (len)
{
case 4194304: // 2048x2048 lump
fflatwidth = fflatheight = 2048.0f;
break;
case 1048576: // 1024x1024 lump
fflatwidth = fflatheight = 1024.0f;
break;
case 262144:// 512x512 lump
fflatwidth = fflatheight = 512.0f;
break;
case 65536: // 256x256 lump
fflatwidth = fflatheight = 256.0f;
break;
case 16384: // 128x128 lump
fflatwidth = fflatheight = 128.0f;
break;
case 1024: // 32x32 lump
fflatwidth = fflatheight = 32.0f;
break;
default: // 64x64 lump
fflatwidth = fflatheight = 64.0f;
break;
}
flatflag = ((INT32)fflatwidth)-1;
size_t sflatsize = R_FlatDimensionsFromLumpSize(len);
fflatwidth = fflatheight = (double)sflatsize;
flatflag = sflatsize-1;
}
else
{
@ -2756,31 +2735,9 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
if (levelflat->type == LEVELFLAT_FLAT)
{
size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
switch (len)
{
case 4194304: // 2048x2048 lump
fflatwidth = fflatheight = 2048.0f;
break;
case 1048576: // 1024x1024 lump
fflatwidth = fflatheight = 1024.0f;
break;
case 262144:// 512x512 lump
fflatwidth = fflatheight = 512.0f;
break;
case 65536: // 256x256 lump
fflatwidth = fflatheight = 256.0f;
break;
case 16384: // 128x128 lump
fflatwidth = fflatheight = 128.0f;
break;
case 1024: // 32x32 lump
fflatwidth = fflatheight = 32.0f;
break;
default: // 64x64 lump
fflatwidth = fflatheight = 64.0f;
break;
}
flatflag = ((INT32)fflatwidth)-1;
size_t sflatsize = R_FlatDimensionsFromLumpSize(len);
fflatwidth = fflatheight = (double)sflatsize;
flatflag = sflatsize-1;
}
else
{

View file

@ -89,6 +89,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop);
void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop);
void R_PlaneBounds(visplane_t *plane);
size_t R_FlatDimensionsFromLumpSize(size_t size);
void R_CheckFlatLength(size_t size);
boolean R_CheckPowersOfTwo(void);

View file

@ -656,6 +656,44 @@ boolean R_CheckPowersOfTwo(void)
return ds_powersoftwo;
}
//
// R_FlatDimensionsFromLumpSize
//
// Returns the flat's square size from its lump length.
//
size_t R_FlatDimensionsFromLumpSize(size_t size)
{
switch (size)
{
case 4194304: // 2048x2048 lump
return 2048;
case 1048576: // 1024x1024 lump
return 1024;
case 262144:// 512x512 lump
return 512;
case 65536: // 256x256 lump
return 256;
case 16384: // 128x128 lump
return 128;
case 1024: // 32x32 lump
return 32;
case 256: // 16x16 lump
return 16;
case 64: // 8x8 lump
return 8;
default: // 64x64 lump
return 64;
}
}
//
// R_CheckFlatLength
//
@ -707,6 +745,20 @@ void R_CheckFlatLength(size_t size)
nflatshiftup = 11;
ds_flatwidth = ds_flatheight = 32;
break;
case 256: // 16x16 lump
nflatmask = 0xF0;
nflatxshift = 28;
nflatyshift = 24;
nflatshiftup = 12;
ds_flatwidth = ds_flatheight = 16;
break;
case 64: // 8x8 lump
nflatmask = 0x38;
nflatxshift = 29;
nflatyshift = 26;
nflatshiftup = 13;
ds_flatwidth = ds_flatheight = 8;
break;
default: // 64x64 lump
nflatmask = 0xFC0;
nflatxshift = 26;
@ -774,30 +826,7 @@ Rloadflats (INT32 i, INT32 w)
W_ReadLumpHeaderPwad(wadnum, lumpnum, header, sizeof header, 0);
lumplength = W_LumpLengthPwad(wadnum, lumpnum);
switch (lumplength)
{
case 4194304: // 2048x2048 lump
flatsize = 2048;
break;
case 1048576: // 1024x1024 lump
flatsize = 1024;
break;
case 262144:// 512x512 lump
flatsize = 512;
break;
case 65536: // 256x256 lump
flatsize = 256;
break;
case 16384: // 128x128 lump
flatsize = 128;
break;
case 1024: // 32x32 lump
flatsize = 32;
break;
default: // 64x64 lump
flatsize = 64;
break;
}
flatsize = R_FlatDimensionsFromLumpSize(lumplength);
//CONS_Printf("\n\"%s\" is a flat, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),flatsize,flatsize);
texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL);

View file

@ -1236,19 +1236,19 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum)
{
case 4194304: // 2048x2048 lump
lflatsize = 2048;
flatshift = 10;
flatshift = 11;
break;
case 1048576: // 1024x1024 lump
lflatsize = 1024;
flatshift = 9;
flatshift = 10;
break;
case 262144:// 512x512 lump
lflatsize = 512;
flatshift = 8;
flatshift = 9;
break;
case 65536: // 256x256 lump
lflatsize = 256;
flatshift = 7;
flatshift = 8;
break;
case 16384: // 128x128 lump
lflatsize = 128;
@ -1258,6 +1258,14 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum)
lflatsize = 32;
flatshift = 5;
break;
case 256: // 16x16 lump
lflatsize = 16;
flatshift = 4;
break;
case 64: // 8x8 lump
lflatsize = 8;
flatshift = 3;
break;
default: // 64x64 lump
lflatsize = 64;
flatshift = 6;