godot-deformablemesh icon indicating copy to clipboard operation
godot-deformablemesh copied to clipboard

Doesn't work when index array is null

Open nan0m opened this issue 1 year ago • 5 comments

It's an amazing plugin. Thank you so much for making this, this saves me a lot of time and allows me to integrate great new features into my game. E.g. the character traveling through pipes, and the pipes deforming.

Currently the plugin crashes if the assigned original_mesh doesn't have an index array. This is for example the case when getting meshes from CSG nodes. Using get_meshes()[1]

nan0m avatar Oct 03 '24 13:10 nan0m

Hi @nan0m,

thank you for your kind words! I'm glad to hear that the plugin is saving you time and helping you integrate cool features like the character traveling through pipes. That sounds like an awesome use case!

Regarding the crash you're experiencing, could you provide me with a specific mesh (as an attachment here) that causes the issue when it's assigned to original_mesh?

This should help me identify and resolve the problem quickly. It sounds like it could be an easy fix, and I'd love to get it sorted out for you.

Thanks again for your feedback!

cloudofoz avatar Oct 03 '24 17:10 cloudofoz

Hi @cloudofoz, thank you so much for replying so quickly. I attached a .zip file of the .tres for the mesh I am having the problem with. mesh_issue.zip

this is the error I get when assigning the mesh to the DeformableMeshInstance, and whenever I move the SphericalDeformer:

sorry i was on mobile before and therefore a bit imprecise, it's not a crash, but the script throws an error and exits early.

res://addons/deformablemesh/dm_surface_data.gd:74 - Out of bounds get index '0' (on base: 'PackedVector2Array') servers/rendering_server.cpp:1264 - Mesh created without vertex array. This mesh will not be visible with the default shader. If using an empty vertex array is intentional, create the mesh with the ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY flag to silence this error. Meshes must contain a vertex array, an index array, or both servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp:567 - Index (uint32_t)p_surface = 0 is out of bounds (mesh->surface_count = 0).

nan0m avatar Oct 03 '24 18:10 nan0m

Thank you for providing the mesh example, and for clarifying the details! I took a look at the issue, and it does appear to be related to the fact that my code currently expects the mesh to have indices and a UV coordinate set.

I've worked on handling this issue in my add-on, but before sharing the fix with you, could you please provide the mesh in a way that ensures it is correctly importable and viewable in Godot? For example, GLTF might work if the .tres format isn't displaying correctly.

Unfortunately, the .tres you provided is visible in the mesh preview but doesn't appear in the real scene (nor in Blender), making it hard for me to verify that my fix is correct.

Thanks again for your help, and I look forward to your response!

cloudofoz avatar Oct 03 '24 19:10 cloudofoz

I don't have a blender file for the relevant mesh. And I fear that if I exported it from Godot to Blender, to send it to you. Some Modifications would take place. This .tscn recreates my setup and the issue exactly: deformer_bug.zip

All that the script does is get the mesh from the csg polygon and assigns them to the DeformableMeshInstance3D.

Does this help?

nan0m avatar Oct 03 '24 22:10 nan0m

I was able to test your scene, and it looks like the fix I implemented has resolved the issue with meshes that don't have indices or a UV set. Before I merge the changes into the main branch, it would be great if you could test it on your end as well.

You can find the updated code here: https://github.com/cloudofoz/godot-deformablemesh/tree/fix/issue-3. Please give it a try and let me know if everything works as expected.

You can download a snapshot of the fixed addon here: https://github.com/cloudofoz/godot-deformablemesh/archive/refs/heads/fix/issue-3.zip

Thanks again for your help, and I look forward to your feedback!

cloudofoz avatar Oct 04 '24 05:10 cloudofoz

I’ve run additional tests myself, and everything seems to be working fine without any issues. Since there haven’t been any further reports or concerns, I will merge the fix into the main branch and close this issue.

If you encounter any problems after the merge, feel free to reopen the issue!

Best regards,

C.

cloudofoz avatar Oct 11 '24 12:10 cloudofoz