mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-23 17:47:17 +01:00
Ported: Allow negative scale in Particles and CPUParticles
This can be used to make 2D particles look more 3D-y with thoughtful use
of scale curve animation.
- Calinou
c4a3560884
This commit is contained in:
parent
6821dfb26e
commit
45c65911b5
@ -266,7 +266,7 @@
|
||||
Emission lifetime randomness ratio.
|
||||
</member>
|
||||
<member name="scale_amount" type="float" setter="set_param" getter="get_param" default="1.0">
|
||||
Initial scale applied to each particle.
|
||||
Initial scale applied to each particle. This can be set to a negative value to flip the particle on all axes.
|
||||
</member>
|
||||
<member name="scale_amount_curve" type="Curve" setter="set_param_curve" getter="get_param_curve">
|
||||
Each particle's scale will vary along this [Curve].
|
||||
|
@ -245,7 +245,7 @@
|
||||
Emission lifetime randomness ratio.
|
||||
</member>
|
||||
<member name="scale_amount" type="float" setter="set_param" getter="get_param" default="1.0">
|
||||
Initial scale applied to each particle.
|
||||
Initial scale applied to each particle. This can be set to a negative value to flip the particle on all axes.
|
||||
</member>
|
||||
<member name="scale_amount_curve" type="Curve" setter="set_param_curve" getter="get_param_curve">
|
||||
Each particle's scale will vary along this [Curve].
|
||||
|
@ -29,9 +29,9 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "cpu_particles_2d.h"
|
||||
#include "core/containers/rid.h"
|
||||
#include "core/core_string_names.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/containers/rid.h"
|
||||
#include "scene/2d/canvas_item.h"
|
||||
#include "scene/resources/particles_material.h"
|
||||
#include "scene/resources/texture.h"
|
||||
@ -926,9 +926,9 @@ void CPUParticles2D::_particles_process(float p_delta) {
|
||||
|
||||
//scale by scale
|
||||
float base_scale = tex_scale * Math::lerp(parameters[PARAM_SCALE], 1.0f, p.scale_rand * randomness[PARAM_SCALE]);
|
||||
if (base_scale < 0.000001) {
|
||||
base_scale = 0.000001;
|
||||
}
|
||||
|
||||
// Prevent zero scale (which can cause rendering issues).
|
||||
base_scale = SGN(base_scale) * MAX(Math::abs(base_scale), 0.000001);
|
||||
|
||||
p.transform.columns[0] *= base_scale;
|
||||
p.transform.columns[1] *= base_scale;
|
||||
@ -1266,7 +1266,7 @@ void CPUParticles2D::_bind_methods() {
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angle_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANGLE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "angle_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_ANGLE);
|
||||
ADD_GROUP("Scale", "");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale_amount", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater"), "set_param", "get_param", PARAM_SCALE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale_amount", PROPERTY_HINT_RANGE, "-1000,1000,0.01,or_greater"), "set_param", "get_param", PARAM_SCALE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale_amount_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_SCALE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "scale_amount_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_SCALE);
|
||||
ADD_GROUP("Color", "");
|
||||
|
@ -997,9 +997,9 @@ void CPUParticles::_particles_process(float p_delta) {
|
||||
|
||||
//scale by scale
|
||||
float base_scale = tex_scale * Math::lerp(parameters[PARAM_SCALE], 1.0f, p.scale_rand * randomness[PARAM_SCALE]);
|
||||
if (base_scale < 0.000001) {
|
||||
base_scale = 0.000001;
|
||||
}
|
||||
|
||||
// Prevent zero scale (which can cause rendering issues).
|
||||
base_scale = SGN(base_scale) * MAX(Math::abs(base_scale), 0.000001);
|
||||
|
||||
p.transform.basis.scale(Vector3(1, 1, 1) * base_scale);
|
||||
|
||||
@ -1482,7 +1482,7 @@ void CPUParticles::_bind_methods() {
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angle_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANGLE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "angle_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_ANGLE);
|
||||
ADD_GROUP("Scale", "");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale_amount", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater"), "set_param", "get_param", PARAM_SCALE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale_amount", PROPERTY_HINT_RANGE, "-1000,1000,0.01,or_greater"), "set_param", "get_param", PARAM_SCALE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "scale_amount_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_SCALE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "scale_amount_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_SCALE);
|
||||
ADD_GROUP("Color", "");
|
||||
|
Loading…
Reference in New Issue
Block a user