Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle non-indexed collision meshes #1876

Merged
merged 2 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/esp/assets/GenericMeshData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,20 @@ void GenericMeshData::setMeshData(Magnum::Trade::MeshData&& meshData) {

/* For collision data we need indices as UnsignedInt. If the mesh already has
those, just make the collision data reference them. If not, unpack them
and store them here. */
if (meshData_->indexType() == Mn::MeshIndexType::UnsignedInt)
and store them here. And if there is no index buffer at all, generate a
trivial one (0, 1, 2, 3...). */
if (!meshData_->isIndexed()) {
collisionMeshData_.indices = indexData_ =
Cr::Containers::Array<Mn::UnsignedInt>{Cr::NoInit,
meshData_->vertexCount()};
for (Mn::UnsignedInt i = 0; i != indexData_.size(); ++i)
indexData_[i] = i;
} else if (meshData_->indexType() == Mn::MeshIndexType::UnsignedInt) {
collisionMeshData_.indices =
meshData_->mutableIndices<Mn::UnsignedInt>().asContiguous();
else
} else {
collisionMeshData_.indices = indexData_ = meshData_->indicesAsArray();
}
} // setMeshData

void GenericMeshData::importAndSetMeshData(
Expand Down
2 changes: 0 additions & 2 deletions src/tests/configure.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#define TEST_ASSETS "${TEST_ASSETS}"
#define DATA_DIR "${DATA_DIR}"

#define FILE_THAT_EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/IOTest.cpp"

#define MAGNUMRENDERERTEST_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}"

#cmakedefine HAS_MAGNUM_GLTFSCENECONVERTER