Skip to content

Commit 9d7b843

Browse files
authored
utils: pxrad: allow self shadowing with "no shadows" spawnflag in vertexlighting (#258)
1 parent ab6100b commit 9d7b843

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

utils/pxrad/trace.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ static void LinkEdict( entity_t *ent, modtype_t modtype, const char *modname, in
648648
}
649649

650650
// don't link into world if shadow was disabled
651-
if(( ent->modtype == mod_studio || ent->modtype == mod_alias ) && !FBitSet( flags, FMESH_CAST_SHADOW ))
651+
if(( ent->modtype == mod_studio || ent->modtype == mod_alias ) && !FBitSet( flags, FMESH_CAST_SHADOW ) && !FBitSet( flags, FMESH_SELF_SHADOW ))
652652
return;
653653

654654
#ifdef HLRAD_RAYTRACE
@@ -1059,8 +1059,23 @@ static void ClipToLinks( areanode_t *node, moveclip_t *clip, bool stop_on_first_
10591059

10601060
touch = ENTITY_FROM_AREA( l );
10611061

1062-
if( touch == clip->ignore )
1063-
continue;
1062+
//hack for self shadowing without casting shadows
1063+
if( touch->modtype == mod_studio || touch->modtype == mod_alias )
1064+
{
1065+
tmesh_t *mesh = (tmesh_t *)touch->cache;
1066+
1067+
if( touch == clip->ignore )
1068+
{
1069+
if( !FBitSet( mesh->flags, FMESH_SELF_SHADOW ) )
1070+
continue;
1071+
}
1072+
else
1073+
if( !FBitSet( mesh->flags, FMESH_CAST_SHADOW ) )
1074+
continue;
1075+
}
1076+
else
1077+
if( touch == clip->ignore )
1078+
continue;
10641079

10651080
if( !BoundsIntersect( clip->boxmins, clip->boxmaxs, touch->absmin, touch->absmax ))
10661081
continue;

utils/pxrad/vertexlight.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ void BuildVertexLights( int indexnum, int thread = -1 )
192192
if( !mesh->verts || mesh->numverts <= 0 )
193193
return;
194194

195-
if( !FBitSet( mesh->flags, FMESH_SELF_SHADOW ))
196-
ignoreent = mapent;
195+
ignoreent = mapent;
197196

198197
GetStylesFromMesh( styles, mesh );
199198

@@ -314,8 +313,7 @@ void VertexPatchLights( int indexnum, int threadnum = -1 )
314313
if( !mesh->verts || mesh->numverts <= 0 )
315314
return;
316315

317-
if( !FBitSet( mesh->flags, FMESH_SELF_SHADOW ))
318-
ignoreent = mapent;
316+
ignoreent = mapent;
319317

320318
GetStylesFromMesh( newstyles, mesh );
321319

0 commit comments

Comments
 (0)