Skip to content

Avoid IndexOutOfRangeException during mesh extraction and submesh removal#60

Open
rikochet9 wants to merge 1 commit into
soupday:mainfrom
rikochet9:fix/submesh-extraction-error
Open

Avoid IndexOutOfRangeException during mesh extraction and submesh removal#60
rikochet9 wants to merge 1 commit into
soupday:mainfrom
rikochet9:fix/submesh-extraction-error

Conversation

@rikochet9

Copy link
Copy Markdown

MeshUtil.cs: When working with submeshes, use the actual number of triangles they report instead of relying on the mesh description's claimed number, which can be inaccurate and result in a crash.

The Problem

For unknown reasons, submesh descriptors can sometimes report an incorrect number of indices. Attempting to iterate using these numbers results in an out of range exception. See detailed example below.

The Solution

Instead of getting all the mesh's triangles and iterating through a subset inferred from the submesh descriptor, get the triangles for that specific submesh and iterate through them as normal. This ensures the index is always in range.

Example

Crash:
Example Subindex Error

In this case, it attempted to iterate up to index 190,935 of an array with only 92,202 objects because of numbers the mesh description reported:
Diagnostic Logs

…iangles they report instead of relying on the mesh description's claimed number, which can be inaccurate and result in a crash.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant