Read ZDRay info thing

This commit is contained in:
RaveYard 2023-09-04 12:28:05 +02:00 committed by Christoph Oelckers
parent efbbdc2925
commit 18a873923f
6 changed files with 42 additions and 5 deletions

View file

@ -178,6 +178,7 @@ public:
FVector3 SunDirection = FVector3(0.0f, 0.0f, -1.0f); FVector3 SunDirection = FVector3(0.0f, 0.0f, -1.0f);
FVector3 SunColor = FVector3(0.0f, 0.0f, 0.0f); FVector3 SunColor = FVector3(0.0f, 0.0f, 0.0f);
uint16_t LightmapSampleDistance = 16;
bool Trace(const FVector3& start, FVector3 direction, float maxDist) bool Trace(const FVector3& start, FVector3 direction, float maxDist)
{ {

View file

@ -458,6 +458,7 @@ public:
TArray<DoomLevelMeshSurface*> LMSurfaces; TArray<DoomLevelMeshSurface*> LMSurfaces;
FVector3 SunDirection; FVector3 SunDirection;
FVector3 SunColor; FVector3 SunColor;
uint16_t LightmapSampleDistance;
// Portal information. // Portal information.
FDisplacementTable Displacements; FDisplacementTable Displacements;

View file

@ -2940,9 +2940,6 @@ void MapLoader::CalcIndices()
void MapLoader::InitLevelMesh() void MapLoader::InitLevelMesh()
{ {
Level->SunColor = FVector3(1.f, 1.f, 1.f);
Level->SunDirection = FVector3(0.45f, 0.3f, 0.9f);
// Propagate sample distance where it isn't yet set // Propagate sample distance where it isn't yet set
for (auto& line : Level->lines) for (auto& line : Level->lines)
{ {
@ -2978,6 +2975,11 @@ void MapLoader::LoadLevel(MapData *map, const char *lumpname, int position)
{ {
const int *oldvertextable = nullptr; const int *oldvertextable = nullptr;
// Reset defaults for lightmapping
Level->SunColor = FVector3(1.f, 1.f, 1.f);
Level->SunDirection = FVector3(0.45f, 0.3f, 0.9f);
Level->LightmapSampleDistance = 16;
// note: most of this ordering is important // note: most of this ordering is important
ForceNodeBuild = gennodes; ForceNodeBuild = gennodes;

View file

@ -754,9 +754,31 @@ public:
break; break;
case NAME_lm_suncolor: case NAME_lm_suncolor:
CHECK_N(Zd | Zdt)
if (CheckInt(key) < 0 || CheckInt(key) > 0xFFFFFF)
{
DPrintf(DMSG_WARNING, "Sun Color '%x' is out of range %s\n", CheckInt(key));
}
else
{
auto n = uint32_t(CheckInt(key));
Level->SunColor = FVector3(float((n >> 16) & 0xFF) / 0xFF, float((n >> 8) & 0xFF) / 0xFF, float(n & 0xFF) / 0xFF);
}
break;
case NAME_lm_sampledistance: case NAME_lm_sampledistance:
CHECK_N(Zd | Zdt) CHECK_N(Zd | Zdt)
break; if (CheckInt(key) >= 0 && CheckInt(key) <= 0xFFFF)
{
Level->LightmapSampleDistance = CheckInt(key);
}
else
{
DPrintf(DMSG_WARNING, "Can't set the global lm_sampledistance to %s\n", key.GetChars());
}
break;
case NAME_lm_gridsize:
CHECK_N(Zd | Zdt)
break;
default: default:
CHECK_N(Zd | Zdt) CHECK_N(Zd | Zdt)
@ -805,6 +827,15 @@ public:
th->special = 0; th->special = 0;
memset(th->args, 0, sizeof (th->args)); memset(th->args, 0, sizeof (th->args));
} }
if (th->EdNum == 9890) // ZDRAY INFO thing
{
FAngle angle = FAngle::fromDeg(float(th->angle));
FAngle pitch = FAngle::fromDeg(float(th->pitch));
auto pc = pitch.Cos();
Level->SunDirection = -FVector3 { pc * angle.Cos(), pc * angle.Sin(), -pitch.Sin() }; // [RaveYard]: is there a dedicated function for this?
}
} }
//=========================================================================== //===========================================================================

View file

@ -857,5 +857,6 @@ xx(lm_sampledist_floor)
xx(lm_sampledist_ceiling) xx(lm_sampledist_ceiling)
xx(lm_suncolor) xx(lm_suncolor)
xx(lm_sampledistance) xx(lm_sampledistance)
xx(lm_gridsize)
xx(Corona) xx(Corona)

View file

@ -27,6 +27,7 @@ DoomLevelMesh::DoomLevelMesh(FLevelLocals &doomMap)
{ {
SunColor = doomMap.SunColor; // TODO keep only one copy? SunColor = doomMap.SunColor; // TODO keep only one copy?
SunDirection = doomMap.SunDirection; SunDirection = doomMap.SunDirection;
LightmapSampleDistance = doomMap.LightmapSampleDistance;
for (unsigned int i = 0; i < doomMap.sides.Size(); i++) for (unsigned int i = 0; i < doomMap.sides.Size(); i++)
{ {
@ -890,7 +891,7 @@ void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTex
if (surface.sampleDimension <= 0) if (surface.sampleDimension <= 0)
{ {
surface.sampleDimension = 16; surface.sampleDimension = LightmapSampleDistance;
} }
//surface->sampleDimension = Math::RoundPowerOfTwo(surface->sampleDimension); //surface->sampleDimension = Math::RoundPowerOfTwo(surface->sampleDimension);