File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 3333#include " editor/plugins/node_3d_editor_plugin.h"
3434#include " scene/3d/mesh_instance_3d.h"
3535#include " scene/3d/soft_body_3d.h"
36+ #include " scene/resources/3d/primitive_meshes.h"
3637
3738MeshInstance3DGizmoPlugin::MeshInstance3DGizmoPlugin () {
3839}
@@ -64,7 +65,22 @@ void MeshInstance3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
6465 return ; // none
6566 }
6667
67- Ref<TriangleMesh> tm = m->generate_triangle_mesh ();
68+ Ref<TriangleMesh> tm;
69+
70+ Ref<PlaneMesh> plane_mesh = mesh->get_mesh ();
71+ if (plane_mesh.is_valid () && (plane_mesh->get_subdivide_depth () > 0 || plane_mesh->get_subdivide_width () > 0 )) {
72+ // PlaneMesh subdiv makes gizmo redraw very slow due to TriangleMesh BVH calculation for every face.
73+ // For gizmo collision this is very much unnecessary since a PlaneMesh is always flat, 2 faces is enough.
74+ Ref<PlaneMesh> simple_plane_mesh;
75+ simple_plane_mesh.instantiate ();
76+ simple_plane_mesh->set_orientation (plane_mesh->get_orientation ());
77+ simple_plane_mesh->set_size (plane_mesh->get_size ());
78+ simple_plane_mesh->set_center_offset (plane_mesh->get_center_offset ());
79+ tm = simple_plane_mesh->generate_triangle_mesh ();
80+ } else {
81+ tm = m->generate_triangle_mesh ();
82+ }
83+
6884 if (tm.is_valid ()) {
6985 p_gizmo->add_collision_triangles (tm);
7086 }
You can’t perform that action at this time.
0 commit comments