mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-13 22:42:07 +00:00
Namespace fixes
This commit is contained in:
parent
ab609d7708
commit
fd7e0d986f
13 changed files with 81 additions and 89 deletions
|
@ -12,10 +12,7 @@
|
|||
|
||||
typedef dp::rect_pack::RectPacker<int> RectPacker;
|
||||
|
||||
namespace hwrenderer
|
||||
{
|
||||
|
||||
class ThingLight
|
||||
class LevelMeshLight
|
||||
{
|
||||
public:
|
||||
FVector3 Origin;
|
||||
|
@ -28,7 +25,7 @@ public:
|
|||
FVector3 Color;
|
||||
};
|
||||
|
||||
enum SurfaceType
|
||||
enum LevelMeshSurfaceType
|
||||
{
|
||||
ST_UNKNOWN,
|
||||
ST_MIDDLESIDE,
|
||||
|
@ -38,9 +35,9 @@ enum SurfaceType
|
|||
ST_FLOOR
|
||||
};
|
||||
|
||||
struct Surface
|
||||
struct LevelMeshSurface
|
||||
{
|
||||
SurfaceType type = ST_UNKNOWN;
|
||||
LevelMeshSurfaceType type = ST_UNKNOWN;
|
||||
int typeIndex;
|
||||
int numVerts;
|
||||
unsigned int startVertIndex;
|
||||
|
@ -84,7 +81,7 @@ struct Surface
|
|||
FVector3 boundsMin, boundsMax;
|
||||
|
||||
// Touching light sources
|
||||
std::vector<ThingLight*> LightList;
|
||||
std::vector<LevelMeshLight*> LightList;
|
||||
|
||||
// Output lightmap for the surface
|
||||
std::vector<FVector3> texPixels;
|
||||
|
@ -96,16 +93,16 @@ struct Surface
|
|||
};
|
||||
|
||||
|
||||
struct SmoothingGroup
|
||||
struct LevelMeshSmoothingGroup
|
||||
{
|
||||
FVector4 plane = FVector4(0, 0, 1, 0);
|
||||
int sectorGroup = 0;
|
||||
std::vector<Surface*> surfaces;
|
||||
std::vector<LevelMeshSurface*> surfaces;
|
||||
};
|
||||
|
||||
struct Portal
|
||||
struct LevelMeshPortal
|
||||
{
|
||||
Portal() { transformation.loadIdentity(); }
|
||||
LevelMeshPortal() { transformation.loadIdentity(); }
|
||||
|
||||
VSMatrix transformation;
|
||||
|
||||
|
@ -125,27 +122,27 @@ struct Portal
|
|||
}
|
||||
|
||||
// Checks only transformation
|
||||
inline bool IsInverseTransformationPortal(const Portal& portal) const
|
||||
inline bool IsInverseTransformationPortal(const LevelMeshPortal& portal) const
|
||||
{
|
||||
auto diff = portal.TransformPosition(TransformPosition(FVector3(0, 0, 0)));
|
||||
return abs(diff.X) < 0.001 && abs(diff.Y) < 0.001 && abs(diff.Z) < 0.001;
|
||||
}
|
||||
|
||||
// Checks only transformation
|
||||
inline bool IsEqualTransformationPortal(const Portal& portal) const
|
||||
inline bool IsEqualTransformationPortal(const LevelMeshPortal& portal) const
|
||||
{
|
||||
auto diff = portal.TransformPosition(FVector3(0, 0, 0)) - TransformPosition(FVector3(0, 0, 0));
|
||||
return (abs(diff.X) < 0.001 && abs(diff.Y) < 0.001 && abs(diff.Z) < 0.001);
|
||||
}
|
||||
|
||||
// Checks transformation, source and destiantion sector groups
|
||||
inline bool IsEqualPortal(const Portal& portal) const
|
||||
inline bool IsEqualPortal(const LevelMeshPortal& portal) const
|
||||
{
|
||||
return sourceSectorGroup == portal.sourceSectorGroup && targetSectorGroup == portal.targetSectorGroup && IsEqualTransformationPortal(portal);
|
||||
}
|
||||
|
||||
// Checks transformation, source and destiantion sector groups
|
||||
inline bool IsInversePortal(const Portal& portal) const
|
||||
inline bool IsInversePortal(const LevelMeshPortal& portal) const
|
||||
{
|
||||
return sourceSectorGroup == portal.targetSectorGroup && targetSectorGroup == portal.sourceSectorGroup && IsInverseTransformationPortal(portal);
|
||||
}
|
||||
|
@ -157,8 +154,8 @@ public:
|
|||
LevelMesh()
|
||||
{
|
||||
// Default portal
|
||||
hwrenderer::Portal portal;
|
||||
portals.Push(portal);
|
||||
LevelMeshPortal portal;
|
||||
Portals.Push(portal);
|
||||
}
|
||||
|
||||
virtual ~LevelMesh() = default;
|
||||
|
@ -170,16 +167,16 @@ public:
|
|||
|
||||
std::unique_ptr<TriangleMeshShape> Collision;
|
||||
|
||||
TArray<hwrenderer::Surface> Surfaces;
|
||||
TArray<LevelMeshSurface> Surfaces;
|
||||
|
||||
TArray<SmoothingGroup> smoothingGroups; // TODO fill
|
||||
TArray<Portal> portals; // TODO fill
|
||||
TArray<LevelMeshSmoothingGroup> SmoothingGroups; // TODO fill
|
||||
TArray<LevelMeshPortal> Portals; // TODO fill
|
||||
|
||||
int LMTextureCount = 0;
|
||||
int LMTextureSize = 0;
|
||||
|
||||
FVector3 SunDirection;
|
||||
FVector3 SunColor;
|
||||
FVector3 SunDirection = FVector3(0.0f, 0.0f, -1.0f);
|
||||
FVector3 SunColor = FVector3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
bool Trace(const FVector3& start, FVector3 direction, float maxDist)
|
||||
{
|
||||
|
@ -187,5 +184,3 @@ public:
|
|||
return !TriangleMeshShape::find_any_hit(Collision.get(), start, end);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -155,7 +155,7 @@ public:
|
|||
virtual bool IsVulkan() { return false; }
|
||||
virtual bool IsPoly() { return false; }
|
||||
virtual bool CompileNextShader() { return true; }
|
||||
virtual void SetLevelMesh(hwrenderer::LevelMesh *mesh) { }
|
||||
virtual void SetLevelMesh(LevelMesh *mesh) { }
|
||||
bool allowSSBO() const
|
||||
{
|
||||
#ifndef HW_BLOCK_SSBO
|
||||
|
|
|
@ -31,7 +31,7 @@ VkLightmap::~VkLightmap()
|
|||
lights.Buffer->Unmap();
|
||||
}
|
||||
|
||||
void VkLightmap::Raytrace(hwrenderer::LevelMesh* level)
|
||||
void VkLightmap::Raytrace(LevelMesh* level)
|
||||
{
|
||||
mesh = level;
|
||||
|
||||
|
@ -105,7 +105,7 @@ void VkLightmap::RenderAtlasImage(size_t pageIndex)
|
|||
|
||||
for (unsigned int i = 0; i < mesh->Surfaces.Size(); i++)
|
||||
{
|
||||
hwrenderer::Surface* targetSurface = &mesh->Surfaces[i];
|
||||
LevelMeshSurface* targetSurface = &mesh->Surfaces[i];
|
||||
if (targetSurface->lightmapperAtlasPage != pageIndex)
|
||||
continue;
|
||||
|
||||
|
@ -118,7 +118,7 @@ void VkLightmap::RenderAtlasImage(size_t pageIndex)
|
|||
cmdbuffer->setViewport(0, 1, &viewport);
|
||||
|
||||
// Paint all surfaces part of the smoothing group into the surface
|
||||
for (hwrenderer::Surface* surface : mesh->smoothingGroups[targetSurface->smoothingGroupIndex].surfaces)
|
||||
for (LevelMeshSurface* surface : mesh->SmoothingGroups[targetSurface->smoothingGroupIndex].surfaces)
|
||||
{
|
||||
FVector2 minUV = ToUV(surface->boundsMin, targetSurface);
|
||||
FVector2 maxUV = ToUV(surface->boundsMax, targetSurface);
|
||||
|
@ -153,7 +153,7 @@ void VkLightmap::RenderAtlasImage(size_t pageIndex)
|
|||
vertices.Pos += vertexCount;
|
||||
|
||||
LightInfo* lightinfo = &lights.Lights[firstLight];
|
||||
for (hwrenderer::ThingLight* light : surface->LightList)
|
||||
for (LevelMeshLight* light : surface->LightList)
|
||||
{
|
||||
lightinfo->Origin = light->Origin;
|
||||
lightinfo->RelativeOrigin = light->RelativeOrigin;
|
||||
|
@ -177,7 +177,7 @@ void VkLightmap::RenderAtlasImage(size_t pageIndex)
|
|||
|
||||
SceneVertex* vertex = &vertices.Vertices[firstVertex];
|
||||
|
||||
if (surface->type == hwrenderer::ST_FLOOR || surface->type == hwrenderer::ST_CEILING)
|
||||
if (surface->type == ST_FLOOR || surface->type == ST_CEILING)
|
||||
{
|
||||
for (int idx = 0; idx < vertexCount; idx++)
|
||||
{
|
||||
|
@ -206,7 +206,7 @@ void VkLightmap::CreateAtlasImages()
|
|||
|
||||
for (unsigned int i = 0; i < mesh->Surfaces.Size(); i++)
|
||||
{
|
||||
hwrenderer::Surface* surface = &mesh->Surfaces[i];
|
||||
LevelMeshSurface* surface = &mesh->Surfaces[i];
|
||||
|
||||
auto result = packer.insert(surface->texWidth + 2, surface->texHeight + 2);
|
||||
surface->lightmapperAtlasX = result.pos.x + 1;
|
||||
|
@ -315,7 +315,7 @@ void VkLightmap::DownloadAtlasImage(size_t pageIndex)
|
|||
|
||||
for (unsigned int i = 0; i < mesh->Surfaces.Size(); i++)
|
||||
{
|
||||
hwrenderer::Surface* surface = &mesh->Surfaces[i];
|
||||
LevelMeshSurface* surface = &mesh->Surfaces[i];
|
||||
if (surface->lightmapperAtlasPage != pageIndex)
|
||||
continue;
|
||||
|
||||
|
@ -337,7 +337,7 @@ void VkLightmap::DownloadAtlasImage(size_t pageIndex)
|
|||
atlasImages[pageIndex].Transfer->Unmap();
|
||||
}
|
||||
|
||||
FVector2 VkLightmap::ToUV(const FVector3& vert, const hwrenderer::Surface* targetSurface)
|
||||
FVector2 VkLightmap::ToUV(const FVector3& vert, const LevelMeshSurface* targetSurface)
|
||||
{
|
||||
FVector3 localPos = vert - targetSurface->translateWorldToLocal;
|
||||
float u = (1.0f + (localPos | targetSurface->projLocalToU)) / (targetSurface->texWidth + 2);
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
VkLightmap(VulkanRenderDevice* fb);
|
||||
~VkLightmap();
|
||||
|
||||
void Raytrace(hwrenderer::LevelMesh* level);
|
||||
void Raytrace(LevelMesh* level);
|
||||
|
||||
private:
|
||||
void UpdateAccelStructDescriptors();
|
||||
|
@ -102,12 +102,12 @@ private:
|
|||
void CreateSceneVertexBuffer();
|
||||
void CreateSceneLightBuffer();
|
||||
|
||||
static FVector2 ToUV(const FVector3& vert, const hwrenderer::Surface* targetSurface);
|
||||
static FVector2 ToUV(const FVector3& vert, const LevelMeshSurface* targetSurface);
|
||||
|
||||
static FString LoadPrivateShaderLump(const char* lumpname);
|
||||
|
||||
VulkanRenderDevice* fb = nullptr;
|
||||
hwrenderer::LevelMesh* mesh = nullptr;
|
||||
LevelMesh* mesh = nullptr;
|
||||
|
||||
bool useRayQuery = true;
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ VkRaytrace::VkRaytrace(VulkanRenderDevice* fb) : fb(fb)
|
|||
SetLevelMesh(nullptr);
|
||||
}
|
||||
|
||||
void VkRaytrace::SetLevelMesh(hwrenderer::LevelMesh* mesh)
|
||||
void VkRaytrace::SetLevelMesh(LevelMesh* mesh)
|
||||
{
|
||||
if (!mesh)
|
||||
mesh = &NullMesh;
|
||||
|
@ -107,7 +107,7 @@ void VkRaytrace::CreateBuffers()
|
|||
nodesHeader.root = Mesh->Collision->get_root();
|
||||
|
||||
TArray<PortalInfo> portalInfo;
|
||||
for (auto& portal : Mesh->portals)
|
||||
for (auto& portal : Mesh->Portals)
|
||||
{
|
||||
PortalInfo info;
|
||||
info.transformation = portal.transformation;
|
||||
|
|
|
@ -46,7 +46,7 @@ class VkRaytrace
|
|||
public:
|
||||
VkRaytrace(VulkanRenderDevice* fb);
|
||||
|
||||
void SetLevelMesh(hwrenderer::LevelMesh* mesh);
|
||||
void SetLevelMesh(LevelMesh* mesh);
|
||||
|
||||
VulkanAccelerationStructure* GetAccelStruct() { return tlAccelStruct.get(); }
|
||||
VulkanBuffer* GetVertexBuffer() { return vertexBuffer.get(); }
|
||||
|
@ -69,8 +69,8 @@ private:
|
|||
|
||||
bool useRayQuery = true;
|
||||
|
||||
hwrenderer::LevelMesh NullMesh;
|
||||
hwrenderer::LevelMesh* Mesh = nullptr;
|
||||
LevelMesh NullMesh;
|
||||
LevelMesh* Mesh = nullptr;
|
||||
|
||||
std::unique_ptr<VulkanBuffer> vertexBuffer;
|
||||
std::unique_ptr<VulkanBuffer> indexBuffer;
|
||||
|
|
|
@ -532,11 +532,11 @@ void VulkanRenderDevice::PrintStartupLog()
|
|||
Printf("Min. uniform buffer offset alignment: %" PRIu64 "\n", limits.minUniformBufferOffsetAlignment);
|
||||
}
|
||||
|
||||
void VulkanRenderDevice::SetLevelMesh(hwrenderer::LevelMesh* mesh)
|
||||
void VulkanRenderDevice::SetLevelMesh(LevelMesh* mesh)
|
||||
{
|
||||
mRaytrace->SetLevelMesh(mesh);
|
||||
|
||||
static hwrenderer::LevelMesh* lastMesh = nullptr; // Temp hack; Since this function is called every frame we only want to do this once
|
||||
static LevelMesh* lastMesh = nullptr; // Temp hack; Since this function is called every frame we only want to do this once
|
||||
if (lastMesh != mesh && mesh->Surfaces.Size() > 0)
|
||||
{
|
||||
lastMesh = mesh;
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
void PostProcessScene(bool swscene, int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D) override;
|
||||
void AmbientOccludeScene(float m5) override;
|
||||
void SetSceneRenderTarget(bool useSSAO) override;
|
||||
void SetLevelMesh(hwrenderer::LevelMesh* mesh) override;
|
||||
void SetLevelMesh(LevelMesh* mesh) override;
|
||||
void SetShadowMaps(const TArray<float>& lights, hwrenderer::LevelAABBTree* tree, bool newTree) override;
|
||||
void SetSaveBuffers(bool yes) override;
|
||||
void ImageTransitionScene(bool unknown) override;
|
||||
|
|
|
@ -1692,7 +1692,7 @@ struct FMiniBSP
|
|||
|
||||
struct LightmapSurface
|
||||
{
|
||||
hwrenderer::SurfaceType Type;
|
||||
LevelMeshSurfaceType Type;
|
||||
subsector_t *Subsector;
|
||||
side_t *Side;
|
||||
sector_t *ControlSector;
|
||||
|
|
|
@ -12,9 +12,6 @@
|
|||
#include "common/rendering/vulkan/accelstructs/vk_lightmap.h"
|
||||
#include <vulkan/accelstructs/halffloat.h>
|
||||
|
||||
using hwrenderer::Surface;
|
||||
using hwrenderer::SurfaceType;
|
||||
|
||||
CCMD(dumplevelmesh)
|
||||
{
|
||||
if (level.levelMesh)
|
||||
|
@ -52,7 +49,7 @@ DoomLevelMesh::DoomLevelMesh(FLevelLocals &doomMap)
|
|||
MeshUVIndex.Push(j);
|
||||
}
|
||||
|
||||
if (s.type == hwrenderer::ST_FLOOR || s.type == hwrenderer::ST_CEILING)
|
||||
if (s.type == ST_FLOOR || s.type == ST_CEILING)
|
||||
{
|
||||
for (int j = 2; j < numVerts; j++)
|
||||
{
|
||||
|
@ -65,7 +62,7 @@ DoomLevelMesh::DoomLevelMesh(FLevelLocals &doomMap)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (s.type == hwrenderer::ST_MIDDLESIDE || s.type == hwrenderer::ST_UPPERSIDE || s.type == hwrenderer::ST_LOWERSIDE)
|
||||
else if (s.type == ST_MIDDLESIDE || s.type == ST_UPPERSIDE || s.type == ST_LOWERSIDE)
|
||||
{
|
||||
if (!IsDegenerate(verts[0], verts[1], verts[2]))
|
||||
{
|
||||
|
@ -139,7 +136,7 @@ void DoomLevelMesh::BindLightmapSurfacesToGeometry(FLevelLocals& doomMap)
|
|||
|
||||
l.LightmapNum = surface.atlasPageIndex;
|
||||
|
||||
if (surface.type == hwrenderer::ST_FLOOR || surface.type == hwrenderer::ST_CEILING)
|
||||
if (surface.type == ST_FLOOR || surface.type == ST_CEILING)
|
||||
{
|
||||
l.Subsector = &doomMap.subsectors[surface.typeIndex];
|
||||
if (l.Subsector->firstline && l.Subsector->firstline->sidedef)
|
||||
|
@ -158,12 +155,12 @@ void DoomLevelMesh::SetSubsectorLightmap(const LightmapSurface& surface)
|
|||
{
|
||||
if (!surface.ControlSector)
|
||||
{
|
||||
int index = surface.Type == hwrenderer::ST_CEILING ? 1 : 0;
|
||||
int index = surface.Type == ST_CEILING ? 1 : 0;
|
||||
surface.Subsector->lightmap[index][0] = surface;
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = surface.Type == hwrenderer::ST_CEILING ? 0 : 1;
|
||||
int index = surface.Type == ST_CEILING ? 0 : 1;
|
||||
const auto& ffloors = surface.Subsector->sector->e->XFloor.ffloors;
|
||||
for (unsigned int i = 0; i < ffloors.Size(); i++)
|
||||
{
|
||||
|
@ -179,16 +176,16 @@ void DoomLevelMesh::SetSideLightmap(const LightmapSurface& surface)
|
|||
{
|
||||
if (!surface.ControlSector)
|
||||
{
|
||||
if (surface.Type == hwrenderer::ST_UPPERSIDE)
|
||||
if (surface.Type == ST_UPPERSIDE)
|
||||
{
|
||||
surface.Side->lightmap[0] = surface;
|
||||
}
|
||||
else if (surface.Type == hwrenderer::ST_MIDDLESIDE)
|
||||
else if (surface.Type == ST_MIDDLESIDE)
|
||||
{
|
||||
surface.Side->lightmap[1] = surface;
|
||||
surface.Side->lightmap[2] = surface;
|
||||
}
|
||||
else if (surface.Type == hwrenderer::ST_LOWERSIDE)
|
||||
else if (surface.Type == ST_LOWERSIDE)
|
||||
{
|
||||
surface.Side->lightmap[3] = surface;
|
||||
}
|
||||
|
@ -233,8 +230,8 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
// line_horizont consumes everything
|
||||
if (side->linedef->special == Line_Horizon && front != back)
|
||||
{
|
||||
Surface surf;
|
||||
surf.type = hwrenderer::ST_MIDDLESIDE;
|
||||
LevelMeshSurface surf;
|
||||
surf.type = ST_MIDDLESIDE;
|
||||
surf.typeIndex = typeIndex;
|
||||
surf.bSky = front->GetTexture(sector_t::floor) == skyflatnum || front->GetTexture(sector_t::ceiling) == skyflatnum;
|
||||
|
||||
|
@ -279,8 +276,8 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
if (bothSides)
|
||||
continue;
|
||||
|
||||
Surface surf;
|
||||
surf.type = hwrenderer::ST_MIDDLESIDE;
|
||||
LevelMeshSurface surf;
|
||||
surf.type = ST_MIDDLESIDE;
|
||||
surf.typeIndex = typeIndex;
|
||||
surf.controlSector = xfloor->model;
|
||||
surf.bSky = false;
|
||||
|
@ -321,7 +318,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
{
|
||||
if (IsBottomSideVisible(side))
|
||||
{
|
||||
Surface surf;
|
||||
LevelMeshSurface surf;
|
||||
|
||||
FVector3 verts[4];
|
||||
verts[0].X = verts[2].X = v1.X;
|
||||
|
@ -341,7 +338,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
MeshVertices.Push(verts[3]);
|
||||
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2]);
|
||||
surf.type = hwrenderer::ST_LOWERSIDE;
|
||||
surf.type = ST_LOWERSIDE;
|
||||
surf.typeIndex = typeIndex;
|
||||
surf.bSky = false;
|
||||
surf.controlSector = nullptr;
|
||||
|
@ -359,7 +356,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
bool bSky = IsTopSideSky(front, back, side);
|
||||
if (bSky || IsTopSideVisible(side))
|
||||
{
|
||||
Surface surf;
|
||||
LevelMeshSurface surf;
|
||||
|
||||
FVector3 verts[4];
|
||||
verts[0].X = verts[2].X = v1.X;
|
||||
|
@ -379,7 +376,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
MeshVertices.Push(verts[3]);
|
||||
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2]);
|
||||
surf.type = hwrenderer::ST_UPPERSIDE;
|
||||
surf.type = ST_UPPERSIDE;
|
||||
surf.typeIndex = typeIndex;
|
||||
surf.bSky = bSky;
|
||||
surf.controlSector = nullptr;
|
||||
|
@ -395,7 +392,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
// middle seg
|
||||
if (back == nullptr)
|
||||
{
|
||||
Surface surf;
|
||||
LevelMeshSurface surf;
|
||||
surf.bSky = false;
|
||||
|
||||
FVector3 verts[4];
|
||||
|
@ -417,7 +414,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
MeshVertices.Push(verts[3]);
|
||||
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2]);
|
||||
surf.type = hwrenderer::ST_MIDDLESIDE;
|
||||
surf.type = ST_MIDDLESIDE;
|
||||
surf.typeIndex = typeIndex;
|
||||
surf.controlSector = nullptr;
|
||||
|
||||
|
@ -427,7 +424,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
|
||||
void DoomLevelMesh::CreateFloorSurface(FLevelLocals &doomMap, subsector_t *sub, sector_t *sector, int typeIndex, bool is3DFloor)
|
||||
{
|
||||
Surface surf;
|
||||
LevelMeshSurface surf;
|
||||
surf.bSky = IsSkySector(sector, sector_t::floor);
|
||||
|
||||
secplane_t plane;
|
||||
|
@ -456,7 +453,7 @@ void DoomLevelMesh::CreateFloorSurface(FLevelLocals &doomMap, subsector_t *sub,
|
|||
verts[j].Z = (float)plane.ZatPoint(verts[j]);
|
||||
}
|
||||
|
||||
surf.type = hwrenderer::ST_FLOOR;
|
||||
surf.type = ST_FLOOR;
|
||||
surf.typeIndex = typeIndex;
|
||||
surf.controlSector = is3DFloor ? sector : nullptr;
|
||||
surf.plane = FVector4((float)plane.Normal().X, (float)plane.Normal().Y, (float)plane.Normal().Z, (float)plane.D);
|
||||
|
@ -466,7 +463,7 @@ void DoomLevelMesh::CreateFloorSurface(FLevelLocals &doomMap, subsector_t *sub,
|
|||
|
||||
void DoomLevelMesh::CreateCeilingSurface(FLevelLocals &doomMap, subsector_t *sub, sector_t *sector, int typeIndex, bool is3DFloor)
|
||||
{
|
||||
Surface surf;
|
||||
LevelMeshSurface surf;
|
||||
surf.bSky = IsSkySector(sector, sector_t::ceiling);
|
||||
|
||||
secplane_t plane;
|
||||
|
@ -495,7 +492,7 @@ void DoomLevelMesh::CreateCeilingSurface(FLevelLocals &doomMap, subsector_t *sub
|
|||
verts[j].Z = (float)plane.ZatPoint(verts[j]);
|
||||
}
|
||||
|
||||
surf.type = hwrenderer::ST_CEILING;
|
||||
surf.type = ST_CEILING;
|
||||
surf.typeIndex = typeIndex;
|
||||
surf.controlSector = is3DFloor ? sector : nullptr;
|
||||
surf.plane = FVector4((float)plane.Normal().X, (float)plane.Normal().Y, (float)plane.Normal().Z, (float)plane.D);
|
||||
|
@ -613,7 +610,7 @@ void DoomLevelMesh::SetupLightmapUvs()
|
|||
{
|
||||
LMTextureSize = 1024; // TODO cvar
|
||||
|
||||
std::vector<Surface*> sortedSurfaces;
|
||||
std::vector<LevelMeshSurface*> sortedSurfaces;
|
||||
sortedSurfaces.reserve(Surfaces.Size());
|
||||
|
||||
for (auto& surface : Surfaces)
|
||||
|
@ -639,7 +636,7 @@ void DoomLevelMesh::SetupLightmapUvs()
|
|||
}
|
||||
|
||||
{
|
||||
hwrenderer::SmoothingGroup smoothing;
|
||||
LevelMeshSmoothingGroup smoothing;
|
||||
|
||||
for (auto& surface : Surfaces)
|
||||
{
|
||||
|
@ -647,14 +644,14 @@ void DoomLevelMesh::SetupLightmapUvs()
|
|||
|
||||
smoothing.surfaces.push_back(&surface);
|
||||
}
|
||||
smoothingGroups.Push(std::move(smoothing));
|
||||
SmoothingGroups.Push(std::move(smoothing));
|
||||
}
|
||||
|
||||
std::sort(sortedSurfaces.begin(), sortedSurfaces.end(), [](Surface* a, Surface* b) { return a->texHeight != b->texHeight ? a->texHeight > b->texHeight : a->texWidth > b->texWidth; });
|
||||
std::sort(sortedSurfaces.begin(), sortedSurfaces.end(), [](LevelMeshSurface* a, LevelMeshSurface* b) { return a->texHeight != b->texHeight ? a->texHeight > b->texHeight : a->texWidth > b->texWidth; });
|
||||
|
||||
RectPacker packer(LMTextureSize, LMTextureSize, RectPacker::Spacing(0));
|
||||
|
||||
for (Surface* surf : sortedSurfaces)
|
||||
for (LevelMeshSurface* surf : sortedSurfaces)
|
||||
{
|
||||
FinishSurface(LMTextureSize, LMTextureSize, packer, *surf);
|
||||
}
|
||||
|
@ -662,9 +659,9 @@ void DoomLevelMesh::SetupLightmapUvs()
|
|||
// You have no idea how long this took me to figure out...
|
||||
|
||||
// Reorder vertices into renderer format
|
||||
for (Surface& surface : Surfaces)
|
||||
for (LevelMeshSurface& surface : Surfaces)
|
||||
{
|
||||
if (surface.type == hwrenderer::ST_FLOOR)
|
||||
if (surface.type == ST_FLOOR)
|
||||
{
|
||||
// reverse vertices on floor
|
||||
for (int j = surface.startUvIndex + surface.numVerts - 1, k = surface.startUvIndex; j > k; j--, k++)
|
||||
|
@ -672,7 +669,7 @@ void DoomLevelMesh::SetupLightmapUvs()
|
|||
std::swap(LightmapUvs[k], LightmapUvs[j]);
|
||||
}
|
||||
}
|
||||
else if (surface.type != hwrenderer::ST_CEILING) // walls
|
||||
else if (surface.type != ST_CEILING) // walls
|
||||
{
|
||||
// from 0 1 2 3
|
||||
// to 0 2 1 3
|
||||
|
@ -684,7 +681,7 @@ void DoomLevelMesh::SetupLightmapUvs()
|
|||
LMTextureCount = (int)packer.getNumPages();
|
||||
}
|
||||
|
||||
void DoomLevelMesh::FinishSurface(int lightmapTextureWidth, int lightmapTextureHeight, RectPacker& packer, Surface& surface)
|
||||
void DoomLevelMesh::FinishSurface(int lightmapTextureWidth, int lightmapTextureHeight, RectPacker& packer, LevelMeshSurface& surface)
|
||||
{
|
||||
int sampleWidth = surface.texWidth;
|
||||
int sampleHeight = surface.texHeight;
|
||||
|
@ -731,7 +728,7 @@ void DoomLevelMesh::FinishSurface(int lightmapTextureWidth, int lightmapTextureH
|
|||
#endif
|
||||
}
|
||||
|
||||
BBox DoomLevelMesh::GetBoundsFromSurface(const Surface& surface) const
|
||||
BBox DoomLevelMesh::GetBoundsFromSurface(const LevelMeshSurface& surface) const
|
||||
{
|
||||
constexpr float M_INFINITY = 1e30f; // TODO cleanup
|
||||
|
||||
|
@ -779,7 +776,7 @@ DoomLevelMesh::PlaneAxis DoomLevelMesh::BestAxis(const FVector4& p)
|
|||
return AXIS_XY;
|
||||
}
|
||||
|
||||
void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTextureHeight, Surface& surface)
|
||||
void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTextureHeight, LevelMeshSurface& surface)
|
||||
{
|
||||
BBox bounds;
|
||||
FVector3 roundedSize;
|
||||
|
|
|
@ -12,7 +12,7 @@ typedef dp::rect_pack::RectPacker<int> RectPacker;
|
|||
|
||||
struct FLevelLocals;
|
||||
|
||||
class DoomLevelMesh : public hwrenderer::LevelMesh
|
||||
class DoomLevelMesh : public LevelMesh
|
||||
{
|
||||
public:
|
||||
DoomLevelMesh(FLevelLocals &doomMap);
|
||||
|
@ -75,10 +75,10 @@ private:
|
|||
};
|
||||
|
||||
static PlaneAxis BestAxis(const FVector4& p);
|
||||
BBox GetBoundsFromSurface(const hwrenderer::Surface& surface) const;
|
||||
BBox GetBoundsFromSurface(const LevelMeshSurface& surface) const;
|
||||
|
||||
inline int AllocUvs(int amount) { return LightmapUvs.Reserve(amount); }
|
||||
|
||||
void BuildSurfaceParams(int lightMapTextureWidth, int lightMapTextureHeight, hwrenderer::Surface& surface);
|
||||
void FinishSurface(int lightmapTextureWidth, int lightmapTextureHeight, RectPacker& packer, hwrenderer::Surface& surface);
|
||||
void BuildSurfaceParams(int lightMapTextureWidth, int lightMapTextureHeight, LevelMeshSurface& surface);
|
||||
void FinishSurface(int lightmapTextureWidth, int lightmapTextureHeight, RectPacker& packer, LevelMeshSurface& surface);
|
||||
};
|
||||
|
|
|
@ -240,7 +240,7 @@ static int CreateIndexedSectorVerticesLM(FRenderState& renderstate, sector_t* se
|
|||
{
|
||||
subsector_t* sub = sec->subsectors[i];
|
||||
LightmapSurface* lightmap = &sub->lightmap[h][lightmapIndex];
|
||||
if (lightmap->Type != hwrenderer::ST_UNKNOWN)
|
||||
if (lightmap->Type != ST_UNKNOWN)
|
||||
{
|
||||
float* luvs = lightmap->TexCoords;
|
||||
int lindex = lightmap->LightmapNum;
|
||||
|
|
|
@ -1016,7 +1016,7 @@ bool HWWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto
|
|||
}
|
||||
|
||||
texcoord* srclightuv;
|
||||
if (lightmap && lightmap->Type != hwrenderer::ST_UNKNOWN)
|
||||
if (lightmap && lightmap->Type != ST_UNKNOWN)
|
||||
{
|
||||
srclightuv = (texcoord*)lightmap->TexCoords;
|
||||
lindex = (float)lightmap->LightmapNum;
|
||||
|
@ -1721,7 +1721,7 @@ void HWWall::BuildFFBlock(HWDrawInfo *di, FRenderState& state, seg_t * seg, F3DF
|
|||
CheckTexturePosition(&tci);
|
||||
|
||||
texcoord* srclightuv;
|
||||
if (lightmap && lightmap->Type != hwrenderer::ST_UNKNOWN)
|
||||
if (lightmap && lightmap->Type != ST_UNKNOWN)
|
||||
{
|
||||
srclightuv = (texcoord*)lightmap->TexCoords;
|
||||
lindex = (float)lightmap->LightmapNum;
|
||||
|
|
Loading…
Reference in a new issue