diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-07-07 09:04:22 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2018-07-07 09:04:22 -0300 |
commit | ea473594086ebc4d0f5ec8d3cb5fac1607909571 (patch) | |
tree | 25741761ed1bc6bfb4eeed6594a1fde114432c14 /editor/plugins/particles_editor_plugin.cpp | |
parent | 7dcaabaf1989f0e4d6957ca123df522c805ac57a (diff) |
Add option to convert Particles to CPUParticles
Diffstat (limited to 'editor/plugins/particles_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/particles_editor_plugin.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp index 91b307293b..e0325702a8 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/particles_editor_plugin.cpp @@ -31,7 +31,7 @@ #include "particles_editor_plugin.h" #include "editor/plugins/spatial_editor_plugin.h" #include "io/resource_loader.h" - +#include "scene/3d/cpu_particles.h" bool ParticlesEditorBase::_generate(PoolVector<Vector3> &points, PoolVector<Vector3> &normals) { bool use_normals = emission_fill->get_selected() == 1; @@ -294,6 +294,21 @@ void ParticlesEditor::_menu_option(int p_option) { emission_tree_dialog->popup_centered_ratio(); } break; + case MENU_OPTION_CONVERT_TO_CPU_PARTICLES: { + + UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); + + CPUParticles *cpu_particles = memnew(CPUParticles); + cpu_particles->convert_from_particles(node); + + undo_redo->create_action("Replace Particles by CPUParticles"); + undo_redo->add_do_method(node, "replace_by", cpu_particles); + undo_redo->add_undo_method(cpu_particles, "replace_by", node); + undo_redo->add_do_reference(cpu_particles); + undo_redo->add_undo_reference(node); + undo_redo->commit_action(); + + } break; } } @@ -424,6 +439,9 @@ ParticlesEditor::ParticlesEditor() { options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("Create Emission Points From Mesh"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH); options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE); + options->get_popup()->add_separator(); + options->get_popup()->add_item(TTR("Convert to CPUParticles"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES); + options->get_popup()->connect("id_pressed", this, "_menu_option"); generate_aabb = memnew(ConfirmationDialog); |