From 7e1ac1e0df1ef15a3813b5cee9830996c960fc62 Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 29 Oct 2002 19:29:58 +0000 Subject: [PATCH] view model is now properly lit in realtime mode git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2586 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_main.c | 17 +++++++++++++++-- gl_rmain.c | 35 ++++++++++++++++++++--------------- view.c | 1 + 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/cl_main.c b/cl_main.c index 59babb2c..e251750c 100644 --- a/cl_main.c +++ b/cl_main.c @@ -473,7 +473,7 @@ static void CL_RelinkStaticEntities(void) CL_RelinkEntities =============== */ -static void CL_RelinkNetworkEntities() +static void CL_RelinkNetworkEntities(void) { entity_t *ent; int i, effects, temp; @@ -746,6 +746,18 @@ static void CL_RelinkNetworkEntities() } } +static void CL_RelinkViewModel(void) +{ + entity_t *ent; + if (!r_drawviewmodel.integer || chase_active.integer || envmap || !r_drawentities.integer || cl.items & IT_INVISIBILITY || cl.stats[STAT_HEALTH] <= 0 || cl.viewent.render.model == NULL) + return; + + ent = &cl.viewent; + // FIXME: set up view model here? + if (r_refdef.numentities < r_refdef.maxentities) + r_refdef.entities[r_refdef.numentities++] = &ent->render; +} + void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate) { int i; @@ -771,7 +783,7 @@ void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float } } -static void CL_RelinkEffects() +static void CL_RelinkEffects(void) { int i, intframe; cl_effect_t *e; @@ -939,6 +951,7 @@ void CL_RelinkEntities (void) CL_RelinkWorld(); CL_RelinkStaticEntities(); CL_RelinkNetworkEntities(); + CL_RelinkViewModel(); CL_RelinkEffects(); CL_RelinkBeams(); CL_MoveParticles(); diff --git a/gl_rmain.c b/gl_rmain.c index 24c9baa0..fcc9f671 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -577,6 +577,7 @@ int R_DrawBrushModelsSky (void) R_DrawViewModel ============= */ +/* void R_DrawViewModel (void) { entity_render_t *ent; @@ -593,6 +594,7 @@ void R_DrawViewModel (void) R_UpdateEntLights(ent); ent->model->Draw(ent); } +*/ void R_DrawNoModel(entity_render_t *ent); void R_DrawModels () @@ -603,7 +605,6 @@ void R_DrawModels () if (!r_drawentities.integer) return; - R_DrawViewModel(); for (i = 0;i < r_refdef.numentities;i++) { ent = r_refdef.entities[i]; @@ -890,10 +891,11 @@ void R_ShadowVolumeLighting (int visiblevolumes) if (!visiblevolumes) R_Shadow_Stage_ShadowVolumes(); + ent = &cl_entities[0].render; if (wl->shadowvolume && r_staticworldlights.integer) - R_Shadow_DrawWorldLightShadowVolume(&cl_entities[0].render.matrix, wl); + R_Shadow_DrawWorldLightShadowVolume(&ent->matrix, wl); else - R_TestAndDrawShadowVolume(&cl_entities[0].render, wl->origin, cullradius, lightradius, clipmins, clipmaxs); + R_TestAndDrawShadowVolume(ent, wl->origin, cullradius / ent->scale, lightradius / ent->scale, clipmins, clipmaxs); if (r_drawentities.integer) { for (i = 0;i < r_refdef.numentities;i++) @@ -903,7 +905,7 @@ void R_ShadowVolumeLighting (int visiblevolumes) && ent->maxs[1] >= wl->mins[1] && ent->mins[1] <= wl->maxs[1] && ent->maxs[2] >= wl->mins[2] && ent->mins[2] <= wl->maxs[2] && !(ent->effects & EF_ADDITIVE) && ent->alpha == 1) - R_TestAndDrawShadowVolume(r_refdef.entities[i], wl->origin, cullradius, lightradius, clipmins, clipmaxs); + R_TestAndDrawShadowVolume(r_refdef.entities[i], wl->origin, cullradius / ent->scale, lightradius / ent->scale, clipmins, clipmaxs); } } @@ -918,7 +920,7 @@ void R_ShadowVolumeLighting (int visiblevolumes) if (wl->numsurfaces) R_Model_Brush_DrawLightForSurfaceList(ent, relativelightorigin, relativeeyeorigin, lightradius, lightcolor, wl->surfaces, wl->numsurfaces); else - ent->model->DrawLight(ent, relativelightorigin, relativeeyeorigin, lightradius, lightcolor); + ent->model->DrawLight(ent, relativelightorigin, relativeeyeorigin, lightradius / ent->scale, lightcolor); } if (r_drawentities.integer) { @@ -933,17 +935,18 @@ void R_ShadowVolumeLighting (int visiblevolumes) { Matrix4x4_Transform(&ent->inversematrix, wl->origin, relativelightorigin); Matrix4x4_Transform(&ent->inversematrix, r_origin, relativeeyeorigin); - ent->model->DrawLight(ent, relativelightorigin, relativeeyeorigin, lightradius, lightcolor); + ent->model->DrawLight(ent, relativelightorigin, relativeeyeorigin, lightradius / ent->scale, lightcolor); } } } if (R_Shadow_Stage_EraseShadowVolumes()) { + ent = &cl_entities[0].render; if (wl->shadowvolume && r_staticworldlights.integer) - R_Shadow_DrawWorldLightShadowVolume(&cl_entities[0].render.matrix, wl); + R_Shadow_DrawWorldLightShadowVolume(&ent->matrix, wl); else - R_TestAndDrawShadowVolume(&cl_entities[0].render, wl->origin, cullradius, lightradius, clipmins, clipmaxs); + R_TestAndDrawShadowVolume(ent, wl->origin, cullradius / ent->scale, lightradius / ent->scale, clipmins, clipmaxs); if (r_drawentities.integer) { for (i = 0;i < r_refdef.numentities;i++) @@ -953,7 +956,7 @@ void R_ShadowVolumeLighting (int visiblevolumes) && ent->maxs[1] >= wl->mins[1] && ent->mins[1] <= wl->maxs[1] && ent->maxs[2] >= wl->mins[2] && ent->mins[2] <= wl->maxs[2] && !(ent->effects & EF_ADDITIVE) && ent->alpha == 1) - R_TestAndDrawShadowVolume(r_refdef.entities[i], wl->origin, cullradius, lightradius, clipmins, clipmaxs); + R_TestAndDrawShadowVolume(r_refdef.entities[i], wl->origin, cullradius / ent->scale, lightradius / ent->scale, clipmins, clipmaxs); } } } @@ -1061,14 +1064,15 @@ void R_ShadowVolumeLighting (int visiblevolumes) if (!visiblevolumes) R_Shadow_Stage_ShadowVolumes(); - R_TestAndDrawShadowVolume(&cl_entities[0].render, rd->origin, cullradius, lightradius, clipmins, clipmaxs); + ent = &cl_entities[0].render; + R_TestAndDrawShadowVolume(ent, rd->origin, cullradius / ent->scale, lightradius / ent->scale, clipmins, clipmaxs); if (r_drawentities.integer) { for (i = 0;i < r_refdef.numentities;i++) { ent = r_refdef.entities[i]; if (ent != rd->ent && !(ent->effects & EF_ADDITIVE) && ent->alpha == 1) - R_TestAndDrawShadowVolume(ent, rd->origin, cullradius, lightradius, clipmins, clipmaxs); + R_TestAndDrawShadowVolume(ent, rd->origin, cullradius / ent->scale, lightradius / ent->scale, clipmins, clipmaxs); } } @@ -1080,7 +1084,7 @@ void R_ShadowVolumeLighting (int visiblevolumes) { Matrix4x4_Transform(&ent->inversematrix, rd->origin, relativelightorigin); Matrix4x4_Transform(&ent->inversematrix, r_origin, relativeeyeorigin); - ent->model->DrawLight(ent, relativelightorigin, relativeeyeorigin, lightradius, lightcolor); + ent->model->DrawLight(ent, relativelightorigin, relativeeyeorigin, lightradius / ent->scale, lightcolor); } if (r_drawentities.integer) { @@ -1092,21 +1096,22 @@ void R_ShadowVolumeLighting (int visiblevolumes) { Matrix4x4_Transform(&ent->inversematrix, rd->origin, relativelightorigin); Matrix4x4_Transform(&ent->inversematrix, r_origin, relativeeyeorigin); - ent->model->DrawLight(ent, relativelightorigin, relativeeyeorigin, lightradius, lightcolor); + ent->model->DrawLight(ent, relativelightorigin, relativeeyeorigin, lightradius / ent->scale, lightcolor); } } } if (R_Shadow_Stage_EraseShadowVolumes()) { - R_TestAndDrawShadowVolume(&cl_entities[0].render, rd->origin, cullradius, lightradius, clipmins, clipmaxs); + ent = &cl_entities[0].render; + R_TestAndDrawShadowVolume(ent, rd->origin, cullradius / ent->scale, lightradius / ent->scale, clipmins, clipmaxs); if (r_drawentities.integer) { for (i = 0;i < r_refdef.numentities;i++) { ent = r_refdef.entities[i]; if (ent != rd->ent && !(ent->effects & EF_ADDITIVE) && ent->alpha == 1) - R_TestAndDrawShadowVolume(ent, rd->origin, cullradius, lightradius, clipmins, clipmaxs); + R_TestAndDrawShadowVolume(ent, rd->origin, cullradius / ent->scale, lightradius / ent->scale, clipmins, clipmaxs); } } } diff --git a/view.c b/view.c index e50d4ce7..b3fdf909 100644 --- a/view.c +++ b/view.c @@ -544,6 +544,7 @@ void V_CalcRefdef (void) view->render.angles[ROLL] = r_refdef.viewangles[ROLL] - v_idlescale.value * sin(cl.time*v_iroll_cycle.value) * v_iroll_level.value; // FIXME: this setup code is somewhat evil (CL_LerpUpdate should be private?) CL_LerpUpdate(view); + CL_BoundingBoxForEntity(&view->render); view->render.colormap = -1; // no special coloring view->render.alpha = ent->render.alpha; // LordHavoc: if the player is transparent, so is the gun view->render.effects = ent->render.effects; -- 2.39.2