From 72be8876ea40984532d283c598dfcc267d30c829 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 18 Aug 2017 15:11:16 -0300 Subject: [PATCH] Properly manage drawing of primitives when they lack an area, fixes #8930 --- core/math/rect3.h | 4 ++-- editor/plugins/path_editor_plugin.cpp | 18 +++++++++++++----- editor/scene_tree_dock.cpp | 2 ++ servers/visual/visual_server_scene.cpp | 6 ++++-- servers/visual_server.cpp | 9 +++++---- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/core/math/rect3.h b/core/math/rect3.h index 7c971f5ac73..4890a19d990 100644 --- a/core/math/rect3.h +++ b/core/math/rect3.h @@ -47,12 +47,12 @@ public: real_t get_area() const; /// get area _FORCE_INLINE_ bool has_no_area() const { - return (size.x <= CMP_EPSILON || size.y <= CMP_EPSILON || size.z <= CMP_EPSILON); + return (size.x <= 0 || size.y <= 0 || size.z <= 0); } _FORCE_INLINE_ bool has_no_surface() const { - return (size.x <= CMP_EPSILON && size.y <= CMP_EPSILON && size.z <= CMP_EPSILON); + return (size.x <= 0 && size.y <= 0 && size.z <= 0); } const Vector3 &get_position() const { return position; } diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp index c32ed1064f9..96a98f3c484 100644 --- a/editor/plugins/path_editor_plugin.cpp +++ b/editor/plugins/path_editor_plugin.cpp @@ -222,8 +222,10 @@ void PathSpatialGizmo::redraw() { //v3p.push_back(r[i]+Vector3(0,0.2,0)); } - add_lines(v3p, PathEditorPlugin::singleton->path_material); - add_collision_segments(v3p); + if (v3p.size() > 1) { + add_lines(v3p, PathEditorPlugin::singleton->path_material); + add_collision_segments(v3p); + } if (PathEditorPlugin::singleton->get_edited_path() == path) { v3p.clear(); @@ -247,9 +249,15 @@ void PathSpatialGizmo::redraw() { } } - add_lines(v3p, PathEditorPlugin::singleton->path_thin_material); - add_handles(handles); - add_handles(sec_handles, false, true); + if (v3p.size() > 1) { + add_lines(v3p, PathEditorPlugin::singleton->path_thin_material); + } + if (handles.size()) { + add_handles(handles); + } + if (sec_handles.size()) { + add_handles(sec_handles, false, true); + } } } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index ce3b85332f0..e984098bd4f 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2030,6 +2030,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel tb->set_tooltip(TTR("Attach a new or existing script for the selected node.")); tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/attach_script")); filter_hbc->add_child(tb); + tb->hide(); button_create_script = tb; tb = memnew(ToolButton); @@ -2038,6 +2039,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/clear_script")); filter_hbc->add_child(tb); button_clear_script = tb; + tb->hide(); scene_tree = memnew(SceneTreeEditor(false, true, true)); vbc->add_child(scene_tree); diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 5faf0e67caf..8e21ecc189b 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -1048,8 +1048,9 @@ void VisualServerScene::_update_instance(Instance *p_instance) { VSG::storage->particles_set_emission_transform(p_instance->base, p_instance->transform); } - if (p_instance->aabb.has_no_surface()) + if (p_instance->aabb.has_no_area()) { return; + } #if 0 if (p_instance->base_type == VS::INSTANCE_PARTICLES) { @@ -3278,8 +3279,9 @@ void VisualServerScene::render_probes() { void VisualServerScene::_update_dirty_instance(Instance *p_instance) { - if (p_instance->update_aabb) + if (p_instance->update_aabb) { _update_instance_aabb(p_instance); + } if (p_instance->update_materials) { diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 65dd4d76613..dacf04f8d6d 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -339,7 +339,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ if (i == 0) { - aabb = Rect2(src[i], Vector2()); + aabb = Rect2(src[i], Vector2(0.00001, 0.00001)); //must have a bit of size } else { aabb.expand_to(src[i]); @@ -355,7 +355,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ if (i == 0) { - aabb = Rect2(src[i], Vector2()); + aabb = Rect2(src[i], Vector2(0.00001, 0.00001)); //must have a bit of size } else { aabb.expand_to(src[i]); @@ -385,7 +385,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ if (i == 0) { - aabb = Rect3(src[i], Vector3()); + aabb = Rect3(src[i], Vector3(0.00001, 0.00001, 0.00001)); } else { aabb.expand_to(src[i]); @@ -401,7 +401,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ if (i == 0) { - aabb = Rect3(src[i], Vector3()); + aabb = Rect3(src[i], Vector3(0.00001, 0.00001, 0.00001)); } else { aabb.expand_to(src[i]); @@ -735,6 +735,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ //first bptr[idx] = Rect3(); bptr[idx].position = v; + bptr[idx].size = Vector3(0.00001, 0.00001, 0.00001); //must have at least a bit of size any_valid = true; } else { bptr[idx].expand_to(v);