Debian Codegraph @

scene/3d/gpu_particles_3d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* gpu_particles_3d.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 "scene/3d/visual_instance_3d.h"
34 #include "scene/resources/3d/skin.h"
35
36 class GPUParticles3D : public GeometryInstance3D {
37 private:
38 GDCLASS(GPUParticles3D, GeometryInstance3D);
39
40 public:
41 enum DrawOrder {
42 DRAW_ORDER_INDEX,
43 DRAW_ORDER_LIFETIME,
44 DRAW_ORDER_REVERSE_LIFETIME,
45 DRAW_ORDER_VIEW_DEPTH,
46 };
47
48 enum TransformAlign {
49 TRANSFORM_ALIGN_DISABLED,
50 TRANSFORM_ALIGN_Z_BILLBOARD,
51 TRANSFORM_ALIGN_Y_TO_VELOCITY,
52 TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY
53 };
54
55 enum {
56 MAX_DRAW_PASSES = 4
57 };
58
59 private:
60 RID particles;
61
62 bool emitting = false;
63 bool active = false;
64 bool signal_canceled = false;
65 bool one_shot = false;
66 int amount = 0;
67 float amount_ratio = 1.0;
68 double lifetime = 0.0;
69 double pre_process_time = 0.0;
70 real_t explosiveness_ratio = 0.0;
71 real_t randomness_ratio = 0.0;
72 double speed_scale = 0.0;
73 AABB visibility_aabb;
74 bool local_coords = false;
75 int fixed_fps = 0;
76 bool fractional_delta = false;
77 bool interpolate = true;
78 NodePath sub_emitter;
79 real_t collision_base_size = 0.01;
80 uint32_t seed = 0;
81 bool use_fixed_seed = false;
82
83 bool trail_enabled = false;
84 double trail_lifetime = 0.3;
85
86 TransformAlign transform_align = TRANSFORM_ALIGN_DISABLED;
87
88 Ref<Material> process_material;
89
90 DrawOrder draw_order = DRAW_ORDER_INDEX;
91
92 Vector<Ref<Mesh>> draw_passes;
93 Ref<Skin> skin;
94
95 double time = 0.0;
96 double emission_time = 0.0;
97 double active_time = 0.0;
98 float interp_to_end_factor = 0;
99 Vector3 previous_velocity;
100 Vector3 previous_position;
101
102 void _attach_sub_emitter();
103
104 void _skinning_changed();
105
106 protected:
107 static void _bind_methods();
108 void _notification(int p_what);
109 void _validate_property(PropertyInfo &p_property) const;
110
111 #ifndef DISABLE_DEPRECATED
112 void _restart_bind_compat_92089();
113 static void _bind_compatibility_methods();
114 #endif
115
116 public:
117 AABB get_aabb() const override;
118
119 void set_emitting(bool p_emitting);
120 void set_amount(int p_amount);
121 void set_lifetime(double p_lifetime);
122 void set_one_shot(bool p_one_shot);
123 void set_pre_process_time(double p_time);
124 void set_explosiveness_ratio(real_t p_ratio);
125 void set_randomness_ratio(real_t p_ratio);
126 void set_visibility_aabb(const AABB &p_aabb);
127 void set_use_local_coordinates(bool p_enable);
128 void set_process_material(const Ref<Material> &p_material);
129 void set_speed_scale(double p_scale);
130 void set_collision_base_size(real_t p_ratio);
131 void set_trail_enabled(bool p_enabled);
132 void set_trail_lifetime(double p_seconds);
133 void set_interp_to_end(float p_interp);
134
135 bool is_emitting() const;
136 int get_amount() const;
137
138 double get_lifetime() const;
139 bool get_one_shot() const;
140 double get_pre_process_time() const;
141 real_t get_explosiveness_ratio() const;
142 real_t get_randomness_ratio() const;
143 AABB get_visibility_aabb() const;
144 bool get_use_local_coordinates() const;
145 Ref<Material> get_process_material() const;
146 double get_speed_scale() const;
147 real_t get_collision_base_size() const;
148 bool is_trail_enabled() const;
149 double get_trail_lifetime() const;
150 float get_interp_to_end() const;
151
152 void set_amount_ratio(float p_ratio);
153 float get_amount_ratio() const;
154
155 void set_fixed_fps(int p_count);
156 int get_fixed_fps() const;
157
158 void set_fractional_delta(bool p_enable);
159 bool get_fractional_delta() const;
160
161 void set_interpolate(bool p_enable);
162 bool get_interpolate() const;
163
164 void set_draw_order(DrawOrder p_order);
165 DrawOrder get_draw_order() const;
166
167 void set_draw_passes(int p_count);
168 int get_draw_passes() const;
169
170 void set_draw_pass_mesh(int p_pass, const Ref<Mesh> &p_mesh);
171 Ref<Mesh> get_draw_pass_mesh(int p_pass) const;
172
173 PackedStringArray get_configuration_warnings() const override;
174
175 void set_sub_emitter(const NodePath &p_path);
176 NodePath get_sub_emitter() const;
177
178 void set_skin(const Ref<Skin> &p_skin);
179 Ref<Skin> get_skin() const;
180
181 void set_transform_align(TransformAlign p_align);
182 TransformAlign get_transform_align() const;
183
184 void restart(bool p_keep_seed = false);
185
186 void set_use_fixed_seed(bool p_use_fixed_seed);
187 bool get_use_fixed_seed() const;
188
189 void set_seed(uint32_t p_seed);
190 uint32_t get_seed() const;
191 void request_particles_process(real_t p_requested_process_time);
192
193 enum EmitFlags {
194 EMIT_FLAG_POSITION = RS::PARTICLES_EMIT_FLAG_POSITION,
195 EMIT_FLAG_ROTATION_SCALE = RS::PARTICLES_EMIT_FLAG_ROTATION_SCALE,
196 EMIT_FLAG_VELOCITY = RS::PARTICLES_EMIT_FLAG_VELOCITY,
197 EMIT_FLAG_COLOR = RS::PARTICLES_EMIT_FLAG_COLOR,
198 EMIT_FLAG_CUSTOM = RS::PARTICLES_EMIT_FLAG_CUSTOM
199 };
200
201 void emit_particle(const Transform3D &p_transform, const Vector3 &p_velocity, const Color &p_color, const Color &p_custom, uint32_t p_emit_flags);
202
203 AABB capture_aabb() const;
204 void convert_from_particles(Node *p_particles);
205
206 GPUParticles3D();
207 ~GPUParticles3D();
208 };
209
210 VARIANT_ENUM_CAST(GPUParticles3D::DrawOrder)
211 VARIANT_ENUM_CAST(GPUParticles3D::TransformAlign)
212 VARIANT_ENUM_CAST(GPUParticles3D::EmitFlags)