mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 16:07:45 +00:00
- clip sprites to linked sector portal planes.
This is the first part of properly handling those transitions.
This commit is contained in:
parent
990f5a79b4
commit
741f054601
2 changed files with 36 additions and 28 deletions
|
@ -107,6 +107,8 @@ void gl_SetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblend
|
|||
|
||||
CVAR(Bool, gl_nolayer, false, 0)
|
||||
|
||||
static const float LARGE_VALUE = 1e19f;
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -218,30 +220,25 @@ void GLSprite::Draw(int pass)
|
|||
|
||||
//gl_SetColor(lightlevel, rel, Colormap, trans);
|
||||
|
||||
unsigned int iter;
|
||||
|
||||
if (lightlist)
|
||||
unsigned int iter = lightlist? lightlist->Size() : 1;
|
||||
bool clipping = false;
|
||||
if (lightlist || topclip != LARGE_VALUE || bottomclip != -LARGE_VALUE)
|
||||
{
|
||||
iter = lightlist->Size();
|
||||
clipping = true;
|
||||
gl_RenderState.EnableSplit(true);
|
||||
glEnable(GL_CLIP_DISTANCE3);
|
||||
glEnable(GL_CLIP_DISTANCE4);
|
||||
}
|
||||
else
|
||||
{
|
||||
iter = 1;
|
||||
}
|
||||
|
||||
secplane_t bottomp = { { 0, 0, -1. }, bottomclip };
|
||||
secplane_t topp = { { 0, 0, -1. }, topclip };
|
||||
for (unsigned i = 0; i < iter; i++)
|
||||
{
|
||||
if (lightlist)
|
||||
{
|
||||
// set up the light slice
|
||||
static secplane_t bottommost = { {0, 0, 1.}, FLT_MAX };
|
||||
static secplane_t topmost = { { 0, 0, 1. }, -FLT_MAX };
|
||||
|
||||
secplane_t *topplane = i == 0 ? &topmost : &(*lightlist)[i].plane;
|
||||
secplane_t *lowplane = i == (*lightlist).Size() - 1 ? &bottommost : &(*lightlist)[i + 1].plane;
|
||||
secplane_t *topplane = i == 0 ? &topp : &(*lightlist)[i].plane;
|
||||
secplane_t *lowplane = i == (*lightlist).Size() - 1 ? &bottomp : &(*lightlist)[i + 1].plane;
|
||||
|
||||
int thisll = (*lightlist)[i].caster != NULL ? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel;
|
||||
FColormap thiscm;
|
||||
|
@ -255,6 +252,10 @@ void GLSprite::Draw(int pass)
|
|||
gl_SetColor(thisll, rel, thiscm, trans);
|
||||
gl_RenderState.SetSplitPlanes(*topplane, *lowplane);
|
||||
}
|
||||
else if (clipping)
|
||||
{
|
||||
gl_RenderState.SetSplitPlanes(topp, bottomp);
|
||||
}
|
||||
|
||||
if (!modelframe)
|
||||
{
|
||||
|
@ -330,7 +331,7 @@ void GLSprite::Draw(int pass)
|
|||
}
|
||||
}
|
||||
|
||||
if (lightlist)
|
||||
if (clipping)
|
||||
{
|
||||
glDisable(GL_CLIP_DISTANCE3);
|
||||
glDisable(GL_CLIP_DISTANCE4);
|
||||
|
@ -476,7 +477,7 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingp
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void GLSprite::Process(AActor* thing,sector_t * sector)
|
||||
void GLSprite::Process(AActor* thing, sector_t * sector, bool thruportal)
|
||||
{
|
||||
sector_t rs;
|
||||
sector_t * rendersector;
|
||||
|
@ -544,7 +545,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
|
|||
player_t *player = &players[consoleplayer];
|
||||
FloatRect r;
|
||||
|
||||
if (sector->sectornum!=thing->Sector->sectornum)
|
||||
if (sector->sectornum != thing->Sector->sectornum && !thruportal)
|
||||
{
|
||||
rendersector = gl_FakeFlat(thing->Sector, &rs, false);
|
||||
}
|
||||
|
@ -552,6 +553,8 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
|
|||
{
|
||||
rendersector = sector;
|
||||
}
|
||||
topclip = rendersector->PortalBlocksMovement(sector_t::ceiling) ? LARGE_VALUE : rendersector->SkyBoxes[sector_t::ceiling]->specialf1;
|
||||
bottomclip = rendersector->PortalBlocksMovement(sector_t::floor) ? -LARGE_VALUE : rendersector->SkyBoxes[sector_t::floor]->specialf1;
|
||||
|
||||
|
||||
x = thingpos.X;
|
||||
|
@ -892,6 +895,8 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s
|
|||
|
||||
modelframe=NULL;
|
||||
gltexture=NULL;
|
||||
topclip = LARGE_VALUE;
|
||||
bottomclip = -LARGE_VALUE;
|
||||
|
||||
// [BB] Load the texture for round or smooth particles
|
||||
if (gl_particles_style)
|
||||
|
|
|
@ -334,6 +334,9 @@ public:
|
|||
int index;
|
||||
int depth;
|
||||
|
||||
float topclip;
|
||||
float bottomclip;
|
||||
|
||||
float x,y,z; // needed for sorting!
|
||||
|
||||
float ul,ur;
|
||||
|
@ -354,7 +357,7 @@ public:
|
|||
|
||||
void Draw(int pass);
|
||||
void PutSprite(bool translucent);
|
||||
void Process(AActor* thing,sector_t * sector);
|
||||
void Process(AActor* thing,sector_t * sector, bool thruportal = false);
|
||||
void ProcessParticle (particle_t *particle, sector_t *sector);//, int shade, int fakeside)
|
||||
void SetThingColor(PalEntry);
|
||||
|
||||
|
|
Loading…
Reference in a new issue