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

Implement conversion from CPUParticles to GPUParticles (3D/2D)

This commit is contained in:
Yuri Roubinski
2023-08-19 11:55:49 +03:00
parent b51ee8b029
commit 7fcb91f077
10 changed files with 246 additions and 5 deletions

View File

@@ -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));
}