|
@@ -302,9 +302,9 @@ void CPUParticles::set_param_curve(Parameter p_param, const Ref<Curve> &p_curve)
|
|
case PARAM_ANGULAR_VELOCITY: {
|
|
case PARAM_ANGULAR_VELOCITY: {
|
|
_adjust_curve_range(p_curve, -360, 360);
|
|
_adjust_curve_range(p_curve, -360, 360);
|
|
} break;
|
|
} break;
|
|
- /*case PARAM_ORBIT_VELOCITY: {
|
|
|
|
|
|
+ case PARAM_ORBIT_VELOCITY: {
|
|
_adjust_curve_range(p_curve, -500, 500);
|
|
_adjust_curve_range(p_curve, -500, 500);
|
|
- } break;*/
|
|
|
|
|
|
+ } break;
|
|
case PARAM_LINEAR_ACCEL: {
|
|
case PARAM_LINEAR_ACCEL: {
|
|
_adjust_curve_range(p_curve, -200, 200);
|
|
_adjust_curve_range(p_curve, -200, 200);
|
|
} break;
|
|
} break;
|
|
@@ -461,11 +461,10 @@ void CPUParticles::_validate_property(PropertyInfo &property) const {
|
|
if (property.name == "emission_normals" && emission_shape != EMISSION_SHAPE_DIRECTED_POINTS) {
|
|
if (property.name == "emission_normals" && emission_shape != EMISSION_SHAPE_DIRECTED_POINTS) {
|
|
property.usage = 0;
|
|
property.usage = 0;
|
|
}
|
|
}
|
|
- /*
|
|
|
|
|
|
+
|
|
if (property.name.begins_with("orbit_") && !flags[FLAG_DISABLE_Z]) {
|
|
if (property.name.begins_with("orbit_") && !flags[FLAG_DISABLE_Z]) {
|
|
property.usage = 0;
|
|
property.usage = 0;
|
|
}
|
|
}
|
|
- */
|
|
|
|
}
|
|
}
|
|
|
|
|
|
static uint32_t idhash(uint32_t x) {
|
|
static uint32_t idhash(uint32_t x) {
|
|
@@ -698,16 +697,14 @@ void CPUParticles::_particles_process(float p_delta) {
|
|
if (curve_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) {
|
|
if (curve_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) {
|
|
tex_linear_velocity = curve_parameters[PARAM_INITIAL_LINEAR_VELOCITY]->interpolate(p.custom[1]);
|
|
tex_linear_velocity = curve_parameters[PARAM_INITIAL_LINEAR_VELOCITY]->interpolate(p.custom[1]);
|
|
}
|
|
}
|
|
- /*
|
|
|
|
- float tex_orbit_velocity = 0.0;
|
|
|
|
|
|
|
|
|
|
+ float tex_orbit_velocity = 0.0;
|
|
if (flags[FLAG_DISABLE_Z]) {
|
|
if (flags[FLAG_DISABLE_Z]) {
|
|
-
|
|
|
|
- if (curve_parameters[PARAM_INITIAL_ORBIT_VELOCITY].is_valid()) {
|
|
|
|
- tex_orbit_velocity = curve_parameters[PARAM_INITIAL_ORBIT_VELOCITY]->interpolate(p.custom[1]);
|
|
|
|
|
|
+ if (curve_parameters[PARAM_ORBIT_VELOCITY].is_valid()) {
|
|
|
|
+ tex_orbit_velocity = curve_parameters[PARAM_ORBIT_VELOCITY]->interpolate(p.custom[1]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-*/
|
|
|
|
|
|
+
|
|
float tex_angular_velocity = 0.0;
|
|
float tex_angular_velocity = 0.0;
|
|
if (curve_parameters[PARAM_ANGULAR_VELOCITY].is_valid()) {
|
|
if (curve_parameters[PARAM_ANGULAR_VELOCITY].is_valid()) {
|
|
tex_angular_velocity = curve_parameters[PARAM_ANGULAR_VELOCITY]->interpolate(p.custom[1]);
|
|
tex_angular_velocity = curve_parameters[PARAM_ANGULAR_VELOCITY]->interpolate(p.custom[1]);
|
|
@@ -772,18 +769,18 @@ void CPUParticles::_particles_process(float p_delta) {
|
|
//apply attractor forces
|
|
//apply attractor forces
|
|
p.velocity += force * local_delta;
|
|
p.velocity += force * local_delta;
|
|
//orbit velocity
|
|
//orbit velocity
|
|
-#if 0
|
|
|
|
if (flags[FLAG_DISABLE_Z]) {
|
|
if (flags[FLAG_DISABLE_Z]) {
|
|
-
|
|
|
|
- float orbit_amount = (orbit_velocity + tex_orbit_velocity) * mix(1.0, rand_from_seed(alt_seed), orbit_velocity_random);
|
|
|
|
|
|
+ float orbit_amount = (parameters[PARAM_ORBIT_VELOCITY] + tex_orbit_velocity) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_ORBIT_VELOCITY]);
|
|
if (orbit_amount != 0.0) {
|
|
if (orbit_amount != 0.0) {
|
|
- float ang = orbit_amount * DELTA * pi * 2.0;
|
|
|
|
- mat2 rot = mat2(vec2(cos(ang), -sin(ang)), vec2(sin(ang), cos(ang)));
|
|
|
|
- TRANSFORM[3].xy -= diff.xy;
|
|
|
|
- TRANSFORM[3].xy += rot * diff.xy;
|
|
|
|
|
|
+ float ang = orbit_amount * local_delta * Math_PI * 2.0;
|
|
|
|
+ // Not sure why the ParticlesMaterial code uses a clockwise rotation matrix,
|
|
|
|
+ // but we use -ang here to reproduce its behavior.
|
|
|
|
+ Transform2D rot = Transform2D(-ang, Vector2());
|
|
|
|
+ Vector2 rotv = rot.basis_xform(Vector2(diff.x, diff.y));
|
|
|
|
+ p.transform.origin -= Vector3(diff.x, diff.y, 0);
|
|
|
|
+ p.transform.origin += Vector3(rotv.x, rotv.y, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-#endif
|
|
|
|
if (curve_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) {
|
|
if (curve_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) {
|
|
p.velocity = p.velocity.normalized() * tex_linear_velocity;
|
|
p.velocity = p.velocity.normalized() * tex_linear_velocity;
|
|
}
|
|
}
|
|
@@ -1179,7 +1176,7 @@ void CPUParticles::convert_from_particles(Node *p_particles) {
|
|
|
|
|
|
CONVERT_PARAM(PARAM_INITIAL_LINEAR_VELOCITY);
|
|
CONVERT_PARAM(PARAM_INITIAL_LINEAR_VELOCITY);
|
|
CONVERT_PARAM(PARAM_ANGULAR_VELOCITY);
|
|
CONVERT_PARAM(PARAM_ANGULAR_VELOCITY);
|
|
- // CONVERT_PARAM(PARAM_ORBIT_VELOCITY);
|
|
|
|
|
|
+ CONVERT_PARAM(PARAM_ORBIT_VELOCITY);
|
|
CONVERT_PARAM(PARAM_LINEAR_ACCEL);
|
|
CONVERT_PARAM(PARAM_LINEAR_ACCEL);
|
|
CONVERT_PARAM(PARAM_RADIAL_ACCEL);
|
|
CONVERT_PARAM(PARAM_RADIAL_ACCEL);
|
|
CONVERT_PARAM(PARAM_TANGENTIAL_ACCEL);
|
|
CONVERT_PARAM(PARAM_TANGENTIAL_ACCEL);
|
|
@@ -1322,12 +1319,10 @@ void CPUParticles::_bind_methods() {
|
|
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_velocity", PROPERTY_HINT_RANGE, "-720,720,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_ANGULAR_VELOCITY);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_velocity", PROPERTY_HINT_RANGE, "-720,720,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_ANGULAR_VELOCITY);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_velocity_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANGULAR_VELOCITY);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_velocity_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANGULAR_VELOCITY);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "angular_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_ANGULAR_VELOCITY);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "angular_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_ANGULAR_VELOCITY);
|
|
- /*
|
|
|
|
ADD_GROUP("Orbit Velocity", "orbit_");
|
|
ADD_GROUP("Orbit Velocity", "orbit_");
|
|
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "orbit_velocity", PROPERTY_HINT_RANGE, "-1000,1000,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_ORBIT_VELOCITY);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "orbit_velocity", PROPERTY_HINT_RANGE, "-1000,1000,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_ORBIT_VELOCITY);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "orbit_velocity_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ORBIT_VELOCITY);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "orbit_velocity_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ORBIT_VELOCITY);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "orbit_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_ORBIT_VELOCITY);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "orbit_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_ORBIT_VELOCITY);
|
|
-*/
|
|
|
|
ADD_GROUP("Linear Accel", "linear_");
|
|
ADD_GROUP("Linear Accel", "linear_");
|
|
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_accel", PROPERTY_HINT_RANGE, "-100,100,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_LINEAR_ACCEL);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_accel", PROPERTY_HINT_RANGE, "-100,100,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_LINEAR_ACCEL);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_accel_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_LINEAR_ACCEL);
|
|
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_accel_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_LINEAR_ACCEL);
|
|
@@ -1370,7 +1365,7 @@ void CPUParticles::_bind_methods() {
|
|
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_INITIAL_LINEAR_VELOCITY);
|
|
BIND_ENUM_CONSTANT(PARAM_INITIAL_LINEAR_VELOCITY);
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_VELOCITY);
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_VELOCITY);
|
|
- //BIND_ENUM_CONSTANT(PARAM_ORBIT_VELOCITY);
|
|
|
|
|
|
+ BIND_ENUM_CONSTANT(PARAM_ORBIT_VELOCITY);
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_ACCEL);
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_ACCEL);
|
|
BIND_ENUM_CONSTANT(PARAM_RADIAL_ACCEL);
|
|
BIND_ENUM_CONSTANT(PARAM_RADIAL_ACCEL);
|
|
BIND_ENUM_CONSTANT(PARAM_TANGENTIAL_ACCEL);
|
|
BIND_ENUM_CONSTANT(PARAM_TANGENTIAL_ACCEL);
|
|
@@ -1384,6 +1379,7 @@ void CPUParticles::_bind_methods() {
|
|
|
|
|
|
BIND_ENUM_CONSTANT(FLAG_ALIGN_Y_TO_VELOCITY);
|
|
BIND_ENUM_CONSTANT(FLAG_ALIGN_Y_TO_VELOCITY);
|
|
BIND_ENUM_CONSTANT(FLAG_ROTATE_Y);
|
|
BIND_ENUM_CONSTANT(FLAG_ROTATE_Y);
|
|
|
|
+ BIND_ENUM_CONSTANT(FLAG_DISABLE_Z);
|
|
BIND_ENUM_CONSTANT(FLAG_MAX);
|
|
BIND_ENUM_CONSTANT(FLAG_MAX);
|
|
|
|
|
|
BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINT);
|
|
BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINT);
|
|
@@ -1422,7 +1418,7 @@ CPUParticles::CPUParticles() {
|
|
set_spread(45);
|
|
set_spread(45);
|
|
set_flatness(0);
|
|
set_flatness(0);
|
|
set_param(PARAM_INITIAL_LINEAR_VELOCITY, 1);
|
|
set_param(PARAM_INITIAL_LINEAR_VELOCITY, 1);
|
|
- //set_param(PARAM_ORBIT_VELOCITY, 0);
|
|
|
|
|
|
+ set_param(PARAM_ORBIT_VELOCITY, 0);
|
|
set_param(PARAM_LINEAR_ACCEL, 0);
|
|
set_param(PARAM_LINEAR_ACCEL, 0);
|
|
set_param(PARAM_RADIAL_ACCEL, 0);
|
|
set_param(PARAM_RADIAL_ACCEL, 0);
|
|
set_param(PARAM_TANGENTIAL_ACCEL, 0);
|
|
set_param(PARAM_TANGENTIAL_ACCEL, 0);
|