2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-11-23 05:12:05 +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.y = yMax;
max.z = zMax; max.z = zMax;
level = treeLevel; level = treeLevel;
splitTree(); splitTree();
} }

View File

@@ -59,6 +59,7 @@ namespace BSP
{ {
public: public:
BSPTree(float xMin, float yMin, float zMin, float xMax, float yMax, float zMax, int treeLevel); BSPTree(float xMin, float yMin, float zMin, float xMax, float yMax, float zMax, int treeLevel);
void splitTree(); void splitTree();
void addObjectToTree(std::shared_ptr<BSPObject> object) const; 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.x = (mins.x + maxs.x) * 0.5f;
result.y = (mins.y + maxs.y) * 0.5f; result.y = (mins.y + maxs.y) * 0.5f;
result.z = (mins.z + maxs.z) * 0.5f; result.z = (mins.z + maxs.z) * 0.5f;
return result; return result;
} }
@@ -71,6 +72,7 @@ namespace BSP
result.x = (maxs.x - mins.x) * 0.5f; result.x = (maxs.x - mins.x) * 0.5f;
result.y = (maxs.y - mins.y) * 0.5f; result.y = (maxs.y - mins.y) * 0.5f;
result.z = (maxs.z - mins.z) * 0.5f; result.z = (maxs.z - mins.z) * 0.5f;
return result; return result;
} }
@@ -91,12 +93,12 @@ namespace BSP
const auto yRadians = angles->y * conversionValue; const auto yRadians = angles->y * conversionValue;
const auto zRadians = angles->z * conversionValue; const auto zRadians = angles->z * conversionValue;
const auto cosX = cos(xRadians); const auto cosX = std::cos(xRadians);
const auto sinX = sin(xRadians); const auto sinX = std::sin(xRadians);
const auto cosY = cos(yRadians); const auto cosY = std::cos(yRadians);
const auto sinY = sin(yRadians); const auto sinY = std::sin(yRadians);
const auto cosZ = cos(zRadians); const auto cosZ = std::cos(zRadians);
const auto sinZ = sin(zRadians); const auto sinZ = std::sin(zRadians);
axis[0].x = cosX * cosY; axis[0].x = cosX * cosY;
axis[0].y = cosX * sinY; axis[0].y = cosX * sinY;

View File

@@ -295,7 +295,7 @@ namespace BSP
BSPUtil::updateAABBWithPoint(vert, childMins, childMaxs); BSPUtil::updateAABBWithPoint(vert, childMins, childMaxs);
} }
CollisionAabbTree childAABBTree; CollisionAabbTree childAABBTree{};
childAABBTree.materialIndex = 0; // always use the first material childAABBTree.materialIndex = 0; // always use the first material
childAABBTree.childCount = 0; childAABBTree.childCount = 0;
childAABBTree.u.partitionIndex = partitionIndex; childAABBTree.u.partitionIndex = partitionIndex;
@@ -311,9 +311,15 @@ namespace BSP
outParentStartIndex = parentAABBArrayIndex; outParentStartIndex = parentAABBArrayIndex;
} }
constexpr vec3_t normalX = {1.0f, 0.0f, 0.0f}; constexpr vec3_t normalX = {
constexpr vec3_t normalY = {0.0f, 1.0f, 0.0f}; {.x = 1.0f, .y = 0.0f, .z = 0.0f}
constexpr vec3_t normalZ = {0.0f, 0.0f, 1.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 // returns the index of the node/leaf parsed by the function
// Nodes are indexed by their index in the node array // 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 // all lights that aren't the sunlight or default light need their own GfxLightDef asset
ComWorld* comWorld = m_memory.Alloc<ComWorld>(); ComWorld* comWorld = m_memory.Alloc<ComWorld>();
comWorld->name = m_memory.Dup(bsp.bspName.c_str()); comWorld->name = m_memory.Dup(bsp.bspName.c_str());
comWorld->isInUse = 1; comWorld->isInUse = 1;
comWorld->primaryLightCount = BSPGameConstants::BSP_DEFAULT_LIGHT_COUNT; comWorld->primaryLightCount = BSPGameConstants::BSP_DEFAULT_LIGHT_COUNT;
@@ -25,6 +26,7 @@ namespace BSP
ComPrimaryLight* sunLight = &comWorld->primaryLights[1]; ComPrimaryLight* sunLight = &comWorld->primaryLights[1];
const vec4_t sunLightColor = BSPEditableConstants::SUNLIGHT_COLOR; const vec4_t sunLightColor = BSPEditableConstants::SUNLIGHT_COLOR;
const vec3_t sunLightDirection = BSPEditableConstants::SUNLIGHT_DIRECTION; const vec3_t sunLightDirection = BSPEditableConstants::SUNLIGHT_DIRECTION;
sunLight->type = GFX_LIGHT_TYPE_DIR; sunLight->type = GFX_LIGHT_TYPE_DIR;
sunLight->diffuseColor.r = sunLightColor.r; sunLight->diffuseColor.r = sunLightColor.r;
sunLight->diffuseColor.g = sunLightColor.g; sunLight->diffuseColor.g = sunLightColor.g;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -91,7 +91,7 @@ namespace
consts[1] = currArgJs["u"]["const1"]; consts[1] = currArgJs["u"]["const1"];
consts[2] = currArgJs["u"]["const2"]; consts[2] = currArgJs["u"]["const2"];
consts[3] = currArgJs["u"]["const3"]; consts[3] = currArgJs["u"]["const3"];
currArg->u.literalConst = (float(*)[4])consts; currArg->u.literalConst = (float (*)[4])consts;
} }
else else
{ {