mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
ref: common: add R_PushDlightsForBmodel
This commit is contained in:
@@ -74,7 +74,8 @@ void Matrix4x4_ToArrayFloatGL( const matrix4x4 in, float out[16] );
|
||||
// ref_light.c
|
||||
//
|
||||
void CL_RunLightStyles_( lightstyle_t *ls, int *lightstylevalue );
|
||||
void R_MarkLights( const dlight_t *light, int bit, const mnode_t *node, model_t *model, int dlightframecount );
|
||||
void R_PushDlightsForBmodel( model_t *model, int framecount, const matrix4x4 object_matrix );
|
||||
int R_PushDlights( model_t *model, int framecount );
|
||||
|
||||
|
||||
#endif // REF_COMMON_H
|
||||
|
||||
@@ -93,7 +93,7 @@ void CL_RunLightStyles_( lightstyle_t *ls, int *lightstylevalue )
|
||||
R_MarkLights
|
||||
=============
|
||||
*/
|
||||
void R_MarkLights( const dlight_t *light, int bit, const mnode_t *node, model_t *model, int dlightframecount )
|
||||
static void R_MarkLights( const dlight_t *light, int bit, const mnode_t *node, model_t *model, int dlightframecount )
|
||||
{
|
||||
const float virtual_radius = light->radius * Q_max( 1.0f, r_dlight_virtual_radius.value );
|
||||
const float maxdist = light->radius * light->radius;
|
||||
@@ -186,3 +186,22 @@ int R_PushDlights( model_t *model, int framecount )
|
||||
|
||||
return framecount;
|
||||
}
|
||||
|
||||
void R_PushDlightsForBmodel( model_t *model, int framecount, const matrix4x4 object_matrix )
|
||||
{
|
||||
for( int i = 0; i < MAX_DLIGHTS; i++ )
|
||||
{
|
||||
dlight_t *l = &gp_dlights[i];
|
||||
|
||||
if( l->die < gp_cl->time || !l->radius )
|
||||
continue;
|
||||
|
||||
vec3_t oldorigin;
|
||||
VectorCopy( l->origin, oldorigin );
|
||||
|
||||
Matrix4x4_VectorITransform( object_matrix, oldorigin, l->origin );
|
||||
R_MarkLights( l, 1 << i, model->nodes + model->hulls[0].firstclipnode, model, framecount );
|
||||
|
||||
VectorCopy( oldorigin, l->origin );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1857,20 +1857,7 @@ void R_DrawBrushModel( cl_entity_t *e )
|
||||
e->visframe = tr.realframecount; // visible
|
||||
|
||||
// calculate dynamic lighting for bmodel
|
||||
for( int k = 0; k < MAX_DLIGHTS; k++ )
|
||||
{
|
||||
dlight_t *l = &gp_dlights[k];
|
||||
vec3_t origin_l, oldorigin;
|
||||
|
||||
if( l->die < gp_cl->time || !l->radius )
|
||||
continue;
|
||||
|
||||
VectorCopy( l->origin, oldorigin ); // save lightorigin
|
||||
Matrix4x4_VectorITransform( RI.objectMatrix, l->origin, origin_l );
|
||||
VectorCopy( origin_l, l->origin ); // move light in bmodel space
|
||||
R_MarkLights( l, 1<<k, clmodel->nodes + clmodel->hulls[0].firstclipnode, clmodel, tr.dlightframecount );
|
||||
VectorCopy( oldorigin, l->origin ); // restore lightorigin
|
||||
}
|
||||
R_PushDlightsForBmodel( clmodel, tr.dlightframecount, RI.objectMatrix );
|
||||
|
||||
// setup the rendermode
|
||||
R_SetRenderMode( e );
|
||||
|
||||
@@ -840,21 +840,8 @@ static void R_DrawBEntitiesOnList( void )
|
||||
R_RotateBmodel();
|
||||
|
||||
// calculate dynamic lighting for bmodel
|
||||
for( k = 0; k < MAX_DLIGHTS; k++ )
|
||||
{
|
||||
dlight_t *l = &gp_dlights[k];
|
||||
vec3_t origin_l, oldorigin;
|
||||
|
||||
if( l->die < gp_cl->time || !l->radius )
|
||||
continue;
|
||||
|
||||
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 << k, RI.currentmodel->nodes + RI.currentmodel->hulls[0].firstclipnode, RI.currentmodel, tr.dlightframecount );
|
||||
VectorCopy( oldorigin, l->origin ); // restore lightorigin
|
||||
}
|
||||
Matrix4x4_CreateFromEntity( RI.objectMatrix, RI.currententity->angles, RI.currententity->origin, 1 );
|
||||
R_PushDlightsForBmodel( RI.currentmodel, tr.dlightframecount, RI.objectMatrix );
|
||||
|
||||
RI.currententity->topnode = topnode;
|
||||
if( topnode->contents >= 0 )
|
||||
@@ -965,22 +952,9 @@ void R_DrawBrushModel( cl_entity_t *pent )
|
||||
R_RotateBmodel();
|
||||
|
||||
// calculate dynamic lighting for bmodel
|
||||
for( k = 0; k < MAX_DLIGHTS; k++ )
|
||||
{
|
||||
dlight_t *l = &gp_dlights[k];
|
||||
vec3_t origin_l, oldorigin;
|
||||
|
||||
if( l->die < gp_cl->time || !l->radius )
|
||||
continue;
|
||||
|
||||
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 << k, RI.currentmodel->nodes + RI.currentmodel->hulls[0].firstclipnode, RI.currentmodel, tr.dlightframecount );
|
||||
VectorCopy( oldorigin, l->origin ); // restore lightorigin*/
|
||||
}
|
||||
Matrix4x4_CreateFromEntity( RI.objectMatrix, RI.currententity->angles, RI.currententity->origin, 1 );
|
||||
R_PushDlightsForBmodel( RI.currentmodel, tr.dlightframecount, RI.objectMatrix );
|
||||
tr.modelviewIdentity = false;
|
||||
|
||||
RI.currententity->topnode = topnode;
|
||||
if( topnode->contents >= 0 )
|
||||
|
||||
Reference in New Issue
Block a user