Skip to content

Commit 57f5209

Browse files
committed
Add Ctrl + R keyboard shortcut to restart particle emission in the editor
Restarting particle animation frequently is often done in the VFX tweaking process. This shortcut is available for both GPUParticles and CPUParticles, in 2D and 3D.
1 parent 8e2141e commit 57f5209

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

editor/editor_node.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6302,6 +6302,9 @@ EditorNode::EditorNode() {
63026302
ED_SHORTCUT("editor/group_selected_nodes", TTR("Group Selected Node(s)"), KeyModifierMask::CMD_OR_CTRL | Key::G);
63036303
ED_SHORTCUT("editor/ungroup_selected_nodes", TTR("Ungroup Selected Node(s)"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::G);
63046304

6305+
// Used in the GPUParticles/CPUParticles 2D/3D editor plugins.
6306+
ED_SHORTCUT("particles/restart_emission", TTR("Restart Emission"), KeyModifierMask::CTRL | Key::R);
6307+
63056308
FileAccess::set_backup_save(EDITOR_GET("filesystem/on_save/safe_save_on_backup_then_rename"));
63066309

63076310
_update_vsync_mode();

editor/plugins/cpu_particles_2d_editor_plugin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "canvas_item_editor_plugin.h"
3434
#include "core/io/image_loader.h"
3535
#include "editor/editor_node.h"
36+
#include "editor/editor_settings.h"
3637
#include "editor/editor_undo_redo_manager.h"
3738
#include "editor/gui/editor_file_dialog.h"
3839
#include "editor/scene_tree_dock.h"
@@ -268,7 +269,7 @@ CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin() {
268269
toolbar->hide();
269270

270271
menu = memnew(MenuButton);
271-
menu->get_popup()->add_item(TTR("Restart"), MENU_RESTART);
272+
menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("particles/restart_emission"), MENU_RESTART);
272273
menu->get_popup()->add_item(TTR("Load Emission Mask"), MENU_LOAD_EMISSION_MASK);
273274
menu->get_popup()->add_item(TTR("Convert to GPUParticles2D"), MENU_CONVERT_TO_GPU_PARTICLES);
274275
menu->set_text(TTR("CPUParticles2D"));

editor/plugins/cpu_particles_3d_editor_plugin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "cpu_particles_3d_editor_plugin.h"
3232

3333
#include "editor/editor_node.h"
34+
#include "editor/editor_settings.h"
3435
#include "editor/editor_undo_redo_manager.h"
3536
#include "editor/gui/scene_tree_editor.h"
3637
#include "editor/plugins/node_3d_editor_plugin.h"
@@ -168,7 +169,7 @@ CPUParticles3DEditor::CPUParticles3DEditor() {
168169
particles_editor_hb->hide();
169170

170171
options->set_text(TTR("CPUParticles3D"));
171-
options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART);
172+
options->get_popup()->add_shortcut(ED_GET_SHORTCUT("particles/restart_emission"), MENU_OPTION_RESTART);
172173
options->get_popup()->add_item(TTR("Generate AABB"), MENU_OPTION_GENERATE_AABB);
173174
options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE);
174175
options->get_popup()->add_item(TTR("Convert to GPUParticles3D"), MENU_OPTION_CONVERT_TO_GPU_PARTICLES);

editor/plugins/gpu_particles_2d_editor_plugin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "canvas_item_editor_plugin.h"
3434
#include "core/io/image_loader.h"
3535
#include "editor/editor_node.h"
36+
#include "editor/editor_settings.h"
3637
#include "editor/editor_undo_redo_manager.h"
3738
#include "editor/gui/editor_file_dialog.h"
3839
#include "editor/scene_tree_dock.h"
@@ -370,7 +371,7 @@ GPUParticles2DEditorPlugin::GPUParticles2DEditorPlugin() {
370371
toolbar->hide();
371372

372373
menu = memnew(MenuButton);
373-
menu->get_popup()->add_item(TTR("Restart"), MENU_RESTART);
374+
menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("particles/restart_emission"), MENU_RESTART);
374375
menu->get_popup()->add_item(TTR("Generate Visibility Rect"), MENU_GENERATE_VISIBILITY_RECT);
375376
menu->get_popup()->add_item(TTR("Load Emission Mask"), MENU_LOAD_EMISSION_MASK);
376377
// menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK);

editor/plugins/gpu_particles_3d_editor_plugin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "core/io/resource_loader.h"
3434
#include "editor/editor_node.h"
35+
#include "editor/editor_settings.h"
3536
#include "editor/editor_undo_redo_manager.h"
3637
#include "editor/plugins/node_3d_editor_plugin.h"
3738
#include "editor/scene_tree_dock.h"
@@ -414,7 +415,7 @@ GPUParticles3DEditor::GPUParticles3DEditor() {
414415
particles_editor_hb->hide();
415416

416417
options->set_text(TTR("GPUParticles3D"));
417-
options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART);
418+
options->get_popup()->add_shortcut(ED_GET_SHORTCUT("particles/restart_emission"), MENU_OPTION_RESTART);
418419
options->get_popup()->add_item(TTR("Generate AABB"), MENU_OPTION_GENERATE_AABB);
419420
options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE);
420421
options->get_popup()->add_item(TTR("Convert to CPUParticles3D"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES);

0 commit comments

Comments
 (0)