mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- fixed: The dynamic light setup for walls did not portal-translate the light's coordinate.
- changed ADynamicLight::CollectWithinRadius to work iteratively to avoid the high stack overhead of 64 bit code.
This commit is contained in:
parent
3aac058022
commit
3558b2234c
2 changed files with 85 additions and 58 deletions
|
@ -582,13 +582,25 @@ double ADynamicLight::DistToSeg(const DVector3 &pos, seg_t *seg)
|
|||
// to sidedefs and sector parts.
|
||||
//
|
||||
//==========================================================================
|
||||
struct LightLinkEntry
|
||||
{
|
||||
subsector_t *sub;
|
||||
DVector3 pos;
|
||||
};
|
||||
static TArray<LightLinkEntry> collected_ss;
|
||||
|
||||
void ADynamicLight::CollectWithinRadius(const DVector3 &pos, subsector_t *subSec, float radius)
|
||||
void ADynamicLight::CollectWithinRadius(const DVector3 &opos, subsector_t *subSec, float radius)
|
||||
{
|
||||
if (!subSec) return;
|
||||
|
||||
collected_ss.Clear();
|
||||
collected_ss.Push({ subSec, opos });
|
||||
subSec->validcount = ::validcount;
|
||||
|
||||
for (unsigned i = 0; i < collected_ss.Size(); i++)
|
||||
{
|
||||
subSec = collected_ss[i].sub;
|
||||
auto &pos = collected_ss[i].pos;
|
||||
|
||||
touching_subsectors = AddLightNode(&subSec->lighthead, subSec, this, touching_subsectors);
|
||||
if (subSec->sector->validcount != ::validcount)
|
||||
{
|
||||
|
@ -622,7 +634,11 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &pos, subsector_t *subSec
|
|||
if (other->validcount != ::validcount)
|
||||
{
|
||||
subsector_t *othersub = R_PointInSubsector(other->v1->fPos() + other->Delta() / 2);
|
||||
if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(other), othersub, radius);
|
||||
if (othersub->validcount != ::validcount)
|
||||
{
|
||||
othersub->validcount = ::validcount;
|
||||
collected_ss.Push({ othersub, PosRelative(other) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -633,7 +649,8 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &pos, subsector_t *subSec
|
|||
subsector_t *sub = partner->Subsector;
|
||||
if (sub != NULL && sub->validcount != ::validcount)
|
||||
{
|
||||
CollectWithinRadius(pos, sub, radius);
|
||||
sub->validcount = ::validcount;
|
||||
collected_ss.Push({ sub, pos });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -646,7 +663,11 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &pos, subsector_t *subSec
|
|||
{
|
||||
DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sec->GetPortalDisplacement(sector_t::ceiling);
|
||||
subsector_t *othersub = R_PointInSubsector(refpos);
|
||||
if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius);
|
||||
if (othersub->validcount != ::validcount)
|
||||
{
|
||||
othersub->validcount = ::validcount;
|
||||
collected_ss.Push({ othersub, PosRelative(othersub->sector) });
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!sec->PortalBlocksSight(sector_t::floor))
|
||||
|
@ -656,7 +677,12 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &pos, subsector_t *subSec
|
|||
{
|
||||
DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sec->GetPortalDisplacement(sector_t::floor);
|
||||
subsector_t *othersub = R_PointInSubsector(refpos);
|
||||
if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius);
|
||||
if (othersub->validcount != ::validcount)
|
||||
{
|
||||
othersub->validcount = ::validcount;
|
||||
collected_ss.Push({ othersub, PosRelative(othersub->sector) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,9 +102,10 @@ void GLWall::SetupLights()
|
|||
|
||||
Vector fn, pos;
|
||||
|
||||
float x = node->lightsource->X();
|
||||
float y = node->lightsource->Y();
|
||||
float z = node->lightsource->Z();
|
||||
DVector3 posrel = node->lightsource->PosRelative(seg->frontsector);
|
||||
float x = posrel.X;
|
||||
float y = posrel.Y;
|
||||
float z = posrel.Z;
|
||||
float dist = fabsf(p.DistToPoint(x, z, y));
|
||||
float radius = node->lightsource->GetRadius();
|
||||
float scale = 1.0f / ((2.f * radius) - dist);
|
||||
|
|
Loading…
Reference in a new issue