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

GLTF: Only create MeshInstance3D when needed #96133

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

aaronfranke
Copy link
Member

@fire pointed out this suboptimal code to me. Right now the code creates a MeshInstance3D, then checks if a mesh is available, and if not it deletes it. This is silly, there's no need to create and then delete when we can instead just move the creation inside of the if statement.

We expect that if an ImporterMeshInstance3D does not have a valid mesh, that the ImporterMeshInstance3D should not have been created in the first place, and there is a problem at some earlier stage of the import process. So I added a warning in the place that there used to be a memdelete.

Also, I renamed the ImporterMeshInstance3D *mesh_3d local variable to importer_mesh_3d for clarity.

@aaronfranke aaronfranke force-pushed the gltf-imp-mesh-inst-create branch from 67dc22d to 263f089 Compare August 27, 2024 11:23
@akien-mga akien-mga merged commit 93f241b into godotengine:master Aug 27, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

@aaronfranke aaronfranke deleted the gltf-imp-mesh-inst-create branch August 27, 2024 20:13
@fire fire mentioned this pull request Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants