- removed the subsector light lists as a preparation step to move over the light traversal code to use sections instead of subsectors.

This commit is contained in:
Christoph Oelckers 2018-11-05 22:35:24 +01:00
parent 375dd7e28f
commit 9ddca3c3a9
9 changed files with 12 additions and 58 deletions

View File

@ -574,7 +574,7 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &opos, subsector_t *subSe
{ {
subSec = collected_ss[i].sub; subSec = collected_ss[i].sub;
touching_subsectors = AddLightNode(&subSec->lighthead, subSec, this, touching_subsectors); //touching_subsectors = AddLightNode(&subSec->lighthead, subSec, this, touching_subsectors);
if (subSec->sector->validcount != ::validcount) if (subSec->sector->validcount != ::validcount)
{ {
touching_sector = AddLightNode(&subSec->render_sector->lighthead, subSec->sector, this, touching_sector); touching_sector = AddLightNode(&subSec->render_sector->lighthead, subSec->sector, this, touching_sector);
@ -682,12 +682,6 @@ void ADynamicLight::LinkLight()
{ {
node->lightsource = NULL; node->lightsource = NULL;
node = node->nextTarget; node = node->nextTarget;
}
node = touching_subsectors;
while (node)
{
node->lightsource = NULL;
node = node->nextTarget;
} }
node = touching_sector; node = touching_sector;
while (node) while (node)
@ -719,17 +713,6 @@ void ADynamicLight::LinkLight()
node = node->nextTarget; node = node->nextTarget;
} }
node = touching_subsectors;
while (node)
{
if (node->lightsource == NULL)
{
node = DeleteLightNode(node);
}
else
node = node->nextTarget;
}
node = touching_sector; node = touching_sector;
while (node) while (node)
{ {
@ -763,7 +746,6 @@ void ADynamicLight::UnlinkLight ()
} }
} }
while (touching_sides) touching_sides = DeleteLightNode(touching_sides); while (touching_sides) touching_sides = DeleteLightNode(touching_sides);
while (touching_subsectors) touching_subsectors = DeleteLightNode(touching_subsectors);
while (touching_sector) touching_sector = DeleteLightNode(touching_sector); while (touching_sector) touching_sector = DeleteLightNode(touching_sector);
shadowmapped = false; shadowmapped = false;
} }
@ -918,7 +900,7 @@ void AActor::RecreateAllAttachedLights()
CCMD(listlights) CCMD(listlights)
{ {
int walls, sectors, subsecs; int walls, sectors;
int allwalls=0, allsectors=0, allsubsecs = 0; int allwalls=0, allsectors=0, allsubsecs = 0;
int i=0, shadowcount = 0; int i=0, shadowcount = 0;
ADynamicLight * dl; ADynamicLight * dl;
@ -928,7 +910,6 @@ CCMD(listlights)
{ {
walls=0; walls=0;
sectors=0; sectors=0;
subsecs = 0;
Printf("%s at (%f, %f, %f), color = 0x%02x%02x%02x, radius = %f %s %s", Printf("%s at (%f, %f, %f), color = 0x%02x%02x%02x, radius = %f %s %s",
dl->target? dl->target->GetClass()->TypeName.GetChars() : dl->GetClass()->TypeName.GetChars(), dl->target? dl->target->GetClass()->TypeName.GetChars() : dl->GetClass()->TypeName.GetChars(),
dl->X(), dl->Y(), dl->Z(), dl->args[LIGHT_RED], dl->X(), dl->Y(), dl->Z(), dl->args[LIGHT_RED],
@ -954,14 +935,6 @@ CCMD(listlights)
node = node->nextTarget; node = node->nextTarget;
} }
node=dl->touching_subsectors;
while (node)
{
allsubsecs++;
subsecs++;
node = node->nextTarget;
}
node = dl->touching_sector; node = dl->touching_sector;
@ -971,27 +944,10 @@ CCMD(listlights)
sectors++; sectors++;
node = node->nextTarget; node = node->nextTarget;
} }
Printf("- %d walls, %d subsectors, %d sectors\n", walls, subsecs, sectors); Printf("- %d walls, %d sectors\n", walls, sectors);
} }
Printf("%i dynamic lights, %d shadowmapped, %d walls, %d subsectors, %d sectors\n\n\n", i, shadowcount, allwalls, allsubsecs, allsectors); Printf("%i dynamic lights, %d shadowmapped, %d walls, %d sectors\n\n\n", i, shadowcount, allwalls, allsectors);
}
CCMD(listsublights)
{
for(auto &sub : level.subsectors)
{
int lights = 0;
FLightNode * node = sub.lighthead;
while (node != NULL)
{
lights++;
node = node->nextLight;
}
Printf(PRINT_LOG, "Subsector %d - %d lights\n", sub.Index(), lights);
}
} }

View File

@ -206,7 +206,6 @@ public:
bool IsSpot() { return !!(lightflags & LF_SPOT); } bool IsSpot() { return !!(lightflags & LF_SPOT); }
FState *targetState; FState *targetState;
FLightNode * touching_sides; FLightNode * touching_sides;
FLightNode * touching_subsectors;
FLightNode * touching_sector; FLightNode * touching_sector;
private: private:

View File

@ -54,7 +54,7 @@ int HWDrawInfo::SetupLightsForOtherPlane(subsector_t * sub, FDynLightData &light
if (level.HasDynamicLights && !isFullbrightScene()) if (level.HasDynamicLights && !isFullbrightScene())
{ {
Plane p; Plane p;
FLightNode * node = sub->lighthead; FLightNode * node = sub->sector->lighthead;
lightdata.Clear(); lightdata.Clear();
while (node) while (node)

View File

@ -131,11 +131,11 @@ void HWDrawInfo::GetDynSpriteLight(AActor *thing, particle_t *particle, float *o
{ {
if (thing != NULL) if (thing != NULL)
{ {
GetDynSpriteLight(thing, (float)thing->X(), (float)thing->Y(), (float)thing->Center(), thing->subsector->lighthead, thing->Sector->PortalGroup, out); GetDynSpriteLight(thing, (float)thing->X(), (float)thing->Y(), (float)thing->Center(), thing->Sector->lighthead, thing->Sector->PortalGroup, out);
} }
else if (particle != NULL) else if (particle != NULL)
{ {
GetDynSpriteLight(NULL, (float)particle->Pos.X, (float)particle->Pos.Y, (float)particle->Pos.Z, particle->subsector->lighthead, particle->subsector->sector->PortalGroup, out); GetDynSpriteLight(NULL, (float)particle->Pos.X, (float)particle->Pos.Y, (float)particle->Pos.Z, particle->subsector->sector->lighthead, particle->subsector->sector->PortalGroup, out);
} }
} }
@ -160,7 +160,7 @@ void hw_GetDynModelLight(AActor *self, FDynLightData &modellightdata)
BSPWalkCircle(x, y, radiusSquared, [&](subsector_t *subsector) // Iterate through all subsectors potentially touched by actor BSPWalkCircle(x, y, radiusSquared, [&](subsector_t *subsector) // Iterate through all subsectors potentially touched by actor
{ {
FLightNode * node = subsector->lighthead; FLightNode * node = subsector->sector->lighthead;
while (node) // check all lights touching a subsector while (node) // check all lights touching a subsector
{ {
ADynamicLight *light = node->lightsource; ADynamicLight *light = node->lightsource;

View File

@ -302,7 +302,7 @@ void GLWall::SetupLights(HWDrawInfo *di, FDynLightData &lightdata)
else if (sub) else if (sub)
{ {
// Polobject segs cannot be checked per sidedef so use the subsector instead. // Polobject segs cannot be checked per sidedef so use the subsector instead.
node = sub->lighthead; node = sub->sector->lighthead;
} }
else node = NULL; else node = NULL;

View File

@ -70,7 +70,7 @@ void PolyModelRenderer::AddLights(AActor *actor)
BSPWalkCircle(x, y, radiusSquared, [&](subsector_t *subsector) // Iterate through all subsectors potentially touched by actor BSPWalkCircle(x, y, radiusSquared, [&](subsector_t *subsector) // Iterate through all subsectors potentially touched by actor
{ {
FLightNode * node = subsector->lighthead; FLightNode * node = subsector->sector->lighthead;
while (node) // check all lights touching a subsector while (node) // check all lights touching a subsector
{ {
ADynamicLight *light = node->lightsource; ADynamicLight *light = node->lightsource;

View File

@ -275,7 +275,7 @@ void RenderPolyPlane::SetDynLights(PolyRenderThread *thread, PolyDrawArgs &args,
return; return;
} }
FLightNode *light_list = sub->lighthead; FLightNode *light_list = sub->sector->lighthead;
auto cameraLight = PolyCameraLight::Instance(); auto cameraLight = PolyCameraLight::Instance();
if ((cameraLight->FixedLightLevel() >= 0) || (cameraLight->FixedColormap() != nullptr)) if ((cameraLight->FixedLightLevel() >= 0) || (cameraLight->FixedColormap() != nullptr))

View File

@ -1460,7 +1460,6 @@ struct subsector_t
uint16_t sectorindex; uint16_t sectorindex;
// subsector related GL data // subsector related GL data
FLightNode * lighthead; // Light nodes (blended and additive)
int validcount; int validcount;
short mapsection; short mapsection;
char hacked; // 1: is part of a render hack char hacked; // 1: is part of a render hack

View File

@ -111,7 +111,7 @@ namespace swrenderer
BSPWalkCircle(x, y, radiusSquared, [&](subsector_t *subsector) // Iterate through all subsectors potentially touched by actor BSPWalkCircle(x, y, radiusSquared, [&](subsector_t *subsector) // Iterate through all subsectors potentially touched by actor
{ {
FLightNode * node = subsector->lighthead; FLightNode * node = subsector->sector->lighthead;
while (node) // check all lights touching a subsector while (node) // check all lights touching a subsector
{ {
ADynamicLight *light = node->lightsource; ADynamicLight *light = node->lightsource;