mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 14:01:45 +00:00
Minor cleanup
This commit is contained in:
parent
005bae7348
commit
e09ac00121
2 changed files with 7 additions and 32 deletions
|
@ -3341,21 +3341,6 @@ void MapLoader::InitLightmap(MapData* map)
|
||||||
Level->LMTextureCount = 1;
|
Level->LMTextureCount = 1;
|
||||||
Level->LMTextureSize = 1024;
|
Level->LMTextureSize = 1024;
|
||||||
|
|
||||||
for (int i = 0; i < 1024; ++i) // avoid crashing lol
|
|
||||||
{
|
|
||||||
Level->LMTexCoords.Push(0);
|
|
||||||
Level->LMTexCoords.Push(0);
|
|
||||||
|
|
||||||
Level->LMTexCoords.Push(1);
|
|
||||||
Level->LMTexCoords.Push(0);
|
|
||||||
|
|
||||||
Level->LMTexCoords.Push(1);
|
|
||||||
Level->LMTexCoords.Push(1);
|
|
||||||
|
|
||||||
Level->LMTexCoords.Push(0);
|
|
||||||
Level->LMTexCoords.Push(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto constructDebugTexture = [&](TArray<uint16_t>& buffer, int width, int height) {
|
auto constructDebugTexture = [&](TArray<uint16_t>& buffer, int width, int height) {
|
||||||
uint16_t* ptr = buffer.Data();
|
uint16_t* ptr = buffer.Data();
|
||||||
|
|
||||||
|
@ -3421,15 +3406,13 @@ void MapLoader::InitLightmap(MapData* map)
|
||||||
for (auto& surface : Level->levelMesh->Surfaces)
|
for (auto& surface : Level->levelMesh->Surfaces)
|
||||||
{
|
{
|
||||||
LightmapSurface l;
|
LightmapSurface l;
|
||||||
//LightmapSurface& l = Level->LMSurfaces[index++];
|
|
||||||
memset(&l, 0, sizeof(LightmapSurface));
|
memset(&l, 0, sizeof(LightmapSurface));
|
||||||
|
|
||||||
l.ControlSector = surface.controlSector;
|
l.ControlSector = surface.controlSector;
|
||||||
l.Type = surface.type;
|
l.Type = surface.type;
|
||||||
l.LightmapNum = 0;
|
l.LightmapNum = 0;
|
||||||
|
|
||||||
//l.TexCoords = &Level->LMTexCoords[0];
|
|
||||||
//l.TexCoords = &Level->levelMesh->LightmapUvs[surface.startUvIndex];
|
|
||||||
l.TexCoords = &Level->LMTexCoords[surface.startUvIndex];
|
l.TexCoords = &Level->LMTexCoords[surface.startUvIndex];
|
||||||
|
|
||||||
if (surface.type == ST_FLOOR || surface.type == ST_CEILING)
|
if (surface.type == ST_FLOOR || surface.type == ST_CEILING)
|
||||||
|
@ -3443,9 +3426,6 @@ void MapLoader::InitLightmap(MapData* map)
|
||||||
l.Side = &Level->sides[surface.typeIndex];
|
l.Side = &Level->sides[surface.typeIndex];
|
||||||
SetSideLightmap(l);
|
SetSideLightmap(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Level->LMSurfaces.Push(l);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf("Generated custom lightmap data");
|
Printf("Generated custom lightmap data");
|
||||||
|
|
|
@ -469,8 +469,6 @@ void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTex
|
||||||
secplane_t* plane;
|
secplane_t* plane;
|
||||||
BBox bounds;
|
BBox bounds;
|
||||||
FVector3 roundedSize;
|
FVector3 roundedSize;
|
||||||
int i;
|
|
||||||
PlaneAxis axis;
|
|
||||||
FVector3 tOrigin;
|
FVector3 tOrigin;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
@ -482,15 +480,12 @@ void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTex
|
||||||
|
|
||||||
if (surface.sampleDimension <= 0)
|
if (surface.sampleDimension <= 0)
|
||||||
{
|
{
|
||||||
surface.sampleDimension = 1; // TODO change?
|
surface.sampleDimension = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
surface.sampleDimension = 1;
|
|
||||||
//surface->sampleDimension = Math::RoundPowerOfTwo(surface->sampleDimension);
|
//surface->sampleDimension = Math::RoundPowerOfTwo(surface->sampleDimension);
|
||||||
|
|
||||||
|
|
||||||
// round off dimensions
|
// round off dimensions
|
||||||
for (i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
bounds.min[i] = surface.sampleDimension * (floor(bounds.min[i] / surface.sampleDimension) - 1);
|
bounds.min[i] = surface.sampleDimension * (floor(bounds.min[i] / surface.sampleDimension) - 1);
|
||||||
bounds.max[i] = surface.sampleDimension * (ceil(bounds.max[i] / surface.sampleDimension) + 1);
|
bounds.max[i] = surface.sampleDimension * (ceil(bounds.max[i] / surface.sampleDimension) + 1);
|
||||||
|
@ -500,7 +495,7 @@ void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTex
|
||||||
|
|
||||||
FVector3 tCoords[2] = { FVector3(0.0f, 0.0f, 0.0f), FVector3(0.0f, 0.0f, 0.0f) };
|
FVector3 tCoords[2] = { FVector3(0.0f, 0.0f, 0.0f), FVector3(0.0f, 0.0f, 0.0f) };
|
||||||
|
|
||||||
axis = BestAxis(*plane);
|
PlaneAxis axis = BestAxis(*plane);
|
||||||
|
|
||||||
switch (axis)
|
switch (axis)
|
||||||
{
|
{
|
||||||
|
@ -546,7 +541,7 @@ void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTex
|
||||||
|
|
||||||
surface.startUvIndex = AllocUvs(surface.numVerts);
|
surface.startUvIndex = AllocUvs(surface.numVerts);
|
||||||
auto uv = surface.startUvIndex;
|
auto uv = surface.startUvIndex;
|
||||||
for (i = 0; i < surface.numVerts; i++)
|
for (int i = 0; i < surface.numVerts; i++)
|
||||||
{
|
{
|
||||||
FVector3 tDelta = MeshVertices[surface.startVertIndex + i] - surface.translateWorldToLocal;
|
FVector3 tDelta = MeshVertices[surface.startVertIndex + i] - surface.translateWorldToLocal;
|
||||||
|
|
||||||
|
@ -561,7 +556,7 @@ void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTex
|
||||||
d = float(((bounds.min | FVector3(plane->Normal())) - plane->D) / plane->Normal()[axis]); //d = (plane->PointToDist(bounds.min)) / plane->Normal()[axis];
|
d = float(((bounds.min | FVector3(plane->Normal())) - plane->D) / plane->Normal()[axis]); //d = (plane->PointToDist(bounds.min)) / plane->Normal()[axis];
|
||||||
tOrigin[axis] -= d;
|
tOrigin[axis] -= d;
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
tCoords[i].MakeUnit();
|
tCoords[i].MakeUnit();
|
||||||
d = (tCoords[i] | FVector3(plane->Normal())) / plane->Normal()[axis]; //d = dot(tCoords[i], plane->Normal()) / plane->Normal()[axis];
|
d = (tCoords[i] | FVector3(plane->Normal())) / plane->Normal()[axis]; //d = dot(tCoords[i], plane->Normal()) / plane->Normal()[axis];
|
||||||
|
@ -574,4 +569,4 @@ void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTex
|
||||||
surface.worldOrigin = tOrigin;
|
surface.worldOrigin = tOrigin;
|
||||||
surface.worldStepX = tCoords[0] * (float)surface.sampleDimension;
|
surface.worldStepX = tCoords[0] * (float)surface.sampleDimension;
|
||||||
surface.worldStepY = tCoords[1] * (float)surface.sampleDimension;
|
surface.worldStepY = tCoords[1] * (float)surface.sampleDimension;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue