2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-11-23 21:22:07 +00:00

chore: misc code improvements

This commit is contained in:
Jan Laupetin
2025-11-10 22:12:17 +01:00
parent 27c3c7dccb
commit 12647a505c
11 changed files with 28 additions and 11 deletions

View File

@@ -88,6 +88,7 @@ namespace BSP
max.y = yMax;
max.z = zMax;
level = treeLevel;
splitTree();
}

View File

@@ -59,6 +59,7 @@ namespace BSP
{
public:
BSPTree(float xMin, float yMin, float zMin, float xMax, float yMax, float zMax, int treeLevel);
void splitTree();
void addObjectToTree(std::shared_ptr<BSPObject> object) const;

View File

@@ -62,6 +62,7 @@ namespace BSP
result.x = (mins.x + maxs.x) * 0.5f;
result.y = (mins.y + maxs.y) * 0.5f;
result.z = (mins.z + maxs.z) * 0.5f;
return result;
}
@@ -71,6 +72,7 @@ namespace BSP
result.x = (maxs.x - mins.x) * 0.5f;
result.y = (maxs.y - mins.y) * 0.5f;
result.z = (maxs.z - mins.z) * 0.5f;
return result;
}
@@ -91,12 +93,12 @@ namespace BSP
const auto yRadians = angles->y * conversionValue;
const auto zRadians = angles->z * conversionValue;
const auto cosX = cos(xRadians);
const auto sinX = sin(xRadians);
const auto cosY = cos(yRadians);
const auto sinY = sin(yRadians);
const auto cosZ = cos(zRadians);
const auto sinZ = sin(zRadians);
const auto cosX = std::cos(xRadians);
const auto sinX = std::sin(xRadians);
const auto cosY = std::cos(yRadians);
const auto sinY = std::sin(yRadians);
const auto cosZ = std::cos(zRadians);
const auto sinZ = std::sin(zRadians);
axis[0].x = cosX * cosY;
axis[0].y = cosX * sinY;

View File

@@ -295,7 +295,7 @@ namespace BSP
BSPUtil::updateAABBWithPoint(vert, childMins, childMaxs);
}
CollisionAabbTree childAABBTree;
CollisionAabbTree childAABBTree{};
childAABBTree.materialIndex = 0; // always use the first material
childAABBTree.childCount = 0;
childAABBTree.u.partitionIndex = partitionIndex;
@@ -311,9 +311,15 @@ namespace BSP
outParentStartIndex = parentAABBArrayIndex;
}
constexpr vec3_t normalX = {1.0f, 0.0f, 0.0f};
constexpr vec3_t normalY = {0.0f, 1.0f, 0.0f};
constexpr vec3_t normalZ = {0.0f, 0.0f, 1.0f};
constexpr vec3_t normalX = {
{.x = 1.0f, .y = 0.0f, .z = 0.0f}
};
constexpr vec3_t normalY = {
{.x = 0.0f, .y = 1.0f, .z = 0.0f}
};
constexpr vec3_t normalZ = {
{.x = 0.0f, .y = 0.0f, .z = 1.0f}
};
// returns the index of the node/leaf parsed by the function
// Nodes are indexed by their index in the node array

View File

@@ -15,6 +15,7 @@ namespace BSP
{
// all lights that aren't the sunlight or default light need their own GfxLightDef asset
ComWorld* comWorld = m_memory.Alloc<ComWorld>();
comWorld->name = m_memory.Dup(bsp.bspName.c_str());
comWorld->isInUse = 1;
comWorld->primaryLightCount = BSPGameConstants::BSP_DEFAULT_LIGHT_COUNT;
@@ -25,6 +26,7 @@ namespace BSP
ComPrimaryLight* sunLight = &comWorld->primaryLights[1];
const vec4_t sunLightColor = BSPEditableConstants::SUNLIGHT_COLOR;
const vec3_t sunLightDirection = BSPEditableConstants::SUNLIGHT_DIRECTION;
sunLight->type = GFX_LIGHT_TYPE_DIR;
sunLight->diffuseColor.r = sunLightColor.r;
sunLight->diffuseColor.g = sunLightColor.g;

View File

@@ -11,6 +11,7 @@ namespace BSP
{
public:
ComWorldLinker(MemoryManager& memory, ISearchPath& searchPath, AssetCreationContext& context);
[[nodiscard]] T6::ComWorld* linkComWorld(const BSPData& bsp) const;
private:

View File

@@ -11,6 +11,7 @@ namespace BSP
{
public:
GameWorldMpLinker(MemoryManager& memory, ISearchPath& searchPath, AssetCreationContext& context);
[[nodiscard]] T6::GameWorldMp* linkGameWorldMp(const BSPData& bsp) const;
private:

View File

@@ -11,6 +11,7 @@ namespace BSP
{
public:
GfxWorldLinker(MemoryManager& memory, ISearchPath& searchPath, AssetCreationContext& context);
[[nodiscard]] T6::GfxWorld* linkGfxWorld(const BSPData& bsp) const;
private:

View File

@@ -11,6 +11,7 @@ namespace BSP
{
public:
MapEntsLinker(MemoryManager& memory, ISearchPath& searchPath, AssetCreationContext& context);
[[nodiscard]] T6::MapEnts* linkMapEnts(const BSPData& bsp) const;
private:

View File

@@ -11,6 +11,7 @@ namespace BSP
{
public:
SkinnedVertsLinker(MemoryManager& memory, ISearchPath& searchPath, AssetCreationContext& context);
[[nodiscard]] T6::SkinnedVertsDef* linkSkinnedVerts(const BSPData& bsp) const;
private: