fix(MeshHelper): get_triangles on meshes without indices - #381
Open
nichinichisou0609 wants to merge 1 commit into
Open
nichinichisou0609 wants to merge 1 commit into
nichinichisou0609 wants to merge 1 commit into
Conversation
MeshHandler only copies a non-empty index buffer, so for a mesh without indices m_IndexBuffer stays None and get_triangles failed its first assertion. Such a mesh (vertices only, e.g. a placeholder mesh, or submeshes with indexCount 0) now gets an empty triangle list per submesh; a submesh that has indices while the mesh has no index buffer raises a ValueError.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MeshHandler.copy_from_meshcopiesmesh.m_IndexBufferonly when it is non-empty, so for a mesh without indicesself.m_IndexBufferstaysNone, andget_trianglesstops atassert self.m_IndexBuffer is not None. Exporting such a mesh (mesh.export()) therefore fails with anAssertionError.Unity serializes meshes like this, for example:
m_SubMeshes == []);indexCountis 0.Changes:
get_triangles: when there is no index buffer, return an empty triangle list for each submesh. If a submesh declares indices (indexCount > 0) while the mesh has no index buffer, raise aValueErrorinstead, since that data is inconsistent. This matches AssetStudio'sGetTriangles, which loops over the submeshes of an empty index buffer without output and fails with an index error when a submesh has indices that the buffer does not hold.copy_from_meshis unchanged, and so are compressed meshes, whose indices come fromm_CompressedMesh; the new check only runs when there is no index buffer at all.tests/test_mesh_helper.pycovers the three cases on thexinzexi_2_n_texsample mesh, with its fields changed in memory: no submeshes and no indices (empty result, OBJ export with vertices and no faces), submeshes withindexCount0, and submeshes with indices but no index buffer (ValueError). All three fail on master with theAssertionError.This is the index-buffer counterpart of the empty
VertexDatahandling added in #366.