From 908c048464a89f27a662a3a8a0005101b02ce93d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 9 Nov 2018 21:55:07 +0100 Subject: [PATCH] - rename classes and enums that used the _t typedef convention --- src/level/doomdata.h | 2 +- src/level/level_light.cpp | 3 +++ src/lightmap/lightmap.cpp | 16 ++++++++-------- src/lightmap/lightmap.h | 12 ++++++------ src/lightmap/lightsurface.cpp | 18 +++++++++--------- src/lightmap/lightsurface.h | 16 ++++++++-------- src/lightmap/surfaces.cpp | 14 +++++++------- src/lightmap/surfaces.h | 13 +++++-------- src/math/mathlib.h | 4 ++-- src/math/plane.cpp | 2 +- 10 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/level/doomdata.h b/src/level/doomdata.h index 3a0eb4e..d776735 100644 --- a/src/level/doomdata.h +++ b/src/level/doomdata.h @@ -246,7 +246,7 @@ class BBox; class Vec3; class Vec2; struct vertex_t; -struct surface_t; +struct Surface; struct thingLight_t; struct FloatVertex diff --git a/src/level/level_light.cpp b/src/level/level_light.cpp index fbb02d5..de8f60d 100644 --- a/src/level/level_light.cpp +++ b/src/level/level_light.cpp @@ -36,6 +36,9 @@ #pragma warning(disable: 4244) // warning C4244: '=': conversion from '__int64' to 'int', possible loss of data #endif +// convert from fixed point(FRACUNIT) to floating point +#define F(x) (((float)(x))/65536.0f) + static const Vec3 defaultSunColor(1, 1, 1); static const Vec3 defaultSunDirection(0.45f, 0.3f, 0.9f); diff --git a/src/lightmap/lightmap.cpp b/src/lightmap/lightmap.cpp index 452abe4..e51c62a 100644 --- a/src/lightmap/lightmap.cpp +++ b/src/lightmap/lightmap.cpp @@ -126,7 +126,7 @@ bool LightmapBuilder::MakeRoomForBlock(const int width, const int height, int *x return false; } -BBox LightmapBuilder::GetBoundsFromSurface(const surface_t *surface) +BBox LightmapBuilder::GetBoundsFromSurface(const Surface *surface) { Vec3 low(M_INFINITY, M_INFINITY, M_INFINITY); Vec3 hi(-M_INFINITY, -M_INFINITY, -M_INFINITY); @@ -156,7 +156,7 @@ BBox LightmapBuilder::GetBoundsFromSurface(const surface_t *surface) } // Traces to the ceiling surface. Will emit light if the surface that was traced is a sky -bool LightmapBuilder::EmitFromCeiling(const surface_t *surface, const Vec3 &origin, const Vec3 &normal, Vec3 &color) +bool LightmapBuilder::EmitFromCeiling(const Surface *surface, const Vec3 &origin, const Vec3 &normal, Vec3 &color) { float attenuation = surface ? normal.Dot(map->GetSunDirection()) : 1.0f; @@ -202,7 +202,7 @@ static float radians(float degrees) } // Traces a line from the texel's origin to the sunlight direction and against all nearby thing lights -Vec3 LightmapBuilder::LightTexelSample(const Vec3 &origin, surface_t *surface) +Vec3 LightmapBuilder::LightTexelSample(const Vec3 &origin, Surface *surface) { Plane plane; if (surface) @@ -303,13 +303,13 @@ Vec3 LightmapBuilder::LightTexelSample(const Vec3 &origin, surface_t *surface) // Determines a lightmap block in which to map to the lightmap texture. // Width and height of the block is calcuated and steps are computed to determine where each texel will be positioned on the surface -void LightmapBuilder::BuildSurfaceParams(surface_t *surface) +void LightmapBuilder::BuildSurfaceParams(Surface *surface) { Plane *plane; BBox bounds; Vec3 roundedSize; int i; - Plane::planeAxis_t axis; + Plane::PlaneAxis axis; Vec3 tCoords[2]; Vec3 tOrigin; int width; @@ -399,7 +399,7 @@ void LightmapBuilder::BuildSurfaceParams(surface_t *surface) // Steps through each texel and traces a line to the world. // For each non-occluded trace, color is accumulated and saved off into the lightmap texture based on what block is mapped to -void LightmapBuilder::TraceSurface(surface_t *surface) +void LightmapBuilder::TraceSurface(Surface *surface) { int sampleWidth; int sampleHeight; @@ -561,7 +561,7 @@ static Vec3 ImportanceSampleGGX(Vec2 Xi, Vec3 N, float roughness) return Vec3::Normalize(sampleVec); } -void LightmapBuilder::TraceIndirectLight(surface_t *surface) +void LightmapBuilder::TraceIndirectLight(Surface *surface) { if (surface->lightmapNum == -1) return; @@ -683,7 +683,7 @@ void LightmapBuilder::CreateLightSurfaces() { for (size_t j = 0; j < mesh->surfaces.size(); ++j) { - surface_t *surface = mesh->surfaces[j].get(); + Surface *surface = mesh->surfaces[j].get(); if (surface->type >= ST_MIDDLESIDE && surface->type <= ST_LOWERSIDE) { diff --git a/src/lightmap/lightmap.h b/src/lightmap/lightmap.h index c6d3ab0..2618c06 100644 --- a/src/lightmap/lightmap.h +++ b/src/lightmap/lightmap.h @@ -73,13 +73,13 @@ public: private: void NewTexture(); bool MakeRoomForBlock(const int width, const int height, int *x, int *y, int *num); - BBox GetBoundsFromSurface(const surface_t *surface); - Vec3 LightTexelSample(const Vec3 &origin, surface_t *surface); - bool EmitFromCeiling(const surface_t *surface, const Vec3 &origin, const Vec3 &normal, Vec3 &color); + BBox GetBoundsFromSurface(const Surface *surface); + Vec3 LightTexelSample(const Vec3 &origin, Surface *surface); + bool EmitFromCeiling(const Surface *surface, const Vec3 &origin, const Vec3 &normal, Vec3 &color); - void BuildSurfaceParams(surface_t *surface); - void TraceSurface(surface_t *surface); - void TraceIndirectLight(surface_t *surface); + void BuildSurfaceParams(Surface *surface); + void TraceSurface(Surface *surface); + void TraceIndirectLight(Surface *surface); void SetupLightCellGrid(); void LightBlock(int blockid); void LightSurfacex(const int surfid); diff --git a/src/lightmap/lightsurface.cpp b/src/lightmap/lightsurface.cpp index 187523c..fcaed21 100644 --- a/src/lightmap/lightsurface.cpp +++ b/src/lightmap/lightsurface.cpp @@ -29,7 +29,7 @@ #include "level/level.h" #include "lightsurface.h" -LightSurface::LightSurface(const surfaceLightDef &lightSurfaceDef, surface_t *surface) +LightSurface::LightSurface(const surfaceLightDef &lightSurfaceDef, Surface *surface) { this->intensity = lightSurfaceDef.intensity; this->distance = lightSurfaceDef.distance; @@ -42,7 +42,7 @@ LightSurface::~LightSurface() } // Splits surface vertices into two groups while adding new ones caused by the split -void LightSurface::Clip(vertexBatch_t &points, const Vec3 &normal, float dist, vertexBatch_t *frontPoints, vertexBatch_t *backPoints) +void LightSurface::Clip(VertexBatch &points, const Vec3 &normal, float dist, VertexBatch *frontPoints, VertexBatch *backPoints) { std::vector dists; std::vector sides; @@ -116,7 +116,7 @@ void LightSurface::Clip(vertexBatch_t &points, const Vec3 &normal, float dist, v } // Recursively divides the surface -bool LightSurface::SubdivideRecursion(vertexBatch_t &surfPoints, float divide, std::vector> &points) +bool LightSurface::SubdivideRecursion(VertexBatch &surfPoints, float divide, std::vector> &points) { BBox bounds; Vec3 splitNormal; @@ -138,8 +138,8 @@ bool LightSurface::SubdivideRecursion(vertexBatch_t &surfPoints, float divide, s dist = (bounds.max[i] + bounds.min[i]) * 0.5f; - auto frontPoints = std::make_unique(); - auto backPoints = std::make_unique(); + auto frontPoints = std::make_unique(); + auto backPoints = std::make_unique(); // start clipping Clip(surfPoints, splitNormal, dist, frontPoints.get(), backPoints.get()); @@ -165,8 +165,8 @@ void LightSurface::Subdivide(const float divide) { if (surface->type == ST_CEILING || surface->type == ST_FLOOR) { - std::vector> points; - vertexBatch_t surfPoints; + std::vector> points; + VertexBatch surfPoints; for (int i = 0; i < surface->numVerts; ++i) { @@ -179,7 +179,7 @@ void LightSurface::Subdivide(const float divide) // creating a origin point based on the center of that group for (size_t i = 0; i < points.size(); ++i) { - vertexBatch_t *vb = points[i].get(); + VertexBatch *vb = points[i].get(); Vec3 center; for (unsigned int j = 0; j < vb->size(); ++j) @@ -234,7 +234,7 @@ void LightSurface::Subdivide(const float divide) } } -float LightSurface::TraceSurface(LevelMesh *mesh, const surface_t *fragmentSurface, const Vec3 &fragmentPos) +float LightSurface::TraceSurface(LevelMesh *mesh, const Surface *fragmentSurface, const Vec3 &fragmentPos) { if (fragmentSurface == surface) return 1.0f; // light surface will always be fullbright diff --git a/src/lightmap/lightsurface.h b/src/lightmap/lightsurface.h index 502b55d..68872e4 100644 --- a/src/lightmap/lightsurface.h +++ b/src/lightmap/lightsurface.h @@ -35,26 +35,26 @@ struct surfaceLightDef; class LightSurface { public: - LightSurface(const surfaceLightDef &lightSurfaceDef, surface_t *surface); + LightSurface(const surfaceLightDef &lightSurfaceDef, Surface *surface); ~LightSurface(); void Subdivide(const float divide); - float TraceSurface(LevelMesh *map, const surface_t *surface, const Vec3 &origin); + float TraceSurface(LevelMesh *map, const Surface *surface, const Vec3 &origin); const float Distance() const { return distance; } const float Intensity() const { return intensity; } const Vec3 GetRGB() const { return rgb; } - const surface_t *Surface() const { return surface; } + const Surface *GetSurface() const { return surface; } private: - typedef std::vector vertexBatch_t; + typedef std::vector VertexBatch; - bool SubdivideRecursion(vertexBatch_t &surfPoints, float divide, std::vector> &points); - void Clip(vertexBatch_t &points, const Vec3 &normal, float dist, vertexBatch_t *frontPoints, vertexBatch_t *backPoints); + bool SubdivideRecursion(VertexBatch &surfPoints, float divide, std::vector> &points); + void Clip(VertexBatch &points, const Vec3 &normal, float dist, VertexBatch *frontPoints, VertexBatch *backPoints); float distance; float intensity; Vec3 rgb; - vertexBatch_t origins; - surface_t *surface; + VertexBatch origins; + Surface *surface; }; diff --git a/src/lightmap/surfaces.cpp b/src/lightmap/surfaces.cpp index 17da189..c18c249 100644 --- a/src/lightmap/surfaces.cpp +++ b/src/lightmap/surfaces.cpp @@ -145,7 +145,7 @@ void LevelMesh::CreateSideSurfaces(FLevel &doomMap, IntSideDef *side) if (bothSides) continue; - auto surf = std::make_unique(); + auto surf = std::make_unique(); surf->type = ST_MIDDLESIDE; surf->typeIndex = typeIndex; surf->controlSector = xfloor; @@ -180,7 +180,7 @@ void LevelMesh::CreateSideSurfaces(FLevel &doomMap, IntSideDef *side) { if (side->bottomtexture[0] != '-') { - auto surf = std::make_unique(); + auto surf = std::make_unique(); surf->numVerts = 4; surf->verts.resize(4); @@ -221,7 +221,7 @@ void LevelMesh::CreateSideSurfaces(FLevel &doomMap, IntSideDef *side) if (side->toptexture[0] != '-' || bSky) { - auto surf = std::make_unique(); + auto surf = std::make_unique(); surf->numVerts = 4; surf->verts.resize(4); @@ -252,7 +252,7 @@ void LevelMesh::CreateSideSurfaces(FLevel &doomMap, IntSideDef *side) // middle seg if (back == nullptr) { - auto surf = std::make_unique(); + auto surf = std::make_unique(); surf->numVerts = 4; surf->verts.resize(4); @@ -277,7 +277,7 @@ void LevelMesh::CreateSideSurfaces(FLevel &doomMap, IntSideDef *side) void LevelMesh::CreateFloorSurface(FLevel &doomMap, MapSubsectorEx *sub, IntSector *sector, int typeIndex, bool is3DFloor) { - auto surf = std::make_unique(); + auto surf = std::make_unique(); surf->numVerts = sub->numlines; surf->verts.resize(surf->numVerts); @@ -309,7 +309,7 @@ void LevelMesh::CreateFloorSurface(FLevel &doomMap, MapSubsectorEx *sub, IntSect void LevelMesh::CreateCeilingSurface(FLevel &doomMap, MapSubsectorEx *sub, IntSector *sector, int typeIndex, bool is3DFloor) { - auto surf = std::make_unique(); + auto surf = std::make_unique(); surf->numVerts = sub->numlines; surf->verts.resize(surf->numVerts); surf->bSky = sector->skySector; @@ -427,7 +427,7 @@ void LevelMesh::WriteMeshToOBJ() { FILE *f = fopen("mesh.obj", "w"); - std::map> sortedSurfs; + std::map> sortedSurfs; for (unsigned int i = 0; i < surfaces.size(); i++) sortedSurfs[surfaces[i]->lightmapNum].push_back(surfaces[i].get()); diff --git a/src/lightmap/surfaces.h b/src/lightmap/surfaces.h index dedcb65..5084d61 100644 --- a/src/lightmap/surfaces.h +++ b/src/lightmap/surfaces.h @@ -38,7 +38,7 @@ struct IntSector; struct IntSideDef; struct FLevel; -enum surfaceType_t +enum SurfaceType { ST_UNKNOWN, ST_MIDDLESIDE, @@ -48,10 +48,7 @@ enum surfaceType_t ST_FLOOR }; -// convert from fixed point(FRACUNIT) to floating point -#define F(x) (((float)(x))/65536.0f) - -struct surface_t +struct Surface { Plane plane; int lightmapNum; @@ -64,7 +61,7 @@ struct surface_t int numVerts; std::vector verts; std::vector lightmapCoords; - surfaceType_t type; + SurfaceType type; int typeIndex; IntSector *controlSector; bool bSky; @@ -76,7 +73,7 @@ struct LevelTraceHit Vec3 end; float fraction; - surface_t *hitSurface; + Surface *hitSurface; int indices[3]; float b, c; }; @@ -91,7 +88,7 @@ public: void WriteMeshToOBJ(); - std::vector> surfaces; + std::vector> surfaces; TArray MeshVertices; TArray MeshUVIndex; diff --git a/src/math/mathlib.h b/src/math/mathlib.h index 4f2be91..71c9404 100644 --- a/src/math/mathlib.h +++ b/src/math/mathlib.h @@ -351,7 +351,7 @@ public: Plane(const Vec3 &normal, const Vec3 &point); Plane(const Plane &plane); - enum planeAxis_t + enum PlaneAxis { AXIS_YZ = 0, AXIS_XZ, @@ -370,7 +370,7 @@ public: Quat ToQuat(); const Vec4 &ToVec4() const; Vec4 &ToVec4(); - const planeAxis_t BestAxis() const; + const PlaneAxis BestAxis() const; Vec3 GetInclination(); static Plane Inverse(const Plane &p) { return Plane(-p.a, -p.b, -p.c, -p.d); } diff --git a/src/math/plane.cpp b/src/math/plane.cpp index f655626..4db0841 100644 --- a/src/math/plane.cpp +++ b/src/math/plane.cpp @@ -144,7 +144,7 @@ Vec4 &Plane::ToVec4() return *reinterpret_cast(&a); } -const Plane::planeAxis_t Plane::BestAxis() const +const Plane::PlaneAxis Plane::BestAxis() const { float na = Math::Fabs(a); float nb = Math::Fabs(b);