mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-09 09:10:51 +00:00
Add lightmaps to 3D floors
This commit is contained in:
parent
3f3769afdb
commit
934b5af975
4 changed files with 49 additions and 29 deletions
|
@ -3274,14 +3274,15 @@ void MapLoader::LoadLevel(MapData *map, const char *lumpname, int position)
|
|||
|
||||
void MapLoader::SetSubsectorLightmap(const LightmapSurface &surface)
|
||||
{
|
||||
int index = surface.Type == ST_CEILING ? 1 : 0;
|
||||
if (!surface.ControlSector)
|
||||
{
|
||||
int index = surface.Type == ST_CEILING ? 1 : 0;
|
||||
surface.Subsector->lightmap[index][0] = surface;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto& ffloors = surface.Subsector->sector->e->XFloor.ffloors;
|
||||
int index = surface.Type == ST_CEILING ? 0 : 1;
|
||||
const auto &ffloors = surface.Subsector->sector->e->XFloor.ffloors;
|
||||
for (unsigned int i = 0; i < ffloors.Size(); i++)
|
||||
{
|
||||
if (ffloors[i]->model == surface.ControlSector)
|
||||
|
@ -3294,18 +3295,20 @@ void MapLoader::SetSubsectorLightmap(const LightmapSurface &surface)
|
|||
|
||||
void MapLoader::SetSideLightmap(const LightmapSurface &surface)
|
||||
{
|
||||
int index = 0;
|
||||
switch (surface.Type)
|
||||
{
|
||||
default:
|
||||
case ST_MIDDLEWALL: index = 1; break;
|
||||
case ST_UPPERWALL: index = 0; break;
|
||||
case ST_LOWERWALL: index = 3; break;
|
||||
}
|
||||
|
||||
if (!surface.ControlSector)
|
||||
{
|
||||
int index = 0;
|
||||
switch (surface.Type)
|
||||
{
|
||||
default:
|
||||
case ST_MIDDLEWALL: index = 1; break;
|
||||
case ST_UPPERWALL: index = 0; break;
|
||||
case ST_LOWERWALL: index = 3; break;
|
||||
}
|
||||
|
||||
surface.Side->lightmap[index][0] = surface;
|
||||
if (surface.Type == ST_MIDDLEWALL)
|
||||
surface.Side->lightmap[index + 1][0] = surface;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3314,7 +3317,7 @@ void MapLoader::SetSideLightmap(const LightmapSurface &surface)
|
|||
{
|
||||
if (ffloors[i]->model == surface.ControlSector)
|
||||
{
|
||||
surface.Side->lightmap[index][i + 1] = surface;
|
||||
surface.Side->lightmap[1][i + 1] = surface;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,6 +154,7 @@ public:
|
|||
vertex_t * vertexes[2]; // required for polygon splitting
|
||||
FGameTexture *texture;
|
||||
TArray<lightlist_t> *lightlist;
|
||||
LightmapSurface *lightmap;
|
||||
|
||||
HWSeg glseg;
|
||||
float ztop[2],zbottom[2];
|
||||
|
@ -238,13 +239,13 @@ public:
|
|||
|
||||
void GetPlanePos(F3DFloor::planeref * planeref, float & left, float & right);
|
||||
|
||||
void BuildFFBlock(HWDrawInfo *di, seg_t * seg, F3DFloor * rover,
|
||||
void BuildFFBlock(HWDrawInfo *di, seg_t * seg, F3DFloor * rover, int roverIndex,
|
||||
float ff_topleft, float ff_topright,
|
||||
float ff_bottomleft, float ff_bottomright);
|
||||
void InverseFloors(HWDrawInfo *di, seg_t * seg, sector_t * frontsector,
|
||||
float topleft, float topright,
|
||||
float bottomleft, float bottomright);
|
||||
void ClipFFloors(HWDrawInfo *di, seg_t * seg, F3DFloor * ffloor, sector_t * frontsector,
|
||||
void ClipFFloors(HWDrawInfo *di, seg_t * seg, F3DFloor * ffloor, int ffloorIndex, sector_t * frontsector,
|
||||
float topleft, float topright,
|
||||
float bottomleft, float bottomright);
|
||||
void DoFFloorBlocks(HWDrawInfo *di, seg_t * seg, sector_t * frontsector, sector_t * backsector,
|
||||
|
|
|
@ -1216,6 +1216,15 @@ void HWWall::DoTexture(HWDrawInfo *di, int _type,seg_t * seg, int peg,
|
|||
|
||||
type = _type;
|
||||
|
||||
if (type >= RENDERWALL_TOP && type <= RENDERWALL_BOTTOM)
|
||||
{
|
||||
lightmap = seg->sidedef->lightmap[type - RENDERWALL_TOP];
|
||||
}
|
||||
else
|
||||
{
|
||||
lightmap = nullptr;
|
||||
}
|
||||
|
||||
float floatceilingref = ceilingrefheight + tci.RowOffset(seg->sidedef->GetTextureYOffset(texpos));
|
||||
if (peg) floatceilingref += tci.mRenderHeight - flh - v_offset;
|
||||
|
||||
|
@ -1583,7 +1592,7 @@ void HWWall::DoMidTexture(HWDrawInfo *di, seg_t * seg, bool drawfogboundary,
|
|||
//
|
||||
//
|
||||
//==========================================================================
|
||||
void HWWall::BuildFFBlock(HWDrawInfo *di, seg_t * seg, F3DFloor * rover,
|
||||
void HWWall::BuildFFBlock(HWDrawInfo *di, seg_t * seg, F3DFloor * rover, int roverIndex,
|
||||
float ff_topleft, float ff_topright,
|
||||
float ff_bottomleft, float ff_bottomright)
|
||||
{
|
||||
|
@ -1676,6 +1685,15 @@ void HWWall::BuildFFBlock(HWDrawInfo *di, seg_t * seg, F3DFloor * rover,
|
|||
translucent = false;
|
||||
}
|
||||
|
||||
LightmapSurface *surf = nullptr;
|
||||
if (seg->sidedef == seg->linedef->sidedef[0])
|
||||
surf = seg->linedef->sidedef[1]->lightmap[1];
|
||||
else
|
||||
surf = seg->linedef->sidedef[0]->lightmap[1];
|
||||
|
||||
if (surf)
|
||||
lightmap = &surf[1 + roverIndex];
|
||||
|
||||
sector_t * sec = sub ? sub->sector : seg->frontsector;
|
||||
|
||||
if (sec->e->XFloor.lightlist.Size() == 0 || di->isFullbrightScene()) PutWall(di, translucent);
|
||||
|
@ -1744,7 +1762,7 @@ void HWWall::InverseFloors(HWDrawInfo *di, seg_t * seg, sector_t * frontsector,
|
|||
}
|
||||
if (ff_topleft < ff_bottomleft || ff_topright < ff_bottomright) continue;
|
||||
|
||||
BuildFFBlock(di, seg, rover, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright);
|
||||
BuildFFBlock(di, seg, rover, i, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright);
|
||||
topleft = ff_bottomleft;
|
||||
topright = ff_bottomright;
|
||||
|
||||
|
@ -1757,7 +1775,7 @@ void HWWall::InverseFloors(HWDrawInfo *di, seg_t * seg, sector_t * frontsector,
|
|||
//
|
||||
//
|
||||
//==========================================================================
|
||||
void HWWall::ClipFFloors(HWDrawInfo *di, seg_t * seg, F3DFloor * ffloor, sector_t * frontsector,
|
||||
void HWWall::ClipFFloors(HWDrawInfo *di, seg_t * seg, F3DFloor * ffloor, int ffloorIndex, sector_t * frontsector,
|
||||
float topleft, float topright,
|
||||
float bottomleft, float bottomright)
|
||||
{
|
||||
|
@ -1808,7 +1826,7 @@ void HWWall::ClipFFloors(HWDrawInfo *di, seg_t * seg, F3DFloor * ffloor, sector_
|
|||
}
|
||||
else if (ff_topleft <= topleft && ff_topright <= topright)
|
||||
{
|
||||
BuildFFBlock(di, seg, ffloor, topleft, topright, ff_topleft, ff_topright);
|
||||
BuildFFBlock(di, seg, ffloor, ffloorIndex, topleft, topright, ff_topleft, ff_topright);
|
||||
if (ff_bottomleft <= bottomleft && ff_bottomright <= bottomright) return;
|
||||
topleft = ff_bottomleft;
|
||||
topright = ff_bottomright;
|
||||
|
@ -1823,7 +1841,7 @@ void HWWall::ClipFFloors(HWDrawInfo *di, seg_t * seg, F3DFloor * ffloor, sector_
|
|||
|
||||
done:
|
||||
// if the program reaches here there is one block left to draw
|
||||
BuildFFBlock(di, seg, ffloor, topleft, topright, bottomleft, bottomright);
|
||||
BuildFFBlock(di, seg, ffloor, ffloorIndex, topleft, topright, bottomleft, bottomright);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -1897,9 +1915,9 @@ void HWWall::DoFFloorBlocks(HWDrawInfo *di, seg_t * seg, sector_t * frontsector,
|
|||
|
||||
// if translucent or liquid clip away adjoining parts of the same type of FFloors on the other side
|
||||
if (rover->flags&(FF_SWIMMABLE | FF_TRANSLUCENT))
|
||||
ClipFFloors(di, seg, rover, frontsector, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright);
|
||||
ClipFFloors(di, seg, rover, i, frontsector, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright);
|
||||
else
|
||||
BuildFFBlock(di, seg, rover, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright);
|
||||
BuildFFBlock(di, seg, rover, i, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright);
|
||||
|
||||
topleft = ff_bottomleft;
|
||||
topright = ff_bottomright;
|
||||
|
@ -1940,6 +1958,8 @@ void HWWall::Process(HWDrawInfo *di, seg_t *seg, sector_t * frontsector, sector_
|
|||
}
|
||||
#endif
|
||||
|
||||
lightmap = nullptr;
|
||||
|
||||
// note: we always have a valid sidedef and linedef reference when getting here.
|
||||
|
||||
this->seg = seg;
|
||||
|
|
|
@ -194,16 +194,12 @@ static float ZeroLightmapUVs[8] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.
|
|||
|
||||
int HWWall::CreateVertices(FFlatVertex *&ptr, bool split)
|
||||
{
|
||||
float *lightuv = ZeroLightmapUVs;
|
||||
float* lightuv = ZeroLightmapUVs;
|
||||
float lindex = -1.0f;
|
||||
if (seg && seg->sidedef && type >= RENDERWALL_TOP && type <= RENDERWALL_BOTTOM)
|
||||
if (lightmap && lightmap->Type != ST_NULL)
|
||||
{
|
||||
LightmapSurface *lightmap = seg->sidedef->lightmap[type - RENDERWALL_TOP];
|
||||
if (lightmap != nullptr && lightmap->Type != ST_NULL)
|
||||
{
|
||||
lightuv = lightmap->TexCoords;
|
||||
lindex = (float)lightmap->LightmapNum;
|
||||
}
|
||||
lightuv = lightmap->TexCoords;
|
||||
lindex = (float)lightmap->LightmapNum;
|
||||
}
|
||||
|
||||
auto oo = ptr;
|
||||
|
|
Loading…
Reference in a new issue