2021-03-18 20:50:02 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Copyright(C) 2000-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
|
2021-04-02 16:22:54 +00:00
|
|
|
// the Free Software Foundation, either version 2 of the License, or
|
2021-03-18 20:50:02 +00:00
|
|
|
// (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_flat.cpp
|
|
|
|
** Flat processing
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "matrix.h"
|
|
|
|
#include "hw_dynlightdata.h"
|
|
|
|
#include "hw_cvars.h"
|
|
|
|
#include "hw_clock.h"
|
|
|
|
#include "hw_material.h"
|
|
|
|
#include "hw_drawinfo.h"
|
|
|
|
#include "flatvertices.h"
|
|
|
|
#include "hw_lightbuffer.h"
|
|
|
|
#include "hw_drawstructs.h"
|
|
|
|
#include "hw_renderstate.h"
|
2021-03-19 22:11:23 +00:00
|
|
|
#include "sectorgeometry.h"
|
2021-12-15 12:05:13 +00:00
|
|
|
#include "hw_sections.h"
|
2021-03-18 20:50:02 +00:00
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
CVAR(Int, gl_breaksec, -1, 0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
#if 0
|
|
|
|
void HWFlat::SetupLights(HWDrawInfo *di, FLightNode * node, FDynLightData &lightdata, int portalgroup)
|
|
|
|
{
|
|
|
|
Plane p;
|
|
|
|
|
|
|
|
lightdata.Clear();
|
|
|
|
if (renderstyle == STYLE_Add && !di->Level->lightadditivesurfaces)
|
|
|
|
{
|
|
|
|
dynlightindex = -1;
|
|
|
|
return; // no lights on additively blended surfaces.
|
|
|
|
}
|
|
|
|
while (node)
|
|
|
|
{
|
|
|
|
FDynamicLight * light = node->lightsource;
|
|
|
|
|
|
|
|
if (!light->IsActive())
|
|
|
|
{
|
|
|
|
node = node->nextLight;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
iter_dlightf++;
|
|
|
|
|
|
|
|
// we must do the side check here because gl_GetLight needs the correct plane orientation
|
|
|
|
// which we don't have for Legacy-style 3D-floors
|
|
|
|
double planeh = plane.plane.ZatPoint(light->Pos);
|
|
|
|
if ((planeh<light->Z() && ceiling) || (planeh>light->Z() && !ceiling))
|
|
|
|
{
|
|
|
|
node = node->nextLight;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
p.Set(plane.plane.Normal(), plane.plane.fD());
|
|
|
|
draw_dlightf += GetLight(lightdata, portalgroup, p, light, false);
|
|
|
|
node = node->nextLight;
|
|
|
|
}
|
|
|
|
|
|
|
|
dynlightindex = screen->mLights->UploadLights(lightdata);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2021-12-21 12:46:11 +00:00
|
|
|
void HWFlat::MakeVertices(HWDrawInfo* di)
|
2021-03-18 20:50:02 +00:00
|
|
|
{
|
2021-03-26 19:28:44 +00:00
|
|
|
if (vertcount > 0) return;
|
2021-03-28 19:00:24 +00:00
|
|
|
bool canvas = texture->isHardwareCanvas();
|
2021-05-06 22:09:30 +00:00
|
|
|
if (Sprite == nullptr)
|
2021-03-18 20:50:02 +00:00
|
|
|
{
|
2021-12-15 11:23:50 +00:00
|
|
|
TArray<int>* pIndices;
|
2021-12-15 12:08:09 +00:00
|
|
|
auto mesh = sectionGeometry.get(§ions[section], plane, geoofs, &pIndices);
|
2021-12-15 11:23:50 +00:00
|
|
|
|
|
|
|
auto ret = screen->mVertexData->AllocVertices(pIndices->Size());
|
|
|
|
auto vp = ret.first;
|
|
|
|
float base = (plane == 0 ? sec->floorz : sec->ceilingz) * (1 / -256.f);
|
|
|
|
for (unsigned i = 0; i < pIndices->Size(); i++)
|
2021-12-12 15:18:53 +00:00
|
|
|
{
|
2021-12-15 11:23:50 +00:00
|
|
|
auto ii = (*pIndices)[i];
|
|
|
|
auto& pt = mesh->vertices[ii];
|
|
|
|
auto& uv = mesh->texcoords[ii];
|
|
|
|
vp->SetVertex(pt.X, base + pt.Z, pt.Y);
|
|
|
|
vp->SetTexCoord(uv.X, canvas ? 1.f - uv.Y : uv.Y);
|
|
|
|
vp++;
|
2021-03-26 19:28:44 +00:00
|
|
|
}
|
2021-12-15 11:23:50 +00:00
|
|
|
vertindex = ret.second;
|
|
|
|
vertcount = pIndices->Size();
|
2022-01-11 22:51:02 +00:00
|
|
|
normal = mesh->normal;
|
2021-03-26 19:28:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vec2_t pos[4];
|
2021-12-21 12:46:11 +00:00
|
|
|
int ofsz[4];
|
2022-01-01 11:55:28 +00:00
|
|
|
auto cstat = Sprite->cstat;
|
2022-01-04 23:18:31 +00:00
|
|
|
if (tspriteGetSlope(Sprite)) cstat &= ~CSTAT_SPRITE_YFLIP; // NBlood doesn't y-flip slope sprites.
|
2022-02-02 18:49:57 +00:00
|
|
|
GetFlatSpritePosition(Sprite, Sprite->int_pos().vec2, pos, ofsz, true);
|
2022-01-01 11:55:28 +00:00
|
|
|
Sprite->cstat = cstat;
|
2021-03-26 19:28:44 +00:00
|
|
|
|
|
|
|
auto ret = screen->mVertexData->AllocVertices(6);
|
|
|
|
auto vp = ret.first;
|
2021-05-06 22:09:30 +00:00
|
|
|
float x = !(Sprite->cstat & CSTAT_SPRITE_XFLIP) ? 0.f : 1.f;
|
|
|
|
float y = !(Sprite->cstat & CSTAT_SPRITE_YFLIP) ? 0.f : 1.f;
|
2021-12-30 18:00:35 +00:00
|
|
|
if (Sprite->clipdist & TSPR_SLOPESPRITE)
|
2021-12-21 12:46:11 +00:00
|
|
|
{
|
|
|
|
int posx = int(di->Viewpoint.Pos.X * 16.f);
|
|
|
|
int posy = int(di->Viewpoint.Pos.Y * -16.f);
|
|
|
|
int posz = int(di->Viewpoint.Pos.Z * -256.f);
|
|
|
|
|
|
|
|
// Make adjustments for poorly aligned slope sprites on floors or ceilings
|
|
|
|
constexpr float ONPLANE_THRESHOLD = 3.f;
|
|
|
|
if (tspriteGetZOfSlope(Sprite, posx, posy) < posz)
|
|
|
|
{
|
|
|
|
float maxofs = -FLT_MAX, minofs = FLT_MAX;
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
2021-12-22 09:28:51 +00:00
|
|
|
float vz = getceilzofslopeptr(Sprite->sectp, pos[i].X, pos[i].Y) * (1 / -256.f);
|
2021-12-21 12:46:11 +00:00
|
|
|
float sz = z + ofsz[i] * (1 / -256.f);
|
|
|
|
int diff = vz - sz;
|
|
|
|
if (diff > maxofs) maxofs = diff;
|
|
|
|
if (diff < minofs) minofs = diff;
|
|
|
|
}
|
|
|
|
if (maxofs > 0 && minofs >= -ONPLANE_THRESHOLD && maxofs <= ONPLANE_THRESHOLD) z -= maxofs;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float maxofs = -FLT_MAX, minofs = FLT_MAX;
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
2021-12-22 09:28:51 +00:00
|
|
|
float vz = getflorzofslopeptr(Sprite->sectp, pos[i].X, pos[i].Y) * (1 / -256.f);
|
2021-12-21 12:46:11 +00:00
|
|
|
float sz = z + ofsz[i] * (1 / -256.f);
|
|
|
|
int diff = vz - sz;
|
|
|
|
if (diff > maxofs) maxofs = diff;
|
|
|
|
if (diff < minofs) minofs = diff;
|
|
|
|
}
|
|
|
|
if (minofs < 0 && maxofs <= -ONPLANE_THRESHOLD && minofs >= ONPLANE_THRESHOLD) z -= minofs;
|
|
|
|
}
|
|
|
|
}
|
2022-01-11 22:51:02 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (z < di->Viewpoint.Pos.Z) normal = { 0,1,0 };
|
2022-01-11 23:20:04 +00:00
|
|
|
else normal = { 0, -1, 0 };
|
2022-01-11 22:51:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-03 11:31:54 +00:00
|
|
|
unsigned svi = di->SlopeSpriteVertices.Reserve(4);
|
|
|
|
auto svp = &di->SlopeSpriteVertices[svi];
|
|
|
|
|
|
|
|
auto& vpt = di->Viewpoint;
|
2022-02-02 18:49:57 +00:00
|
|
|
depth = (float)((Sprite->int_pos().X * (1/16.f) - vpt.Pos.X) * vpt.TanCos + (Sprite->int_pos().Y * (1 / -16.f) - vpt.Pos.Y) * vpt.TanSin);
|
2022-01-03 11:31:54 +00:00
|
|
|
|
|
|
|
for (unsigned j = 0; j < 4; j++)
|
|
|
|
{
|
|
|
|
svp->SetVertex(pos[j].X * (1 / 16.f), z + ofsz[j] * (1 / -256.f), pos[j].Y * (1 / -16.f));
|
|
|
|
if (!canvas) svp->SetTexCoord(j == 1 || j == 2 ? 1.f - x : x, j == 2 || j == 3 ? 1.f - y : y);
|
|
|
|
else svp->SetTexCoord(j == 1 || j == 2 ? 1.f - x : x, j == 2 || j == 3 ? y : 1.f - y);
|
|
|
|
svp++;
|
|
|
|
}
|
2022-01-11 22:51:02 +00:00
|
|
|
if (Sprite->clipdist & TSPR_SLOPESPRITE)
|
|
|
|
{
|
|
|
|
FVector3 v1 = {
|
|
|
|
di->SlopeSpriteVertices[svi + 1].x - di->SlopeSpriteVertices[svi].x,
|
|
|
|
di->SlopeSpriteVertices[svi + 1].y - di->SlopeSpriteVertices[svi].y,
|
|
|
|
di->SlopeSpriteVertices[svi + 1].z - di->SlopeSpriteVertices[svi].z };
|
|
|
|
FVector3 v2 = {
|
|
|
|
di->SlopeSpriteVertices[svi + 2].x - di->SlopeSpriteVertices[svi].x,
|
|
|
|
di->SlopeSpriteVertices[svi + 2].y - di->SlopeSpriteVertices[svi].y,
|
|
|
|
di->SlopeSpriteVertices[svi + 2].z - di->SlopeSpriteVertices[svi].z };
|
|
|
|
|
|
|
|
normal = (v1 ^ v2).Unit();
|
|
|
|
}
|
2021-03-26 19:28:44 +00:00
|
|
|
for (unsigned i = 0; i < 6; i++)
|
|
|
|
{
|
|
|
|
const static unsigned indices[] = { 0, 1, 2, 0, 2, 3 };
|
2022-01-03 11:31:54 +00:00
|
|
|
*vp++ = di->SlopeSpriteVertices[svi + indices[i]];
|
2021-03-26 19:28:44 +00:00
|
|
|
}
|
2022-01-03 11:31:54 +00:00
|
|
|
slopeindex = svi;
|
|
|
|
slopecount = 4;
|
2021-03-26 19:28:44 +00:00
|
|
|
vertindex = ret.second;
|
|
|
|
vertcount = 6;
|
2021-03-18 20:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
|
|
|
|
{
|
2022-01-13 23:49:57 +00:00
|
|
|
rendered_flats++;
|
2021-05-06 22:09:30 +00:00
|
|
|
if (screen->BuffersArePersistent() && !Sprite)
|
2021-03-18 20:50:02 +00:00
|
|
|
{
|
2021-12-21 12:46:11 +00:00
|
|
|
MakeVertices(di);
|
2021-03-18 20:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
2021-11-11 19:20:00 +00:00
|
|
|
if (sectnum(sec) == gl_breaksec)
|
2021-03-18 20:50:02 +00:00
|
|
|
{
|
|
|
|
int a = 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-01-11 22:51:02 +00:00
|
|
|
state.SetNormal(normal);
|
2022-01-08 11:42:15 +00:00
|
|
|
SetLightAndFog(di, state, fade, palette, shade, visibility, alpha);
|
2021-03-18 20:50:02 +00:00
|
|
|
|
|
|
|
if (translucent)
|
|
|
|
{
|
2021-03-27 22:12:41 +00:00
|
|
|
if (RenderStyle.BlendOp != STYLEOP_Add)
|
|
|
|
{
|
|
|
|
state.EnableBrightmap(false);
|
|
|
|
}
|
|
|
|
|
2021-03-26 19:28:44 +00:00
|
|
|
state.SetRenderStyle(RenderStyle);
|
2021-03-27 22:12:41 +00:00
|
|
|
state.SetTextureMode(RenderStyle);
|
2021-04-08 17:56:18 +00:00
|
|
|
|
2021-04-11 16:38:26 +00:00
|
|
|
if (texture && !checkTranslucentReplacement(texture->GetID(), palette)) state.AlphaFunc(Alpha_GEqual, texture->alphaThreshold);
|
2021-03-18 20:50:02 +00:00
|
|
|
else state.AlphaFunc(Alpha_GEqual, 0.f);
|
|
|
|
}
|
2021-06-01 19:48:39 +00:00
|
|
|
else if (shade > numshades && (GlobalMapFog || (fade & 0xffffff)))
|
|
|
|
{
|
|
|
|
state.SetObjectColor(fade | 0xff000000);
|
|
|
|
state.EnableTexture(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-05-06 22:09:30 +00:00
|
|
|
state.SetMaterial(texture, UF_Texture, 0, Sprite == nullptr? CLAMP_NONE : CLAMP_XY, TRANSLATION(Translation_Remap + curbasepal, palette), -1);
|
2021-03-18 20:50:02 +00:00
|
|
|
|
|
|
|
state.SetLightIndex(dynlightindex);
|
|
|
|
state.Draw(DT_Triangles, vertindex, vertcount);
|
|
|
|
vertexcount += vertcount;
|
|
|
|
|
2021-03-22 11:07:29 +00:00
|
|
|
if (translucent) state.SetRenderStyle(LegacyRenderStyles[STYLE_Translucent]);
|
2021-03-27 22:12:41 +00:00
|
|
|
state.EnableBrightmap(true);
|
|
|
|
|
2021-05-15 08:40:25 +00:00
|
|
|
state.SetObjectColor(0xffffffff);
|
2021-06-01 19:48:39 +00:00
|
|
|
state.EnableTexture(true);
|
2021-03-18 20:50:02 +00:00
|
|
|
//state.SetAddColor(0);
|
|
|
|
//state.ApplyTextureManipulation(nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// HWFlat::PutFlat
|
|
|
|
//
|
|
|
|
// submit to the renderer
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void HWFlat::PutFlat(HWDrawInfo *di, int whichplane)
|
|
|
|
{
|
2021-03-26 19:28:44 +00:00
|
|
|
vertcount = 0;
|
2021-03-19 22:11:23 +00:00
|
|
|
plane = whichplane;
|
2021-05-06 22:09:30 +00:00
|
|
|
if (!screen->BuffersArePersistent() || Sprite || di->ingeo) // should be made static buffer content later (when the logic is working)
|
2021-03-18 20:50:02 +00:00
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
if (di->Level->HasDynamicLights && texture != nullptr && !di->isFullbrightScene() && !(hacktype & (SSRF_PLANEHACK | SSRF_FLOODHACK)))
|
|
|
|
{
|
|
|
|
SetupLights(di, section->lighthead, lightdata, sector->PortalGroup);
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-21 12:46:11 +00:00
|
|
|
MakeVertices(di);
|
2021-03-18 20:50:02 +00:00
|
|
|
}
|
|
|
|
di->AddFlat(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Process a sector's flats for rendering
|
|
|
|
// This function is only called once per sector.
|
|
|
|
// Subsequent subsectors are just quickly added to the ss_renderflags array
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2021-12-15 11:23:50 +00:00
|
|
|
void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, int section_, int which)
|
2021-03-18 20:50:02 +00:00
|
|
|
{
|
|
|
|
#ifdef _DEBUG
|
2021-11-11 19:20:00 +00:00
|
|
|
if (sectnum(sec) == gl_breaksec)
|
2021-03-18 20:50:02 +00:00
|
|
|
{
|
|
|
|
int a = 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
dynlightindex = -1;
|
|
|
|
|
2021-12-29 18:41:41 +00:00
|
|
|
const auto &vp = di->Viewpoint;
|
2021-03-18 20:50:02 +00:00
|
|
|
|
|
|
|
float florz, ceilz;
|
2022-01-27 18:27:27 +00:00
|
|
|
PlanesAtPoint(frontsector, vp.Pos.X, -vp.Pos.Y, &ceilz, &florz);
|
2021-03-18 20:50:02 +00:00
|
|
|
|
|
|
|
visibility = sectorVisibility(frontsector);
|
|
|
|
sec = frontsector;
|
2021-12-15 11:23:50 +00:00
|
|
|
section = section_;
|
2021-05-06 22:09:30 +00:00
|
|
|
Sprite = nullptr;
|
2021-04-02 20:52:46 +00:00
|
|
|
geoofs = di->geoofs;
|
2021-03-18 20:50:02 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// do floors
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
if ((which & SSRF_RENDERFLOOR) && !(frontsector->floorstat & CSTAT_SECTOR_SKY) && florz <= vp.Pos.Z)
|
|
|
|
{
|
|
|
|
// process the original floor first.
|
|
|
|
|
2021-05-20 17:17:21 +00:00
|
|
|
fade = lookups.getFade(frontsector->floorpal);
|
2021-04-21 20:31:56 +00:00
|
|
|
shade = frontsector->floorshade;
|
2021-03-18 20:50:02 +00:00
|
|
|
palette = frontsector->floorpal;
|
2021-03-30 21:27:11 +00:00
|
|
|
stack = frontsector->portalflags == PORTAL_SECTOR_FLOOR || frontsector->portalflags == PORTAL_SECTOR_FLOOR_REFLECT;
|
2021-03-18 20:50:02 +00:00
|
|
|
|
2021-03-30 21:27:11 +00:00
|
|
|
if (stack && (frontsector->floorstat & CSTAT_SECTOR_METHOD))
|
2021-03-18 20:50:02 +00:00
|
|
|
{
|
2021-03-30 21:27:11 +00:00
|
|
|
RenderStyle = GetRenderStyle(0, !!(frontsector->floorstat & CSTAT_SECTOR_TRANS_INVERT));
|
|
|
|
alpha = GetAlphaFromBlend((frontsector->floorstat & CSTAT_SECTOR_TRANS_INVERT) ? DAMETH_TRANS2 : DAMETH_TRANS1, 0);
|
2021-03-18 20:50:02 +00:00
|
|
|
}
|
|
|
|
else
|
2021-03-30 21:27:11 +00:00
|
|
|
{
|
|
|
|
RenderStyle = STYLE_Translucent;
|
|
|
|
alpha = 1.f;
|
|
|
|
}
|
2021-03-18 20:50:02 +00:00
|
|
|
|
|
|
|
if (alpha != 0.f)
|
|
|
|
{
|
|
|
|
int tilenum = frontsector->floorpicnum;
|
2021-12-17 21:36:59 +00:00
|
|
|
gotpic.Set(tilenum);
|
2022-08-05 16:47:35 +00:00
|
|
|
tileUpdatePicnum(&tilenum);
|
2021-03-18 20:50:02 +00:00
|
|
|
texture = tileGetTexture(tilenum);
|
|
|
|
if (texture && texture->isValid())
|
|
|
|
{
|
|
|
|
//iboindex = frontsector->iboindex[sector_t::floor];
|
|
|
|
PutFlat(di, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// do ceilings
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
if ((which & SSRF_RENDERCEILING) && !(frontsector->ceilingstat & CSTAT_SECTOR_SKY) && ceilz >= vp.Pos.Z)
|
|
|
|
{
|
|
|
|
// process the original ceiling first.
|
|
|
|
|
2021-05-20 17:17:21 +00:00
|
|
|
fade = lookups.getFade(frontsector->ceilingpal);
|
2021-04-21 20:31:56 +00:00
|
|
|
shade = frontsector->ceilingshade;
|
2021-03-18 20:50:02 +00:00
|
|
|
palette = frontsector->ceilingpal;
|
2021-03-30 21:27:11 +00:00
|
|
|
stack = frontsector->portalflags == PORTAL_SECTOR_CEILING || frontsector->portalflags == PORTAL_SECTOR_CEILING_REFLECT;
|
2021-03-18 20:50:02 +00:00
|
|
|
|
2021-03-30 21:27:11 +00:00
|
|
|
if (stack && (frontsector->ceilingstat & CSTAT_SECTOR_METHOD))
|
2021-03-18 20:50:02 +00:00
|
|
|
{
|
2021-03-30 21:27:11 +00:00
|
|
|
RenderStyle = GetRenderStyle(0, !!(frontsector->ceilingstat & CSTAT_SECTOR_TRANS_INVERT));
|
|
|
|
alpha = GetAlphaFromBlend((frontsector->ceilingstat & CSTAT_SECTOR_TRANS_INVERT) ? DAMETH_TRANS2 : DAMETH_TRANS1, 0);
|
2021-03-18 20:50:02 +00:00
|
|
|
}
|
2021-03-30 21:27:11 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
RenderStyle = STYLE_Translucent;
|
|
|
|
alpha = 1.f;
|
|
|
|
}
|
|
|
|
|
2021-03-18 20:50:02 +00:00
|
|
|
|
|
|
|
if (alpha != 0.f)
|
|
|
|
{
|
|
|
|
//iboindex = frontsector->iboindex[sector_t::ceiling];
|
|
|
|
|
|
|
|
int tilenum = frontsector->ceilingpicnum;
|
2021-12-17 21:36:59 +00:00
|
|
|
gotpic.Set(tilenum);
|
2022-08-05 16:47:35 +00:00
|
|
|
tileUpdatePicnum(&tilenum);
|
2021-03-18 20:50:02 +00:00
|
|
|
texture = tileGetTexture(tilenum);
|
|
|
|
if (texture && texture->isValid())
|
|
|
|
{
|
|
|
|
//iboindex = frontsector->iboindex[sector_t::floor];
|
|
|
|
PutFlat(di, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-12 15:18:53 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Process a floor sprite
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2021-12-04 18:08:50 +00:00
|
|
|
void HWFlat::ProcessFlatSprite(HWDrawInfo* di, tspritetype* sprite, sectortype* sector)
|
2021-03-26 19:28:44 +00:00
|
|
|
{
|
|
|
|
int tilenum = sprite->picnum;
|
|
|
|
texture = tileGetTexture(tilenum);
|
2022-01-01 19:01:36 +00:00
|
|
|
bool belowfloor = false;
|
2022-02-02 18:49:57 +00:00
|
|
|
if (sprite->int_pos().Z > sprite->sectp->floorz)
|
2022-01-01 19:01:36 +00:00
|
|
|
{
|
|
|
|
belowfloor = true;
|
2022-02-02 19:03:02 +00:00
|
|
|
sprite->__int_pos.Z = sprite->sectp->floorz;
|
2022-01-01 19:01:36 +00:00
|
|
|
}
|
2022-02-02 18:49:57 +00:00
|
|
|
z = sprite->int_pos().Z * (1 / -256.f);
|
2021-03-26 19:28:44 +00:00
|
|
|
if (z == di->Viewpoint.Pos.Z) return; // looking right at the edge.
|
2021-10-11 20:28:26 +00:00
|
|
|
dynlightindex = -1;
|
2021-03-26 19:28:44 +00:00
|
|
|
|
2021-04-14 17:17:40 +00:00
|
|
|
visibility = sectorVisibility(sector) *(4.f / 5.f); // The factor comes directly from Polymost. What is it with Build and these magic factors?
|
2021-03-26 19:28:44 +00:00
|
|
|
|
|
|
|
// Weird Build logic that really makes no sense.
|
2022-01-01 16:27:09 +00:00
|
|
|
if ((sprite->cstat & CSTAT_SPRITE_ONE_SIDE) != 0)
|
|
|
|
{
|
|
|
|
double myz = !(sprite->clipdist & TSPR_SLOPESPRITE) ? z :
|
|
|
|
tspriteGetZOfSlope(sprite, int(di->Viewpoint.Pos.X * 16), int(di->Viewpoint.Pos.Y * -16)) * -(1. / 256.);
|
|
|
|
if ((di->Viewpoint.Pos.Z < myz) == ((sprite->cstat & CSTAT_SPRITE_YFLIP) == 0))
|
|
|
|
return;
|
|
|
|
}
|
2021-03-26 19:28:44 +00:00
|
|
|
|
|
|
|
if (texture && texture->isValid())
|
|
|
|
{
|
2021-05-06 22:09:30 +00:00
|
|
|
this->Sprite = sprite;
|
2021-03-26 19:28:44 +00:00
|
|
|
sec = sector;
|
2021-04-21 20:31:56 +00:00
|
|
|
shade = sprite->shade;
|
2021-03-26 19:28:44 +00:00
|
|
|
palette = sprite->pal;
|
2021-04-14 17:17:40 +00:00
|
|
|
fade = lookups.getFade(sector->floorpal); // fog is per sector.
|
2021-03-26 19:28:44 +00:00
|
|
|
|
2021-04-08 17:45:18 +00:00
|
|
|
SetSpriteTranslucency(sprite, alpha, RenderStyle);
|
2022-01-01 19:01:36 +00:00
|
|
|
if (belowfloor) alpha *= 0.33f;
|
2021-04-08 17:45:18 +00:00
|
|
|
|
2021-06-02 18:32:35 +00:00
|
|
|
PutFlat(di, z > di->Viewpoint.Pos.Z);
|
2021-03-26 19:28:44 +00:00
|
|
|
}
|
|
|
|
}
|