summaryrefslogtreecommitdiff
path: root/editor/plugins/node_3d_editor_plugin.cpp
diff options
context:
space:
mode:
authorGordon MacPherson <gordon@gordonite.tech>2020-12-30 09:56:49 +0000
committerGordon MacPherson <gordon@gordonite.tech>2021-01-26 19:48:18 +0000
commit86c7faa169a2d11be7ea3c83ae833ffba0660556 (patch)
tree098bce42aa4f6e889825fbdae82890c595c3bf9b /editor/plugins/node_3d_editor_plugin.cpp
parentfa498f6105bb18a038210f4c000e1a97b7c86354 (diff)
Fix zero scaling and material mappings being mapped to wrong fields
- fixes scale values of 0.0013 (det == 0.00004) not rendering, they should render even at small values, but not at zero like the editor grid plugin supplies zero exactly. - fixes node_3d_editor_plugin visibility bug when scale is zero - fix culling with small scaling values - which are still valid to be rendered like 0.00004 note: grid is still not fixed, it has det == 0 issues but this fixes one of them.
Diffstat (limited to 'editor/plugins/node_3d_editor_plugin.cpp')
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 4fb0013620..dcf38e0617 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -3321,6 +3321,21 @@ void Node3DEditorViewport::update_transform_gizmo_view() {
xform.basis.scale(scale);
+ // if the determinant is zero, we should disable the gizmo from being rendered
+ // this prevents supplying bad values to the renderer and then having to filter it out again
+ if (xform.basis.determinant() == 0) {
+ for (int i = 0; i < 3; i++) {
+ RenderingServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false);
+ }
+ // Rotation white outline
+ RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[3], false);
+ return;
+ }
+
for (int i = 0; i < 3; i++) {
RenderingServer::get_singleton()->instance_set_transform(move_gizmo_instance[i], xform);
RenderingServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE));