Rename GPUParticles2D/3D's `trail_length_secs` to `trail_lifetime`
The property already has a "seconds" suffix in the inspector. The "lifetime" term makes it more obvious that the property is specified as time, not a distance in units. The property hint now allows manually entering values greater than 10 seconds. The internal rendering value's default now matches the particles nodes' default.
This commit is contained in:
parent
f814e15c7f
commit
ab7a807f2b
|
@ -89,12 +89,17 @@
|
||||||
Particle texture. If [code]null[/code], particles will be squares.
|
Particle texture. If [code]null[/code], particles will be squares.
|
||||||
</member>
|
</member>
|
||||||
<member name="trail_enabled" type="bool" setter="set_trail_enabled" getter="is_trail_enabled" default="false">
|
<member name="trail_enabled" type="bool" setter="set_trail_enabled" getter="is_trail_enabled" default="false">
|
||||||
|
If [code]true[/code], enables particle trails using a mesh skinning system.
|
||||||
|
[b]Note:[/b] Unlike [GPUParticles3D], the number of trail sections and subdivisions is set with the [member trail_sections] and [member trail_section_subdivisions] properties.
|
||||||
</member>
|
</member>
|
||||||
<member name="trail_length_secs" type="float" setter="set_trail_length" getter="get_trail_length" default="0.3">
|
<member name="trail_lifetime" type="float" setter="set_trail_lifetime" getter="get_trail_lifetime" default="0.3">
|
||||||
|
The amount of time the particle's trail should represent (in seconds). Only effective if [member trail_enabled] is [code]true[/code].
|
||||||
</member>
|
</member>
|
||||||
<member name="trail_section_subdivisions" type="int" setter="set_trail_section_subdivisions" getter="get_trail_section_subdivisions" default="4">
|
<member name="trail_section_subdivisions" type="int" setter="set_trail_section_subdivisions" getter="get_trail_section_subdivisions" default="4">
|
||||||
|
The number of subdivisions to use for the particle trail rendering. Higher values can result in smoother trail curves, at the cost of performance due to increased mesh complexity. See also [member trail_sections]. Only effective if [member trail_enabled] is [code]true[/code].
|
||||||
</member>
|
</member>
|
||||||
<member name="trail_sections" type="int" setter="set_trail_sections" getter="get_trail_sections" default="8">
|
<member name="trail_sections" type="int" setter="set_trail_sections" getter="get_trail_sections" default="8">
|
||||||
|
The number of sections to use for the particle trail rendering. Higher values can result in smoother trail curves, at the cost of performance due to increased mesh complexity. See also [member trail_section_subdivisions]. Only effective if [member trail_enabled] is [code]true[/code].
|
||||||
</member>
|
</member>
|
||||||
<member name="visibility_rect" type="Rect2" setter="set_visibility_rect" getter="get_visibility_rect" default="Rect2(-100, -100, 200, 200)">
|
<member name="visibility_rect" type="Rect2" setter="set_visibility_rect" getter="get_visibility_rect" default="Rect2(-100, -100, 200, 200)">
|
||||||
The [Rect2] that determines the node's region which needs to be visible on screen for the particle system to be active.
|
The [Rect2] that determines the node's region which needs to be visible on screen for the particle system to be active.
|
||||||
|
|
|
@ -116,8 +116,12 @@
|
||||||
<member name="sub_emitter" type="NodePath" setter="set_sub_emitter" getter="get_sub_emitter" default="NodePath("")">
|
<member name="sub_emitter" type="NodePath" setter="set_sub_emitter" getter="get_sub_emitter" default="NodePath("")">
|
||||||
</member>
|
</member>
|
||||||
<member name="trail_enabled" type="bool" setter="set_trail_enabled" getter="is_trail_enabled" default="false">
|
<member name="trail_enabled" type="bool" setter="set_trail_enabled" getter="is_trail_enabled" default="false">
|
||||||
|
If [code]true[/code], enables particle trails using a mesh skinning system. Designed to work with [RibbonTrailMesh] and [TubeTrailMesh].
|
||||||
|
[b]Note:[/b] [member BaseMaterial3D.use_particle_trails] must also be enabled on the particle mesh's material. Otherwise, setting [member trail_enabled] to [code]true[/code] will have no effect.
|
||||||
|
[b]Note:[/b] Unlike [GPUParticles2D], the number of trail sections and subdivisions is set in the [RibbonTrailMesh] or the [TubeTrailMesh]'s properties.
|
||||||
</member>
|
</member>
|
||||||
<member name="trail_length_secs" type="float" setter="set_trail_length" getter="get_trail_length" default="0.3">
|
<member name="trail_lifetime" type="float" setter="set_trail_lifetime" getter="get_trail_lifetime" default="0.3">
|
||||||
|
The amount of time the particle's trail should represent (in seconds). Only effective if [member trail_enabled] is [code]true[/code].
|
||||||
</member>
|
</member>
|
||||||
<member name="transform_align" type="int" setter="set_transform_align" getter="get_transform_align" enum="GPUParticles3D.TransformAlign" default="0">
|
<member name="transform_align" type="int" setter="set_transform_align" getter="get_transform_align" enum="GPUParticles3D.TransformAlign" default="0">
|
||||||
</member>
|
</member>
|
||||||
|
|
|
@ -141,16 +141,16 @@ void GPUParticles2D::set_process_material(const Ref<Material> &p_material) {
|
||||||
|
|
||||||
void GPUParticles2D::set_trail_enabled(bool p_enabled) {
|
void GPUParticles2D::set_trail_enabled(bool p_enabled) {
|
||||||
trail_enabled = p_enabled;
|
trail_enabled = p_enabled;
|
||||||
RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_length);
|
RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_lifetime);
|
||||||
queue_redraw();
|
queue_redraw();
|
||||||
|
|
||||||
RS::get_singleton()->particles_set_transform_align(particles, p_enabled ? RS::PARTICLES_TRANSFORM_ALIGN_Y_TO_VELOCITY : RS::PARTICLES_TRANSFORM_ALIGN_DISABLED);
|
RS::get_singleton()->particles_set_transform_align(particles, p_enabled ? RS::PARTICLES_TRANSFORM_ALIGN_Y_TO_VELOCITY : RS::PARTICLES_TRANSFORM_ALIGN_DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUParticles2D::set_trail_length(double p_seconds) {
|
void GPUParticles2D::set_trail_lifetime(double p_seconds) {
|
||||||
ERR_FAIL_COND(p_seconds < 0.001);
|
ERR_FAIL_COND(p_seconds < 0.001);
|
||||||
trail_length = p_seconds;
|
trail_lifetime = p_seconds;
|
||||||
RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_length);
|
RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_lifetime);
|
||||||
queue_redraw();
|
queue_redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,8 +181,8 @@ bool GPUParticles2D::is_trail_enabled() const {
|
||||||
return trail_enabled;
|
return trail_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
double GPUParticles2D::get_trail_length() const {
|
double GPUParticles2D::get_trail_lifetime() const {
|
||||||
return trail_length;
|
return trail_lifetime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUParticles2D::_update_collision_size() {
|
void GPUParticles2D::_update_collision_size() {
|
||||||
|
@ -614,10 +614,10 @@ void GPUParticles2D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("emit_particle", "xform", "velocity", "color", "custom", "flags"), &GPUParticles2D::emit_particle);
|
ClassDB::bind_method(D_METHOD("emit_particle", "xform", "velocity", "color", "custom", "flags"), &GPUParticles2D::emit_particle);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_trail_enabled", "enabled"), &GPUParticles2D::set_trail_enabled);
|
ClassDB::bind_method(D_METHOD("set_trail_enabled", "enabled"), &GPUParticles2D::set_trail_enabled);
|
||||||
ClassDB::bind_method(D_METHOD("set_trail_length", "secs"), &GPUParticles2D::set_trail_length);
|
ClassDB::bind_method(D_METHOD("set_trail_lifetime", "secs"), &GPUParticles2D::set_trail_lifetime);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("is_trail_enabled"), &GPUParticles2D::is_trail_enabled);
|
ClassDB::bind_method(D_METHOD("is_trail_enabled"), &GPUParticles2D::is_trail_enabled);
|
||||||
ClassDB::bind_method(D_METHOD("get_trail_length"), &GPUParticles2D::get_trail_length);
|
ClassDB::bind_method(D_METHOD("get_trail_lifetime"), &GPUParticles2D::get_trail_lifetime);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_trail_sections", "sections"), &GPUParticles2D::set_trail_sections);
|
ClassDB::bind_method(D_METHOD("set_trail_sections", "sections"), &GPUParticles2D::set_trail_sections);
|
||||||
ClassDB::bind_method(D_METHOD("get_trail_sections"), &GPUParticles2D::get_trail_sections);
|
ClassDB::bind_method(D_METHOD("get_trail_sections"), &GPUParticles2D::get_trail_sections);
|
||||||
|
@ -647,7 +647,7 @@ void GPUParticles2D::_bind_methods() {
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime,Reverse Lifetime"), "set_draw_order", "get_draw_order");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime,Reverse Lifetime"), "set_draw_order", "get_draw_order");
|
||||||
ADD_GROUP("Trails", "trail_");
|
ADD_GROUP("Trails", "trail_");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "trail_enabled"), "set_trail_enabled", "is_trail_enabled");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "trail_enabled"), "set_trail_enabled", "is_trail_enabled");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "trail_length_secs", PROPERTY_HINT_RANGE, "0.01,10,0.01,suffix:s"), "set_trail_length", "get_trail_length");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "trail_lifetime", PROPERTY_HINT_RANGE, "0.01,10,0.01,or_greater,suffix:s"), "set_trail_lifetime", "get_trail_lifetime");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "trail_sections", PROPERTY_HINT_RANGE, "2,128,1"), "set_trail_sections", "get_trail_sections");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "trail_sections", PROPERTY_HINT_RANGE, "2,128,1"), "set_trail_sections", "get_trail_sections");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "trail_section_subdivisions", PROPERTY_HINT_RANGE, "1,1024,1"), "set_trail_section_subdivisions", "get_trail_section_subdivisions");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "trail_section_subdivisions", PROPERTY_HINT_RANGE, "1,1024,1"), "set_trail_section_subdivisions", "get_trail_section_subdivisions");
|
||||||
ADD_GROUP("Process Material", "process_");
|
ADD_GROUP("Process Material", "process_");
|
||||||
|
|
|
@ -74,7 +74,7 @@ private:
|
||||||
real_t collision_base_size = 1.0;
|
real_t collision_base_size = 1.0;
|
||||||
|
|
||||||
bool trail_enabled = false;
|
bool trail_enabled = false;
|
||||||
double trail_length = 0.3;
|
double trail_lifetime = 0.3;
|
||||||
int trail_sections = 8;
|
int trail_sections = 8;
|
||||||
int trail_section_subdivisions = 4;
|
int trail_section_subdivisions = 4;
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public:
|
||||||
void set_speed_scale(double p_scale);
|
void set_speed_scale(double p_scale);
|
||||||
void set_collision_base_size(real_t p_ratio);
|
void set_collision_base_size(real_t p_ratio);
|
||||||
void set_trail_enabled(bool p_enabled);
|
void set_trail_enabled(bool p_enabled);
|
||||||
void set_trail_length(double p_seconds);
|
void set_trail_lifetime(double p_seconds);
|
||||||
void set_trail_sections(int p_sections);
|
void set_trail_sections(int p_sections);
|
||||||
void set_trail_section_subdivisions(int p_subdivisions);
|
void set_trail_section_subdivisions(int p_subdivisions);
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ public:
|
||||||
|
|
||||||
real_t get_collision_base_size() const;
|
real_t get_collision_base_size() const;
|
||||||
bool is_trail_enabled() const;
|
bool is_trail_enabled() const;
|
||||||
double get_trail_length() const;
|
double get_trail_lifetime() const;
|
||||||
int get_trail_sections() const;
|
int get_trail_sections() const;
|
||||||
int get_trail_section_subdivisions() const;
|
int get_trail_section_subdivisions() const;
|
||||||
|
|
||||||
|
|
|
@ -176,22 +176,22 @@ void GPUParticles3D::set_draw_order(DrawOrder p_order) {
|
||||||
|
|
||||||
void GPUParticles3D::set_trail_enabled(bool p_enabled) {
|
void GPUParticles3D::set_trail_enabled(bool p_enabled) {
|
||||||
trail_enabled = p_enabled;
|
trail_enabled = p_enabled;
|
||||||
RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_length);
|
RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_lifetime);
|
||||||
update_configuration_warnings();
|
update_configuration_warnings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUParticles3D::set_trail_length(double p_seconds) {
|
void GPUParticles3D::set_trail_lifetime(double p_seconds) {
|
||||||
ERR_FAIL_COND(p_seconds < 0.001);
|
ERR_FAIL_COND(p_seconds < 0.001);
|
||||||
trail_length = p_seconds;
|
trail_lifetime = p_seconds;
|
||||||
RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_length);
|
RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GPUParticles3D::is_trail_enabled() const {
|
bool GPUParticles3D::is_trail_enabled() const {
|
||||||
return trail_enabled;
|
return trail_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
double GPUParticles3D::get_trail_length() const {
|
double GPUParticles3D::get_trail_lifetime() const {
|
||||||
return trail_length;
|
return trail_lifetime;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUParticles3D::DrawOrder GPUParticles3D::get_draw_order() const {
|
GPUParticles3D::DrawOrder GPUParticles3D::get_draw_order() const {
|
||||||
|
@ -552,10 +552,10 @@ void GPUParticles3D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("emit_particle", "xform", "velocity", "color", "custom", "flags"), &GPUParticles3D::emit_particle);
|
ClassDB::bind_method(D_METHOD("emit_particle", "xform", "velocity", "color", "custom", "flags"), &GPUParticles3D::emit_particle);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_trail_enabled", "enabled"), &GPUParticles3D::set_trail_enabled);
|
ClassDB::bind_method(D_METHOD("set_trail_enabled", "enabled"), &GPUParticles3D::set_trail_enabled);
|
||||||
ClassDB::bind_method(D_METHOD("set_trail_length", "secs"), &GPUParticles3D::set_trail_length);
|
ClassDB::bind_method(D_METHOD("set_trail_lifetime", "secs"), &GPUParticles3D::set_trail_lifetime);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("is_trail_enabled"), &GPUParticles3D::is_trail_enabled);
|
ClassDB::bind_method(D_METHOD("is_trail_enabled"), &GPUParticles3D::is_trail_enabled);
|
||||||
ClassDB::bind_method(D_METHOD("get_trail_length"), &GPUParticles3D::get_trail_length);
|
ClassDB::bind_method(D_METHOD("get_trail_lifetime"), &GPUParticles3D::get_trail_lifetime);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_transform_align", "align"), &GPUParticles3D::set_transform_align);
|
ClassDB::bind_method(D_METHOD("set_transform_align", "align"), &GPUParticles3D::set_transform_align);
|
||||||
ClassDB::bind_method(D_METHOD("get_transform_align"), &GPUParticles3D::get_transform_align);
|
ClassDB::bind_method(D_METHOD("get_transform_align"), &GPUParticles3D::get_transform_align);
|
||||||
|
@ -583,7 +583,7 @@ void GPUParticles3D::_bind_methods() {
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "transform_align", PROPERTY_HINT_ENUM, "Disabled,Z-Billboard,Y to Velocity,Z-Billboard + Y to Velocity"), "set_transform_align", "get_transform_align");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "transform_align", PROPERTY_HINT_ENUM, "Disabled,Z-Billboard,Y to Velocity,Z-Billboard + Y to Velocity"), "set_transform_align", "get_transform_align");
|
||||||
ADD_GROUP("Trails", "trail_");
|
ADD_GROUP("Trails", "trail_");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "trail_enabled"), "set_trail_enabled", "is_trail_enabled");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "trail_enabled"), "set_trail_enabled", "is_trail_enabled");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "trail_length_secs", PROPERTY_HINT_RANGE, "0.01,10,0.01,suffix:s"), "set_trail_length", "get_trail_length");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "trail_lifetime", PROPERTY_HINT_RANGE, "0.01,10,0.01,or_greater,suffix:s"), "set_trail_lifetime", "get_trail_lifetime");
|
||||||
ADD_GROUP("Process Material", "");
|
ADD_GROUP("Process Material", "");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "process_material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,ParticleProcessMaterial"), "set_process_material", "get_process_material");
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "process_material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,ParticleProcessMaterial"), "set_process_material", "get_process_material");
|
||||||
ADD_GROUP("Draw Passes", "draw_");
|
ADD_GROUP("Draw Passes", "draw_");
|
||||||
|
@ -627,7 +627,7 @@ GPUParticles3D::GPUParticles3D() {
|
||||||
set_pre_process_time(0);
|
set_pre_process_time(0);
|
||||||
set_explosiveness_ratio(0);
|
set_explosiveness_ratio(0);
|
||||||
set_randomness_ratio(0);
|
set_randomness_ratio(0);
|
||||||
set_trail_length(0.3);
|
set_trail_lifetime(0.3);
|
||||||
set_visibility_aabb(AABB(Vector3(-4, -4, -4), Vector3(8, 8, 8)));
|
set_visibility_aabb(AABB(Vector3(-4, -4, -4), Vector3(8, 8, 8)));
|
||||||
set_use_local_coordinates(false);
|
set_use_local_coordinates(false);
|
||||||
set_draw_passes(1);
|
set_draw_passes(1);
|
||||||
|
|
|
@ -76,7 +76,7 @@ private:
|
||||||
real_t collision_base_size = 0.01;
|
real_t collision_base_size = 0.01;
|
||||||
|
|
||||||
bool trail_enabled = false;
|
bool trail_enabled = false;
|
||||||
double trail_length = 0.3;
|
double trail_lifetime = 0.3;
|
||||||
|
|
||||||
TransformAlign transform_align = TRANSFORM_ALIGN_DISABLED;
|
TransformAlign transform_align = TRANSFORM_ALIGN_DISABLED;
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public:
|
||||||
void set_speed_scale(double p_scale);
|
void set_speed_scale(double p_scale);
|
||||||
void set_collision_base_size(real_t p_ratio);
|
void set_collision_base_size(real_t p_ratio);
|
||||||
void set_trail_enabled(bool p_enabled);
|
void set_trail_enabled(bool p_enabled);
|
||||||
void set_trail_length(double p_seconds);
|
void set_trail_lifetime(double p_seconds);
|
||||||
|
|
||||||
bool is_emitting() const;
|
bool is_emitting() const;
|
||||||
int get_amount() const;
|
int get_amount() const;
|
||||||
|
@ -127,7 +127,7 @@ public:
|
||||||
double get_speed_scale() const;
|
double get_speed_scale() const;
|
||||||
real_t get_collision_base_size() const;
|
real_t get_collision_base_size() const;
|
||||||
bool is_trail_enabled() const;
|
bool is_trail_enabled() const;
|
||||||
double get_trail_length() const;
|
double get_trail_lifetime() const;
|
||||||
|
|
||||||
void set_fixed_fps(int p_count);
|
void set_fixed_fps(int p_count);
|
||||||
int get_fixed_fps() const;
|
int get_fixed_fps() const;
|
||||||
|
|
|
@ -425,7 +425,7 @@ void ParticlesStorage::particles_set_trails(RID p_particles, bool p_enable, doub
|
||||||
p_length = MIN(10.0, p_length);
|
p_length = MIN(10.0, p_length);
|
||||||
|
|
||||||
particles->trails_enabled = p_enable;
|
particles->trails_enabled = p_enable;
|
||||||
particles->trail_length = p_length;
|
particles->trail_lifetime = p_length;
|
||||||
|
|
||||||
_particles_free_data(particles);
|
_particles_free_data(particles);
|
||||||
|
|
||||||
|
@ -1351,7 +1351,7 @@ void ParticlesStorage::update_particles() {
|
||||||
int history_size = 1;
|
int history_size = 1;
|
||||||
int trail_steps = 1;
|
int trail_steps = 1;
|
||||||
if (particles->trails_enabled && particles->trail_bind_poses.size() > 1) {
|
if (particles->trails_enabled && particles->trail_bind_poses.size() > 1) {
|
||||||
history_size = MAX(1, int(particles->trail_length * fixed_fps));
|
history_size = MAX(1, int(particles->trail_lifetime * fixed_fps));
|
||||||
trail_steps = particles->trail_bind_poses.size();
|
trail_steps = particles->trail_bind_poses.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,7 +232,7 @@ private:
|
||||||
|
|
||||||
Dependency dependency;
|
Dependency dependency;
|
||||||
|
|
||||||
double trail_length = 1.0;
|
double trail_lifetime = 0.3;
|
||||||
bool trails_enabled = false;
|
bool trails_enabled = false;
|
||||||
LocalVector<ParticlesFrameParams> frame_history;
|
LocalVector<ParticlesFrameParams> frame_history;
|
||||||
LocalVector<ParticlesFrameParams> trail_params;
|
LocalVector<ParticlesFrameParams> trail_params;
|
||||||
|
|
Loading…
Reference in New Issue