vmap: skip remapped materials when looking for an already allocated material.
This commit is contained in:
parent
f753e6f3ba
commit
d8e2eb103c
12 changed files with 96 additions and 30 deletions
|
@ -251,7 +251,7 @@ static void ConvertShader( FILE *f, bspShader_t *shader, int shaderNum ){
|
|||
|
||||
|
||||
/* get shader */
|
||||
si = ShaderInfoForShader( shader->shader );
|
||||
si = ShaderInfoForShader( shader->shader, 0 );
|
||||
if ( si == NULL ) {
|
||||
Sys_FPrintf( SYS_WRN, "WARNING: NULL shader in BSP\n" );
|
||||
return;
|
||||
|
|
|
@ -269,7 +269,7 @@ static void ConvertBrush( FILE *f, int num, bspBrush_t *brush, vec3_t origin, qb
|
|||
buildBrush->numsides++;
|
||||
|
||||
/* tag it */
|
||||
buildSide->shaderInfo = ShaderInfoForShader( shader->shader );
|
||||
buildSide->shaderInfo = ShaderInfoForShader( shader->shader, 0 );
|
||||
buildSide->planenum = side->planeNum;
|
||||
buildSide->winding = NULL;
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ static void ConvertShaderToMTL( FILE *f, bspShader_t *shader, int shaderNum ){
|
|||
|
||||
|
||||
/* get shader */
|
||||
si = ShaderInfoForShader( shader->shader );
|
||||
si = ShaderInfoForShader( shader->shader, 0 );
|
||||
if ( si == NULL ) {
|
||||
Sys_FPrintf( SYS_WRN, "WARNING: NULL shader in BSP\n" );
|
||||
return;
|
||||
|
|
|
@ -1190,7 +1190,7 @@ void SetupSurfaceLightmaps( void ){
|
|||
/* get extra data */
|
||||
info->si = GetSurfaceExtraShaderInfo( num );
|
||||
if ( info->si == NULL ) {
|
||||
info->si = ShaderInfoForShader( bspShaders[ ds->shaderNum ].shader );
|
||||
info->si = ShaderInfoForShader( bspShaders[ ds->shaderNum ].shader, 0 );
|
||||
}
|
||||
info->parentSurfaceNum = GetSurfaceExtraParentSurfaceNum( num );
|
||||
info->entityNum = GetSurfaceExtraEntityNum( num );
|
||||
|
|
|
@ -1128,7 +1128,7 @@ static void ParseRawBrush( qboolean onlyLights ){
|
|||
si = &shaderInfo[ 0 ];
|
||||
}
|
||||
else{
|
||||
si = ShaderInfoForShader( shader );
|
||||
si = ShaderInfoForShader( shader, 0 );
|
||||
}
|
||||
side->shaderInfo = si;
|
||||
side->surfaceFlags = si->surfaceFlags;
|
||||
|
@ -1847,7 +1847,7 @@ static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups )
|
|||
if ( value[ 0 ] != '\0' ) {
|
||||
if ( strcmp( value, "none" ) ) {
|
||||
sprintf( shader, "textures/%s", value );
|
||||
celShader = ShaderInfoForShader( shader );
|
||||
celShader = ShaderInfoForShader( shader, 0 );
|
||||
Sys_Printf( "Entity %d (%s) has cel shader %s\n", mapEnt->mapEntityNum, classname, celShader->shader );
|
||||
}
|
||||
else
|
||||
|
@ -1856,7 +1856,7 @@ static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups )
|
|||
}
|
||||
}
|
||||
else{
|
||||
celShader = ( *globalCelShader ? ShaderInfoForShader( globalCelShader ) : NULL );
|
||||
celShader = ( *globalCelShader ? ShaderInfoForShader( globalCelShader, 0 ) : NULL );
|
||||
}
|
||||
|
||||
/* jal : entity based _shadeangle */
|
||||
|
|
|
@ -392,10 +392,10 @@ void InsertModel( const char *name, int skin, int frame, m4x4_t transform, remap
|
|||
else{
|
||||
strcat( shaderName, "_BSP" );
|
||||
}
|
||||
si = ShaderInfoForShader( shaderName );
|
||||
si = ShaderInfoForShader( shaderName, 0 );
|
||||
}
|
||||
else{
|
||||
si = ShaderInfoForShader( picoShaderName );
|
||||
si = ShaderInfoForShader( picoShaderName, 0 );
|
||||
}
|
||||
|
||||
/* allocate a surface (ydnar: gs mods) */
|
||||
|
@ -860,10 +860,10 @@ void AddTriangleModels( entity_t *e ){
|
|||
}
|
||||
if ( value[ 0 ] != '\0' ) {
|
||||
sprintf( shader, "textures/%s", value );
|
||||
celShader = ShaderInfoForShader( shader );
|
||||
celShader = ShaderInfoForShader( shader, 0 );
|
||||
}
|
||||
else{
|
||||
celShader = *globalCelShader ? ShaderInfoForShader( globalCelShader ) : NULL;
|
||||
celShader = *globalCelShader ? ShaderInfoForShader( globalCelShader, 0 ) : NULL;
|
||||
}
|
||||
|
||||
/* jal : entity based _samplesize */
|
||||
|
|
|
@ -406,7 +406,7 @@ void ParsePatch( qboolean onlyLights, qboolean fixedtess, qboolean extended ){
|
|||
|
||||
/* set shader */
|
||||
sprintf( shader, "textures/%s", texture );
|
||||
pm->shaderInfo = ShaderInfoForShader( shader );
|
||||
pm->shaderInfo = ShaderInfoForShader( shader, 0 );
|
||||
|
||||
/* set mesh */
|
||||
pm->mesh = m;
|
||||
|
|
|
@ -439,7 +439,7 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ){
|
|||
|
||||
/* dummy check */
|
||||
if ( si == NULL ) {
|
||||
return ShaderInfoForShader( "default" );
|
||||
return ShaderInfoForShader( "default", 0 );
|
||||
}
|
||||
|
||||
/* default shader text source */
|
||||
|
@ -561,7 +561,7 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ){
|
|||
digest[ 8 ], digest[ 9 ], digest[ 10 ], digest[ 11 ], digest[ 12 ], digest[ 13 ], digest[ 14 ], digest[ 15 ] );
|
||||
|
||||
/* get shader */
|
||||
csi = ShaderInfoForShader( shader );
|
||||
csi = ShaderInfoForShader( shader, 0 );
|
||||
|
||||
/* might be a preexisting shader */
|
||||
if ( csi->custom ) {
|
||||
|
@ -662,6 +662,7 @@ static shaderInfo_t *AllocShaderInfo( void ){
|
|||
si->forceSunlight = qfalse;
|
||||
si->vertexScale = 1.0;
|
||||
si->notjunc = qfalse;
|
||||
si->remapped = qfalse;
|
||||
|
||||
/* ydnar: set texture coordinate transform matrix to identity */
|
||||
TCModIdentity( si->mod );
|
||||
|
@ -820,7 +821,7 @@ shaderInfo_t *ShaderInfoForShaderNull( const char *shaderName ){
|
|||
if ( !strcmp( shaderName, "noshader" ) ) {
|
||||
return NULL;
|
||||
}
|
||||
return ShaderInfoForShader( shaderName );
|
||||
return ShaderInfoForShader( shaderName, 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -887,7 +888,64 @@ void Parse1DMatMatrixAppend( char *buffer, int x, vec_t *m ){
|
|||
}
|
||||
}
|
||||
|
||||
shaderInfo_t *ShaderInfoForShader( const char *shaderName ){
|
||||
int
|
||||
ShaderInfoExists(const char *shaderName)
|
||||
{
|
||||
int i;
|
||||
shaderInfo_t *si;
|
||||
char shader[ MAX_QPATH ];
|
||||
char filename[ MAX_QPATH ];
|
||||
char shaderText[ 8192 ], temp[ 1024 ];
|
||||
int val;
|
||||
qboolean parsedContent;
|
||||
|
||||
|
||||
/* init */
|
||||
si = NULL;
|
||||
|
||||
/* dummy check */
|
||||
if ( shaderName == NULL || shaderName[ 0 ] == '\0' ) {
|
||||
Sys_FPrintf( SYS_WRN, "WARNING: Null or empty shader name\n" );
|
||||
shaderName = "missing";
|
||||
}
|
||||
|
||||
/* strip off extension */
|
||||
strcpy( shader, shaderName );
|
||||
StripExtension( shader );
|
||||
|
||||
int deprecationDepth = 0;
|
||||
for ( i = 0; i < numShaderInfo; i++ )
|
||||
{
|
||||
si = &shaderInfo[ i ];
|
||||
if ( !Q_stricmp( shader, si->shader ) ) {
|
||||
/* check if shader is deprecated */
|
||||
if ( deprecationDepth < MAX_SHADER_DEPRECATION_DEPTH && si->deprecateShader && si->deprecateShader[ 0 ] ) {
|
||||
/* override name */
|
||||
strcpy( shader, si->deprecateShader );
|
||||
StripExtension( shader );
|
||||
/* increase deprecation depth */
|
||||
deprecationDepth++;
|
||||
if ( deprecationDepth == MAX_SHADER_DEPRECATION_DEPTH ) {
|
||||
Sys_FPrintf( SYS_WRN, "WARNING: Max deprecation depth of %i is reached on shader '%s'\n", MAX_SHADER_DEPRECATION_DEPTH, shader );
|
||||
}
|
||||
/* search again from beginning */
|
||||
i = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* load image if necessary */
|
||||
if ( si->finished == qfalse ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
shaderInfo_t *ShaderInfoForShader( const char *shaderName, int force ){
|
||||
int i;
|
||||
int deprecationDepth;
|
||||
shaderInfo_t *si;
|
||||
|
@ -911,7 +969,8 @@ shaderInfo_t *ShaderInfoForShader( const char *shaderName ){
|
|||
strcpy( shader, shaderName );
|
||||
StripExtension( shader );
|
||||
|
||||
#if 1
|
||||
/* force new allocation */
|
||||
if (force == 0) {
|
||||
deprecationDepth = 0;
|
||||
for ( i = 0; i < numShaderInfo; i++ )
|
||||
{
|
||||
|
@ -938,11 +997,16 @@ shaderInfo_t *ShaderInfoForShader( const char *shaderName ){
|
|||
FinishShader( si );
|
||||
}
|
||||
|
||||
/* this is a remapped shader, continue */
|
||||
if (si->remapped == qtrue) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* return it */
|
||||
return si;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* allocate a default shader */
|
||||
si = AllocShaderInfo();
|
||||
|
@ -1174,7 +1238,7 @@ shaderInfo_t *ShaderInfoForShader( const char *shaderName ){
|
|||
//% Sys_FPrintf( SYS_VRB, "Shader %s has base shader %s\n", si->shader, mattoken );
|
||||
oldWarnImage = warnImage;
|
||||
warnImage = qfalse;
|
||||
si2 = ShaderInfoForShader( mattoken );
|
||||
si2 = ShaderInfoForShader( mattoken, 0 );
|
||||
warnImage = oldWarnImage;
|
||||
|
||||
/* subclass it */
|
||||
|
@ -2245,7 +2309,7 @@ static void ParseShaderFile( const char *filename ){
|
|||
//% Sys_FPrintf( SYS_VRB, "Shader %s has base shader %s\n", si->shader, token );
|
||||
oldWarnImage = warnImage;
|
||||
warnImage = qfalse;
|
||||
si2 = ShaderInfoForShader( token );
|
||||
si2 = ShaderInfoForShader( token, 0 );
|
||||
warnImage = oldWarnImage;
|
||||
|
||||
/* subclass it */
|
||||
|
|
|
@ -99,12 +99,12 @@ void FinishSurface( mapDrawSurface_t *ds ){
|
|||
|
||||
/* ydnar: rocking surface cloning (fur baby yeah!) */
|
||||
if ( ds->shaderInfo->cloneShader != NULL && ds->shaderInfo->cloneShader[ 0 ] != '\0' ) {
|
||||
CloneSurface( ds, ShaderInfoForShader( ds->shaderInfo->cloneShader ) );
|
||||
CloneSurface( ds, ShaderInfoForShader( ds->shaderInfo->cloneShader, 0 ) );
|
||||
}
|
||||
|
||||
/* ydnar: q3map_backShader support */
|
||||
if ( ds->shaderInfo->backShader != NULL && ds->shaderInfo->backShader[ 0 ] != '\0' ) {
|
||||
ds2 = CloneSurface( ds, ShaderInfoForShader( ds->shaderInfo->backShader ) );
|
||||
ds2 = CloneSurface( ds, ShaderInfoForShader( ds->shaderInfo->backShader, 0 ) );
|
||||
ds2->backSide = qtrue;
|
||||
}
|
||||
}
|
||||
|
@ -1038,7 +1038,7 @@ mapDrawSurface_t *DrawSurfaceForShader( char *shader ){
|
|||
|
||||
|
||||
/* get shader */
|
||||
si = ShaderInfoForShader( shader );
|
||||
si = ShaderInfoForShader( shader, 0 );
|
||||
|
||||
/* find existing surface */
|
||||
for ( i = 0; i < numMapDrawSurfs; i++ )
|
||||
|
@ -1055,7 +1055,7 @@ mapDrawSurface_t *DrawSurfaceForShader( char *shader ){
|
|||
/* create a new surface */
|
||||
ds = AllocDrawSurface( SURFACE_SHADER );
|
||||
ds->entityNum = 0;
|
||||
ds->shaderInfo = ShaderInfoForShader( shader );
|
||||
ds->shaderInfo = ShaderInfoForShader( shader, 0 );
|
||||
|
||||
/* return to sender */
|
||||
return ds;
|
||||
|
@ -2788,7 +2788,7 @@ void MakeDebugPortalSurfs( tree_t *tree ){
|
|||
Sys_FPrintf( SYS_VRB, "--- MakeDebugPortalSurfs ---\n" );
|
||||
|
||||
/* get portal debug shader */
|
||||
si = ShaderInfoForShader( "debugportals" );
|
||||
si = ShaderInfoForShader( "debugportals", 0 );
|
||||
|
||||
/* walk the tree */
|
||||
MakeDebugPortalSurfs_r( tree->headnode, si );
|
||||
|
@ -2834,7 +2834,7 @@ void MakeFogHullSurfs( entity_t *e, tree_t *tree, char *shader ){
|
|||
}
|
||||
|
||||
/* get foghull shader */
|
||||
si = ShaderInfoForShader( shader );
|
||||
si = ShaderInfoForShader( shader, 0 );
|
||||
|
||||
/* allocate a drawsurface */
|
||||
ds = AllocDrawSurface( SURFACE_FOGHULL );
|
||||
|
@ -3377,8 +3377,9 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ){
|
|||
/* ydnar: remap shader */
|
||||
if ( ds->shaderInfo->remapShader && ds->shaderInfo->remapShader[ 0 ] ) {
|
||||
int surfaceflags = ds->shaderInfo->surfaceFlags;
|
||||
ds->shaderInfo = ShaderInfoForShader( ds->shaderInfo->remapShader );
|
||||
ds->shaderInfo = ShaderInfoForShader( ds->shaderInfo->remapShader, 1 );
|
||||
ds->shaderInfo->surfaceFlags = surfaceflags;
|
||||
ds->shaderInfo->remapped = qtrue;
|
||||
}
|
||||
|
||||
/* ydnar: gs mods: handle the various types of surfaces */
|
||||
|
|
|
@ -380,7 +380,7 @@ void LoadSurfaceExtraFile( const char *surfaceFilePath ){
|
|||
/* shader */
|
||||
if ( !Q_stricmp( token, "shader" ) ) {
|
||||
GetToken( qfalse );
|
||||
se->si = ShaderInfoForShader( token );
|
||||
se->si = ShaderInfoForShader( token, 0 );
|
||||
}
|
||||
|
||||
/* parent surface number */
|
||||
|
|
|
@ -782,6 +782,7 @@ typedef struct shaderInfo_s
|
|||
char *shaderText; /* ydnar */
|
||||
qb_t custom;
|
||||
qb_t finished;
|
||||
qb_t remapped;
|
||||
}
|
||||
shaderInfo_t;
|
||||
|
||||
|
@ -1886,7 +1887,7 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *r
|
|||
void EmitVertexRemapShader( char *from, char *to );
|
||||
|
||||
void LoadShaderInfo( void );
|
||||
shaderInfo_t *ShaderInfoForShader( const char *shader );
|
||||
shaderInfo_t *ShaderInfoForShader( const char *shader, int force );
|
||||
shaderInfo_t *ShaderInfoForShaderNull( const char *shader );
|
||||
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ int EmitShader( const char *shader, int *contentFlags, int *surfaceFlags ){
|
|||
}
|
||||
|
||||
/* get shaderinfo */
|
||||
si = ShaderInfoForShader( shader );
|
||||
si = ShaderInfoForShader( shader, 0 );
|
||||
|
||||
/* emit a new shader */
|
||||
AUTOEXPAND_BY_REALLOC_BSP( Shaders, 1024 );
|
||||
|
|
Loading…
Reference in a new issue