godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.66k stars 20.11k forks source link

`EditorNode3DGizmo::add_collision_triangles` replaces previous meshes instead of adding #94519

Open juanjp600 opened 1 month ago

juanjp600 commented 1 month ago

Tested versions

Reproducible in: 4.3.beta [0918fd2], 4.2.2.stable, 4.1.4.stable

System information

Windows 10 - Godot v4.2.2.stable

Issue description

I'm playing around with the plugin system, and I wanted to add a gizmo that has collision triangles. A gizmo that needs to add collision triangles will not work correctly if it's working with multiple TriangleMeshes: only the last one added is checked for collision.

The implementation of EditorNode3DGizmo::add_collision_triangles seems to be the culprit: https://github.com/godotengine/godot/blob/ff8a2780ee777c2456ce42368e1065774c7c4c3f/editor/plugins/node_3d_editor_gizmos.cpp#L361-L363

I consider this a bug because it is inconsistent with the way other functions, like add_mesh and add_collision_segment, work.

Steps to reproduce

Minimal reproduction project (MRP)

Editor3DNodeGizmo AddCollisionTriangles MRP.zip

jsjtxietian commented 1 month ago

I have an idea of fixing this, I'll make a pr later