1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-17 14:11:06 +00:00

GPU Particles (2D + 3D) visibility rect / gizmo optimization for reduced visual clutter

This commit is contained in:
Raffaele Picca
2021-12-09 21:31:51 +01:00
parent e00d20aa5a
commit 995408b492
4 changed files with 45 additions and 1 deletions

View File

@@ -57,6 +57,28 @@ void Particles2DEditorPlugin::_file_selected(const String &p_file) {
emission_mask->popup_centered_minsize();
}
void Particles2DEditorPlugin::_selection_changed() {
List<Node *> selected_nodes = editor->get_editor_selection()->get_selected_node_list();
if (selected_particles.empty() && selected_nodes.empty()) {
return;
}
for (int i = 0; i < selected_particles.size(); i++) {
selected_particles[i]->set_show_visibility_rect(false);
}
selected_particles.clear();
for (int i = 0; i < selected_nodes.size(); i++) {
Particles2D *selected_particle = Object::cast_to<Particles2D>(selected_nodes[i]);
if (selected_particle != nullptr) {
selected_particle->set_show_visibility_rect(true);
selected_particles.push_back(selected_particle);
}
}
}
void Particles2DEditorPlugin::_menu_callback(int p_idx) {
switch (p_idx) {
case MENU_GENERATE_VISIBILITY_RECT: {
@@ -331,12 +353,14 @@ void Particles2DEditorPlugin::_notification(int p_what) {
menu->get_popup()->connect("id_pressed", this, "_menu_callback");
menu->set_icon(menu->get_popup()->get_icon("Particles2D", "EditorIcons"));
file->connect("file_selected", this, "_file_selected");
EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", this, "_selection_changed");
}
}
void Particles2DEditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("_menu_callback"), &Particles2DEditorPlugin::_menu_callback);
ClassDB::bind_method(D_METHOD("_file_selected"), &Particles2DEditorPlugin::_file_selected);
ClassDB::bind_method(D_METHOD("_selection_changed"), &Particles2DEditorPlugin::_selection_changed);
ClassDB::bind_method(D_METHOD("_generate_visibility_rect"), &Particles2DEditorPlugin::_generate_visibility_rect);
ClassDB::bind_method(D_METHOD("_generate_emission_mask"), &Particles2DEditorPlugin::_generate_emission_mask);
}