First step towards refactoring

This commit is contained in:
RaveYard 2023-08-31 20:32:38 +02:00 committed by Christoph Oelckers
parent c63fc707a4
commit 3495a5ca13
4 changed files with 35 additions and 29 deletions

View file

@ -62,7 +62,7 @@ public:
// Surface geometry
SurfaceType type = ST_UNKNOWN;
TArray<FVector3> verts;
TArray<FVector3> uvs;
TArray<FVector2> uvs;
//Plane plane;
FVector3 boundsMin, boundsMax;
@ -165,6 +165,20 @@ struct Portal
class LevelMesh
{
public:
LevelMesh()
{
// Default portal
PortalInfo portalInfo;
hwrenderer::Portal portal;
for (int i = 0; i < 16; ++i)
{
portalInfo.transformation[i] = (&portal.transformation[0][0])[i];
}
this->portalInfo.Push(portalInfo);
}
virtual ~LevelMesh() = default;
TArray<FVector3> MeshVertices;

View file

@ -478,7 +478,7 @@ void VulkanRenderDevice::BeginFrame()
void VulkanRenderDevice::InitLightmap(int LMTextureSize, int LMTextureCount, TArray<uint16_t>& LMTextureData, hwrenderer::LevelMesh& mesh)
{
if(mesh.surfaces.size() > 0)
if(false && mesh.surfaces.size() > 0)
{
Printf("Running VkLightmap.\n");
@ -495,7 +495,7 @@ void VulkanRenderDevice::InitLightmap(int LMTextureSize, int LMTextureCount, TAr
std::sort(mesh.surfaces.begin(), mesh.surfaces.end(), [](const std::unique_ptr<hwrenderer::Surface>& a, const std::unique_ptr<hwrenderer::Surface>& b) { return a->texHeight != b->texHeight ? a->texHeight > b->texHeight : a->texWidth > b->texWidth; });
RectPacker packer(LMTextureSize, LMTextureSize);
RectPacker packer(LMTextureSize, LMTextureSize, RectPacker::Spacing(0));
for (auto& surface : mesh.surfaces)
{

View file

@ -3390,7 +3390,7 @@ void MapLoader::InitLightmap(MapData* map)
return buffer.Data() + ((y * width) + x + (height * width * page)) * 3;
};
#if 0
//#if 0
srand(1337);
for (auto& surface : Level->levelMesh->Surfaces)
{
@ -3419,7 +3419,7 @@ void MapLoader::InitLightmap(MapData* map)
ptr[2] = floatToHalf(0.0f);
}
if (Level->levelMesh->TraceSky(surface.worldOrigin - surface.worldStepX - surface.worldStepY + surface.worldStepX * x + surface.worldStepY * y + FVector3(surface.plane.Normal()), Level->SunDirection, 32000.0f))
/*if (Level->levelMesh->TraceSky(surface.worldOrigin - surface.worldStepX - surface.worldStepY + surface.worldStepX * x + surface.worldStepY * y + FVector3(surface.plane.Normal()), Level->SunDirection, 32000.0f))
{
ptr[0] = floatToHalf(Level->SunColor.X);
ptr[1] = floatToHalf(Level->SunColor.Y);
@ -3430,11 +3430,11 @@ void MapLoader::InitLightmap(MapData* map)
ptr[0] = 0;
ptr[1] = 0;
ptr[2] = 0;
}
}*/
}
}
}
#endif
//#endif
};
int size = Level->LMTextureSize;

View file

@ -492,28 +492,25 @@ int DoomLevelMesh::SetupLightmapUvs(int lightmapSize)
sortedSurfaces.push_back(&surface);
}
{
this->portalInfo.Clear(); // TODO portals
PortalInfo portalInfo;
hwrenderer::Portal portal;
for (int i = 0; i < 16; ++i)
{
portalInfo.transformation[i] = (&portal.transformation[0][0])[i];
}
this->portalInfo.Push(portalInfo);
}
for (const auto& surface : Surfaces)
{
auto hwSurface = std::make_unique<hwrenderer::Surface>();
for (int i = 0; i < surface.numVerts; ++i)
{
hwSurface->verts.Push(MeshVertices[surface.startVertIndex + i]);
}
for (int i = 0; i < surface.numVerts; ++i)
{
hwSurface->uvs.Push(
FVector2(LightmapUvs[surface.startUvIndex + i * 2], LightmapUvs[surface.startUvIndex + i * 2 + 1]));
}
hwSurface->boundsMax = surface.bounds.max;
hwSurface->boundsMin = surface.bounds.min;
// hwSurface->LightList = // TODO
hwSurface->projLocalToU = surface.projLocalToU;
hwSurface->projLocalToV = surface.projLocalToV;
hwSurface->smoothingGroupIndex = 0;
@ -527,14 +524,9 @@ int DoomLevelMesh::SetupLightmapUvs(int lightmapSize)
for (auto& pixel : hwSurface->texPixels)
{
pixel.X = floatToHalf(0.0);
pixel.X = floatToHalf(1.0);
pixel.X = floatToHalf(0.0);
}
for (int i = 0; i < surface.numVerts; ++i)
{
hwSurface->verts.Push(MeshVertices[surface.startVertIndex + i]);
pixel.X = 0.0;
pixel.Y = 1.0;
pixel.Z = 0.0;
}
// TODO push