diff options
author | Yuri Roubinski <chaosus89@gmail.com> | 2023-08-19 11:55:49 +0300 |
---|---|---|
committer | Yuri Roubinski <chaosus89@gmail.com> | 2023-08-19 11:58:57 +0300 |
commit | 7fcb91f0779c9deb21c57127207a8860e44be0f3 (patch) | |
tree | 57a7aa307df0751db5a24fdb40f2f96300218950 /editor/plugins/cpu_particles_3d_editor_plugin.cpp | |
parent | b51ee8b029b0b9f719f01bbdd21a329e65d4d238 (diff) | |
download | redot-engine-7fcb91f0779c9deb21c57127207a8860e44be0f3.tar.gz |
Implement conversion from `CPUParticles` to `GPUParticles` (3D/2D)
Diffstat (limited to 'editor/plugins/cpu_particles_3d_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/cpu_particles_3d_editor_plugin.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.cpp b/editor/plugins/cpu_particles_3d_editor_plugin.cpp index 6edfc2ef2e..1f1bc0e561 100644 --- a/editor/plugins/cpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_3d_editor_plugin.cpp @@ -31,8 +31,10 @@ #include "cpu_particles_3d_editor_plugin.h" #include "editor/editor_node.h" +#include "editor/editor_undo_redo_manager.h" #include "editor/gui/scene_tree_editor.h" #include "editor/plugins/node_3d_editor_plugin.h" +#include "editor/scene_tree_dock.h" #include "scene/gui/menu_button.h" void CPUParticles3DEditor::_node_removed(Node *p_node) { @@ -59,6 +61,20 @@ void CPUParticles3DEditor::_menu_option(int p_option) { case MENU_OPTION_RESTART: { node->restart(); + } break; + + case MENU_OPTION_CONVERT_TO_GPU_PARTICLES: { + GPUParticles3D *gpu_particles = memnew(GPUParticles3D); + gpu_particles->convert_from_particles(node); + gpu_particles->set_name(node->get_name()); + gpu_particles->set_transform(node->get_transform()); + gpu_particles->set_visible(node->is_visible()); + gpu_particles->set_process_mode(node->get_process_mode()); + + EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton(); + ur->create_action(TTR("Convert to GPUParticles3D")); + SceneTreeDock::get_singleton()->replace_node(node, gpu_particles); + ur->commit_action(false); } break; } @@ -102,6 +118,7 @@ CPUParticles3DEditor::CPUParticles3DEditor() { options->set_text(TTR("CPUParticles3D")); options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART); options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE); + options->get_popup()->add_item(TTR("Convert to GPUParticles3D"), MENU_OPTION_CONVERT_TO_GPU_PARTICLES); options->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticles3DEditor::_menu_option)); } |