From 653f3f0f7be068b9b459ea0f7a39414df5e5516d Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 3 Nov 2002 23:10:45 +0000 Subject: [PATCH] fix polygon distance checks (the radius comparison was completely wrong) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2596 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rsurf.c | 6 +++--- model_brush.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gl_rsurf.c b/gl_rsurf.c index 263bb96d..7177b463 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -1836,7 +1836,7 @@ void R_Model_Brush_DrawShadowVolume (entity_render_t *ent, vec3_t relativelighto if (projectdistance >= 0.1 && projectdistance < lightradius) { VectorSubtract(relativelightorigin, surf->poly_center, temp); - if (DotProduct(temp, temp) < (surf->poly_radius2 + lightradius2)) + if (DotProduct(temp, temp) < lightradius2 - surf->poly_radius2) { for (mesh = surf->mesh;mesh;mesh = mesh->chain) { @@ -1894,7 +1894,7 @@ void R_Model_Brush_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, v for (surfnum = 0, surf = ent->model->surfaces + ent->model->firstmodelsurface;surfnum < ent->model->nummodelsurfaces;surfnum++, surf++) { VectorSubtract(relativelightorigin, surf->poly_center, temp); - if (DotProduct(temp, temp) < lightradius2 + surf->poly_radius2) + if (DotProduct(temp, temp) < lightradius2 - surf->poly_radius2) { f = PlaneDiff(relativelightorigin, surf->plane); if (surf->flags & SURF_PLANEBACK) @@ -1930,7 +1930,7 @@ void R_Model_Brush_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, v if (surf->visframe == r_framecount) { VectorSubtract(relativelightorigin, surf->poly_center, temp); - if (DotProduct(temp, temp) < lightradius2 + surf->poly_radius2) + if (DotProduct(temp, temp) < lightradius2 - surf->poly_radius2) { f = PlaneDiff(relativelightorigin, surf->plane); if (surf->flags & SURF_PLANEBACK) diff --git a/model_brush.c b/model_brush.c index 3296a68d..f62506f5 100644 --- a/model_brush.c +++ b/model_brush.c @@ -784,7 +784,7 @@ void Mod_ProcessLightList(void) if (dist > 0 && dist < e->cullradius) { VectorSubtract(e->origin, surf->poly_center, temp); - if (DotProduct(temp, temp) - surf->poly_radius2 < e->cullradius2) + if (DotProduct(temp, temp) < e->cullradius2 - surf->poly_radius2) loadmodel->surfacevisframes[*mark] = -2; } } -- 2.39.2