1/**************************************************************************/
2/* gpu_particles_3d_editor_plugin.h */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#ifndef GPU_PARTICLES_3D_EDITOR_PLUGIN_H
32#define GPU_PARTICLES_3D_EDITOR_PLUGIN_H
33
34#include "editor/editor_plugin.h"
35#include "scene/3d/gpu_particles_3d.h"
36#include "scene/gui/spin_box.h"
37
38class ConfirmationDialog;
39class HBoxContainer;
40class MenuButton;
41class OptionButton;
42class SceneTreeDialog;
43
44class GPUParticles3DEditorBase : public Control {
45 GDCLASS(GPUParticles3DEditorBase, Control);
46
47protected:
48 Node3D *base_node = nullptr;
49 Panel *panel = nullptr;
50 MenuButton *options = nullptr;
51 HBoxContainer *particles_editor_hb = nullptr;
52
53 SceneTreeDialog *emission_tree_dialog = nullptr;
54
55 ConfirmationDialog *emission_dialog = nullptr;
56 SpinBox *emission_amount = nullptr;
57 OptionButton *emission_fill = nullptr;
58
59 Vector<Face3> geometry;
60
61 bool _generate(Vector<Vector3> &points, Vector<Vector3> &normals);
62 virtual void _generate_emission_points(){};
63 void _node_selected(const NodePath &p_path);
64
65 static void _bind_methods();
66
67public:
68 GPUParticles3DEditorBase();
69};
70
71class GPUParticles3DEditor : public GPUParticles3DEditorBase {
72 GDCLASS(GPUParticles3DEditor, GPUParticles3DEditorBase);
73
74 ConfirmationDialog *generate_aabb = nullptr;
75 SpinBox *generate_seconds = nullptr;
76 GPUParticles3D *node = nullptr;
77
78 enum Menu {
79 MENU_OPTION_GENERATE_AABB,
80 MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE,
81 MENU_OPTION_CLEAR_EMISSION_VOLUME,
82 MENU_OPTION_CONVERT_TO_CPU_PARTICLES,
83 MENU_OPTION_RESTART,
84
85 };
86
87 void _generate_aabb();
88
89 void _menu_option(int);
90
91 friend class GPUParticles3DEditorPlugin;
92
93 virtual void _generate_emission_points() override;
94
95protected:
96 void _notification(int p_notification);
97 void _node_removed(Node *p_node);
98 static void _bind_methods();
99
100public:
101 void edit(GPUParticles3D *p_particles);
102 GPUParticles3DEditor();
103};
104
105class GPUParticles3DEditorPlugin : public EditorPlugin {
106 GDCLASS(GPUParticles3DEditorPlugin, EditorPlugin);
107
108 GPUParticles3DEditor *particles_editor = nullptr;
109
110public:
111 virtual String get_name() const override { return "GPUParticles3D"; }
112 bool has_main_screen() const override { return false; }
113 virtual void edit(Object *p_object) override;
114 virtual bool handles(Object *p_object) const override;
115 virtual void make_visible(bool p_visible) override;
116
117 GPUParticles3DEditorPlugin();
118 ~GPUParticles3DEditorPlugin();
119};
120
121#endif // GPU_PARTICLES_3D_EDITOR_PLUGIN_H
122