minor tweaks

This commit is contained in:
Garux
2025-09-18 23:36:30 +05:00
parent 2501b86856
commit fb3698b820
14 changed files with 352 additions and 414 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ static void autocaulk_write(){
ApplySurfaceParm( "lava", &flava, NULL, NULL );
// many setups have nodraw shader nonsolid, including vQ3; and nondrawnonsolid also... fall back to caulk in such case
// it would be better to decide in Radiant, as it has configurable per game common shaders, but it has no solidity info
const bool nodraw_is_solid = ShaderInfoForShader( "textures/common/nodraw" )->compileFlags & C_SOLID;
const bool nodraw_is_solid = ShaderInfoForShader( "textures/common/nodraw" ).compileFlags & C_SOLID;
for ( const brush_t& b : entities[0].brushes ) {
fprintf( file, "%i ", b.brushNum );
+3 -3
View File
@@ -97,10 +97,10 @@ static void SwapBSPFile(){
for ( bspShader_t& shader : bspShaders )
{
if ( doingBSP ){
const shaderInfo_t *si = ShaderInfoForShader( shader.shader );
if ( !strEmptyOrNull( si->remapShader ) ) {
const shaderInfo_t& si = ShaderInfoForShader( shader.shader );
if ( !strEmptyOrNull( si.remapShader ) ) {
// copy and clear the rest of memory // check for overflow by String64
const String64 remap( si->remapShader );
const String64 remap( si.remapShader );
strncpy( shader.shader, remap, sizeof( shader.shader ) );
}
}
+9 -20
View File
@@ -234,34 +234,23 @@ static void ConvertModel( FILE *f, int modelNum, const Vector3& origin, const st
*/
static void ConvertShader( FILE *f, const bspShader_t& shader ){
shaderInfo_t *si;
char *c, filename[ 1024 ];
/* get shader */
si = ShaderInfoForShader( shader.shader );
if ( si == NULL ) {
Sys_Warning( "NULL shader in BSP\n" );
return;
}
shaderInfo_t& si = ShaderInfoForShader( shader.shader );
/* set bitmap filename */
if ( si->shaderImage->filename.c_str()[ 0 ] != '*' ) {
strcpy( filename, si->shaderImage->filename.c_str() );
}
else{
sprintf( filename, "%s.tga", si->shader.c_str() );
}
for ( c = filename; *c; c++ )
if ( *c == '/' ) {
auto filename = si.shaderImage->filename.c_str()[ 0 ] == '*'
? StringStream<64>( si.shader, ".tga" )
: StringStream<64>( si.shaderImage->filename );
for ( char *c = filename.c_str(); !strEmpty( c ); ++c )
if ( *c == '/' )
*c = '\\';
}
/* print shader info */
fprintf( f, "\t*MATERIAL\t%d\t{\r\n", int( &shader - bspShaders.data() ) );
fprintf( f, "\t\t*MATERIAL_NAME\t\"%s\"\r\n", shader.shader );
fprintf( f, "\t\t*MATERIAL_CLASS\t\"Standard\"\r\n" );
fprintf( f, "\t\t*MATERIAL_DIFFUSE\t%f\t%f\t%f\r\n", si->color[ 0 ], si->color[ 1 ], si->color[ 2 ] );
fprintf( f, "\t\t*MATERIAL_DIFFUSE\t%f\t%f\t%f\r\n", si.color[ 0 ], si.color[ 1 ], si.color[ 2 ] );
fprintf( f, "\t\t*MATERIAL_SHADING Phong\r\n" );
/* print map info */
@@ -275,7 +264,7 @@ static void ConvertShader( FILE *f, const bspShader_t& shader ){
fprintf( f, "\t\t\t*BITMAP\t\"%s\"\r\n", shader.shader );
}
else{
fprintf( f, "\t\t\t*BITMAP\t\"..\\%s\"\r\n", filename );
fprintf( f, "\t\t\t*BITMAP\t\"..\\%s\"\r\n", filename.c_str() );
}
fprintf( f, "\t\t\t*BITMAP_FILTER\tPyramidal\r\n" );
fprintf( f, "\t\t}\r\n" );
+1 -1
View File
@@ -239,7 +239,7 @@ static void bspBrush_to_buildBrush( const bspBrush_t& brush ){
buildBrush.sides.emplace_back();
/* tag it */
buildBrush.sides.back().shaderInfo = ShaderInfoForShader( shader.shader );
buildBrush.sides.back().shaderInfo = &ShaderInfoForShader( shader.shader );
buildBrush.sides.back().planenum = side.planeNum;
}
}
+7 -18
View File
@@ -143,34 +143,23 @@ static void ConvertModelToOBJ( FILE *f, int modelNum, const Vector3& origin, con
*/
static void ConvertShaderToMTL( FILE *f, const bspShader_t& shader ){
shaderInfo_t *si;
char filename[ 1024 ];
/* get shader */
si = ShaderInfoForShader( shader.shader );
if ( si == NULL ) {
Sys_Warning( "NULL shader in BSP\n" );
return;
}
shaderInfo_t& si = ShaderInfoForShader( shader.shader );
/* set bitmap filename */
if ( si->shaderImage->filename.c_str()[ 0 ] != '*' ) {
strcpy( filename, si->shaderImage->filename.c_str() );
}
else{
sprintf( filename, "%s.tga", si->shader.c_str() );
}
auto filename = si.shaderImage->filename.c_str()[ 0 ] == '*'
? StringStream<64>( si.shader, ".tga" )
: StringStream<64>( si.shaderImage->filename );
/* blender hates this, so let's not do it
for( c = filename; *c; c++ )
for( char *c = filename; *c; c++ )
if( *c == '/' )
*c = '\\';
*/
/* print shader info */
fprintf( f, "newmtl %s\r\n", shader.shader );
fprintf( f, "Kd %f %f %f\r\n", si->color[ 0 ], si->color[ 1 ], si->color[ 2 ] );
fprintf( f, "Kd %f %f %f\r\n", si.color[ 0 ], si.color[ 1 ], si.color[ 2 ] );
if ( shadersAsBitmap ) {
fprintf( f, "map_Kd %s\r\n", shader.shader );
}
@@ -178,7 +167,7 @@ static void ConvertShaderToMTL( FILE *f, const bspShader_t& shader ){
/* blender hates this, so let's not do it
fprintf( f, "map_Kd ..\\%s\r\n", filename );
*/
fprintf( f, "map_Kd ../%s\r\n", filename );
fprintf( f, "map_Kd ../%s\r\n", filename.c_str() );
}
}
+8 -14
View File
@@ -993,7 +993,7 @@ void SetupSurfaceLightmaps(){
const surfaceExtra_t& se = GetSurfaceExtra( num );
info->si = se.si;
if ( info->si == NULL ) {
info->si = ShaderInfoForShader( bspShaders[ ds->shaderNum ].shader );
info->si = &ShaderInfoForShader( bspShaders[ ds->shaderNum ].shader );
}
info->parentSurfaceNum = se.parentSurfaceNum;
info->entityNum = se.entityNum;
@@ -2331,7 +2331,6 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){
outLightmap_t *olm;
bspDrawVert_t *dv, *ydv, *dvParent;
char dirname[ 1024 ], filename[ 1024 ];
const shaderInfo_t *csi;
char lightmapName[ 128 ];
const char *rgbGenValues[ 256 ] = {0};
const char *alphaGenValues[ 256 ] = {0};
@@ -3285,21 +3284,16 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){
}
/* create custom shader */
if ( info->si->styleMarker == 2 ) {
csi = CustomShader( info->si, "q3map_styleMarker2", styleStages );
}
else{
csi = CustomShader( info->si, "q3map_styleMarker", styleStages );
}
const shaderInfo_t& csi = CustomShader( info->si, info->si->styleMarker == 2? "q3map_styleMarker2" : "q3map_styleMarker", styleStages );
/* emit remap command */
//% EmitVertexRemapShader( csi->shader, info->si->shader );
//% EmitVertexRemapShader( csi.shader, info->si->shader );
/* store it */
//% Sys_Printf( "Emitting: %s (%d", csi->shader, strlen( csi->shader ) );
//% Sys_Printf( "Emitting: %s (%d", csi.shader, strlen( csi.shader ) );
const int cont = bspShaders[ ds->shaderNum ].contentFlags;
const int surf = bspShaders[ ds->shaderNum ].surfaceFlags;
ds->shaderNum = EmitShader( csi->shader, &cont, &surf );
ds->shaderNum = EmitShader( csi.shader, &cont, &surf );
//% Sys_Printf( ")\n" );
}
@@ -3313,13 +3307,13 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){
sprintf( lightmapName, "maps/%s/" EXTERNAL_LIGHTMAP "\n\t\ttcgen lightmap", mapName.c_str(), olm->extLightmapNum );
/* create custom shader */
csi = CustomShader( info->si, "$lightmap", lightmapName );
const shaderInfo_t& csi = CustomShader( info->si, "$lightmap", lightmapName );
/* store it */
//% Sys_Printf( "Emitting: %s (%d", csi->shader, strlen( csi->shader ) );
//% Sys_Printf( "Emitting: %s (%d", csi.shader, strlen( csi.shader ) );
const int cont = bspShaders[ ds->shaderNum ].contentFlags;
const int surf = bspShaders[ ds->shaderNum ].surfaceFlags;
ds->shaderNum = EmitShader( csi->shader, &cont, &surf );
ds->shaderNum = EmitShader( csi.shader, &cont, &surf );
//% Sys_Printf( ")\n" );
}
+11 -11
View File
@@ -1003,13 +1003,13 @@ static void ParseRawBrush( bool onlyLights ){
const String64 shader( "textures/", token );
/* set default flags and values */
shaderInfo_t *si = onlyLights? shaderInfo.begin().operator->()
shaderInfo_t& si = onlyLights? *shaderInfo.begin()
: ShaderInfoForShader( shader );
side.shaderInfo = si;
side.surfaceFlags = si->surfaceFlags;
side.contentFlags = si->contentFlags;
side.compileFlags = si->compileFlags;
side.value = si->value;
side.shaderInfo = &si;
side.surfaceFlags = si.surfaceFlags;
side.contentFlags = si.contentFlags;
side.compileFlags = si.compileFlags;
side.value = si.value;
/* AP or 220? */
if ( g_brushType == EBrushType::Undefined ){
@@ -1040,9 +1040,9 @@ static void ParseRawBrush( bool onlyLights ){
scale[ 1 ] = atof( token );
/* ydnar: gs mods: bias texture shift */
if ( !si->globalTexture ) {
shift[ 0 ] -= ( floor( shift[ 0 ] / si->shaderWidth ) * si->shaderWidth );
shift[ 1 ] -= ( floor( shift[ 1 ] / si->shaderHeight ) * si->shaderHeight );
if ( !si.globalTexture ) {
shift[ 0 ] -= ( floor( shift[ 0 ] / si.shaderWidth ) * si.shaderWidth );
shift[ 1 ] -= ( floor( shift[ 1 ] / si.shaderHeight ) * si.shaderHeight );
}
/* get the texture mapping for this texturedef / plane combination */
@@ -1574,11 +1574,11 @@ static bool ParseMapEntity( bool onlyLights, bool noCollapseGroups, int mapEntit
const char *value;
if( mapEnt.read_keyvalue( value, "_celshader" ) ||
entities[ 0 ].read_keyvalue( value, "_celshader" ) ){
celShader = ShaderInfoForShader( String64( "textures/", value ) );
celShader = &ShaderInfoForShader( String64( "textures/", value ) );
Sys_Printf( "Entity %d (%s) has cel shader %s\n", mapEnt.mapEntityNum, classname, celShader->shader.c_str() );
}
else{
celShader = globalCelShader.empty() ? NULL : ShaderInfoForShader( globalCelShader );
celShader = globalCelShader.empty() ? nullptr : &ShaderInfoForShader( globalCelShader );
}
/* jal : entity based _shadeangle */
+23 -27
View File
@@ -391,19 +391,19 @@ inline size_t normal_make_axial( Vector3& normal ){
}
template<size_t N> // N = 4 or 5
static void make_brush_sides( const Plane3f plane, const Plane3f (&p)[3], const Plane3f& reverse, Vector3 (&points)[4], shaderInfo_t *si ){
static void make_brush_sides( const Plane3f plane, const Plane3f (&p)[3], const Plane3f& reverse, Vector3 (&points)[4], shaderInfo_t& si ){
/* set up brush sides */
buildBrush.sides.clear(); // clear, so resize() will value-initialize elements
buildBrush.sides.resize( N );
if( debugClip ){
buildBrush.sides[ 0 ].shaderInfo = ShaderInfoForShader( "debugclip2" );
buildBrush.sides[ 0 ].shaderInfo = &ShaderInfoForShader( "debugclip2" );
for ( size_t i = 1; i < N; ++i )
buildBrush.sides[i].shaderInfo = ShaderInfoForShader( "debugclip" );
buildBrush.sides[i].shaderInfo = &ShaderInfoForShader( "debugclip" );
}
else{
buildBrush.sides[0].shaderInfo = si;
buildBrush.sides[0].surfaceFlags = si->surfaceFlags;
buildBrush.sides[0].shaderInfo = &si;
buildBrush.sides[0].surfaceFlags = si.surfaceFlags;
for ( size_t i = 1; i < N; ++i )
buildBrush.sides[i].shaderInfo = NULL; // don't emit these faces as draw surfaces, should make smaller BSPs; hope this works
}
@@ -418,11 +418,11 @@ static void make_brush_sides( const Plane3f plane, const Plane3f (&p)[3], const
buildBrush.sides[4].planenum = FindFloatPlane( reverse, 0, NULL );
}
static void ClipModel( int spawnFlags, float clipDepth, shaderInfo_t *si, const mapDrawSurface_t *ds, const char *modelName, entity_t& entity ){
static void ClipModel( int spawnFlags, float clipDepth, shaderInfo_t& si, const mapDrawSurface_t *ds, const char *modelName, entity_t& entity ){
const int spf = ( spawnFlags & ( eClipFlags & ~eClipModel ) );
/* ydnar: giant hack land: generate clipping brushes for model triangles */
if ( ( si->clipModel && spf == 0 ) // default CLIPMODEL
if ( ( si.clipModel && spf == 0 ) // default CLIPMODEL
|| ( spawnFlags & eClipFlags ) == eClipModel //default CLIPMODEL
|| spf == eExtrudeFaceNormals
|| spf == eExtrudeTerrain
@@ -457,7 +457,7 @@ static void ClipModel( int spawnFlags, float clipDepth, shaderInfo_t *si, const
int axis;
/* temp hack */
if ( !si->clipModel && !( si->compileFlags & C_SOLID ) ) {
if ( !si.clipModel && !( si.compileFlags & C_SOLID ) ) {
return;
}
@@ -493,9 +493,9 @@ static void ClipModel( int spawnFlags, float clipDepth, shaderInfo_t *si, const
/* prepare a brush */
buildBrush.sides.reserve( MAX_BUILD_SIDES );
buildBrush.entityNum = entity.mapEntityNum;
buildBrush.contentShader = si;
buildBrush.compileFlags = si->compileFlags;
buildBrush.contentFlags = si->contentFlags;
buildBrush.contentShader = &si;
buildBrush.compileFlags = si.compileFlags;
buildBrush.contentFlags = si.contentFlags;
buildBrush.detail = true;
/* walk triangle list */
@@ -933,7 +933,7 @@ static void ClipModel( int spawnFlags, float clipDepth, shaderInfo_t *si, const
}
else if ( ( si->clipModel && spf == 0 ) || ( spawnFlags & eClipFlags ) == eClipModel ){ //default CLIPMODEL
else if ( ( si.clipModel && spf == 0 ) || ( spawnFlags & eClipFlags ) == eClipModel ){ //default CLIPMODEL
default_CLIPMODEL:
// axial normal
@@ -988,7 +988,6 @@ void InsertModel( const char *name, const char *skin, int frame, const Matrix4&
const Matrix4 nTransform( matrix4_for_normal_transform( transform ) );
const bool transform_lefthanded = MATRIX4_LEFTHANDED == matrix4_handedness( transform );
AssModel *model;
shaderInfo_t *si;
mapDrawSurface_t *ds;
const char *picoShaderName;
@@ -1117,12 +1116,9 @@ void InsertModel( const char *name, const char *skin, int frame, const Matrix4&
}
/* shader renaming for sof2 */
if ( renameModelShaders ) {
si = ShaderInfoForShader( String64( PathExtensionless( picoShaderName ), ( spawnFlags & eRMG_BSP )? "_RMG_BSP" : "_BSP" ) );
}
else{
si = ShaderInfoForShader( picoShaderName );
}
shaderInfo_t& si = renameModelShaders
? ShaderInfoForShader( String64( PathExtensionless( picoShaderName ), ( spawnFlags & eRMG_BSP )? "_RMG_BSP" : "_BSP" ) )
: ShaderInfoForShader( picoShaderName );
/* allocate a surface (ydnar: gs mods) */
ds = AllocDrawSurface( ESurfaceType::Triangles );
@@ -1131,10 +1127,10 @@ void InsertModel( const char *name, const char *skin, int frame, const Matrix4&
ds->recvShadows = recvShadows;
/* set shader */
ds->shaderInfo = si;
ds->shaderInfo = &si;
/* force to meta? */
if ( ( si != NULL && si->forceMeta ) || ( spawnFlags & eForceMeta ) ) { /* 3rd bit */
if ( si.forceMeta || ( spawnFlags & eForceMeta ) ) { /* 3rd bit */
ds->type = ESurfaceType::ForcedMeta;
}
@@ -1183,14 +1179,14 @@ void InsertModel( const char *name, const char *skin, int frame, const Matrix4&
/* ydnar: tek-fu celshading support for flat shaded shit */
if ( flat ) {
dv.st = si->stFlat;
dv.st = si.stFlat;
}
/* ydnar: gs mods: added support for explicit shader texcoord generation */
else if ( si->tcGen ) {
else if ( si.tcGen ) {
/* project the texture */
dv.st[ 0 ] = vector3_dot( si->vecs[ 0 ], dv.xyz );
dv.st[ 1 ] = vector3_dot( si->vecs[ 1 ], dv.xyz );
dv.st[ 0 ] = vector3_dot( si.vecs[ 0 ], dv.xyz );
dv.st[ 1 ] = vector3_dot( si.vecs[ 1 ], dv.xyz );
}
/* normal texture coordinates */
@@ -1366,10 +1362,10 @@ void AddTriangleModels( entity_t& eparent ){
shaderInfo_t *celShader;
if( const char *value; e.read_keyvalue( value, "_celshader" ) ||
entities[ 0 ].read_keyvalue( value, "_celshader" ) ){
celShader = ShaderInfoForShader( String64( "textures/", value ) );
celShader = &ShaderInfoForShader( String64( "textures/", value ) );
}
else{
celShader = globalCelShader.empty() ? NULL : ShaderInfoForShader( globalCelShader );
celShader = globalCelShader.empty() ? nullptr : &ShaderInfoForShader( globalCelShader );
}
/* jal : entity based _samplesize */
+1 -1
View File
@@ -318,7 +318,7 @@ void ParsePatch( bool onlyLights, entity_t& mapEnt, int mapPrimitiveNum ){
pm->brushNum = mapPrimitiveNum;
/* set shader */
pm->shaderInfo = ShaderInfoForShader( shader );
pm->shaderInfo = &ShaderInfoForShader( shader );
/* set mesh */
pm->mesh = m;
+2 -2
View File
@@ -1698,11 +1698,11 @@ const surfaceParm_t &GetRequiredSurfaceParm(){
void BeginMapShaderFile( const char *mapFile );
void WriteMapShaderFile();
const shaderInfo_t *CustomShader( const shaderInfo_t *si, const char *find, char *replace );
const shaderInfo_t &CustomShader( const shaderInfo_t *si, const char *find, char *replace );
void EmitVertexRemapShader( char *from, char *to );
void LoadShaderInfo();
shaderInfo_t *ShaderInfoForShader( const char *shader );
shaderInfo_t &ShaderInfoForShader( const char *shader );
shaderInfo_t *ShaderInfoForShaderNull( const char *shader );
File diff suppressed because it is too large Load Diff
+30 -51
View File
@@ -86,12 +86,12 @@ static void FinishSurface( mapDrawSurface_t *ds ){
/* ydnar: rocking surface cloning (fur baby yeah!) */
if ( !strEmptyOrNull( ds->shaderInfo->cloneShader ) ) {
CloneSurface( ds, ShaderInfoForShader( ds->shaderInfo->cloneShader ) );
CloneSurface( ds, &ShaderInfoForShader( ds->shaderInfo->cloneShader ) );
}
/* ydnar: q3map_backShader support */
if ( !strEmptyOrNull( ds->shaderInfo->backShader ) ) {
ds2 = CloneSurface( ds, ShaderInfoForShader( ds->shaderInfo->backShader ) );
ds2 = CloneSurface( ds, &ShaderInfoForShader( ds->shaderInfo->backShader ) );
ds2->backSide = true;
}
}
@@ -618,7 +618,7 @@ static byte GetShaderIndexForPoint( const indexMap_t *im, const MinMax& eMinmax,
this combines a couple different functions from terrain.c
*/
static shaderInfo_t *GetIndexedShader( const shaderInfo_t *parent, const indexMap_t *im, int numPoints, byte *shaderIndexes ){
static shaderInfo_t& GetIndexedShader( const shaderInfo_t *parent, const indexMap_t *im, int numPoints, byte *shaderIndexes ){
/* early out if bad data */
if ( im == NULL || numPoints <= 0 || shaderIndexes == NULL ) {
return ShaderInfoForShader( "default" );
@@ -646,32 +646,32 @@ static shaderInfo_t *GetIndexedShader( const shaderInfo_t *parent, const indexMa
}
/* get the shader */
shaderInfo_t *si = ShaderInfoForShader( ( minShaderIndex == maxShaderIndex )?
String64( "textures/", im->shader, '_', int( maxShaderIndex ) ):
String64( "textures/", im->shader, '_', int( minShaderIndex ), "to", int( maxShaderIndex ) ) );
shaderInfo_t& si = ShaderInfoForShader( ( minShaderIndex == maxShaderIndex )
? String64( "textures/", im->shader, '_', int( maxShaderIndex ) )
: String64( "textures/", im->shader, '_', int( minShaderIndex ), "to", int( maxShaderIndex ) ) );
/* inherit a few things from parent shader */
if ( parent->globalTexture ) {
si->globalTexture = true;
si.globalTexture = true;
}
if ( parent->forceMeta ) {
si->forceMeta = true;
si.forceMeta = true;
}
if ( parent->nonplanar ) {
si->nonplanar = true;
si.nonplanar = true;
}
if ( si->shadeAngleDegrees == 0.0 ) {
si->shadeAngleDegrees = parent->shadeAngleDegrees;
if ( si.shadeAngleDegrees == 0.0 ) {
si.shadeAngleDegrees = parent->shadeAngleDegrees;
}
if ( parent->tcGen && !si->tcGen ) {
if ( parent->tcGen && !si.tcGen ) {
/* set xy texture projection */
si->tcGen = true;
si->vecs[ 0 ] = parent->vecs[ 0 ];
si->vecs[ 1 ] = parent->vecs[ 1 ];
si.tcGen = true;
si.vecs[ 0 ] = parent->vecs[ 0 ];
si.vecs[ 1 ] = parent->vecs[ 1 ];
}
if ( parent->lightmapAxis != g_vector3_identity && si->lightmapAxis == g_vector3_identity ) {
if ( parent->lightmapAxis != g_vector3_identity && si.lightmapAxis == g_vector3_identity ) {
/* set lightmap projection axis */
si->lightmapAxis = parent->lightmapAxis;
si.lightmapAxis = parent->lightmapAxis;
}
/* return the shader */
@@ -732,7 +732,7 @@ mapDrawSurface_t *DrawSurfaceForSide( const entity_t& e, const brush_t& b, const
/* get matching shader and set alpha */
parent = si;
si = GetIndexedShader( parent, b.im, w.size(), shaderIndexes );
si = &GetIndexedShader( parent, b.im, w.size(), shaderIndexes );
}
else{
indexed = false;
@@ -914,7 +914,7 @@ mapDrawSurface_t *DrawSurfaceForMesh( const entity_t& e, parseMesh_t *p, mesh_t
/* get matching shader and set alpha */
parent = si;
si = GetIndexedShader( parent, p->im, numVerts, shaderIndexes );
si = &GetIndexedShader( parent, p->im, numVerts, shaderIndexes );
}
else{
indexed = false;
@@ -1028,25 +1028,17 @@ mapDrawSurface_t *DrawSurfaceForMesh( const entity_t& e, parseMesh_t *p, mesh_t
*/
mapDrawSurface_t *DrawSurfaceForFlare( int entNum, const Vector3& origin, const Vector3& normal, const Vector3& color, const char *flareShader, int lightStyle ){
mapDrawSurface_t *ds;
/* emit flares? */
if ( !emitFlares ) {
return NULL;
}
/* allocate drawsurface */
ds = AllocDrawSurface( ESurfaceType::Flare );
mapDrawSurface_t *ds = AllocDrawSurface( ESurfaceType::Flare );
ds->entityNum = entNum;
/* set it up */
if ( !strEmptyOrNull( flareShader ) ) {
ds->shaderInfo = ShaderInfoForShader( flareShader );
}
else{
ds->shaderInfo = ShaderInfoForShader( g_game->flareShader );
}
ds->shaderInfo = &ShaderInfoForShader( !strEmptyOrNull( flareShader )? flareShader : g_game->flareShader );
ds->lightmapOrigin = origin;
ds->lightmapVecs[ 2 ] = normal;
ds->lightmapVecs[ 0 ] = color;
@@ -1069,7 +1061,7 @@ mapDrawSurface_t *DrawSurfaceForFlare( int entNum, const Vector3& origin, const
static mapDrawSurface_t *DrawSurfaceForShader( const char *shader ){
/* get shader */
shaderInfo_t *si = ShaderInfoForShader( shader );
shaderInfo_t *si = &ShaderInfoForShader( shader );
/* find existing surface */
for ( mapDrawSurface_t& ds : Span( mapDrawSurfs, numMapDrawSurfs ) )
@@ -2620,11 +2612,9 @@ static void EmitFaceSurface( mapDrawSurface_t *ds ){
generates drawsurfaces for passable portals in the bsp
*/
static void MakeDebugPortalSurfs_r( const node_t *node, shaderInfo_t *si ){
static void MakeDebugPortalSurfs_r( const node_t *node, shaderInfo_t& si ){
int i, c, s;
const portal_t *p;
mapDrawSurface_t *ds;
bspDrawVert_t *dv;
/* recurse if decision node */
@@ -2659,8 +2649,8 @@ static void MakeDebugPortalSurfs_r( const node_t *node, shaderInfo_t *si ){
}
/* allocate a drawsurface */
ds = AllocDrawSurface( ESurfaceType::Face );
ds->shaderInfo = si;
mapDrawSurface_t *ds = AllocDrawSurface( ESurfaceType::Face );
ds->shaderInfo = &si;
ds->planar = true;
ds->planeNum = FindFloatPlane( p->plane.plane, 0, NULL );
ds->lightmapVecs[ 2 ] = p->plane.normal();
@@ -2672,7 +2662,7 @@ static void MakeDebugPortalSurfs_r( const node_t *node, shaderInfo_t *si ){
for ( i = 0; i < ds->numVerts; i++ )
{
/* get vert */
dv = ds->verts + i;
bspDrawVert_t *dv = ds->verts + i;
/* set it */
dv->xyz = w[ i ];
@@ -2696,17 +2686,11 @@ static void MakeDebugPortalSurfs_r( const node_t *node, shaderInfo_t *si ){
*/
void MakeDebugPortalSurfs( const tree_t& tree ){
shaderInfo_t *si;
/* note it */
Sys_FPrintf( SYS_VRB, "--- MakeDebugPortalSurfs ---\n" );
/* get portal debug shader */
si = ShaderInfoForShader( "debugportals" );
/* walk the tree */
MakeDebugPortalSurfs_r( tree.headnode, si );
MakeDebugPortalSurfs_r( tree.headnode, ShaderInfoForShader( "debugportals" ) );
}
@@ -2717,8 +2701,6 @@ void MakeDebugPortalSurfs( const tree_t& tree ){
*/
void MakeFogHullSurfs( const char *shader ){
shaderInfo_t *si;
mapDrawSurface_t *ds;
int indexes[] =
{
0, 1, 2, 0, 2, 3,
@@ -2742,12 +2724,9 @@ void MakeFogHullSurfs( const char *shader ){
const Vector3 fogMins = g_mapMinmax.mins - Vector3( 128 );
const Vector3 fogMaxs = g_mapMinmax.maxs + Vector3( 128 );
/* get foghull shader */
si = ShaderInfoForShader( shader );
/* allocate a drawsurface */
ds = AllocDrawSurface( ESurfaceType::Foghull );
ds->shaderInfo = si;
mapDrawSurface_t *ds = AllocDrawSurface( ESurfaceType::Foghull );
ds->shaderInfo = &ShaderInfoForShader( shader );
ds->fogNum = -1;
ds->numVerts = 8;
ds->verts = safe_calloc( ds->numVerts * sizeof( *ds->verts ) );
@@ -3212,7 +3191,7 @@ void FilterDrawsurfsIntoTree( entity_t& e, tree_t& tree ){
/* ydnar: remap shader */
/* if ( !strEmptyOrNull( ds->shaderInfo->remapShader ) ) {
ds->shaderInfo = ShaderInfoForShader( ds->shaderInfo->remapShader );
ds->shaderInfo = &ShaderInfoForShader( ds->shaderInfo->remapShader );
}
*/
/* ydnar: gs mods: handle the various types of surfaces */
+1 -1
View File
@@ -246,7 +246,7 @@ void LoadSurfaceExtraFile( const char *path ){
/* shader */
if ( striEqual( token, "shader" ) ) {
GetToken( false );
se->si = ShaderInfoForShader( token );
se->si = &ShaderInfoForShader( token );
}
/* parent surface number */
+10 -13
View File
@@ -40,9 +40,6 @@
*/
int EmitShader( const char *shader, const int *contentFlags, const int *surfaceFlags ){
shaderInfo_t *si;
/* handle special cases */
if ( shader == NULL ) {
shader = "noshader";
@@ -59,9 +56,9 @@ int EmitShader( const char *shader, const int *contentFlags, const int *surfaceF
continue;
}
if ( !doingBSP ){
si = ShaderInfoForShader( shader );
if ( !strEmptyOrNull( si->remapShader ) ) {
shader = si->remapShader;
const shaderInfo_t& si = ShaderInfoForShader( shader );
if ( !strEmptyOrNull( si.remapShader ) ) {
shader = si.remapShader;
}
}
/* compare name */
@@ -71,21 +68,21 @@ int EmitShader( const char *shader, const int *contentFlags, const int *surfaceF
}
/* get shaderinfo */
si = ShaderInfoForShader( shader );
const shaderInfo_t& si = ShaderInfoForShader( shader );
/* emit a new shader */
const int i = bspShaders.size(); // store index
bspShader_t& bspShader = bspShaders.emplace_back();
strcpy( bspShader.shader, si->shader );
strcpy( bspShader.shader, si.shader );
/* handle custom content/surface flags */
bspShader.surfaceFlags = ( surfaceFlags != NULL )? *surfaceFlags : si->surfaceFlags;
bspShader.contentFlags = ( contentFlags != NULL )? *contentFlags : si->contentFlags;
bspShader.surfaceFlags = ( surfaceFlags != NULL )? *surfaceFlags : si.surfaceFlags;
bspShader.contentFlags = ( contentFlags != NULL )? *contentFlags : si.contentFlags;
/* recursively emit any damage shaders */
if ( !strEmptyOrNull( si->damageShader ) ) {
Sys_FPrintf( SYS_VRB, "Shader %s has damage shader %s\n", si->shader.c_str(), si->damageShader );
EmitShader( si->damageShader, NULL, NULL );
if ( !strEmptyOrNull( si.damageShader ) ) {
Sys_FPrintf( SYS_VRB, "Shader %s has damage shader %s\n", si.shader.c_str(), si.damageShader );
EmitShader( si.damageShader, NULL, NULL );
}
/* return index */