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
+27 -28
View File
@@ -463,20 +463,16 @@ namespace
size_t materialIndex;
if (primitive.material)
{
size_t originalMaterialIdx = *primitive.material;
if (node.extras && node.extras->contains("flags"))
{
bool isNoDrawFlagSet = false;
materialIndex = createMaterialWithFlags(originalMaterialIdx, node.extras->at("flags"), isNoDrawFlagSet);
if (isNoDrawFlagSet && m_is_world_gfx)
continue; // noDraw flag doesn't work, so remove the surface from the graphics data instead
}
else
materialIndex = originalMaterialIdx;
}
materialIndex = *primitive.material;
else
materialIndex = m_emptyMaterialIndex;
if (node.extras && node.extras->contains("flags"))
{
bool isNoDrawFlagSet = false;
materialIndex = createMaterialWithFlags(materialIndex, node.extras->at("flags"), isNoDrawFlagSet);
if (isNoDrawFlagSet && m_is_world_gfx)
continue; // noDraw flag doesn't work, so remove the surface from the graphics data instead
}
BSPSurface surface;
CreateSurface(accessorsForVertex, nodeMatrix, materialIndex, false, surface);
@@ -856,24 +852,15 @@ namespace
assert(node.extras->contains("classname"));
BSPEntity entity;
bool doesClassContainModel = false;
for (auto& element : node.extras->items())
std::string classname = node.extras->at("classname");
if (node.mesh && (classname.starts_with("trigger_") || !classname.compare("info_volume") || !classname.compare("script_brushmodel")))
{
std::string key = element.key();
if (!key.compare("origin") || !key.compare("angles") || !key.compare("flags"))
continue;
if (node.extras->contains("model"))
{
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)
entity.modelIndex = addScriptTerrainModel(jRoot, node, nodeMatrix);
else
@@ -882,6 +869,18 @@ namespace
else
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 transformedPosition = nodeMatrix * position;
entity.origin.x = transformedPosition.x();
@@ -159,11 +159,13 @@ namespace
entityString.append("{\n");
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)
entityString.append(std::format("\"{}\" \"{}\"\n", entry.key, entry.value));
if (entity.modelIndex != 0)
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");
}