mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-11-23 13:12:06 +00:00
chore: use enum class for non-game enums
This commit is contained in:
@@ -3,12 +3,13 @@
|
|||||||
#include "Game/T6/T6.h"
|
#include "Game/T6/T6.h"
|
||||||
#include "Utils/Logging/Log.h"
|
#include "Utils/Logging/Log.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace BSP
|
namespace BSP
|
||||||
{
|
{
|
||||||
enum BSPMaterialType
|
enum class BSPMaterialType : std::uint8_t
|
||||||
{
|
{
|
||||||
MATERIAL_TYPE_COLOUR,
|
MATERIAL_TYPE_COLOUR,
|
||||||
MATERIAL_TYPE_TEXTURE,
|
MATERIAL_TYPE_TEXTURE,
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "BSPCalculation.h"
|
#include "BSPCalculation.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
namespace BSP
|
namespace BSP
|
||||||
{
|
{
|
||||||
constexpr int MAX_NODE_SIZE = 512; // maximum size a BSP node can be before it becomes a leaf
|
constexpr int MAX_NODE_SIZE = 512; // maximum size a BSP node can be before it becomes a leaf
|
||||||
@@ -44,18 +46,20 @@ namespace BSP
|
|||||||
float minCoord, maxCoord;
|
float minCoord, maxCoord;
|
||||||
|
|
||||||
// Select the relevant coordinate based on the plane's axis
|
// Select the relevant coordinate based on the plane's axis
|
||||||
if (axis == AXIS_X)
|
if (axis == PlaneAxis::AXIS_X)
|
||||||
{
|
{
|
||||||
minCoord = object.min.x;
|
minCoord = object.min.x;
|
||||||
maxCoord = object.max.x;
|
maxCoord = object.max.x;
|
||||||
}
|
}
|
||||||
else if (axis == AXIS_Y)
|
else if (axis == PlaneAxis::AXIS_Y)
|
||||||
{
|
{
|
||||||
minCoord = object.min.y;
|
minCoord = object.min.y;
|
||||||
maxCoord = object.max.y;
|
maxCoord = object.max.y;
|
||||||
}
|
}
|
||||||
else // axis == AXIS_Z
|
else
|
||||||
{
|
{
|
||||||
|
assert(axis == PlaneAxis::AXIS_Z);
|
||||||
|
|
||||||
minCoord = object.min.z;
|
minCoord = object.min.z;
|
||||||
maxCoord = object.max.z;
|
maxCoord = object.max.z;
|
||||||
}
|
}
|
||||||
@@ -63,15 +67,15 @@ namespace BSP
|
|||||||
// Compare with the plane's distance
|
// Compare with the plane's distance
|
||||||
if (maxCoord < distance)
|
if (maxCoord < distance)
|
||||||
{
|
{
|
||||||
return SIDE_BACK; // Object is entirely on the negative side
|
return PlaneSide::SIDE_BACK; // Object is entirely on the negative side
|
||||||
}
|
}
|
||||||
else if (minCoord > distance)
|
else if (minCoord > distance)
|
||||||
{
|
{
|
||||||
return SIDE_FRONT; // Object is entirely on the positive side
|
return PlaneSide::SIDE_FRONT; // Object is entirely on the positive side
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return SIDE_INTERSECTS;
|
return PlaneSide::SIDE_INTERSECTS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +105,7 @@ namespace BSP
|
|||||||
back = std::make_unique<BSPTree>(min.x, min.y, min.z, halfLength, max.y, max.z, level + 1);
|
back = std::make_unique<BSPTree>(min.x, min.y, min.z, halfLength, max.y, max.z, level + 1);
|
||||||
|
|
||||||
isLeaf = false;
|
isLeaf = false;
|
||||||
node = std::make_unique<BSPNode>(std::move(front), std::move(back), AXIS_X, halfLength);
|
node = std::make_unique<BSPNode>(std::move(front), std::move(back), PlaneAxis::AXIS_X, halfLength);
|
||||||
leaf = nullptr;
|
leaf = nullptr;
|
||||||
}
|
}
|
||||||
else if (max.y - min.y > MAX_NODE_SIZE)
|
else if (max.y - min.y > MAX_NODE_SIZE)
|
||||||
@@ -112,7 +116,7 @@ namespace BSP
|
|||||||
back = std::make_unique<BSPTree>(min.x, min.y, min.z, max.x, halfLength, max.z, level + 1);
|
back = std::make_unique<BSPTree>(min.x, min.y, min.z, max.x, halfLength, max.z, level + 1);
|
||||||
|
|
||||||
isLeaf = false;
|
isLeaf = false;
|
||||||
node = std::make_unique<BSPNode>(std::move(front), std::move(back), AXIS_Y, halfLength);
|
node = std::make_unique<BSPNode>(std::move(front), std::move(back), PlaneAxis::AXIS_Y, halfLength);
|
||||||
leaf = nullptr;
|
leaf = nullptr;
|
||||||
}
|
}
|
||||||
else if (max.z - min.z > MAX_NODE_SIZE)
|
else if (max.z - min.z > MAX_NODE_SIZE)
|
||||||
@@ -123,7 +127,7 @@ namespace BSP
|
|||||||
back = std::make_unique<BSPTree>(min.x, min.y, min.z, max.x, max.y, halfLength, level + 1);
|
back = std::make_unique<BSPTree>(min.x, min.y, min.z, max.x, max.y, halfLength, level + 1);
|
||||||
|
|
||||||
isLeaf = false;
|
isLeaf = false;
|
||||||
node = std::make_unique<BSPNode>(std::move(front), std::move(back), AXIS_Z, halfLength);
|
node = std::make_unique<BSPNode>(std::move(front), std::move(back), PlaneAxis::AXIS_Z, halfLength);
|
||||||
leaf = nullptr;
|
leaf = nullptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -143,11 +147,12 @@ namespace BSP
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto side = node->objectIsInFront(*object);
|
const auto side = node->objectIsInFront(*object);
|
||||||
if (side == SIDE_FRONT)
|
|
||||||
|
if (side == PlaneSide::SIDE_FRONT)
|
||||||
{
|
{
|
||||||
node->front->addObjectToTree(std::move(object));
|
node->front->addObjectToTree(std::move(object));
|
||||||
}
|
}
|
||||||
else if (side == SIDE_BACK)
|
else if (side == PlaneSide::SIDE_BACK)
|
||||||
{
|
{
|
||||||
node->back->addObjectToTree(std::move(object));
|
node->back->addObjectToTree(std::move(object));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,18 @@
|
|||||||
|
|
||||||
#include "BSP.h"
|
#include "BSP.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace BSP
|
namespace BSP
|
||||||
{
|
{
|
||||||
enum PlaneAxis
|
enum class PlaneAxis : std::uint8_t
|
||||||
{
|
{
|
||||||
AXIS_X,
|
AXIS_X,
|
||||||
AXIS_Y,
|
AXIS_Y,
|
||||||
AXIS_Z
|
AXIS_Z
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PlaneSide
|
enum class PlaneSide : std::uint8_t
|
||||||
{
|
{
|
||||||
SIDE_FRONT,
|
SIDE_FRONT,
|
||||||
SIDE_BACK,
|
SIDE_BACK,
|
||||||
|
|||||||
@@ -67,12 +67,12 @@ namespace
|
|||||||
|
|
||||||
if (mesh->materials.count == 0)
|
if (mesh->materials.count == 0)
|
||||||
{
|
{
|
||||||
surface.material.materialType = MATERIAL_TYPE_EMPTY;
|
surface.material.materialType = BSPMaterialType::MATERIAL_TYPE_EMPTY;
|
||||||
surface.material.materialName = "";
|
surface.material.materialName = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
surface.material.materialType = MATERIAL_TYPE_TEXTURE;
|
surface.material.materialType = BSPMaterialType::MATERIAL_TYPE_TEXTURE;
|
||||||
surface.material.materialName = mesh->materials.data[meshPart.index]->name.data;
|
surface.material.materialName = mesh->materials.data[meshPart.index]->name.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,15 +98,18 @@ namespace
|
|||||||
blenderCoords.z = static_cast<float>(transformedPos.z);
|
blenderCoords.z = static_cast<float>(transformedPos.z);
|
||||||
vertex.pos = BSPUtil::convertToBO2Coords(blenderCoords);
|
vertex.pos = BSPUtil::convertToBO2Coords(blenderCoords);
|
||||||
|
|
||||||
if (surface.material.materialType == MATERIAL_TYPE_TEXTURE || surface.material.materialType == MATERIAL_TYPE_EMPTY)
|
if (surface.material.materialType == BSPMaterialType::MATERIAL_TYPE_TEXTURE
|
||||||
|
|| surface.material.materialType == BSPMaterialType::MATERIAL_TYPE_EMPTY)
|
||||||
{
|
{
|
||||||
vertex.color.x = 1.0f;
|
vertex.color.x = 1.0f;
|
||||||
vertex.color.y = 1.0f;
|
vertex.color.y = 1.0f;
|
||||||
vertex.color.z = 1.0f;
|
vertex.color.z = 1.0f;
|
||||||
vertex.color.w = 1.0f;
|
vertex.color.w = 1.0f;
|
||||||
}
|
}
|
||||||
else // surface->material.materialType == MATERIAL_TYPE_COLOUR
|
else
|
||||||
{
|
{
|
||||||
|
assert(surface.material.materialType == BSPMaterialType::MATERIAL_TYPE_COLOUR);
|
||||||
|
|
||||||
float factor = static_cast<float>(mesh->materials.data[meshPart.index]->fbx.diffuse_factor.value_real);
|
float factor = static_cast<float>(mesh->materials.data[meshPart.index]->fbx.diffuse_factor.value_real);
|
||||||
ufbx_vec4 diffuse = mesh->materials.data[meshPart.index]->fbx.diffuse_color.value_vec4;
|
ufbx_vec4 diffuse = mesh->materials.data[meshPart.index]->fbx.diffuse_color.value_vec4;
|
||||||
vertex.color.x = static_cast<float>(diffuse.x * factor);
|
vertex.color.x = static_cast<float>(diffuse.x * factor);
|
||||||
|
|||||||
@@ -361,18 +361,20 @@ namespace BSP
|
|||||||
{
|
{
|
||||||
cplane_s plane;
|
cplane_s plane;
|
||||||
plane.dist = tree.node->distance;
|
plane.dist = tree.node->distance;
|
||||||
if (tree.node->axis == AXIS_X)
|
if (tree.node->axis == PlaneAxis::AXIS_X)
|
||||||
{
|
{
|
||||||
plane.normal = normalX;
|
plane.normal = normalX;
|
||||||
plane.type = 0;
|
plane.type = 0;
|
||||||
}
|
}
|
||||||
else if (tree.node->axis == AXIS_Y)
|
else if (tree.node->axis == PlaneAxis::AXIS_Y)
|
||||||
{
|
{
|
||||||
plane.normal = normalY;
|
plane.normal = normalY;
|
||||||
plane.type = 1;
|
plane.type = 1;
|
||||||
}
|
}
|
||||||
else // tree->node->axis == AXIS_Z
|
else
|
||||||
{
|
{
|
||||||
|
assert(tree.node->axis == PlaneAxis::AXIS_Z);
|
||||||
|
|
||||||
plane.normal = normalZ;
|
plane.normal = normalZ;
|
||||||
plane.type = 2;
|
plane.type = 2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ namespace BSP
|
|||||||
gfxSurface->tris.vertexDataOffset1 = 0;
|
gfxSurface->tris.vertexDataOffset1 = 0;
|
||||||
|
|
||||||
std::string surfMaterialName;
|
std::string surfMaterialName;
|
||||||
if (bspSurface.material.materialType == MATERIAL_TYPE_TEXTURE)
|
if (bspSurface.material.materialType == BSPMaterialType::MATERIAL_TYPE_TEXTURE)
|
||||||
surfMaterialName = bspSurface.material.materialName;
|
surfMaterialName = bspSurface.material.materialName;
|
||||||
else // MATERIAL_TYPE_COLOUR || MATERIAL_TYPE_EMPTY
|
else // MATERIAL_TYPE_COLOUR || MATERIAL_TYPE_EMPTY
|
||||||
surfMaterialName = BSPLinkingConstants::COLOR_ONLY_IMAGE_NAME;
|
surfMaterialName = BSPLinkingConstants::COLOR_ONLY_IMAGE_NAME;
|
||||||
@@ -200,9 +200,9 @@ namespace BSP
|
|||||||
currModelInst->maxs.z = currModel->model->maxs.z + currModel->placement.origin.z;
|
currModelInst->maxs.z = currModel->model->maxs.z + currModel->placement.origin.z;
|
||||||
|
|
||||||
currModel->cullDist = DEFAULT_SMODEL_CULL_DIST;
|
currModel->cullDist = DEFAULT_SMODEL_CULL_DIST;
|
||||||
currModel->flags = DEFAULT_SMODEL_FLAGS;
|
currModel->flags = BSPEditableConstants::DEFAULT_SMODEL_FLAGS;
|
||||||
currModel->primaryLightIndex = DEFAULT_SMODEL_LIGHT;
|
currModel->primaryLightIndex = BSPEditableConstants::DEFAULT_SMODEL_LIGHT;
|
||||||
currModel->reflectionProbeIndex = DEFAULT_SMODEL_REFLECTION_PROBE;
|
currModel->reflectionProbeIndex = BSPEditableConstants::DEFAULT_SMODEL_REFLECTION_PROBE;
|
||||||
|
|
||||||
// unknown use / unused
|
// unknown use / unused
|
||||||
currModel->smid = i;
|
currModel->smid = i;
|
||||||
|
|||||||
Reference in New Issue
Block a user