mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Cache TERRAIN on texture_t
- K_GetTerrainForTextureNum no longer performs a string lookup
This commit is contained in:
parent
2d4cc49101
commit
03deb45c67
3 changed files with 14 additions and 1 deletions
|
|
@ -370,7 +370,7 @@ terrain_t *K_GetTerrainForTextureNum(INT32 textureNum)
|
|||
if (textureNum >= 0 && textureNum < numtextures)
|
||||
{
|
||||
texture_t *tex = textures[textureNum];
|
||||
return K_GetTerrainForTextureName(tex->name);
|
||||
return tex->terrain;
|
||||
}
|
||||
|
||||
// This texture doesn't have a terrain directly applied to it,
|
||||
|
|
@ -2036,6 +2036,12 @@ static boolean K_TERRAINLumpParser(char *data, size_t size)
|
|||
{
|
||||
f->terrainID = K_GetTerrainHeapIndex(t);
|
||||
CONS_Printf("Texture '%s' set to Terrain '%s'\n", f->textureName, tkn);
|
||||
|
||||
INT32 tex = R_CheckTextureNumForName(f->textureName);
|
||||
if (tex != -1)
|
||||
{
|
||||
textures[tex]->terrain = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -2211,4 +2217,6 @@ void K_InitTerrain(UINT16 wadNum)
|
|||
free(name);
|
||||
}
|
||||
}
|
||||
|
||||
R_ClearTextureNumCache(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "p_setup.h" // levelflats
|
||||
#include "byteptr.h"
|
||||
#include "dehacked.h"
|
||||
#include "k_terrain.h"
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "hardware/hw_glob.h" // HWR_LoadMapTextures
|
||||
|
|
@ -1191,6 +1192,7 @@ Rloadflats (INT32 i, INT32 w)
|
|||
texture->patchcount = 1;
|
||||
texture->holes = false;
|
||||
texture->flip = 0;
|
||||
texture->terrain = K_GetTerrainForTextureName(texture->name);
|
||||
|
||||
// Allocate information for the texture's patches.
|
||||
patch = &texture->patches[0];
|
||||
|
|
@ -1293,6 +1295,7 @@ Rloadtextures (INT32 i, INT32 w)
|
|||
texture->patchcount = 1;
|
||||
texture->holes = false;
|
||||
texture->flip = 0;
|
||||
texture->terrain = K_GetTerrainForTextureName(texture->name);
|
||||
|
||||
// Allocate information for the texture's patches.
|
||||
patch = &texture->patches[0];
|
||||
|
|
@ -1830,6 +1833,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
|
|||
resultTexture->width = newTextureWidth;
|
||||
resultTexture->height = newTextureHeight;
|
||||
resultTexture->type = TEXTURETYPE_COMPOSITE;
|
||||
resultTexture->terrain = K_GetTerrainForTextureName(newTextureName);
|
||||
}
|
||||
Z_Free(texturesToken);
|
||||
texturesToken = M_GetToken(NULL);
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ struct texture_t
|
|||
boolean holes;
|
||||
UINT8 flip; // 1 = flipx, 2 = flipy, 3 = both
|
||||
void *flat; // The texture, as a flat.
|
||||
terrain_t *terrain;
|
||||
|
||||
// All the patches[patchcount] are drawn back to front into the cached texture.
|
||||
INT16 patchcount;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue