Skip to content

Commit

Permalink
Sync CPUParticles INSTANCE_CUSTOM with GPUParticles
Browse files Browse the repository at this point in the history
  • Loading branch information
arkology committed Dec 30, 2024
1 parent 99a8ab7 commit 7d9b474
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
11 changes: 6 additions & 5 deletions scene/2d/cpu_particles_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,15 +754,16 @@ void CPUParticles2D::_particles_process(double p_delta) {
real_t base_angle = tex_angle * Math::lerp(parameters_min[PARAM_ANGLE], parameters_max[PARAM_ANGLE], p.angle_rand);
p.rotation = Math::deg_to_rad(base_angle);

p.custom[0] = 0.0; // unused
p.custom[1] = 0.0; // phase [0..1]
p.custom[2] = tex_anim_offset * Math::lerp(parameters_min[PARAM_ANIM_OFFSET], parameters_max[PARAM_ANIM_OFFSET], p.anim_offset_rand);
p.custom[3] = (1.0 - Math::randf() * lifetime_randomness);
p.transform = Transform2D();
p.time = 0;
p.lifetime = lifetime * p.custom[3];
p.lifetime = lifetime * (1.0 - Math::randf() * lifetime_randomness);
p.base_color = Color(1, 1, 1, 1);

p.custom[0] = p.rotation;
p.custom[1] = 0.0; // Phase [0;1].
p.custom[2] = tex_anim_offset * Math::lerp(parameters_min[PARAM_ANIM_OFFSET], parameters_max[PARAM_ANIM_OFFSET], p.anim_offset_rand);
p.custom[3] = p.lifetime;

switch (emission_shape) {
case EMISSION_SHAPE_POINT: {
//do none
Expand Down
12 changes: 7 additions & 5 deletions scene/3d/cpu_particles_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,15 +820,17 @@ void CPUParticles3D::_particles_process(double p_delta) {
}

real_t base_angle = tex_angle * Math::lerp(parameters_min[PARAM_ANGLE], parameters_max[PARAM_ANGLE], p.angle_rand);
p.custom[0] = Math::deg_to_rad(base_angle); //angle
p.custom[1] = 0.0; //phase
p.custom[2] = tex_anim_offset * Math::lerp(parameters_min[PARAM_ANIM_OFFSET], parameters_max[PARAM_ANIM_OFFSET], p.anim_offset_rand); //animation offset (0-1)
p.custom[3] = (1.0 - Math::randf() * lifetime_randomness);

p.transform = Transform3D();
p.time = 0;
p.lifetime = lifetime * p.custom[3];
p.lifetime = lifetime * (1.0 - Math::randf() * lifetime_randomness);
p.base_color = Color(1, 1, 1, 1);

p.custom[0] = Math::deg_to_rad(base_angle);
p.custom[1] = 0.0; // Phase [0;1].
p.custom[2] = tex_anim_offset * Math::lerp(parameters_min[PARAM_ANIM_OFFSET], parameters_max[PARAM_ANIM_OFFSET], p.anim_offset_rand);
p.custom[3] = p.lifetime;

switch (emission_shape) {
case EMISSION_SHAPE_POINT: {
//do none
Expand Down

0 comments on commit 7d9b474

Please sign in to comment.