2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-06-06 08:42:35 +00:00

feat: minor bug fixes

This commit is contained in:
LJW-Dev
2026-04-19 19:23:54 +08:00
committed by Jan Laupetin
parent 093203f9bf
commit 1191322abe
2 changed files with 30 additions and 29 deletions
+22 -23
View File
@@ -463,20 +463,16 @@ namespace
size_t materialIndex; size_t materialIndex;
if (primitive.material) if (primitive.material)
{ materialIndex = *primitive.material;
size_t originalMaterialIdx = *primitive.material; else
materialIndex = m_emptyMaterialIndex;
if (node.extras && node.extras->contains("flags")) if (node.extras && node.extras->contains("flags"))
{ {
bool isNoDrawFlagSet = false; bool isNoDrawFlagSet = false;
materialIndex = createMaterialWithFlags(originalMaterialIdx, node.extras->at("flags"), isNoDrawFlagSet); materialIndex = createMaterialWithFlags(materialIndex, node.extras->at("flags"), isNoDrawFlagSet);
if (isNoDrawFlagSet && m_is_world_gfx) if (isNoDrawFlagSet && m_is_world_gfx)
continue; // noDraw flag doesn't work, so remove the surface from the graphics data instead continue; // noDraw flag doesn't work, so remove the surface from the graphics data instead
} }
else
materialIndex = originalMaterialIdx;
}
else
materialIndex = m_emptyMaterialIndex;
BSPSurface surface; BSPSurface surface;
CreateSurface(accessorsForVertex, nodeMatrix, materialIndex, false, surface); CreateSurface(accessorsForVertex, nodeMatrix, materialIndex, false, surface);
@@ -856,24 +852,15 @@ namespace
assert(node.extras->contains("classname")); assert(node.extras->contains("classname"));
BSPEntity entity; BSPEntity entity;
bool doesClassContainModel = false; std::string classname = node.extras->at("classname");
for (auto& element : node.extras->items()) if (node.mesh && (classname.starts_with("trigger_") || !classname.compare("info_volume") || !classname.compare("script_brushmodel")))
{ {
std::string key = element.key(); if (node.extras->contains("model"))
if (!key.compare("origin") || !key.compare("angles") || !key.compare("flags")) {
continue; con::error("Node {} cannot have a model property when its class is a trigger, info_volume or script_brushmodel");
return false;
if (!key.compare("model"))
doesClassContainModel = true;
BSPEntityEntry entry;
entry.key = key;
entry.value = element.value();
entity.entries.emplace_back(entry);
} }
if (node.mesh && !doesClassContainModel)
{
if (m_is_world_gfx) if (m_is_world_gfx)
entity.modelIndex = addScriptTerrainModel(jRoot, node, nodeMatrix); entity.modelIndex = addScriptTerrainModel(jRoot, node, nodeMatrix);
else else
@@ -882,6 +869,18 @@ namespace
else else
entity.modelIndex = 0; entity.modelIndex = 0;
for (auto& element : node.extras->items())
{
std::string key = element.key();
if (!key.compare("origin") || !key.compare("angles") || !key.compare("flags"))
continue;
BSPEntityEntry entry;
entry.key = key;
entry.value = element.value();
entity.entries.emplace_back(entry);
}
Eigen::Vector4f position(0, 0, 0, 1.0f); Eigen::Vector4f position(0, 0, 0, 1.0f);
Eigen::Vector4f transformedPosition = nodeMatrix * position; Eigen::Vector4f transformedPosition = nodeMatrix * position;
entity.origin.x = transformedPosition.x(); entity.origin.x = transformedPosition.x();
@@ -159,11 +159,13 @@ namespace
entityString.append("{\n"); entityString.append("{\n");
entityString.append(std::format("\"origin\" \"{}\"\n", BSP::BSPUtil::convertVec3ToString(origin))); entityString.append(std::format("\"origin\" \"{}\"\n", BSP::BSPUtil::convertVec3ToString(origin)));
entityString.append(std::format("\"angles\" \"{}\"\n", BSP::BSPUtil::convertVec3ToString(angles)));
for (auto& entry : entity.entries) for (auto& entry : entity.entries)
entityString.append(std::format("\"{}\" \"{}\"\n", entry.key, entry.value)); entityString.append(std::format("\"{}\" \"{}\"\n", entry.key, entry.value));
if (entity.modelIndex != 0) if (entity.modelIndex != 0)
entityString.append(std::format("\"model\" \"*{}\"\n", entity.modelIndex)); entityString.append(std::format("\"model\" \"*{}\"\n", entity.modelIndex));
else // entities with generated models can't have rotation data
entityString.append(std::format("\"angles\" \"{}\"\n", BSP::BSPUtil::convertVec3ToString(angles)));
entityString.append("}\n"); entityString.append("}\n");
} }