Skip to content

Commit

Permalink
Merge pull request godotengine#12706 from MillionOstrich/particle-ran…
Browse files Browse the repository at this point in the history
…dom-velocity

Fix randomisation of initial particle velocity
  • Loading branch information
akien-mga authored Nov 8, 2017
2 parents b5e8cd3 + eaa8c46 commit 5fb359d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scene/3d/particles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,15 +642,15 @@ void ParticlesMaterial::_update_shader() {

code += " float angle1 = (rand_from_seed(alt_seed)*2.0-1.0)*spread/180.0*3.1416;\n";
code += " vec3 rot = vec3( cos(angle1), sin(angle1),0.0 );\n";
code += " VELOCITY = (rot*initial_linear_velocity+rot*initial_linear_velocity_random*rand_from_seed(alt_seed));\n";
code += " VELOCITY = rot*initial_linear_velocity*mix(1.0, rand_from_seed(alt_seed), initial_linear_velocity_random);\n";

} else {
//initiate velocity spread in 3D
code += " float angle1 = rand_from_seed(alt_seed)*spread*3.1416;\n";
code += " float angle2 = rand_from_seed(alt_seed)*20.0*3.1416; // make it more random like\n";
code += " vec3 rot_xz = vec3( sin(angle1), 0.0, cos(angle1) );\n";
code += " vec3 rot = vec3( cos(angle2)*rot_xz.x,sin(angle2)*rot_xz.x, rot_xz.z);\n";
code += " VELOCITY = (rot*initial_linear_velocity+rot*initial_linear_velocity_random*rand_from_seed(alt_seed));\n";
code += " VELOCITY = rot*initial_linear_velocity*mix(1.0, rand_from_seed(alt_seed), initial_linear_velocity_random);\n";
}

code += " float base_angle = (initial_angle+tex_angle)*mix(1.0,angle_rand,initial_angle_random);\n";
Expand Down

0 comments on commit 5fb359d

Please sign in to comment.