smol opitmizations and cleanup
This commit is contained in:
1 parent
fccfcd12fd
commit
962b68c5c3
3 files changed
+35
-35
No files matched your search
@@ -378,13 +378,10 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe
|
||||
// Composite the columns together.
|
||||
for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++)
|
||||
{
|
||||
pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE);
|
||||
pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_LEVEL);
|
||||
realpatch = (softwarepatch_t *)pdata;
|
||||
|
||||
if (realpatch != NULL)
|
||||
{
|
||||
HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch);
|
||||
}
|
||||
HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch);
|
||||
}
|
||||
|
||||
//Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :(
|
||||
@@ -863,9 +860,9 @@ void HWR_LoadMapTextures(size_t pnumtextures)
|
||||
|
||||
gl_numtextures = pnumtextures;
|
||||
#ifdef GLENCORE
|
||||
gl_textures = calloc(pnumtextures, sizeof (*gl_textures)*2); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore)
|
||||
gl_textures = calloc(gl_numtextures, sizeof (*gl_textures)*2); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore)
|
||||
#else
|
||||
gl_textures = calloc(pnumtextures, sizeof (*gl_textures));
|
||||
gl_textures = calloc(gl_numtextures, sizeof (*gl_textures));
|
||||
#endif
|
||||
if (gl_textures == NULL)
|
||||
I_Error("HWR_LoadMapTextures: ran out of memory for OpenGL textures. Sad!");
|
||||
@@ -1121,6 +1118,7 @@ void HWR_UnlockCachedPatch(GLPatch_t *glPatch)
|
||||
patch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum)
|
||||
{
|
||||
lumpcache_t *lumpcache = wadfiles[wadnum]->patchcache;
|
||||
|
||||
if (!lumpcache[lumpnum])
|
||||
{
|
||||
void *ptr = Z_Calloc(sizeof(patch_t), PU_PATCH, &lumpcache[lumpnum]);
|
||||
@@ -1393,6 +1391,7 @@ UINT32 HWR_CreateLightTable(UINT8 *lighttable)
|
||||
UINT32 HWR_GetLightTableID(extracolormap_t *colormap)
|
||||
{
|
||||
boolean default_colormap = false;
|
||||
|
||||
if (!colormap)
|
||||
{
|
||||
colormap = &extra_colormaps[num_extra_colormaps]; // a place to store the hw lighttable id
|
||||
|
||||
+26
-25
@@ -329,29 +329,31 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
||||
// Check the patch for holes.
|
||||
if (texture->width > SHORT(realpatch->width) || texture->height > SHORT(realpatch->height))
|
||||
holey = true;
|
||||
|
||||
colofs = (UINT8 *)realpatch->columnofs;
|
||||
|
||||
for (x = 0; x < texture->width && !holey; x++)
|
||||
else
|
||||
{
|
||||
column_t *col = (column_t *)((UINT8 *)realpatch + LONG(*(UINT32 *)&colofs[x<<2]));
|
||||
colofs = (UINT8 *)realpatch->columnofs;
|
||||
|
||||
INT32 topdelta, prevdelta = -1, y = 0;
|
||||
|
||||
while (col->topdelta != 0xff)
|
||||
for (x = 0; x < texture->width; x++)
|
||||
{
|
||||
topdelta = col->topdelta;
|
||||
if (topdelta <= prevdelta)
|
||||
topdelta += prevdelta;
|
||||
prevdelta = topdelta;
|
||||
if (topdelta > y)
|
||||
break;
|
||||
y = topdelta + col->length + 1;
|
||||
col = (column_t *)((UINT8 *)col + col->length + 4);
|
||||
}
|
||||
column_t *col = (column_t *)((UINT8 *)realpatch + LONG(*(UINT32 *)&colofs[x<<2]));
|
||||
|
||||
if (y < texture->height)
|
||||
holey = true; // this texture is HOLEy! D:
|
||||
INT32 topdelta, prevdelta = -1, y = 0;
|
||||
|
||||
while (col->topdelta != 0xff)
|
||||
{
|
||||
topdelta = col->topdelta;
|
||||
if (topdelta <= prevdelta)
|
||||
topdelta += prevdelta;
|
||||
prevdelta = topdelta;
|
||||
if (topdelta > y)
|
||||
break;
|
||||
y = topdelta + col->length + 1;
|
||||
col = (column_t *)((UINT8 *)col + col->length + 4);
|
||||
}
|
||||
|
||||
if (y < texture->height)
|
||||
holey = true; // this texture is HOLEy! D:
|
||||
}
|
||||
}
|
||||
|
||||
// If the patch uses transparency, we have to save it this way.
|
||||
@@ -359,8 +361,7 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
||||
{
|
||||
texture->holes = true;
|
||||
blocksize = W_LumpLengthPwad(patch->wad, patch->lump);
|
||||
block = Z_Calloc(blocksize, PU_LEVEL, // will change tag at end of this function
|
||||
&texturecache[texnum]);
|
||||
block = Z_Calloc(blocksize, PU_LEVEL, &texturecache[texnum]);
|
||||
M_Memcpy(block, realpatch, blocksize);
|
||||
texturememory += blocksize;
|
||||
|
||||
@@ -368,8 +369,12 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
||||
colofs = (block + 8);
|
||||
texturecolumnofs[texnum] = (UINT32 *)colofs;
|
||||
blocktex = block;
|
||||
|
||||
for (x = 0; x < texture->width; x++)
|
||||
{
|
||||
*(UINT32 *)&colofs[x<<2] = LONG(LONG(*(UINT32 *)&colofs[x<<2]) + 3);
|
||||
}
|
||||
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -397,10 +402,6 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
||||
pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_LEVEL);
|
||||
realpatch = (softwarepatch_t *)pdata;
|
||||
|
||||
// Well, it's not valid...
|
||||
if (realpatch == NULL)
|
||||
continue;
|
||||
|
||||
x1 = patch->originx;
|
||||
width = SHORT(realpatch->width);
|
||||
height = SHORT(realpatch->height);
|
||||
|
||||
+3
-3
@@ -128,7 +128,7 @@ static void R_CalculatePlaneRipple(visplane_t *plane, INT32 y, fixed_t plheight,
|
||||
{
|
||||
fixed_t distance = FixedMul(plheight, yslope[y]);
|
||||
const INT32 yay = (planeripple.offset + (distance>>9)) & 8191;
|
||||
|
||||
|
||||
// ripples da water texture
|
||||
ds_bgofs = FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS;
|
||||
|
||||
@@ -630,7 +630,7 @@ void R_DrawPlanes(void)
|
||||
R_DrawSinglePlane(pl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef NOWATER
|
||||
R_UpdatePlaneRipple();
|
||||
#endif
|
||||
@@ -1050,7 +1050,7 @@ void R_DrawSinglePlane(visplane_t *pl)
|
||||
|
||||
xoffs = (fixed_t)(xoffs*fudgecanyon);
|
||||
yoffs = (fixed_t)(yoffs/fudgecanyon);
|
||||
|
||||
|
||||
#ifndef NOWATER
|
||||
if (planeripple.active)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user