Skip to content

Commit

Permalink
Fixed, RecursiveLightPoint(): don't try to sample SURF_NODRAW surface…
Browse files Browse the repository at this point in the history
…s or surfaces with uninitialized lightmap size.
  • Loading branch information
m-x-d committed Apr 27, 2019
1 parent 559a1f6 commit 624e59c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions renderer/r_light.c
Expand Up @@ -203,10 +203,10 @@ int RecursiveLightPoint(vec3_t color, mnode_t *node, vec3_t start, vec3_t end)

for (int i = 0; i < node->numsurfaces; i++, surf++)
{
if (!surf->samples)
if (!surf->samples || surf->light_smax == 0 || surf->light_tmax == 0) //mxd. Also skip surfaces with non-initialized lightmap size
continue; //mxd. No lightmap data. Was return 0;

if (surf->flags & (SURF_DRAWTURB | SURF_DRAWSKY))
if (surf->flags & (SURF_DRAWTURB | SURF_DRAWSKY) || surf->texinfo->flags & SURF_NODRAW) //mxd. Also skip NODRAW surfaces
continue; // No lightmaps

mtexinfo_t *tex = surf->texinfo;
Expand Down
9 changes: 9 additions & 0 deletions renderer/r_surface.c
Expand Up @@ -2314,6 +2314,15 @@ static int fix_coord(int in, const int width)

void R_SetupLightmapPoints(msurface_t *surf)
{
// Sky / nodraw / water / transparent surfaces won't have light_smax/tmax set
if(surf->light_smax == 0 || surf->light_tmax == 0)
{
surf->lightmap_points = NULL;
surf->normalmap_normals = NULL;

return;
}

// Setup world matrix
vec3_t facenormal;
VectorCopy(surf->plane->normal, facenormal);
Expand Down

0 comments on commit 624e59c

Please sign in to comment.