mirror of
https://github.com/ZDoom/ZDRay.git
synced 2024-11-25 21:31:32 +00:00
Fix light probe Z coordinate
This commit is contained in:
parent
ba36819da9
commit
ef7caddb2c
3 changed files with 28 additions and 16 deletions
|
@ -346,6 +346,8 @@ struct FLevel
|
|||
MapSubsectorEx *PointInSubSector(const int x, const int y);
|
||||
FloatVertex GetSegVertex(int index);
|
||||
|
||||
Vec3 GetLightProbePosition(int index);
|
||||
|
||||
private:
|
||||
void CheckSkySectors();
|
||||
void CreateLights();
|
||||
|
|
|
@ -402,3 +402,24 @@ void FLevel::CreateLights()
|
|||
|
||||
printf("Surface lights: %i\n", (int)SurfaceLights.Size());
|
||||
}
|
||||
|
||||
Vec3 FLevel::GetLightProbePosition(int index)
|
||||
{
|
||||
int thingIndex = ThingLightProbes[index];
|
||||
const IntThing& thing = Things[thingIndex];
|
||||
|
||||
float x = (float)(thing.x >> FRACBITS);
|
||||
float y = (float)(thing.y >> FRACBITS);
|
||||
float z = 0.0f;
|
||||
|
||||
MapSubsectorEx* ssect = PointInSubSector(x, y);
|
||||
if (ssect)
|
||||
{
|
||||
IntSector* sector = GetSectorFromSubSector(ssect);
|
||||
if (sector)
|
||||
{
|
||||
z = sector->floorplane.zAt(x, y) + thing.height;
|
||||
}
|
||||
}
|
||||
return Vec3(x, y, z);
|
||||
}
|
||||
|
|
|
@ -692,13 +692,7 @@ void LightmapBuilder::CreateSurfaceLights()
|
|||
|
||||
void LightmapBuilder::LightProbe(int id)
|
||||
{
|
||||
int thingIndex = map->ThingLightProbes[id];
|
||||
const IntThing& thing = map->Things[thingIndex];
|
||||
float x = (float)(thing.x >> FRACBITS);
|
||||
float y = (float)(thing.y >> FRACBITS);
|
||||
float z = (float)thing.z /* + thing.height * 0.5f*/;
|
||||
|
||||
lightProbes[id] = LightTexelSample({ x, y, z }, nullptr);
|
||||
lightProbes[id] = LightTexelSample(map->GetLightProbePosition(id), nullptr);
|
||||
}
|
||||
|
||||
void LightmapBuilder::AddLightmapLump(FWadWriter &wadFile)
|
||||
|
@ -741,15 +735,10 @@ void LightmapBuilder::AddLightmapLump(FWadWriter &wadFile)
|
|||
// Write light probes
|
||||
for (size_t i = 0; i < lightProbes.size(); i++)
|
||||
{
|
||||
int thingIndex = map->ThingLightProbes[i];
|
||||
const IntThing& thing = map->Things[thingIndex];
|
||||
float x = (float)(thing.x >> FRACBITS);
|
||||
float y = (float)(thing.y >> FRACBITS);
|
||||
float z = (float)thing.z /* + thing.height * 0.5f*/;
|
||||
|
||||
lumpFile.WriteFloat(x);
|
||||
lumpFile.WriteFloat(y);
|
||||
lumpFile.WriteFloat(z);
|
||||
Vec3 pos = map->GetLightProbePosition(i);
|
||||
lumpFile.WriteFloat(pos.x);
|
||||
lumpFile.WriteFloat(pos.y);
|
||||
lumpFile.WriteFloat(pos.z);
|
||||
lumpFile.WriteFloat(lightProbes[i].x);
|
||||
lumpFile.WriteFloat(lightProbes[i].y);
|
||||
lumpFile.WriteFloat(lightProbes[i].z);
|
||||
|
|
Loading…
Reference in a new issue