Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/scene/2d/particles_2d_editor_plugin.h
9903 views
1
/**************************************************************************/
2
/* particles_2d_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
#pragma once
32
33
#include "editor/scene/particles_editor_plugin.h"
34
35
class EditorFileDialog;
36
37
class Particles2DEditorPlugin : public ParticlesEditorPlugin {
38
GDCLASS(Particles2DEditorPlugin, ParticlesEditorPlugin);
39
40
protected:
41
enum {
42
MENU_LOAD_EMISSION_MASK = 100,
43
};
44
45
List<Node *> selected_particles;
46
47
enum EmissionMode {
48
EMISSION_MODE_SOLID,
49
EMISSION_MODE_BORDER,
50
EMISSION_MODE_BORDER_DIRECTED
51
};
52
53
EditorFileDialog *file = nullptr;
54
ConfirmationDialog *emission_mask = nullptr;
55
OptionButton *emission_mask_mode = nullptr;
56
CheckBox *emission_mask_centered = nullptr;
57
CheckBox *emission_colors = nullptr;
58
String source_emission_file;
59
60
virtual void _menu_callback(int p_idx) override;
61
virtual void _add_menu_options(PopupMenu *p_menu) override;
62
63
void _file_selected(const String &p_file);
64
void _get_base_emission_mask(PackedVector2Array &r_valid_positions, PackedVector2Array &r_valid_normals, PackedByteArray &r_valid_colors, Vector2i &r_image_size);
65
virtual void _generate_emission_mask() = 0;
66
void _notification(int p_what);
67
void _set_show_gizmos(Node *p_node, bool p_show);
68
void _selection_changed();
69
void _node_removed(Node *p_node);
70
71
public:
72
Particles2DEditorPlugin();
73
};
74
75
class GPUParticles2DEditorPlugin : public Particles2DEditorPlugin {
76
GDCLASS(GPUParticles2DEditorPlugin, Particles2DEditorPlugin);
77
78
enum {
79
MENU_GENERATE_VISIBILITY_RECT = 200,
80
};
81
82
ConfirmationDialog *generate_visibility_rect = nullptr;
83
SpinBox *generate_seconds = nullptr;
84
85
void _generate_visibility_rect();
86
87
protected:
88
void _menu_callback(int p_idx) override;
89
void _add_menu_options(PopupMenu *p_menu) override;
90
91
Node *_convert_particles() override;
92
93
void _generate_emission_mask() override;
94
95
public:
96
GPUParticles2DEditorPlugin();
97
};
98
99
class CPUParticles2DEditorPlugin : public Particles2DEditorPlugin {
100
GDCLASS(CPUParticles2DEditorPlugin, Particles2DEditorPlugin);
101
102
protected:
103
Node *_convert_particles() override;
104
105
void _generate_emission_mask() override;
106
107
public:
108
CPUParticles2DEditorPlugin();
109
};
110
111