-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide visibility rects of Particle Systems by default (show when selected) #3554
Comments
3D gizmos can only have their alpha multiplied by a constant value when unselected; they can't be hidden entirely. Last time I checked, it would require a significant rework to allow hiding specific gizmos entirely when a node isn't selected. For 2D, I've tried to modify diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp
index f1f4d1b769..e8b095623a 100644
--- a/scene/2d/gpu_particles_2d.cpp
+++ b/scene/2d/gpu_particles_2d.cpp
@@ -34,6 +34,7 @@
#ifdef TOOLS_ENABLED
#include "core/config/engine.h"
+#include "editor/editor_node.h"
#endif
void GPUParticles2D::set_emitting(bool p_emitting) {
@@ -452,7 +453,8 @@ void GPUParticles2D::_notification(int p_what) {
RS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid);
#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_ancestor_of(this))) {
+ if (Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton()->get_editor_selection()->is_selected(this)) {
+ // Draw visibility rectangle only when the node is selected to reduce visual noise.
draw_rect(visibility_rect, Color(0, 0.7, 0.9, 0.4), false);
}
#endif Testing project ( |
I actually jumped into cold water and even tho I'm not by any means a C++ programmer I managed to get it running ... (man that feels fantastic 🤣 ) FBx7YGcaC0.mp4I worked on the 3.4 codebase (by mistake), but I guess this could be easily adapted to 4.0: diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp
index a0241a2bf0..98af650edb 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/particles_2d.cpp
@@ -36,6 +36,7 @@
#ifdef TOOLS_ENABLED
#include "core/engine.h"
+#include "editor/editor_node.h"
#endif
void Particles2D::set_emitting(bool p_emitting) {
@@ -203,6 +204,13 @@ bool Particles2D::get_fractional_delta() const {
return fractional_delta;
}
+void Particles2D::_selection_changed() {
+ // Update the visibility rect state
+ draw_visibility_rect = EditorNode::get_singleton()->get_editor_selection()->is_selected(this);
+ update();
+}
+
+
String Particles2D::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning();
if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) {
@@ -274,6 +282,11 @@ void Particles2D::restart() {
}
void Particles2D::_notification(int p_what) {
+#ifdef TOOLS_ENABLED
+ if ((Engine::get_singleton()->is_editor_hint()) && (p_what == NOTIFICATION_ENTER_CANVAS)) {
+ EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", this, "_selection_changed");
+ }
+#endif
if (p_what == NOTIFICATION_DRAW) {
RID texture_rid;
if (texture.is_valid()) {
@@ -287,7 +300,7 @@ void Particles2D::_notification(int p_what) {
VS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid, normal_rid);
#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
+ if ((Engine::get_singleton()->is_editor_hint()) && (draw_visibility_rect)) {
draw_rect(visibility_rect, Color(0, 0.7, 0.9, 0.4), false);
}
#endif
@@ -355,6 +368,8 @@ void Particles2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("restart"), &Particles2D::restart);
+ ClassDB::bind_method(D_METHOD("_selection_changed"), &Particles2D::_selection_changed);
+
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emitting"), "set_emitting", "is_emitting");
ADD_PROPERTY(PropertyInfo(Variant::INT, "amount", PROPERTY_HINT_EXP_RANGE, "1,1000000,1"), "set_amount", "get_amount");
ADD_GROUP("Time", ""); diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h
index 91e8d31df9..5cbd24c4a9 100644
--- a/scene/2d/particles_2d.h
+++ b/scene/2d/particles_2d.h
@@ -70,9 +70,11 @@ private:
void _update_particle_emission_transform();
protected:
+ bool draw_visibility_rect;
static void _bind_methods();
virtual void _validate_property(PropertyInfo &property) const;
void _notification(int p_what);
+ void _selection_changed();
public:
void set_emitting(bool p_emitting); |
Nice work! Feel free to open a pull request for this 🙂 Note that we'll need a pull request against both |
I've just opened a PR for master: If this will be accepted, I will open a PR for 3.x right away 👍 |
Fixed by godotengine/godot#55052. |
Describe the project you are working on
I work on FRANZ FURY, I often use a lot of particle systems in certain scenes.
Describe the problem or limitation you are having in your project
When building scenes or maps containing these scenes, the visual representation of the visibility rect on Particle Systems is very annoying.
I also had this problem when trying out Godot 4 with 3D Particles.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
The feature would reduce the visual distraction when working in the editor. The information about the actual size of the visibility rect is probably helpful when the Node is selected. In a scene with a lot of particle systems, the information is lost in the amount of boxes.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
By default, all boxes are hidden, when a user selects a node containing one of those boxes, the visibility rect is shown.
If this enhancement will not be used often, can it be worked around with a few lines of script?
Can't be worked around with GDscript, the only way of hiding the box is to hide the Node (which will also hide the effect).
Is there a reason why this should be core and not an add-on in the asset library?
Because it can't be made using GDscript.
The text was updated successfully, but these errors were encountered: