mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-22 01:11:49 +00:00
Read lm_sampledist properties from map geometry
This commit is contained in:
parent
9bd20ce5a8
commit
efbbdc2925
5 changed files with 86 additions and 7 deletions
|
@ -657,6 +657,7 @@ struct sector_t
|
||||||
float GlowHeight;
|
float GlowHeight;
|
||||||
FTextureID Texture;
|
FTextureID Texture;
|
||||||
TextureManipulation TextureFx;
|
TextureManipulation TextureFx;
|
||||||
|
uint16_t LightmapSampleDistance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1204,6 +1205,7 @@ struct side_t
|
||||||
TextureManipulation TextureFx;
|
TextureManipulation TextureFx;
|
||||||
PalEntry SpecialColors[2];
|
PalEntry SpecialColors[2];
|
||||||
PalEntry AdditiveColor;
|
PalEntry AdditiveColor;
|
||||||
|
uint16_t LightmapSampleDistance;
|
||||||
|
|
||||||
|
|
||||||
void InitFrom(const part &other)
|
void InitFrom(const part &other)
|
||||||
|
@ -1491,6 +1493,8 @@ struct line_t : public linebase_t
|
||||||
int healthgroup; // [ZZ] this is the "destructible object" id
|
int healthgroup; // [ZZ] this is the "destructible object" id
|
||||||
int linenum;
|
int linenum;
|
||||||
|
|
||||||
|
uint16_t LightmapSampleDistance[3]; // Used only as storage during map loading.
|
||||||
|
|
||||||
void setAlpha(double a)
|
void setAlpha(double a)
|
||||||
{
|
{
|
||||||
alpha = a;
|
alpha = a;
|
||||||
|
|
|
@ -2938,6 +2938,42 @@ void MapLoader::CalcIndices()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
|
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
|
||||||
|
for (auto& line : Level->lines)
|
||||||
|
{
|
||||||
|
if (line.LightmapSampleDistance[0] || line.LightmapSampleDistance[1] || line.LightmapSampleDistance[2])
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 2; ++i)
|
||||||
|
{
|
||||||
|
if (auto sidedef = line.sidedef[i])
|
||||||
|
{
|
||||||
|
for (int j = 0; j < 3; ++j)
|
||||||
|
{
|
||||||
|
if (!sidedef->textures[j].LightmapSampleDistance)
|
||||||
|
{
|
||||||
|
sidedef->textures[j].LightmapSampleDistance = line.LightmapSampleDistance[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Level->levelMesh = new DoomLevelMesh(*Level);
|
||||||
|
Level->lightmaps = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
void MapLoader::LoadLevel(MapData *map, const char *lumpname, int position)
|
void MapLoader::LoadLevel(MapData *map, const char *lumpname, int position)
|
||||||
{
|
{
|
||||||
const int *oldvertextable = nullptr;
|
const int *oldvertextable = nullptr;
|
||||||
|
@ -3204,12 +3240,7 @@ void MapLoader::LoadLevel(MapData *map, const char *lumpname, int position)
|
||||||
|
|
||||||
SpawnThings(position);
|
SpawnThings(position);
|
||||||
|
|
||||||
// TODO read from ZDRayInfoThing
|
InitLevelMesh();
|
||||||
Level->SunColor = FVector3(1.f, 1.f, 1.f);
|
|
||||||
Level->SunDirection = FVector3(0.45f, 0.3f, 0.9f);
|
|
||||||
|
|
||||||
Level->levelMesh = new DoomLevelMesh(*Level);
|
|
||||||
Level->lightmaps = true;
|
|
||||||
|
|
||||||
for (int i = 0; i < MAXPLAYERS; ++i)
|
for (int i = 0; i < MAXPLAYERS; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -304,6 +304,8 @@ public:
|
||||||
void SetSlopes();
|
void SetSlopes();
|
||||||
void CopySlopes();
|
void CopySlopes();
|
||||||
|
|
||||||
|
void InitLevelMesh();
|
||||||
|
|
||||||
void LoadLevel(MapData *map, const char *lumpname, int position);
|
void LoadLevel(MapData *map, const char *lumpname, int position);
|
||||||
|
|
||||||
MapLoader(FLevelLocals *lev)
|
MapLoader(FLevelLocals *lev)
|
||||||
|
|
|
@ -1129,10 +1129,22 @@ public:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NAME_lm_sampledist_line:
|
case NAME_lm_sampledist_line:
|
||||||
|
CHECK_N(Zd | Zdt)
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
if (!ld->LightmapSampleDistance[i])
|
||||||
|
ld->LightmapSampleDistance[i] = CheckInt(key);
|
||||||
|
break;
|
||||||
case NAME_lm_sampledist_top:
|
case NAME_lm_sampledist_top:
|
||||||
|
CHECK_N(Zd | Zdt)
|
||||||
|
ld->LightmapSampleDistance[side_t::top] = CheckInt(key);
|
||||||
|
break;
|
||||||
case NAME_lm_sampledist_mid:
|
case NAME_lm_sampledist_mid:
|
||||||
|
CHECK_N(Zd | Zdt)
|
||||||
|
ld->LightmapSampleDistance[side_t::mid] = CheckInt(key);
|
||||||
|
break;
|
||||||
case NAME_lm_sampledist_bot:
|
case NAME_lm_sampledist_bot:
|
||||||
CHECK_N(Zd | Zdt)
|
CHECK_N(Zd | Zdt)
|
||||||
|
ld->LightmapSampleDistance[side_t::bottom] = CheckInt(key);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1477,12 +1489,27 @@ public:
|
||||||
sd->Flags |= WALLF_EXTCOLOR;
|
sd->Flags |= WALLF_EXTCOLOR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
CHECK_N(Zd | Zdt)
|
||||||
|
break;
|
||||||
|
|
||||||
case NAME_lm_sampledist_line:
|
case NAME_lm_sampledist_line:
|
||||||
|
CHECK_N(Zd | Zdt)
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
if (!sd->textures[i].LightmapSampleDistance)
|
||||||
|
sd->textures[i].LightmapSampleDistance = CheckInt(key);
|
||||||
|
break;
|
||||||
case NAME_lm_sampledist_top:
|
case NAME_lm_sampledist_top:
|
||||||
|
CHECK_N(Zd | Zdt)
|
||||||
|
sd->textures[side_t::top].LightmapSampleDistance = CheckInt(key);
|
||||||
|
break;
|
||||||
case NAME_lm_sampledist_mid:
|
case NAME_lm_sampledist_mid:
|
||||||
|
CHECK_N(Zd | Zdt)
|
||||||
|
sd->textures[side_t::mid].LightmapSampleDistance = CheckInt(key);
|
||||||
|
break;
|
||||||
case NAME_lm_sampledist_bot:
|
case NAME_lm_sampledist_bot:
|
||||||
CHECK_N(Zd | Zdt)
|
CHECK_N(Zd | Zdt)
|
||||||
break;
|
sd->textures[side_t::bottom].LightmapSampleDistance = CheckInt(key);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (strnicmp("user_", key.GetChars(), 5))
|
if (strnicmp("user_", key.GetChars(), 5))
|
||||||
|
@ -1992,9 +2019,17 @@ public:
|
||||||
sec->health3dgroup = CheckInt(key);
|
sec->health3dgroup = CheckInt(key);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
CHECK_N(Zd | Zdt)
|
||||||
|
break;
|
||||||
|
|
||||||
case NAME_lm_sampledist_floor:
|
case NAME_lm_sampledist_floor:
|
||||||
|
CHECK_N(Zd | Zdt)
|
||||||
|
sec->planes[sector_t::floor].LightmapSampleDistance = CheckInt(key);
|
||||||
|
break;
|
||||||
|
|
||||||
case NAME_lm_sampledist_ceiling:
|
case NAME_lm_sampledist_ceiling:
|
||||||
CHECK_N(Zd | Zdt)
|
CHECK_N(Zd | Zdt)
|
||||||
|
sec->planes[sector_t::ceiling].LightmapSampleDistance = CheckInt(key);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -287,6 +287,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
||||||
surf.Type = ST_MIDDLESIDE;
|
surf.Type = ST_MIDDLESIDE;
|
||||||
surf.typeIndex = typeIndex;
|
surf.typeIndex = typeIndex;
|
||||||
surf.bSky = front->GetTexture(sector_t::floor) == skyflatnum || front->GetTexture(sector_t::ceiling) == skyflatnum;
|
surf.bSky = front->GetTexture(sector_t::floor) == skyflatnum || front->GetTexture(sector_t::ceiling) == skyflatnum;
|
||||||
|
surf.sampleDimension = side->textures[side_t::mid].LightmapSampleDistance;
|
||||||
|
|
||||||
FVector3 verts[4];
|
FVector3 verts[4];
|
||||||
verts[0].X = verts[2].X = v1.X;
|
verts[0].X = verts[2].X = v1.X;
|
||||||
|
@ -334,6 +335,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
||||||
surf.typeIndex = typeIndex;
|
surf.typeIndex = typeIndex;
|
||||||
surf.ControlSector = xfloor->model;
|
surf.ControlSector = xfloor->model;
|
||||||
surf.bSky = false;
|
surf.bSky = false;
|
||||||
|
surf.sampleDimension = side->textures[side_t::mid].LightmapSampleDistance;
|
||||||
|
|
||||||
FVector3 verts[4];
|
FVector3 verts[4];
|
||||||
verts[0].X = verts[2].X = v2.X;
|
verts[0].X = verts[2].X = v2.X;
|
||||||
|
@ -394,6 +396,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
||||||
surf.Type = ST_LOWERSIDE;
|
surf.Type = ST_LOWERSIDE;
|
||||||
surf.typeIndex = typeIndex;
|
surf.typeIndex = typeIndex;
|
||||||
surf.bSky = false;
|
surf.bSky = false;
|
||||||
|
surf.sampleDimension = side->textures[side_t::bottom].LightmapSampleDistance;
|
||||||
surf.ControlSector = nullptr;
|
surf.ControlSector = nullptr;
|
||||||
|
|
||||||
Surfaces.Push(surf);
|
Surfaces.Push(surf);
|
||||||
|
@ -432,6 +435,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
||||||
surf.Type = ST_UPPERSIDE;
|
surf.Type = ST_UPPERSIDE;
|
||||||
surf.typeIndex = typeIndex;
|
surf.typeIndex = typeIndex;
|
||||||
surf.bSky = bSky;
|
surf.bSky = bSky;
|
||||||
|
surf.sampleDimension = side->textures[side_t::top].LightmapSampleDistance;
|
||||||
surf.ControlSector = nullptr;
|
surf.ControlSector = nullptr;
|
||||||
|
|
||||||
Surfaces.Push(surf);
|
Surfaces.Push(surf);
|
||||||
|
@ -469,6 +473,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
||||||
surf.plane = ToPlane(verts[0], verts[1], verts[2]);
|
surf.plane = ToPlane(verts[0], verts[1], verts[2]);
|
||||||
surf.Type = ST_MIDDLESIDE;
|
surf.Type = ST_MIDDLESIDE;
|
||||||
surf.typeIndex = typeIndex;
|
surf.typeIndex = typeIndex;
|
||||||
|
surf.sampleDimension = side->textures[side_t::mid].LightmapSampleDistance;
|
||||||
surf.ControlSector = nullptr;
|
surf.ControlSector = nullptr;
|
||||||
|
|
||||||
Surfaces.Push(surf);
|
Surfaces.Push(surf);
|
||||||
|
@ -508,6 +513,7 @@ void DoomLevelMesh::CreateFloorSurface(FLevelLocals &doomMap, subsector_t *sub,
|
||||||
|
|
||||||
surf.Type = ST_FLOOR;
|
surf.Type = ST_FLOOR;
|
||||||
surf.typeIndex = typeIndex;
|
surf.typeIndex = typeIndex;
|
||||||
|
surf.sampleDimension = sector->planes[sector_t::floor].LightmapSampleDistance;
|
||||||
surf.ControlSector = is3DFloor ? sector : nullptr;
|
surf.ControlSector = is3DFloor ? sector : nullptr;
|
||||||
surf.plane = FVector4((float)plane.Normal().X, (float)plane.Normal().Y, (float)plane.Normal().Z, -(float)plane.D);
|
surf.plane = FVector4((float)plane.Normal().X, (float)plane.Normal().Y, (float)plane.Normal().Z, -(float)plane.D);
|
||||||
|
|
||||||
|
@ -547,6 +553,7 @@ void DoomLevelMesh::CreateCeilingSurface(FLevelLocals &doomMap, subsector_t *sub
|
||||||
|
|
||||||
surf.Type = ST_CEILING;
|
surf.Type = ST_CEILING;
|
||||||
surf.typeIndex = typeIndex;
|
surf.typeIndex = typeIndex;
|
||||||
|
surf.sampleDimension = sector->planes[sector_t::ceiling].LightmapSampleDistance;
|
||||||
surf.ControlSector = is3DFloor ? sector : nullptr;
|
surf.ControlSector = is3DFloor ? sector : nullptr;
|
||||||
surf.plane = FVector4((float)plane.Normal().X, (float)plane.Normal().Y, (float)plane.Normal().Z, -(float)plane.D);
|
surf.plane = FVector4((float)plane.Normal().X, (float)plane.Normal().Y, (float)plane.Normal().Z, -(float)plane.D);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue