summaryrefslogtreecommitdiff
path: root/scene/2d/particles_2d.h
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d/particles_2d.h')
-rw-r--r--scene/2d/particles_2d.h247
1 files changed, 55 insertions, 192 deletions
diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h
index 856beaa836..ab7dcb1464 100644
--- a/scene/2d/particles_2d.h
+++ b/scene/2d/particles_2d.h
@@ -34,235 +34,98 @@
#include "scene/resources/color_ramp.h"
#include "scene/resources/texture.h"
-class Particles2D;
-class ParticleAttractor2D : public Node2D {
-
- GDCLASS(ParticleAttractor2D, Node2D);
-
- friend class Particles2D;
- bool enabled;
- float radius;
- float disable_radius;
- float gravity;
- float absorption;
- NodePath path;
-
- Particles2D *owner;
-
- void _update_owner();
- void _owner_exited();
- void _set_owner(Particles2D *p_owner);
-
- void _notification(int p_what);
- static void _bind_methods();
-
-public:
- void set_enabled(bool p_enabled);
- bool is_enabled() const;
-
- void set_radius(float p_radius);
- float get_radius() const;
-
- void set_disable_radius(float p_disable_radius);
- float get_disable_radius() const;
-
- void set_gravity(float p_gravity);
- float get_gravity() const;
-
- void set_absorption(float p_absorption);
- float get_absorption() const;
-
- void set_particles_path(NodePath p_path);
- NodePath get_particles_path() const;
-
- virtual String get_configuration_warning() const;
-
- ParticleAttractor2D();
-};
-
class Particles2D : public Node2D {
-
- GDCLASS(Particles2D, Node2D);
+private:
+ GDCLASS(Particles2D, Node2D)
public:
- enum Parameter {
- PARAM_DIRECTION,
- PARAM_SPREAD,
- PARAM_LINEAR_VELOCITY,
- PARAM_SPIN_VELOCITY,
- PARAM_ORBIT_VELOCITY,
- PARAM_GRAVITY_DIRECTION,
- PARAM_GRAVITY_STRENGTH,
- PARAM_RADIAL_ACCEL,
- PARAM_TANGENTIAL_ACCEL,
- PARAM_DAMPING,
- PARAM_INITIAL_ANGLE,
- PARAM_INITIAL_SIZE,
- PARAM_FINAL_SIZE,
- PARAM_HUE_VARIATION,
- PARAM_ANIM_SPEED_SCALE,
- PARAM_ANIM_INITIAL_POS,
- PARAM_MAX
- };
-
- enum {
- MAX_COLOR_PHASES = 4
- };
-
- enum ProcessMode {
- PROCESS_FIXED,
- PROCESS_IDLE,
+ enum DrawOrder {
+ DRAW_ORDER_INDEX,
+ DRAW_ORDER_LIFETIME,
};
private:
- float param[PARAM_MAX];
- float randomness[PARAM_MAX];
+ RID particles;
- struct Particle {
- bool active;
- Point2 pos;
- Vector2 velocity;
- float rot;
- float frame;
- uint64_t seed;
- Particle() {
- active = false;
- seed = 123465789;
- rot = 0;
- frame = 0;
- }
- };
-
- Vector<Particle> particles;
-
- struct AttractorCache {
-
- Vector2 pos;
- ParticleAttractor2D *attractor;
- };
-
- Vector<AttractorCache> attractor_cache;
-
- float explosiveness;
- float preprocess;
- float lifetime;
bool emitting;
- bool local_space;
- float emit_timeout;
- float time_to_live;
- float time_scale;
- bool flip_h;
- bool flip_v;
- int h_frames;
+ int amount;
+ float lifetime;
+ float pre_process_time;
+ float explosiveness_ratio;
+ float randomness_ratio;
+ float speed_scale;
+ Rect2 visibility_rect;
+ bool local_coords;
+ int fixed_fps;
+ bool fractional_delta;
int v_frames;
- Point2 emissor_offset;
- Vector2 initial_velocity;
- Vector2 extents;
- PoolVector<Vector2> emission_points;
+ int h_frames;
- ProcessMode process_mode;
+ Ref<Material> process_material;
- float time;
- int active_count;
+ DrawOrder draw_order;
Ref<Texture> texture;
+ Ref<Texture> normal_map;
- //If no color ramp is set then default color is used. Created as simple alternative to color_ramp.
- Color default_color;
- Ref<Gradient> gradient;
-
- void _process_particles(float p_delta);
- friend class ParticleAttractor2D;
-
- Set<ParticleAttractor2D *> attractors;
+ void _update_particle_emission_transform();
protected:
- void _notification(int p_what);
static void _bind_methods();
+ virtual void _validate_property(PropertyInfo &property) const;
+ void _notification(int p_what);
public:
void set_emitting(bool p_emitting);
- bool is_emitting() const;
-
- void set_process_mode(ProcessMode p_mode);
- ProcessMode get_process_mode() const;
-
void set_amount(int p_amount);
- int get_amount() const;
-
void set_lifetime(float p_lifetime);
- float get_lifetime() const;
-
- void set_time_scale(float p_time_scale);
- float get_time_scale() const;
+ void set_pre_process_time(float p_time);
+ void set_explosiveness_ratio(float p_ratio);
+ void set_randomness_ratio(float p_ratio);
+ void set_visibility_rect(const Rect2 &p_aabb);
+ void set_use_local_coordinates(bool p_enable);
+ void set_process_material(const Ref<Material> &p_material);
+ void set_speed_scale(float p_scale);
- void set_pre_process_time(float p_pre_process_time);
+ bool is_emitting() const;
+ int get_amount() const;
+ float get_lifetime() const;
float get_pre_process_time() const;
+ float get_explosiveness_ratio() const;
+ float get_randomness_ratio() const;
+ Rect2 get_visibility_rect() const;
+ bool get_use_local_coordinates() const;
+ Ref<Material> get_process_material() const;
+ float get_speed_scale() const;
- void set_emit_timeout(float p_timeout);
- float get_emit_timeout() const;
-
- void set_emission_half_extents(const Vector2 &p_extents);
- Vector2 get_emission_half_extents() const;
+ void set_fixed_fps(int p_count);
+ int get_fixed_fps() const;
- void set_param(Parameter p_param, float p_value);
- float get_param(Parameter p_param) const;
+ void set_fractional_delta(bool p_enable);
+ bool get_fractional_delta() const;
- void set_randomness(Parameter p_randomness, float p_value);
- float get_randomness(Parameter p_randomness) const;
-
- void set_explosiveness(float p_value);
- float get_explosiveness() const;
-
- void set_flip_h(bool p_flip);
- bool is_flipped_h() const;
-
- void set_flip_v(bool p_flip);
- bool is_flipped_v() const;
-
- void set_h_frames(int p_frames);
- int get_h_frames() const;
-
- void set_v_frames(int p_frames);
- int get_v_frames() const;
-
- void set_color_phases(int p_phases);
- int get_color_phases() const;
-
- void set_color_phase_color(int p_phase, const Color &p_color);
- Color get_color_phase_color(int p_phase) const;
-
- void set_color_phase_pos(int p_phase, float p_pos);
- float get_color_phase_pos(int p_phase) const;
+ void set_draw_order(DrawOrder p_order);
+ DrawOrder get_draw_order() const;
void set_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_texture() const;
- void set_color(const Color &p_color);
- Color get_color() const;
-
- void set_gradient(const Ref<Gradient> &p_texture);
- Ref<Gradient> get_gradient() const;
-
- void set_emissor_offset(const Point2 &p_offset);
- Point2 get_emissor_offset() const;
+ void set_normal_map(const Ref<Texture> &p_normal_map);
+ Ref<Texture> get_normal_map() const;
- void set_use_local_space(bool p_use);
- bool is_using_local_space() const;
-
- void set_initial_velocity(const Vector2 &p_velocity);
- Vector2 get_initial_velocity() const;
+ virtual String get_configuration_warning() const;
- void set_emission_points(const PoolVector<Vector2> &p_points);
- PoolVector<Vector2> get_emission_points() const;
+ void set_v_frames(int p_count);
+ int get_v_frames() const;
- void pre_process(float p_delta);
- void reset();
+ void set_h_frames(int p_count);
+ int get_h_frames() const;
+ Rect2 capture_rect() const;
Particles2D();
+ ~Particles2D();
};
-VARIANT_ENUM_CAST(Particles2D::ProcessMode);
-VARIANT_ENUM_CAST(Particles2D::Parameter);
+VARIANT_ENUM_CAST(Particles2D::DrawOrder)
#endif // PARTICLES_FRAME_H