diff --git a/r_edge.c b/r_edge.c index 4da740af..e8b73f8d 100644 --- a/r_edge.c +++ b/r_edge.c @@ -1115,12 +1115,19 @@ void D_SolidSurf (surf_t *s) R_RotateBmodel (); // FIXME: don't mess with the frustum, // make entity passed in + // setup dlight transform + if( s->msurf && s->msurf->dlightframe == tr.framecount ) + { + Matrix4x4_CreateFromEntity( RI.objectMatrix, RI.currententity->angles, RI.currententity->origin, 1 ); + tr.modelviewIdentity = false; + } } else { if( alphaspans ) return; RI.currententity = gEngfuncs.GetEntityByIndex(0); //r_worldentity; + tr.modelviewIdentity = true; } pface = s->msurf; diff --git a/r_main.c b/r_main.c index bc788275..e1cf762a 100644 --- a/r_main.c +++ b/r_main.c @@ -1196,16 +1196,18 @@ void R_DrawBEntitiesOnList (void) for( k = 0; k < MAX_DLIGHTS; k++ ) { dlight_t *l = gEngfuncs.GetDynamicLight( k ); + vec3_t origin_l, oldorigin; if( l->die < gpGlobals->time || !l->radius ) continue; - /*VectorCopy( l->origin, oldorigin ); // save lightorigin + VectorCopy( l->origin, oldorigin ); // save lightorigin + Matrix4x4_CreateFromEntity( RI.objectMatrix, RI.currententity->angles, RI.currententity->origin, 1 ); Matrix4x4_VectorITransform( RI.objectMatrix, l->origin, origin_l ); VectorCopy( origin_l, l->origin ); // move light in bmodel space - R_MarkLights( l, 1<nodes + clmodel->hulls[0].firstclipnode ); - VectorCopy( oldorigin, l->origin ); // restore lightorigin*/ R_MarkLights( l, 1<nodes + RI.currentmodel->hulls[0].firstclipnode ); + VectorCopy( oldorigin, l->origin ); // restore lightorigin*/ + //R_MarkLights( l, 1<nodes + RI.currentmodel->hulls[0].firstclipnode ); } // RI.currentmodel = tr.draw_list->solid_entities[i]->model; @@ -1350,16 +1352,19 @@ void R_DrawBrushModel(cl_entity_t *pent) for( k = 0; k < MAX_DLIGHTS; k++ ) { dlight_t *l = gEngfuncs.GetDynamicLight( k ); + vec3_t origin_l, oldorigin; if( l->die < gpGlobals->time || !l->radius ) continue; - /*VectorCopy( l->origin, oldorigin ); // save lightorigin + VectorCopy( l->origin, oldorigin ); // save lightorigin + Matrix4x4_CreateFromEntity( RI.objectMatrix, RI.currententity->angles, RI.currententity->origin, 1 ); Matrix4x4_VectorITransform( RI.objectMatrix, l->origin, origin_l ); + tr.modelviewIdentity = false; VectorCopy( origin_l, l->origin ); // move light in bmodel space - R_MarkLights( l, 1<nodes + clmodel->hulls[0].firstclipnode ); - VectorCopy( oldorigin, l->origin ); // restore lightorigin*/ R_MarkLights( l, 1<nodes + RI.currentmodel->hulls[0].firstclipnode ); + VectorCopy( oldorigin, l->origin ); // restore lightorigin*/ + //R_MarkLights( l, 1<nodes + RI.currentmodel->hulls[0].firstclipnode ); } // RI.currentmodel = tr.draw_list->solid_entities[i]->model; @@ -1598,6 +1603,7 @@ void R_RenderScene( void ) R_SetupProjectionMatrix( RI.projectionMatrix ); Matrix4x4_Concat( RI.worldviewProjectionMatrix, RI.projectionMatrix, RI.worldviewMatrix ); + tr.modelviewIdentity = true; // R_SetupGL( true ); //R_Clear( ~0 ); diff --git a/r_surf.c b/r_surf.c index 633657e4..b8c0bde4 100644 --- a/r_surf.c +++ b/r_surf.c @@ -105,10 +105,10 @@ void R_AddDynamicLights( msurface_t *surf ) dl = gEngfuncs.GetDynamicLight( lnum ); // transform light origin to local bmodel space - //if( !tr.modelviewIdentity ) - //Matrix4x4_VectorITransform( RI.objectMatrix, dl->origin, origin_l ); - //else - VectorCopy( dl->origin, origin_l ); + if( !tr.modelviewIdentity ) + Matrix4x4_VectorITransform( RI.objectMatrix, dl->origin, origin_l ); + else + VectorCopy( dl->origin, origin_l ); rad = dl->radius; dist = PlaneDiff( origin_l, surf->plane );