Răsfoiți Sursa

Properly manage drawing of primitives when they lack an area, fixes #8930

Juan Linietsky 8 ani în urmă
părinte
comite
72be8876ea

+ 2 - 2
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; }

+ 13 - 5
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);
+		}
 	}
 }
 

+ 2 - 0
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);

+ 4 - 2
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) {
 

+ 5 - 4
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);