mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- made the glow getter functions members of sector_t.
This commit is contained in:
parent
d01bc452ba
commit
52c5328412
15 changed files with 119 additions and 183 deletions
|
@ -1043,7 +1043,6 @@ set (PCH_SOURCES
|
|||
g_statusbar/shared_sbar.cpp
|
||||
gl/compatibility/gl_20.cpp
|
||||
gl/data/gl_vertexbuffer.cpp
|
||||
gl/dynlights/gl_glow.cpp
|
||||
gl/dynlights/gl_lightbuffer.cpp
|
||||
gl/dynlights/gl_aabbtree.cpp
|
||||
gl/dynlights/gl_shadowmap.cpp
|
||||
|
|
|
@ -1,139 +0,0 @@
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 2005-2016 Christoph Oelckers
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see http://www.gnu.org/licenses/
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
//
|
||||
/*
|
||||
** gl_glow.cpp
|
||||
** Glowing flats like Doomsday
|
||||
**
|
||||
**/
|
||||
|
||||
#include "w_wad.h"
|
||||
#include "sc_man.h"
|
||||
#include "v_video.h"
|
||||
#include "r_defs.h"
|
||||
#include "textures/textures.h"
|
||||
|
||||
#include "gl/dynlights/gl_glow.h"
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Checks whether a sprite should be affected by a glow
|
||||
//
|
||||
//==========================================================================
|
||||
int gl_CheckSpriteGlow(sector_t *sector, int lightlevel, const DVector3 &pos)
|
||||
{
|
||||
float bottomglowcolor[4];
|
||||
bottomglowcolor[3] = 0;
|
||||
auto c = sector->planes[sector_t::floor].GlowColor;
|
||||
if (c == 0)
|
||||
{
|
||||
FTexture *tex = TexMan[sector->GetTexture(sector_t::floor)];
|
||||
if (tex != NULL && tex->isGlowing())
|
||||
{
|
||||
if (!tex->bAutoGlowing) tex = TexMan(sector->GetTexture(sector_t::floor));
|
||||
if (tex->isGlowing()) // recheck the current animation frame.
|
||||
{
|
||||
tex->GetGlowColor(bottomglowcolor);
|
||||
bottomglowcolor[3] = (float)tex->GlowHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (c != ~0u)
|
||||
{
|
||||
bottomglowcolor[0] = c.r / 255.f;
|
||||
bottomglowcolor[1] = c.g / 255.f;
|
||||
bottomglowcolor[2] = c.b / 255.f;
|
||||
bottomglowcolor[3] = sector->planes[sector_t::floor].GlowHeight;
|
||||
}
|
||||
|
||||
if (bottomglowcolor[3]> 0)
|
||||
{
|
||||
double floordiff = pos.Z - sector->floorplane.ZatPoint(pos);
|
||||
if (floordiff < bottomglowcolor[3])
|
||||
{
|
||||
int maxlight = (255 + lightlevel) >> 1;
|
||||
double lightfrac = floordiff / bottomglowcolor[3];
|
||||
if (lightfrac < 0) lightfrac = 0;
|
||||
lightlevel = int(lightfrac*lightlevel + maxlight*(1 - lightfrac));
|
||||
}
|
||||
}
|
||||
return lightlevel;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Checks whether a wall should glow
|
||||
//
|
||||
//==========================================================================
|
||||
bool gl_GetWallGlow(sector_t *sector, float *topglowcolor, float *bottomglowcolor)
|
||||
{
|
||||
bool ret = false;
|
||||
bottomglowcolor[3] = topglowcolor[3] = 0;
|
||||
auto c = sector->planes[sector_t::ceiling].GlowColor;
|
||||
if (c == 0)
|
||||
{
|
||||
FTexture *tex = TexMan[sector->GetTexture(sector_t::ceiling)];
|
||||
if (tex != NULL && tex->isGlowing())
|
||||
{
|
||||
if (!tex->bAutoGlowing) tex = TexMan(sector->GetTexture(sector_t::ceiling));
|
||||
if (tex->isGlowing()) // recheck the current animation frame.
|
||||
{
|
||||
ret = true;
|
||||
tex->GetGlowColor(topglowcolor);
|
||||
topglowcolor[3] = (float)tex->GlowHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (c != ~0u)
|
||||
{
|
||||
topglowcolor[0] = c.r / 255.f;
|
||||
topglowcolor[1] = c.g / 255.f;
|
||||
topglowcolor[2] = c.b / 255.f;
|
||||
topglowcolor[3] = sector->planes[sector_t::ceiling].GlowHeight;
|
||||
ret = topglowcolor[3] > 0;
|
||||
}
|
||||
|
||||
c = sector->planes[sector_t::floor].GlowColor;
|
||||
if (c == 0)
|
||||
{
|
||||
FTexture *tex = TexMan[sector->GetTexture(sector_t::floor)];
|
||||
if (tex != NULL && tex->isGlowing())
|
||||
{
|
||||
if (!tex->bAutoGlowing) tex = TexMan(sector->GetTexture(sector_t::floor));
|
||||
if (tex->isGlowing()) // recheck the current animation frame.
|
||||
{
|
||||
ret = true;
|
||||
tex->GetGlowColor(bottomglowcolor);
|
||||
bottomglowcolor[3] = (float)tex->GlowHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (c != ~0u)
|
||||
{
|
||||
bottomglowcolor[0] = c.r / 255.f;
|
||||
bottomglowcolor[1] = c.g / 255.f;
|
||||
bottomglowcolor[2] = c.b / 255.f;
|
||||
bottomglowcolor[3] = sector->planes[sector_t::floor].GlowHeight;
|
||||
ret = bottomglowcolor[3] > 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
#ifndef __GL_GLOW
|
||||
#define __GL_GLOW
|
||||
|
||||
struct sector_t;
|
||||
|
||||
void gl_InitGlow(const char * lumpnm);
|
||||
int gl_CheckSpriteGlow(sector_t *sec, int lightlevel, const DVector3 &pos);
|
||||
bool gl_GetWallGlow(sector_t *sector, float *topglowcolor, float *bottomglowcolor);
|
||||
|
||||
#endif
|
|
@ -46,7 +46,6 @@
|
|||
#include "gl/data/gl_data.h"
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
#include "gl/dynlights/gl_dynlight.h"
|
||||
#include "gl/dynlights/gl_glow.h"
|
||||
#include "gl/dynlights/gl_lightbuffer.h"
|
||||
#include "gl/scene/gl_drawinfo.h"
|
||||
#include "gl/shaders/gl_shader.h"
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include "gl/renderer/gl_renderer.h"
|
||||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/renderer/gl_quaddrawer.h"
|
||||
#include "gl/dynlights/gl_glow.h"
|
||||
#include "gl/data/gl_data.h"
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
#include "gl/scene/gl_clipper.h"
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
|
||||
#include "gl/renderer/gl_renderer.h"
|
||||
#include "gl/data/gl_data.h"
|
||||
#include "gl/dynlights/gl_glow.h"
|
||||
#include "gl/scene/gl_drawinfo.h"
|
||||
#include "gl/scene/gl_portal.h"
|
||||
#include "gl/scene/gl_scenedrawer.h"
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/renderer/gl_renderer.h"
|
||||
#include "gl/data/gl_data.h"
|
||||
#include "gl/dynlights/gl_glow.h"
|
||||
#include "gl/scene/gl_drawinfo.h"
|
||||
#include "gl/scene/gl_scenedrawer.h"
|
||||
#include "gl/scene/gl_portal.h"
|
||||
|
@ -425,7 +424,7 @@ void GLSprite::Draw(int pass)
|
|||
secplane_t *lowplane = i == (*lightlist).Size() - 1 ? &bottomp : &(*lightlist)[i + 1].plane;
|
||||
|
||||
int thislight = (*lightlist)[i].caster != NULL ? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel;
|
||||
int thisll = actor == nullptr? thislight : (uint8_t)gl_CheckSpriteGlow(actor->Sector, thislight, actor->InterpolatedPosition(r_viewpoint.TicFrac));
|
||||
int thisll = actor == nullptr? thislight : (uint8_t)actor->Sector->CheckSpriteGlow(thislight, actor->InterpolatedPosition(r_viewpoint.TicFrac));
|
||||
|
||||
FColormap thiscm;
|
||||
thiscm.CopyFog(Colormap);
|
||||
|
@ -947,7 +946,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
|
|||
rendersector->GetCeilingLight() : rendersector->GetFloorLight());
|
||||
foglevel = (uint8_t)clamp<short>(rendersector->lightlevel, 0, 255);
|
||||
|
||||
lightlevel = gl_CheckSpriteGlow(rendersector, lightlevel, thingpos);
|
||||
lightlevel = rendersector->CheckSpriteGlow(lightlevel, thingpos);
|
||||
|
||||
ThingColor = (thing->RenderStyle.Flags & STYLEF_ColorIsFixed) ? thing->fillcolor : 0xffffff;
|
||||
ThingColor.a = 255;
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "gl/renderer/gl_lightdata.h"
|
||||
#include "gl/data/gl_data.h"
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
#include "gl/dynlights/gl_glow.h"
|
||||
#include "gl/scene/gl_drawinfo.h"
|
||||
#include "gl/scene/gl_portal.h"
|
||||
#include "gl/shaders/gl_shader.h"
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "gl/renderer/gl_lightdata.h"
|
||||
#include "gl/data/gl_data.h"
|
||||
#include "gl/dynlights/gl_dynlight.h"
|
||||
#include "gl/dynlights/gl_glow.h"
|
||||
#include "gl/scene/gl_drawinfo.h"
|
||||
#include "gl/scene/gl_portal.h"
|
||||
#include "gl/scene/gl_scenedrawer.h"
|
||||
|
@ -1537,7 +1536,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
|
|||
gltexture = NULL;
|
||||
|
||||
|
||||
if (gl_GetWallGlow(frontsector, topglowcolor, bottomglowcolor)) flags |= GLWF_GLOW;
|
||||
if (frontsector->GetWallGlow(topglowcolor, bottomglowcolor)) flags |= GLWF_GLOW;
|
||||
topplane = frontsector->ceilingplane;
|
||||
bottomplane = frontsector->floorplane;
|
||||
|
||||
|
@ -1773,7 +1772,7 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t *
|
|||
RenderStyle = STYLE_Normal;
|
||||
Colormap = frontsector->Colormap;
|
||||
|
||||
if (gl_GetWallGlow(frontsector, topglowcolor, bottomglowcolor)) flags |= GLWF_GLOW;
|
||||
if (frontsector->GetWallGlow(topglowcolor, bottomglowcolor)) flags |= GLWF_GLOW;
|
||||
topplane = frontsector->ceilingplane;
|
||||
bottomplane = frontsector->floorplane;
|
||||
dynlightindex = -1;
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include "gl/data/gl_data.h"
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
#include "gl/dynlights/gl_dynlight.h"
|
||||
#include "gl/dynlights/gl_glow.h"
|
||||
#include "gl/dynlights/gl_lightbuffer.h"
|
||||
#include "gl/scene/gl_drawinfo.h"
|
||||
#include "gl/scene/gl_portal.h"
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/data/gl_data.h"
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
#include "gl/dynlights/gl_glow.h"
|
||||
#include "gl/scene/gl_drawinfo.h"
|
||||
#include "gl/scene/gl_scenedrawer.h"
|
||||
#include "gl/models/gl_models.h"
|
||||
|
@ -330,7 +329,7 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
|
|||
{
|
||||
lightlevel = (2 * lightlevel + 255) / 3;
|
||||
}
|
||||
lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->Pos());
|
||||
lightlevel = viewsector->CheckSpriteGlow(lightlevel, playermo->Pos());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -115,21 +115,7 @@ int TexFormat[]={
|
|||
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// GL status data for a texture
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture::MiscGLInfo::MiscGLInfo() throw()
|
||||
{
|
||||
bNoExpand = false;
|
||||
|
||||
Material[1] = Material[0] = NULL;
|
||||
SystemTexture[1] = SystemTexture[0] = NULL;
|
||||
}
|
||||
|
||||
FTexture::MiscGLInfo::~MiscGLInfo()
|
||||
FTexture::GLTexInfo::~GLTexInfo()
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// Copyright 1993-1996 id Software
|
||||
// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
|
||||
// Copyright 1999-2016 Randy Heit
|
||||
// Copyright 2002-2017 Christoph Oelckers
|
||||
// Copyright 2002-2018 Christoph Oelckers
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
|
@ -1527,6 +1527,112 @@ DEFINE_ACTION_FUNCTION(_Sector, NextLowestFloorAt)
|
|||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Checks whether a sprite should be affected by a glow
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int sector_t::CheckSpriteGlow(int lightlevel, const DVector3 &pos)
|
||||
{
|
||||
float bottomglowcolor[4];
|
||||
bottomglowcolor[3] = 0;
|
||||
auto c = planes[sector_t::floor].GlowColor;
|
||||
if (c == 0)
|
||||
{
|
||||
FTexture *tex = TexMan[GetTexture(sector_t::floor)];
|
||||
if (tex != NULL && tex->isGlowing())
|
||||
{
|
||||
if (!tex->bAutoGlowing) tex = TexMan(GetTexture(sector_t::floor));
|
||||
if (tex->isGlowing()) // recheck the current animation frame.
|
||||
{
|
||||
tex->GetGlowColor(bottomglowcolor);
|
||||
bottomglowcolor[3] = (float)tex->GlowHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (c != ~0u)
|
||||
{
|
||||
bottomglowcolor[0] = c.r / 255.f;
|
||||
bottomglowcolor[1] = c.g / 255.f;
|
||||
bottomglowcolor[2] = c.b / 255.f;
|
||||
bottomglowcolor[3] = planes[sector_t::floor].GlowHeight;
|
||||
}
|
||||
|
||||
if (bottomglowcolor[3]> 0)
|
||||
{
|
||||
double floordiff = pos.Z - floorplane.ZatPoint(pos);
|
||||
if (floordiff < bottomglowcolor[3])
|
||||
{
|
||||
int maxlight = (255 + lightlevel) >> 1;
|
||||
double lightfrac = floordiff / bottomglowcolor[3];
|
||||
if (lightfrac < 0) lightfrac = 0;
|
||||
lightlevel = int(lightfrac*lightlevel + maxlight * (1 - lightfrac));
|
||||
}
|
||||
}
|
||||
return lightlevel;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Checks whether a wall should glow
|
||||
//
|
||||
//==========================================================================
|
||||
bool sector_t::GetWallGlow(float *topglowcolor, float *bottomglowcolor)
|
||||
{
|
||||
bool ret = false;
|
||||
bottomglowcolor[3] = topglowcolor[3] = 0;
|
||||
auto c = planes[sector_t::ceiling].GlowColor;
|
||||
if (c == 0)
|
||||
{
|
||||
FTexture *tex = TexMan[GetTexture(sector_t::ceiling)];
|
||||
if (tex != NULL && tex->isGlowing())
|
||||
{
|
||||
if (!tex->bAutoGlowing) tex = TexMan(GetTexture(sector_t::ceiling));
|
||||
if (tex->isGlowing()) // recheck the current animation frame.
|
||||
{
|
||||
ret = true;
|
||||
tex->GetGlowColor(topglowcolor);
|
||||
topglowcolor[3] = (float)tex->GlowHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (c != ~0u)
|
||||
{
|
||||
topglowcolor[0] = c.r / 255.f;
|
||||
topglowcolor[1] = c.g / 255.f;
|
||||
topglowcolor[2] = c.b / 255.f;
|
||||
topglowcolor[3] = planes[sector_t::ceiling].GlowHeight;
|
||||
ret = topglowcolor[3] > 0;
|
||||
}
|
||||
|
||||
c = planes[sector_t::floor].GlowColor;
|
||||
if (c == 0)
|
||||
{
|
||||
FTexture *tex = TexMan[GetTexture(sector_t::floor)];
|
||||
if (tex != NULL && tex->isGlowing())
|
||||
{
|
||||
if (!tex->bAutoGlowing) tex = TexMan(GetTexture(sector_t::floor));
|
||||
if (tex->isGlowing()) // recheck the current animation frame.
|
||||
{
|
||||
ret = true;
|
||||
tex->GetGlowColor(bottomglowcolor);
|
||||
bottomglowcolor[3] = (float)tex->GlowHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (c != ~0u)
|
||||
{
|
||||
bottomglowcolor[0] = c.r / 255.f;
|
||||
bottomglowcolor[1] = c.g / 255.f;
|
||||
bottomglowcolor[2] = c.b / 255.f;
|
||||
bottomglowcolor[3] = planes[sector_t::floor].GlowHeight;
|
||||
ret = bottomglowcolor[3] > 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
|
|
|
@ -663,6 +663,9 @@ public:
|
|||
FSectorPortal *ValidatePortal(int which);
|
||||
void CheckPortalPlane(int plane);
|
||||
|
||||
int CheckSpriteGlow(int lightlevel, const DVector3 &pos);
|
||||
bool GetWallGlow(float *topglowcolor, float *bottomglowcolor);
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -477,15 +477,15 @@ public:
|
|||
|
||||
public:
|
||||
|
||||
struct MiscGLInfo
|
||||
struct GLTexInfo
|
||||
{
|
||||
FMaterial *Material[2] = { nullptr, nullptr };
|
||||
FGLTexture *SystemTexture[2] = { nullptr, nullptr };
|
||||
bool bNoExpand = false;
|
||||
|
||||
~MiscGLInfo();
|
||||
~GLTexInfo();
|
||||
};
|
||||
MiscGLInfo gl_info;
|
||||
GLTexInfo gl_info;
|
||||
|
||||
void GetGlowColor(float *data);
|
||||
bool isGlowing() { return bGlowing; }
|
||||
|
|
Loading…
Reference in a new issue