2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2020-03-27 07:44:44 +00:00
|
|
|
/* gpu_particles_2d.h */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2022-01-03 20:27:34 +00:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2022-07-23 21:41:51 +00:00
|
|
|
#ifndef GPU_PARTICLES_2D_H
|
|
|
|
#define GPU_PARTICLES_2D_H
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
#include "scene/2d/node_2d.h"
|
|
|
|
|
2020-03-27 07:44:44 +00:00
|
|
|
class GPUParticles2D : public Node2D {
|
2017-06-21 19:25:45 +00:00
|
|
|
private:
|
2020-03-27 07:44:44 +00:00
|
|
|
GDCLASS(GPUParticles2D, Node2D);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2017-06-21 19:25:45 +00:00
|
|
|
enum DrawOrder {
|
|
|
|
DRAW_ORDER_INDEX,
|
|
|
|
DRAW_ORDER_LIFETIME,
|
2021-05-20 14:25:06 +00:00
|
|
|
DRAW_ORDER_REVERSE_LIFETIME,
|
2017-02-27 09:47:28 +00:00
|
|
|
};
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
private:
|
2017-06-21 19:25:45 +00:00
|
|
|
RID particles;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-05-02 14:28:25 +00:00
|
|
|
bool one_shot = false;
|
|
|
|
int amount = 0;
|
|
|
|
double lifetime = 0.0;
|
|
|
|
double pre_process_time = 0.0;
|
|
|
|
real_t explosiveness_ratio = 0.0;
|
|
|
|
real_t randomness_ratio = 0.0;
|
|
|
|
double speed_scale = 0.0;
|
2017-06-21 19:25:45 +00:00
|
|
|
Rect2 visibility_rect;
|
2022-05-02 14:28:25 +00:00
|
|
|
bool local_coords = false;
|
|
|
|
int fixed_fps = 0;
|
|
|
|
bool fractional_delta = false;
|
2022-03-01 18:59:49 +00:00
|
|
|
bool interpolate = true;
|
2021-11-17 09:58:52 +00:00
|
|
|
#ifdef TOOLS_ENABLED
|
2022-05-02 14:28:25 +00:00
|
|
|
bool show_visibility_rect = false;
|
2021-11-17 09:58:52 +00:00
|
|
|
#endif
|
2017-06-21 19:25:45 +00:00
|
|
|
Ref<Material> process_material;
|
2017-02-27 09:47:28 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
DrawOrder draw_order;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-06-11 18:43:37 +00:00
|
|
|
Ref<Texture2D> texture;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void _update_particle_emission_transform();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-05-20 14:25:06 +00:00
|
|
|
NodePath sub_emitter;
|
2021-08-12 14:07:47 +00:00
|
|
|
real_t collision_base_size = 1.0;
|
2021-05-20 14:25:06 +00:00
|
|
|
|
|
|
|
bool trail_enabled = false;
|
2021-08-12 14:07:47 +00:00
|
|
|
double trail_length = 0.3;
|
2021-05-20 14:25:06 +00:00
|
|
|
int trail_sections = 8;
|
|
|
|
int trail_section_subdivisions = 4;
|
|
|
|
|
|
|
|
RID mesh;
|
|
|
|
|
2022-01-24 20:28:59 +00:00
|
|
|
void _attach_sub_emitter();
|
|
|
|
|
2022-08-24 18:20:47 +00:00
|
|
|
void _texture_changed();
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2022-08-12 20:57:11 +00:00
|
|
|
void _validate_property(PropertyInfo &p_property) const;
|
2017-06-21 19:25:45 +00:00
|
|
|
void _notification(int p_what);
|
2021-05-20 14:25:06 +00:00
|
|
|
void _update_collision_size();
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
public:
|
|
|
|
void set_emitting(bool p_emitting);
|
|
|
|
void set_amount(int p_amount);
|
2021-02-02 02:16:37 +00:00
|
|
|
void set_lifetime(double p_lifetime);
|
2017-08-11 19:10:05 +00:00
|
|
|
void set_one_shot(bool p_enable);
|
2021-02-02 02:16:37 +00:00
|
|
|
void set_pre_process_time(double p_time);
|
2021-08-12 14:07:47 +00:00
|
|
|
void set_explosiveness_ratio(real_t p_ratio);
|
|
|
|
void set_randomness_ratio(real_t p_ratio);
|
2018-08-17 09:47:29 +00:00
|
|
|
void set_visibility_rect(const Rect2 &p_visibility_rect);
|
2017-06-21 19:25:45 +00:00
|
|
|
void set_use_local_coordinates(bool p_enable);
|
|
|
|
void set_process_material(const Ref<Material> &p_material);
|
2021-02-02 02:16:37 +00:00
|
|
|
void set_speed_scale(double p_scale);
|
|
|
|
void set_collision_base_size(real_t p_ratio);
|
2021-05-20 14:25:06 +00:00
|
|
|
void set_trail_enabled(bool p_enabled);
|
2021-02-02 02:16:37 +00:00
|
|
|
void set_trail_length(double p_seconds);
|
2021-05-20 14:25:06 +00:00
|
|
|
void set_trail_sections(int p_sections);
|
|
|
|
void set_trail_section_subdivisions(int p_subdivisions);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-11-17 09:58:52 +00:00
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
void set_show_visibility_rect(bool p_show_visibility_rect);
|
|
|
|
#endif
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
bool is_emitting() const;
|
|
|
|
int get_amount() const;
|
2021-02-02 02:16:37 +00:00
|
|
|
double get_lifetime() const;
|
2017-06-25 11:01:15 +00:00
|
|
|
bool get_one_shot() const;
|
2021-02-02 02:16:37 +00:00
|
|
|
double get_pre_process_time() const;
|
2021-08-09 22:15:17 +00:00
|
|
|
real_t get_explosiveness_ratio() const;
|
|
|
|
real_t get_randomness_ratio() const;
|
2017-06-21 19:25:45 +00:00
|
|
|
Rect2 get_visibility_rect() const;
|
|
|
|
bool get_use_local_coordinates() const;
|
|
|
|
Ref<Material> get_process_material() const;
|
2021-02-02 02:16:37 +00:00
|
|
|
double get_speed_scale() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-08-09 22:15:17 +00:00
|
|
|
real_t get_collision_base_size() const;
|
2021-05-20 14:25:06 +00:00
|
|
|
bool is_trail_enabled() const;
|
2021-08-12 14:07:47 +00:00
|
|
|
double get_trail_length() const;
|
2021-05-20 14:25:06 +00:00
|
|
|
int get_trail_sections() const;
|
|
|
|
int get_trail_section_subdivisions() const;
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void set_fixed_fps(int p_count);
|
|
|
|
int get_fixed_fps() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void set_fractional_delta(bool p_enable);
|
|
|
|
bool get_fractional_delta() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-03-01 18:59:49 +00:00
|
|
|
void set_interpolate(bool p_enable);
|
|
|
|
bool get_interpolate() const;
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void set_draw_order(DrawOrder p_order);
|
|
|
|
DrawOrder get_draw_order() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-06-11 18:43:37 +00:00
|
|
|
void set_texture(const Ref<Texture2D> &p_texture);
|
|
|
|
Ref<Texture2D> get_texture() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-09-19 15:43:15 +00:00
|
|
|
PackedStringArray get_configuration_warnings() const override;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-01-24 20:28:59 +00:00
|
|
|
void set_sub_emitter(const NodePath &p_path);
|
|
|
|
NodePath get_sub_emitter() const;
|
|
|
|
|
|
|
|
enum EmitFlags {
|
|
|
|
EMIT_FLAG_POSITION = RS::PARTICLES_EMIT_FLAG_POSITION,
|
|
|
|
EMIT_FLAG_ROTATION_SCALE = RS::PARTICLES_EMIT_FLAG_ROTATION_SCALE,
|
|
|
|
EMIT_FLAG_VELOCITY = RS::PARTICLES_EMIT_FLAG_VELOCITY,
|
|
|
|
EMIT_FLAG_COLOR = RS::PARTICLES_EMIT_FLAG_COLOR,
|
|
|
|
EMIT_FLAG_CUSTOM = RS::PARTICLES_EMIT_FLAG_CUSTOM
|
|
|
|
};
|
|
|
|
|
|
|
|
void emit_particle(const Transform2D &p_transform, const Vector2 &p_velocity, const Color &p_color, const Color &p_custom, uint32_t p_emit_flags);
|
|
|
|
|
2017-06-25 11:01:15 +00:00
|
|
|
void restart();
|
2017-06-21 19:25:45 +00:00
|
|
|
Rect2 capture_rect() const;
|
2020-03-27 07:44:44 +00:00
|
|
|
GPUParticles2D();
|
|
|
|
~GPUParticles2D();
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2020-03-27 07:44:44 +00:00
|
|
|
VARIANT_ENUM_CAST(GPUParticles2D::DrawOrder)
|
2022-01-24 20:28:59 +00:00
|
|
|
VARIANT_ENUM_CAST(GPUParticles2D::EmitFlags)
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-07-23 21:41:51 +00:00
|
|
|
#endif // GPU_PARTICLES_2D_H
|