Skip to content

Commit

Permalink
--exit calc if not strictly triangle-based mesh; make temp dedup copy
Browse files Browse the repository at this point in the history
  • Loading branch information
jturner65 committed Aug 1, 2024
1 parent 1ed8b18 commit 263679a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/esp/assets/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1048,22 +1048,30 @@ void ResourceManager::computeGeneralMeshAreaAndVolume(

Cr::Containers::Optional<Mn::Trade::MeshData>& meshData =
meshes_.at(meshID)->getMeshData();
if (meshData->primitive() != Mn::MeshPrimitive::Triangles) {
// These calculations rely on this mesh being purely triangle-based
continue;
}
CORRADE_ASSERT(
meshData,
"::computeGeneralMeshAreaAndVolume: The mesh data specified at ID:"
<< meshID << "is empty/undefined. Aborting", );
// Make temp copy that removes dupes for volume calc
Cr::Containers::Optional<Mn::Trade::MeshData> newMeshData =
Mn::MeshTools::removeDuplicates(Mn::MeshTools::filterOnlyAttributes(
*meshData, {Mn::Trade::MeshAttribute::Position}));

// Precalc all transformed verts - only use first position array for this
Cr::Containers::Array<Mn::Vector3> posArray =
meshData->positions3DAsArray(0);
newMeshData->positions3DAsArray(0);
Mn::MeshTools::transformPointsInPlace(absTransforms[iEntry], posArray);

// Getting the view properly relies on having the appropriate type of the
// loaded data
// const auto idxView = meshData->indices<std::uint32_t>();
const auto idxAra = meshData->indicesAsArray();
// const auto idxView = newMeshData->indices<std::uint32_t>();
const auto idxAra = newMeshData->indicesAsArray();
// # of indices
uint32_t numIdxs = meshData->indexCount();
uint32_t numIdxs = newMeshData->indexCount();
// Assuming no duplicate vertices with different idxs
// Determine that all edges have exactly 2 sides ->
// idxAra describes exactly 2 pairs of the same idxs, a->b and b->a
Expand Down

0 comments on commit 263679a

Please sign in to comment.