From 1a9c6074e61bde66fa7c2e560809e9653672293b Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 1 Apr 2009 17:58:29 +0000 Subject: [PATCH] reset rsurface.entity to NULL after each entity is rendered git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8840 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 4 ++++ gl_rsurf.c | 3 +++ r_shadow.c | 8 ++++++++ 3 files changed, 15 insertions(+) diff --git a/gl_rmain.c b/gl_rmain.c index a3b2ae8d..917f6266 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -7153,6 +7153,7 @@ void R_DrawWorldSurfaces(qboolean skysurfaces, qboolean writedepth, qboolean dep if (debug) { R_DrawDebugModel(r_refdef.scene.worldentity); + rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity return; } @@ -7188,6 +7189,7 @@ void R_DrawWorldSurfaces(qboolean skysurfaces, qboolean writedepth, qboolean dep for (j = 0;j < numsurfacelist;j++) r_refdef.stats.world_triangles += r_surfacelist[j]->num_triangles; } + rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity } void R_DrawModelSurfaces(entity_render_t *ent, qboolean skysurfaces, qboolean writedepth, qboolean depthonly, qboolean debug) @@ -7243,6 +7245,7 @@ void R_DrawModelSurfaces(entity_render_t *ent, qboolean skysurfaces, qboolean wr if (debug) { R_DrawDebugModel(ent); + rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity return; } @@ -7274,4 +7277,5 @@ void R_DrawModelSurfaces(entity_render_t *ent, qboolean skysurfaces, qboolean wr for (j = 0;j < numsurfacelist;j++) r_refdef.stats.entities_triangles += r_surfacelist[j]->num_triangles; } + rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity } diff --git a/gl_rsurf.c b/gl_rsurf.c index b3557b55..7d68daed 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -580,6 +580,7 @@ void R_Q1BSP_DrawAddWaterPlanes(entity_render_t *ent) R_Water_AddWaterPlane(surfaces + j); } } + rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity } void R_Q1BSP_Draw(entity_render_t *ent) @@ -977,6 +978,8 @@ void R_Q1BSP_GetLightInfo(entity_render_t *ent, vec3_t relativelightorigin, floa R_Q1BSP_CallRecursiveGetLightInfo(&info, r_shadow_compilingrtlight ? r_shadow_realtime_world_compilesvbsp.integer : r_shadow_realtime_dlight_svbspculling.integer); } + rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity + // limit combined leaf box to light boundaries outmins[0] = max(info.outmins[0] - 1, info.lightmins[0]); outmins[1] = max(info.outmins[1] - 1, info.lightmins[1]); diff --git a/r_shadow.c b/r_shadow.c index 02a90e7f..a14df78c 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -2995,6 +2995,8 @@ void R_Shadow_DrawWorldShadow(int numsurfaces, int *surfacelist, const unsigned } else if (numsurfaces) r_refdef.scene.worldmodel->DrawShadowVolume(r_refdef.scene.worldentity, rsurface.rtlight->shadoworigin, NULL, rsurface.rtlight->radius, numsurfaces, surfacelist, rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs); + + rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity } void R_Shadow_DrawEntityShadow(entity_render_t *ent) @@ -3011,6 +3013,7 @@ void R_Shadow_DrawEntityShadow(entity_render_t *ent) relativeshadowmaxs[1] = relativeshadoworigin[1] + relativeshadowradius; relativeshadowmaxs[2] = relativeshadoworigin[2] + relativeshadowradius; ent->model->DrawShadowVolume(ent, relativeshadoworigin, NULL, relativeshadowradius, ent->model->nummodelsurfaces, ent->model->sortedmodelsurfaces, relativeshadowmins, relativeshadowmaxs); + rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity } void R_Shadow_SetupEntityLight(const entity_render_t *ent) @@ -3042,6 +3045,8 @@ void R_Shadow_DrawWorldLight(int numsurfaces, int *surfacelist, const unsigned c R_Mesh_TexMatrix(3, &rsurface.entitytolight); r_refdef.scene.worldmodel->DrawLight(r_refdef.scene.worldentity, numsurfaces, surfacelist, trispvs); + + rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity } void R_Shadow_DrawEntityLight(entity_render_t *ent) @@ -3053,6 +3058,8 @@ void R_Shadow_DrawEntityLight(entity_render_t *ent) R_Shadow_SetupEntityLight(ent); model->DrawLight(ent, model->nummodelsurfaces, model->sortedmodelsurfaces, NULL); + + rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity } void R_DrawRTLight(rtlight_t *rtlight, qboolean visible) @@ -3462,6 +3469,7 @@ void R_DrawModelShadows(void) VectorScale(relativelightdirection, -relativethrowdistance, relativelightorigin); RSurf_ActiveModelEntity(ent, false, false); ent->model->DrawShadowVolume(ent, relativelightorigin, relativelightdirection, relativethrowdistance, ent->model->nummodelsurfaces, ent->model->sortedmodelsurfaces, relativeshadowmins, relativeshadowmaxs); + rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity } } -- 2.39.2