summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorJFonS <joan.fonssanchez@gmail.com>2018-09-27 13:05:57 +0200
committerJFonS <joan.fonssanchez@gmail.com>2018-11-04 15:58:12 +0100
commit85ce4a67ed37a2b38bc6d9e3f0211a9b73a8516d (patch)
treeaf25828c7f277efd609ce78cc7d68b14493f824f /editor/plugins
parentf84893f70901dfca356d949ea1585a56154cb59f (diff)
Remove animation loop from ParticlesMaterial + improvements to CPUParticles2D
Remove animation loop from ParticlesMaterial and move it to SpatialMaterial for 3D particles and Particles2D for the 2D case. Added animation to CPUParticles2D as well as the "Convert to CPUParticles2D" to the PAarticles2D menu.
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/particles_2d_editor_plugin.cpp22
-rw-r--r--editor/plugins/particles_2d_editor_plugin.h3
2 files changed, 24 insertions, 1 deletions
diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/particles_2d_editor_plugin.cpp
index 5dcbca2ed6..ab94258c44 100644
--- a/editor/plugins/particles_2d_editor_plugin.cpp
+++ b/editor/plugins/particles_2d_editor_plugin.cpp
@@ -32,6 +32,7 @@
#include "canvas_item_editor_plugin.h"
#include "core/io/image_loader.h"
+#include "scene/2d/cpu_particles_2d.h"
#include "scene/gui/separator.h"
#include "scene/resources/particles_material.h"
@@ -82,6 +83,25 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) {
emission_mask->popup_centered_minsize();
} break;
+ case MENU_OPTION_CONVERT_TO_CPU_PARTICLES: {
+
+ UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
+
+ CPUParticles2D *cpu_particles = memnew(CPUParticles2D);
+ cpu_particles->convert_from_particles(particles);
+ cpu_particles->set_name(particles->get_name());
+ cpu_particles->set_transform(particles->get_transform());
+ cpu_particles->set_visible(particles->is_visible());
+ cpu_particles->set_pause_mode(particles->get_pause_mode());
+
+ undo_redo->create_action("Replace Particles by CPUParticles");
+ undo_redo->add_do_method(particles, "replace_by", cpu_particles);
+ undo_redo->add_undo_method(cpu_particles, "replace_by", particles);
+ undo_redo->add_do_reference(cpu_particles);
+ undo_redo->add_undo_reference(particles);
+ undo_redo->commit_action();
+
+ } break;
}
}
@@ -355,6 +375,8 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
menu->get_popup()->add_separator();
menu->get_popup()->add_item(TTR("Load Emission Mask"), MENU_LOAD_EMISSION_MASK);
// menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK);
+ menu->get_popup()->add_separator();
+ menu->get_popup()->add_item(TTR("Convert to CPUParticles"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES);
menu->set_text(TTR("Particles"));
toolbar->add_child(menu);
diff --git a/editor/plugins/particles_2d_editor_plugin.h b/editor/plugins/particles_2d_editor_plugin.h
index 71ca8ef499..eaa96d84e9 100644
--- a/editor/plugins/particles_2d_editor_plugin.h
+++ b/editor/plugins/particles_2d_editor_plugin.h
@@ -46,7 +46,8 @@ class Particles2DEditorPlugin : public EditorPlugin {
MENU_GENERATE_VISIBILITY_RECT,
MENU_LOAD_EMISSION_MASK,
- MENU_CLEAR_EMISSION_MASK
+ MENU_CLEAR_EMISSION_MASK,
+ MENU_OPTION_CONVERT_TO_CPU_PARTICLES
};
enum EmissionMode {