File tree 1 file changed +17
-1
lines changed
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 33
33
#include " editor/plugins/node_3d_editor_plugin.h"
34
34
#include " scene/3d/mesh_instance_3d.h"
35
35
#include " scene/3d/soft_body_3d.h"
36
+ #include " scene/resources/3d/primitive_meshes.h"
36
37
37
38
MeshInstance3DGizmoPlugin::MeshInstance3DGizmoPlugin () {
38
39
}
@@ -64,7 +65,22 @@ void MeshInstance3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
64
65
return ; // none
65
66
}
66
67
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
+
68
84
if (tm .is_valid ()) {
69
85
p_gizmo->add_collision_triangles (tm );
70
86
}
You can’t perform that action at this time.
0 commit comments