2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* particles_2d.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* 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
|
|
|
/*************************************************************************/
|
2018-01-01 13:40:08 +00:00
|
|
|
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2018 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
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "particles_2d.h"
|
2017-06-22 10:12:30 +00:00
|
|
|
|
2017-08-18 23:02:56 +00:00
|
|
|
#include "engine.h"
|
2017-06-21 19:25:45 +00:00
|
|
|
#include "scene/3d/particles.h"
|
2017-02-25 14:06:00 +00:00
|
|
|
#include "scene/scene_string_names.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_emitting(bool p_emitting) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-12-23 04:08:50 +00:00
|
|
|
VS::get_singleton()->particles_set_emitting(particles, p_emitting);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_amount(int p_amount) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
ERR_FAIL_COND(p_amount < 1);
|
|
|
|
amount = p_amount;
|
|
|
|
VS::get_singleton()->particles_set_amount(particles, amount);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_lifetime(float p_lifetime) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
ERR_FAIL_COND(p_lifetime <= 0);
|
|
|
|
lifetime = p_lifetime;
|
|
|
|
VS::get_singleton()->particles_set_lifetime(particles, lifetime);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2017-06-25 11:01:15 +00:00
|
|
|
|
|
|
|
void Particles2D::set_one_shot(bool p_enable) {
|
|
|
|
|
|
|
|
one_shot = p_enable;
|
|
|
|
VS::get_singleton()->particles_set_one_shot(particles, one_shot);
|
2017-12-23 04:08:50 +00:00
|
|
|
if (!one_shot && is_emitting())
|
2017-08-12 08:13:29 +00:00
|
|
|
VisualServer::get_singleton()->particles_restart(particles);
|
2017-06-25 11:01:15 +00:00
|
|
|
}
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_pre_process_time(float p_time) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
pre_process_time = p_time;
|
|
|
|
VS::get_singleton()->particles_set_pre_process_time(particles, pre_process_time);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_explosiveness_ratio(float p_ratio) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
explosiveness_ratio = p_ratio;
|
|
|
|
VS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_randomness_ratio(float p_ratio) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
randomness_ratio = p_ratio;
|
|
|
|
VS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2018-08-17 09:47:29 +00:00
|
|
|
void Particles2D::set_visibility_rect(const Rect2 &p_visibility_rect) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2018-08-17 09:47:29 +00:00
|
|
|
visibility_rect = p_visibility_rect;
|
2017-11-17 02:09:00 +00:00
|
|
|
AABB aabb;
|
2018-08-17 09:47:29 +00:00
|
|
|
aabb.position.x = p_visibility_rect.position.x;
|
|
|
|
aabb.position.y = p_visibility_rect.position.y;
|
|
|
|
aabb.size.x = p_visibility_rect.size.x;
|
|
|
|
aabb.size.y = p_visibility_rect.size.y;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
VS::get_singleton()->particles_set_custom_aabb(particles, aabb);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
_change_notify("visibility_rect");
|
2014-02-10 01:10:30 +00:00
|
|
|
update();
|
|
|
|
}
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_use_local_coordinates(bool p_enable) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
local_coords = p_enable;
|
|
|
|
VS::get_singleton()->particles_set_use_local_coordinates(particles, local_coords);
|
|
|
|
set_notify_transform(!p_enable);
|
2017-06-25 11:01:15 +00:00
|
|
|
if (!p_enable && is_inside_tree()) {
|
2017-06-21 19:25:45 +00:00
|
|
|
_update_particle_emission_transform();
|
2016-05-17 21:27:15 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::_update_particle_emission_transform() {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
Transform2D xf2d = get_global_transform();
|
|
|
|
Transform xf;
|
|
|
|
xf.basis.set_axis(0, Vector3(xf2d.get_axis(0).x, xf2d.get_axis(0).y, 0));
|
|
|
|
xf.basis.set_axis(1, Vector3(xf2d.get_axis(1).x, xf2d.get_axis(1).y, 0));
|
|
|
|
xf.set_origin(Vector3(xf2d.get_origin().x, xf2d.get_origin().y, 0));
|
2017-02-23 08:28:09 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
VS::get_singleton()->particles_set_emission_transform(particles, xf);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_process_material(const Ref<Material> &p_material) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
process_material = p_material;
|
|
|
|
Ref<ParticlesMaterial> pm = p_material;
|
|
|
|
if (pm.is_valid() && !pm->get_flag(ParticlesMaterial::FLAG_DISABLE_Z) && pm->get_gravity() == Vector3(0, -9.8, 0)) {
|
|
|
|
//likely a new material, modify it!
|
|
|
|
pm->set_flag(ParticlesMaterial::FLAG_DISABLE_Z, true);
|
|
|
|
pm->set_gravity(Vector3(0, 98, 0));
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2017-06-21 19:25:45 +00:00
|
|
|
RID material_rid;
|
|
|
|
if (process_material.is_valid())
|
|
|
|
material_rid = process_material->get_rid();
|
|
|
|
VS::get_singleton()->particles_set_process_material(particles, material_rid);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
update_configuration_warning();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_speed_scale(float p_scale) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
speed_scale = p_scale;
|
|
|
|
VS::get_singleton()->particles_set_speed_scale(particles, p_scale);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Particles2D::is_emitting() const {
|
|
|
|
|
2017-12-23 04:08:50 +00:00
|
|
|
return VS::get_singleton()->particles_get_emitting(particles);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
int Particles2D::get_amount() const {
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
return amount;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
float Particles2D::get_lifetime() const {
|
|
|
|
|
|
|
|
return lifetime;
|
|
|
|
}
|
2017-06-25 11:01:15 +00:00
|
|
|
|
|
|
|
bool Particles2D::get_one_shot() const {
|
|
|
|
|
|
|
|
return one_shot;
|
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
float Particles2D::get_pre_process_time() const {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
return pre_process_time;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2017-06-21 19:25:45 +00:00
|
|
|
float Particles2D::get_explosiveness_ratio() const {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
return explosiveness_ratio;
|
2015-05-24 18:18:52 +00:00
|
|
|
}
|
2017-06-21 19:25:45 +00:00
|
|
|
float Particles2D::get_randomness_ratio() const {
|
2015-05-24 18:18:52 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
return randomness_ratio;
|
2015-05-24 18:18:52 +00:00
|
|
|
}
|
2017-06-21 19:25:45 +00:00
|
|
|
Rect2 Particles2D::get_visibility_rect() const {
|
2015-05-24 18:18:52 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
return visibility_rect;
|
2015-05-24 18:18:52 +00:00
|
|
|
}
|
2017-06-21 19:25:45 +00:00
|
|
|
bool Particles2D::get_use_local_coordinates() const {
|
2015-05-24 18:18:52 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
return local_coords;
|
2015-05-24 18:18:52 +00:00
|
|
|
}
|
2017-06-21 19:25:45 +00:00
|
|
|
Ref<Material> Particles2D::get_process_material() const {
|
2015-05-24 18:18:52 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
return process_material;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
float Particles2D::get_speed_scale() const {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
return speed_scale;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_draw_order(DrawOrder p_order) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
draw_order = p_order;
|
|
|
|
VS::get_singleton()->particles_set_draw_order(particles, VS::ParticlesDrawOrder(p_order));
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
Particles2D::DrawOrder Particles2D::get_draw_order() const {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
return draw_order;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_fixed_fps(int p_count) {
|
|
|
|
fixed_fps = p_count;
|
|
|
|
VS::get_singleton()->particles_set_fixed_fps(particles, p_count);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
int Particles2D::get_fixed_fps() const {
|
|
|
|
return fixed_fps;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_fractional_delta(bool p_enable) {
|
|
|
|
fractional_delta = p_enable;
|
|
|
|
VS::get_singleton()->particles_set_fractional_delta(particles, p_enable);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2015-05-24 18:18:52 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
bool Particles2D::get_fractional_delta() const {
|
|
|
|
return fractional_delta;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
String Particles2D::get_configuration_warning() const {
|
2015-05-24 18:18:52 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
String warnings;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
if (process_material.is_null()) {
|
|
|
|
if (warnings != String())
|
|
|
|
warnings += "\n";
|
|
|
|
warnings += "- " + TTR("A material to process the particles is not assigned, so no behavior is imprinted.");
|
2015-05-24 18:18:52 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
return warnings;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
Rect2 Particles2D::capture_rect() const {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-11-17 02:09:00 +00:00
|
|
|
AABB aabb = VS::get_singleton()->particles_get_current_aabb(particles);
|
2017-06-21 19:25:45 +00:00
|
|
|
Rect2 r;
|
|
|
|
r.position.x = aabb.position.x;
|
|
|
|
r.position.y = aabb.position.y;
|
|
|
|
r.size.x = aabb.size.x;
|
|
|
|
r.size.y = aabb.size.y;
|
|
|
|
return r;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_texture(const Ref<Texture> &p_texture) {
|
|
|
|
texture = p_texture;
|
|
|
|
update();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
Ref<Texture> Particles2D::get_texture() const {
|
|
|
|
return texture;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_normal_map(const Ref<Texture> &p_normal_map) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
normal_map = p_normal_map;
|
|
|
|
update();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
Ref<Texture> Particles2D::get_normal_map() const {
|
|
|
|
return normal_map;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::_validate_property(PropertyInfo &property) const {
|
2014-02-13 21:03:28 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_v_frames(int p_count) {
|
2014-02-13 21:03:28 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
ERR_FAIL_COND(p_count < 1);
|
|
|
|
v_frames = p_count;
|
|
|
|
update();
|
2014-02-13 21:03:28 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
int Particles2D::get_v_frames() const {
|
2014-02-13 21:03:28 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
return v_frames;
|
2014-02-13 21:03:28 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::set_h_frames(int p_count) {
|
2014-11-17 10:46:11 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
ERR_FAIL_COND(p_count < 1);
|
|
|
|
h_frames = p_count;
|
|
|
|
update();
|
2014-11-17 10:46:11 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
int Particles2D::get_h_frames() const {
|
2014-11-17 10:46:11 +00:00
|
|
|
|
|
|
|
return h_frames;
|
|
|
|
}
|
|
|
|
|
2017-06-25 11:01:15 +00:00
|
|
|
void Particles2D::restart() {
|
|
|
|
VS::get_singleton()->particles_restart(particles);
|
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
void Particles2D::_notification(int p_what) {
|
2014-11-17 10:46:11 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
if (p_what == NOTIFICATION_DRAW) {
|
2014-11-17 10:46:11 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
RID texture_rid;
|
|
|
|
if (texture.is_valid())
|
|
|
|
texture_rid = texture->get_rid();
|
|
|
|
RID normal_rid;
|
|
|
|
if (normal_map.is_valid())
|
2017-12-06 21:27:39 +00:00
|
|
|
normal_rid = normal_map->get_rid();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
VS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid, normal_rid, h_frames, v_frames);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-22 10:12:30 +00:00
|
|
|
#ifdef TOOLS_ENABLED
|
2017-08-18 23:02:56 +00:00
|
|
|
if (Engine::get_singleton()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
draw_rect(visibility_rect, Color(0, 0.7, 0.9, 0.4), false);
|
|
|
|
}
|
2017-06-22 10:12:30 +00:00
|
|
|
#endif
|
2017-06-21 19:25:45 +00:00
|
|
|
}
|
2015-12-29 21:53:45 +00:00
|
|
|
|
2017-08-07 22:01:30 +00:00
|
|
|
if (p_what == NOTIFICATION_PAUSED || p_what == NOTIFICATION_UNPAUSED) {
|
|
|
|
if (can_process()) {
|
|
|
|
VS::get_singleton()->particles_set_speed_scale(particles, speed_scale);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
VS::get_singleton()->particles_set_speed_scale(particles, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
|
|
|
|
_update_particle_emission_transform();
|
2015-12-29 21:53:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void Particles2D::_bind_methods() {
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &Particles2D::set_emitting);
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_amount", "amount"), &Particles2D::set_amount);
|
2017-06-21 19:25:45 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &Particles2D::set_lifetime);
|
2017-06-25 11:01:15 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_one_shot", "secs"), &Particles2D::set_one_shot);
|
2017-06-21 19:25:45 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_pre_process_time", "secs"), &Particles2D::set_pre_process_time);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_explosiveness_ratio", "ratio"), &Particles2D::set_explosiveness_ratio);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_randomness_ratio", "ratio"), &Particles2D::set_randomness_ratio);
|
2018-08-17 09:47:29 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_visibility_rect", "visibility_rect"), &Particles2D::set_visibility_rect);
|
2017-06-21 19:25:45 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_use_local_coordinates", "enable"), &Particles2D::set_use_local_coordinates);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_fixed_fps", "fps"), &Particles2D::set_fixed_fps);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_fractional_delta", "enable"), &Particles2D::set_fractional_delta);
|
2017-08-09 11:19:41 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_process_material", "material"), &Particles2D::set_process_material);
|
2017-06-21 19:25:45 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_speed_scale", "scale"), &Particles2D::set_speed_scale);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("is_emitting"), &Particles2D::is_emitting);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_amount"), &Particles2D::get_amount);
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("get_lifetime"), &Particles2D::get_lifetime);
|
2017-06-25 11:01:15 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("get_one_shot"), &Particles2D::get_one_shot);
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("get_pre_process_time"), &Particles2D::get_pre_process_time);
|
2017-06-21 19:25:45 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("get_explosiveness_ratio"), &Particles2D::get_explosiveness_ratio);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_randomness_ratio"), &Particles2D::get_randomness_ratio);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_visibility_rect"), &Particles2D::get_visibility_rect);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_use_local_coordinates"), &Particles2D::get_use_local_coordinates);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_fixed_fps"), &Particles2D::get_fixed_fps);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_fractional_delta"), &Particles2D::get_fractional_delta);
|
2017-08-09 11:19:41 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("get_process_material"), &Particles2D::get_process_material);
|
2017-06-21 19:25:45 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("get_speed_scale"), &Particles2D::get_speed_scale);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("set_draw_order", "order"), &Particles2D::set_draw_order);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_draw_order"), &Particles2D::get_draw_order);
|
|
|
|
|
2017-08-09 11:19:41 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Particles2D::set_texture);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_texture"), &Particles2D::get_texture);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-08-09 11:19:41 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_normal_map", "texture"), &Particles2D::set_normal_map);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_normal_map"), &Particles2D::get_normal_map);
|
2014-02-13 21:03:28 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("capture_rect"), &Particles2D::capture_rect);
|
2014-11-17 10:46:11 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_v_frames", "frames"), &Particles2D::set_v_frames);
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("get_v_frames"), &Particles2D::get_v_frames);
|
2014-11-17 10:46:11 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_h_frames", "frames"), &Particles2D::set_h_frames);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_h_frames"), &Particles2D::get_h_frames);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-25 11:01:15 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("restart"), &Particles2D::restart);
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emitting"), "set_emitting", "is_emitting");
|
2018-05-16 12:13:41 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "amount", PROPERTY_HINT_EXP_RANGE, "1,1000000,1"), "set_amount", "get_amount");
|
2017-06-25 21:57:28 +00:00
|
|
|
ADD_GROUP("Time", "");
|
2018-05-16 12:13:41 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "lifetime", PROPERTY_HINT_RANGE, "0.01,600.0,0.01,or_greater"), "set_lifetime", "get_lifetime");
|
2017-06-25 11:01:15 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "one_shot"), "set_one_shot", "get_one_shot");
|
2017-06-21 19:25:45 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "preprocess", PROPERTY_HINT_RANGE, "0.00,600.0,0.01"), "set_pre_process_time", "get_pre_process_time");
|
2018-08-24 16:10:47 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "speed_scale", PROPERTY_HINT_RANGE, "0,64,0.01"), "set_speed_scale", "get_speed_scale");
|
2017-06-21 19:25:45 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "explosiveness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_explosiveness_ratio", "get_explosiveness_ratio");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "randomness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_randomness_ratio", "get_randomness_ratio");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "fixed_fps", PROPERTY_HINT_RANGE, "0,1000,1"), "set_fixed_fps", "get_fixed_fps");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fract_delta"), "set_fractional_delta", "get_fractional_delta");
|
2017-06-25 21:57:28 +00:00
|
|
|
ADD_GROUP("Drawing", "");
|
2018-08-17 09:47:29 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::RECT2, "visibility_rect"), "set_visibility_rect", "get_visibility_rect");
|
2017-06-25 21:57:28 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates");
|
2017-06-21 19:25:45 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime"), "set_draw_order", "get_draw_order");
|
|
|
|
ADD_GROUP("Process Material", "process_");
|
2017-06-22 12:17:06 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "process_material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,ParticlesMaterial"), "set_process_material", "get_process_material");
|
2017-06-21 19:25:45 +00:00
|
|
|
ADD_GROUP("Textures", "");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_normal_map", "get_normal_map");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "h_frames", PROPERTY_HINT_RANGE, "1,1024,1"), "set_h_frames", "get_h_frames");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "v_frames", PROPERTY_HINT_RANGE, "1,1024,1"), "set_v_frames", "get_v_frames");
|
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(DRAW_ORDER_INDEX);
|
|
|
|
BIND_ENUM_CONSTANT(DRAW_ORDER_LIFETIME);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Particles2D::Particles2D() {
|
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
particles = VS::get_singleton()->particles_create();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
set_emitting(true);
|
2017-06-25 11:01:15 +00:00
|
|
|
set_one_shot(false);
|
2017-06-21 19:25:45 +00:00
|
|
|
set_amount(8);
|
|
|
|
set_lifetime(1);
|
|
|
|
set_fixed_fps(0);
|
|
|
|
set_fractional_delta(true);
|
|
|
|
set_pre_process_time(0);
|
|
|
|
set_explosiveness_ratio(0);
|
|
|
|
set_randomness_ratio(0);
|
|
|
|
set_visibility_rect(Rect2(Vector2(-100, -100), Vector2(200, 200)));
|
|
|
|
set_use_local_coordinates(true);
|
2017-08-05 10:46:49 +00:00
|
|
|
set_draw_order(DRAW_ORDER_INDEX);
|
2017-06-21 19:25:45 +00:00
|
|
|
set_speed_scale(1);
|
2017-03-05 15:44:50 +00:00
|
|
|
h_frames = 1;
|
2017-06-21 19:25:45 +00:00
|
|
|
v_frames = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Particles2D::~Particles2D() {
|
2014-02-13 21:03:28 +00:00
|
|
|
|
2017-06-21 19:25:45 +00:00
|
|
|
VS::get_singleton()->free(particles);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|