mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
- Improve dynamic lights for the HUD model
This commit is contained in:
parent
0c0f0789c2
commit
cbda6e9427
6 changed files with 38 additions and 6 deletions
|
@ -58,7 +58,7 @@ struct FDynLightData
|
|||
|
||||
|
||||
|
||||
bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, FDynLightData &data, bool planecheck = true);
|
||||
bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, FDynLightData &data, bool planecheck = true, bool hudmodel = false);
|
||||
void gl_UploadLights(FDynLightData &data);
|
||||
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ CVAR(Int, gl_attenuate, -1, 0); // This is mainly a debug option.
|
|||
// Sets up the parameters to render one dynamic light onto one plane
|
||||
//
|
||||
//==========================================================================
|
||||
bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, FDynLightData &ldata, bool planecheck)
|
||||
bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, FDynLightData &ldata, bool planecheck, bool hudmodel)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
|
@ -82,6 +82,31 @@ bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, FD
|
|||
}
|
||||
}
|
||||
|
||||
if (hudmodel)
|
||||
{
|
||||
// HUD model is already translated and rotated. We must rotate the lights into that view space.
|
||||
|
||||
DVector3 rotation;
|
||||
DVector3 localpos = pos - r_viewpoint.Pos;
|
||||
|
||||
rotation.X = localpos.X * r_viewpoint.Angles.Yaw.Sin() - localpos.Y * r_viewpoint.Angles.Yaw.Cos();
|
||||
rotation.Y = localpos.X * r_viewpoint.Angles.Yaw.Cos() + localpos.Y * r_viewpoint.Angles.Yaw.Sin();
|
||||
rotation.Z = localpos.Z;
|
||||
localpos = rotation;
|
||||
|
||||
rotation.X = localpos.X;
|
||||
rotation.Y = localpos.Y * r_viewpoint.Angles.Pitch.Sin() - localpos.Z * r_viewpoint.Angles.Pitch.Cos();
|
||||
rotation.Z = localpos.Y * r_viewpoint.Angles.Pitch.Cos() + localpos.Z * r_viewpoint.Angles.Pitch.Sin();
|
||||
localpos = rotation;
|
||||
|
||||
rotation.Y = localpos.Y;
|
||||
rotation.Z = localpos.Z * r_viewpoint.Angles.Roll.Sin() - localpos.X * r_viewpoint.Angles.Roll.Cos();
|
||||
rotation.X = localpos.Z * r_viewpoint.Angles.Roll.Cos() + localpos.X * r_viewpoint.Angles.Roll.Sin();
|
||||
localpos = rotation;
|
||||
|
||||
pos = localpos;
|
||||
}
|
||||
|
||||
float cs;
|
||||
if (light->IsAdditive())
|
||||
{
|
||||
|
|
|
@ -1099,6 +1099,9 @@ void gl_RenderHUDModel(DPSprite *psp, float ofsX, float ofsY)
|
|||
// so we have to reset the view matrix.
|
||||
gl_RenderState.mViewMatrix.loadIdentity();
|
||||
|
||||
// Need to reset the normal matrix too
|
||||
gl_RenderState.mNormalViewMatrix.loadIdentity();
|
||||
|
||||
// Scaling model (y scale for a sprite means height, i.e. z in the world!).
|
||||
gl_RenderState.mViewMatrix.scale(smf->xscale, smf->zscale, smf->yscale);
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ void gl_SetDynSpriteLight(AActor *thing, particle_t *particle)
|
|||
}
|
||||
}
|
||||
|
||||
void gl_SetDynModelLight(AActor *self, float x, float y, float z, subsector_t * subsec)
|
||||
void gl_SetDynModelLight(AActor *self, float x, float y, float z, subsector_t * subsec, bool hudmodel)
|
||||
{
|
||||
Plane p;
|
||||
p.Set(subsec->sector->ceilingplane); // Is this correct?
|
||||
|
@ -146,7 +146,7 @@ void gl_SetDynModelLight(AActor *self, float x, float y, float z, subsector_t *
|
|||
ADynamicLight *light = node->lightsource;
|
||||
if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->lightflags&LF_DONTLIGHTSELF) || light->target != self) && !(light->lightflags&LF_DONTLIGHTACTORS))
|
||||
{
|
||||
gl_GetLight(subsec->sector->PortalGroup, p, node->lightsource, false, modellightdata, false);
|
||||
gl_GetLight(subsec->sector->PortalGroup, p, node->lightsource, false, modellightdata, false, hudmodel);
|
||||
}
|
||||
node = node->nextLight;
|
||||
}
|
||||
|
|
|
@ -422,6 +422,6 @@ inline float Dist2(float x1,float y1,float x2,float y2)
|
|||
|
||||
void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t *subsec);
|
||||
void gl_SetDynSpriteLight(AActor *actor, particle_t *particle);
|
||||
void gl_SetDynModelLight(AActor *self, float x, float y, float z, subsector_t * subsec);
|
||||
void gl_SetDynModelLight(AActor *self, float x, float y, float z, subsector_t * subsec, bool hudmodel = false);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -420,7 +420,11 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
|
|||
{
|
||||
if (gl_lights && GLRenderer->mLightCount && FixedColormap == CM_DEFAULT && gl_light_sprites)
|
||||
{
|
||||
gl_SetDynSpriteLight(playermo, NULL);
|
||||
FSpriteModelFrame *smf = gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetState()->sprite, psp->GetState()->GetFrame(), false);
|
||||
if (smf)
|
||||
gl_SetDynModelLight(playermo, playermo->X(), playermo->Y(), playermo->Center(), playermo->subsector, true);
|
||||
else
|
||||
gl_SetDynSpriteLight(playermo, NULL);
|
||||
}
|
||||
SetColor(ll, 0, cmc, trans, true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue