Rename lightmap fields to surface as it is being used for more than lightmaps now

This commit is contained in:
Magnus Norddahl 2023-10-25 18:43:36 +02:00
commit 9f963e2c06
10 changed files with 55 additions and 55 deletions

View file

@ -465,7 +465,7 @@ public:
// Lightmaps
bool lightmaps = false;
TArray<DoomLevelMeshSurface*> LMSurfaces;
TArray<DoomLevelMeshSurface*> Surfaces;
FVector3 SunDirection;
FVector3 SunColor;
uint16_t LightmapSampleDistance;

View file

@ -1256,7 +1256,7 @@ struct side_t
uint16_t Flags;
int UDMFIndex; // needed to access custom UDMF fields which are stored in loading order.
FLightNode * lighthead; // all dynamic lights that may affect this wall
TArrayView<DoomLevelMeshSurface*> lightmap; // all mesh surfaces belonging to this sidedef. Used for lightmapping
TArrayView<DoomLevelMeshSurface*> surface; // all mesh surfaces belonging to this sidedef
seg_t **segs; // all segs belonging to this sidedef in ascending order. Used for precise rendering
int numsegs;
int sidenum;
@ -1673,7 +1673,7 @@ struct subsector_t
// 2: has one-sided walls
FPortalCoverage portalcoverage[2];
TArrayView<DoomLevelMeshSurface*> lightmap[2]; // all mesh surfaces belonging to this subsector. Used for lightmapping
TArrayView<DoomLevelMeshSurface*> surface[2]; // all mesh surfaces belonging to this subsector
};

View file

@ -2989,22 +2989,22 @@ void MapLoader::InitLevelMesh(MapData* map)
for (unsigned int i = 0; i < Level->subsectors.Size(); i++)
allSurfaces += 2 + Level->subsectors[i].sector->e->XFloor.ffloors.Size() * 2;
Level->LMSurfaces.Resize(allSurfaces);
memset(Level->LMSurfaces.Data(), 0, sizeof(DoomLevelMeshSurface*) * allSurfaces);
Level->Surfaces.Resize(allSurfaces);
memset(Level->Surfaces.Data(), 0, sizeof(DoomLevelMeshSurface*) * allSurfaces);
unsigned int offset = 0;
for (unsigned int i = 0; i < Level->sides.Size(); i++)
{
auto& side = Level->sides[i];
side.lightmap = &Level->LMSurfaces[offset];
side.surface = &Level->Surfaces[offset];
offset += 4 + side.sector->e->XFloor.ffloors.Size();
}
for (unsigned int i = 0; i < Level->subsectors.Size(); i++)
{
auto& subsector = Level->subsectors[i];
unsigned int count = 1 + subsector.sector->e->XFloor.ffloors.Size();
subsector.lightmap[0] = &Level->LMSurfaces[offset];
subsector.lightmap[1] = &Level->LMSurfaces[offset + count];
subsector.surface[0] = &Level->Surfaces[offset];
subsector.surface[1] = &Level->Surfaces[offset + count];
offset += count * 2;
}
@ -3110,7 +3110,7 @@ bool MapLoader::LoadLightmap(MapData* map)
{
surface.NeedsUpdate = false; // let's consider everything valid until we make a mistake trying to change this surface
if (surface.Type > ST_UNKNOWN && surface.Type <= ST_FLOOR)
if (surface.Type > ST_NONE && surface.Type <= ST_FLOOR)
{
if (auto list = surfaceGroups[surface.Type - 1].CheckKey(surface.TypeIndex))
{
@ -3140,7 +3140,7 @@ bool MapLoader::LoadLightmap(MapData* map)
// Check against the internal levelmesh
if (surface.type <= ST_UNKNOWN || surface.type > ST_FLOOR)
if (surface.type <= ST_NONE || surface.type > ST_FLOOR)
{
errors = true;
if (developer >= 1)

View file

@ -281,8 +281,8 @@ void DoomLevelMesh::DumpMesh(const FString& objFilename, const FString& mtlFilen
return "upperside";
case ST_MIDDLESIDE:
return "middleside";
case ST_UNKNOWN:
return "unknown";
case ST_NONE:
return "none";
default:
break;
}

View file

@ -68,11 +68,11 @@ void DoomLevelSubmesh::UpdateDynamic(FLevelLocals& doomMap, int lightmapStartInd
if (isPolyLine)
{
// Make sure we have a lightmap array on the polyobj sidedef
if (!side->lightmap)
if (!side->surface)
{
auto array = std::make_unique<DoomLevelMeshSurface*[]>(4);
memset(array.get(), 0, sizeof(DoomLevelMeshSurface*));
side->lightmap = array.get();
side->surface = array.get();
PolyLMSurfaces.Push(std::move(array));
}
@ -334,7 +334,7 @@ void DoomLevelSubmesh::SetSubsectorLightmap(DoomLevelMeshSurface* surface)
if (!surface->ControlSector)
{
int index = surface->Type == ST_CEILING ? 1 : 0;
surface->Subsector->lightmap[index][0] = surface;
surface->Subsector->surface[index][0] = surface;
}
else
{
@ -344,7 +344,7 @@ void DoomLevelSubmesh::SetSubsectorLightmap(DoomLevelMeshSurface* surface)
{
if (ffloors[i]->model == surface->ControlSector)
{
surface->Subsector->lightmap[index][i + 1] = surface;
surface->Subsector->surface[index][i + 1] = surface;
}
}
}
@ -356,16 +356,16 @@ void DoomLevelSubmesh::SetSideLightmap(DoomLevelMeshSurface* surface)
{
if (surface->Type == ST_UPPERSIDE)
{
surface->Side->lightmap[0] = surface;
surface->Side->surface[0] = surface;
}
else if (surface->Type == ST_MIDDLESIDE)
{
surface->Side->lightmap[1] = surface;
surface->Side->lightmap[2] = surface;
surface->Side->surface[1] = surface;
surface->Side->surface[2] = surface;
}
else if (surface->Type == ST_LOWERSIDE)
{
surface->Side->lightmap[3] = surface;
surface->Side->surface[3] = surface;
}
}
else
@ -375,7 +375,7 @@ void DoomLevelSubmesh::SetSideLightmap(DoomLevelMeshSurface* surface)
{
if (ffloors[i]->model == surface->ControlSector)
{
surface->Side->lightmap[4 + i] = surface;
surface->Side->surface[4 + i] = surface;
}
}
}

View file

@ -16,7 +16,7 @@ struct FPolyObj;
enum DoomLevelMeshSurfaceType
{
ST_UNKNOWN,
ST_NONE,
ST_MIDDLESIDE,
ST_UPPERSIDE,
ST_LOWERSIDE,
@ -26,7 +26,7 @@ enum DoomLevelMeshSurfaceType
struct DoomLevelMeshSurface : public LevelMeshSurface
{
DoomLevelMeshSurfaceType Type = ST_UNKNOWN;
DoomLevelMeshSurfaceType Type = ST_NONE;
int TypeIndex = 0;
subsector_t* Subsector = nullptr;

View file

@ -243,8 +243,8 @@ static int CreateIndexedSectorVerticesLM(FRenderState& renderstate, sector_t* se
for(auto& sub : section.subsectors)
{
// vertices
DoomLevelMeshSurface* lightmap = sub->lightmap[h].Size() > lightmapIndex ? sub->lightmap[h][lightmapIndex] : nullptr;
if (lightmap && lightmap->Type != ST_UNKNOWN) // lightmap may be missing if the subsector is degenerate triangle
DoomLevelMeshSurface* lightmap = sub->surface[h].Size() > lightmapIndex ? sub->surface[h][lightmapIndex] : nullptr;
if (lightmap && lightmap->Type != ST_NONE) // surface may be missing if the subsector is degenerate triangle
{
FFlatVertex* luvs = lightmap->Vertices;
for (unsigned int j = 0; j < sub->numlines; j++)

View file

@ -162,7 +162,7 @@ public:
vertex_t* vertexes[2]; // required for polygon splitting
FGameTexture* texture;
TArray<lightlist_t>* lightlist;
DoomLevelMeshSurface* lightmap;
DoomLevelMeshSurface* surface;
HWSeg glseg;
float ztop[2], zbottom[2];

View file

@ -522,9 +522,9 @@ void HWFlat::ProcessSector(HWDrawInfo *di, FRenderState& state, sector_t * front
unsigned int count = sector->e->XFloor.ffloors.Size() + 1;
for (unsigned int j = 0; j < count; j++)
{
if (auto lightmap = sector->subsectors[i]->lightmap[plane].Size() > j ? sector->subsectors[i]->lightmap[plane][j] : nullptr)
if (auto surface = sector->subsectors[i]->surface[plane].Size() > j ? sector->subsectors[i]->surface[plane][j] : nullptr)
{
di->PushVisibleSurface(lightmap);
di->PushVisibleSurface(surface);
}
}
}

View file

@ -918,13 +918,13 @@ bool HWWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto
}
texcoord srclightuv[4];
if (lightmap && lightmap->Type != ST_UNKNOWN)
if (surface && surface->Type != ST_NONE)
{
srclightuv[0] = { lightmap->Vertices[0].lu, lightmap->Vertices[0].lv };
srclightuv[1] = { lightmap->Vertices[1].lu, lightmap->Vertices[1].lv };
srclightuv[2] = { lightmap->Vertices[2].lu, lightmap->Vertices[2].lv };
srclightuv[3] = { lightmap->Vertices[3].lu, lightmap->Vertices[3].lv };
lindex = lightmap->Vertices[0].lindex;
srclightuv[0] = { surface->Vertices[0].lu, surface->Vertices[0].lv };
srclightuv[1] = { surface->Vertices[1].lu, surface->Vertices[1].lv };
srclightuv[2] = { surface->Vertices[2].lu, surface->Vertices[2].lv };
srclightuv[3] = { surface->Vertices[3].lu, surface->Vertices[3].lv };
lindex = surface->Vertices[0].lindex;
}
else
{
@ -1170,17 +1170,17 @@ void HWWall::DoTexture(HWWallDispatcher *di, FRenderState& state, int _type,seg_
type = _type;
if (seg->sidedef->lightmap.Size() >= 4 && type >= RENDERWALL_TOP && type <= RENDERWALL_BOTTOM)
if (seg->sidedef->surface.Size() >= 4 && type >= RENDERWALL_TOP && type <= RENDERWALL_BOTTOM)
{
lightmap = seg->sidedef->lightmap[type - RENDERWALL_TOP];
if (lightmap && di->di)
surface = seg->sidedef->surface[type - RENDERWALL_TOP];
if (surface && di->di)
{
di->di->PushVisibleSurface(lightmap);
di->di->PushVisibleSurface(surface);
}
}
else
{
lightmap = nullptr;
surface = nullptr;
}
float floatceilingref = ceilingrefheight + tci.RowOffset(seg->sidedef->GetTextureYOffset(texpos));
@ -1237,12 +1237,12 @@ void HWWall::DoMidTexture(HWWallDispatcher *di, FRenderState& state, seg_t * seg
//
if (texture)
{
if (seg->sidedef->lightmap.Size() >= 4)
if (seg->sidedef->surface.Size() >= 4)
{
lightmap = seg->sidedef->lightmap[side_t::mid];
if (lightmap && di->di)
surface = seg->sidedef->surface[side_t::mid];
if (surface && di->di)
{
di->di->PushVisibleSurface(lightmap);
di->di->PushVisibleSurface(surface);
}
}
@ -1575,15 +1575,15 @@ void HWWall::BuildFFBlock(HWWallDispatcher *di, FRenderState& state, seg_t * seg
float texlength;
FTexCoordInfo tci;
lightmap = nullptr;
surface = nullptr;
if (seg->sidedef == seg->linedef->sidedef[0])
lightmap = seg->linedef->sidedef[1]->lightmap.Size() > 4 + roverIndex ? seg->linedef->sidedef[1]->lightmap[4 + roverIndex] : nullptr;
surface = seg->linedef->sidedef[1]->surface.Size() > 4 + roverIndex ? seg->linedef->sidedef[1]->surface[4 + roverIndex] : nullptr;
else
lightmap = seg->linedef->sidedef[0]->lightmap.Size() > 4 + roverIndex ? seg->linedef->sidedef[0]->lightmap[4 + roverIndex] : nullptr;
surface = seg->linedef->sidedef[0]->surface.Size() > 4 + roverIndex ? seg->linedef->sidedef[0]->surface[4 + roverIndex] : nullptr;
if (lightmap && di->di)
if (surface && di->di)
{
di->di->PushVisibleSurface(lightmap);
di->di->PushVisibleSurface(surface);
}
if (rover->flags&FF_FOG)
@ -1646,13 +1646,13 @@ void HWWall::BuildFFBlock(HWWallDispatcher *di, FRenderState& state, seg_t * seg
CheckTexturePosition(&tci);
texcoord srclightuv[4];
if (lightmap && lightmap->Type != ST_UNKNOWN)
if (surface && surface->Type != ST_NONE)
{
srclightuv[0] = { lightmap->Vertices[0].lu, lightmap->Vertices[0].lv };
srclightuv[1] = { lightmap->Vertices[1].lu, lightmap->Vertices[1].lv };
srclightuv[2] = { lightmap->Vertices[2].lu, lightmap->Vertices[2].lv };
srclightuv[3] = { lightmap->Vertices[3].lu, lightmap->Vertices[3].lv };
lindex = lightmap->Vertices[0].lindex;
srclightuv[0] = { surface->Vertices[0].lu, surface->Vertices[0].lv };
srclightuv[1] = { surface->Vertices[1].lu, surface->Vertices[1].lv };
srclightuv[2] = { surface->Vertices[2].lu, surface->Vertices[2].lv };
srclightuv[3] = { surface->Vertices[3].lu, surface->Vertices[3].lv };
lindex = surface->Vertices[0].lindex;
}
else
{
@ -1977,7 +1977,7 @@ void HWWall::Process(HWWallDispatcher *di, FRenderState& state, seg_t *seg, sect
}
#endif
lightmap = nullptr;
surface = nullptr;
// note: we always have a valid sidedef and linedef reference when getting here.