Fix 2D Particle velocity with directed emission mask
Changed CPU velocity calculation for EMISSION_SHAPE_DIRECTED_POINTS
to follow the same logic as in the GPU version:
mat2 rotm;
rotm[0] = texelFetch(emission_texture_normal, emission_tex_ofs, 0).xy;
rotm[1] = rotm[0].yx * vec2(1.0, -1.0);
VELOCITY.xy = rotm * VELOCITY.xy;
Now both CPUParticles2D & CPUParticles3D (z disabled) show the same results
as their GPU counterparts and take the initial velocity settings into account.
(cherry picked from commit 1c231cacb3
)
This commit is contained in:
parent
f3ed06cfd7
commit
d82cc621e1
|
@ -785,7 +785,11 @@ void CPUParticles2D::_particles_process(float p_delta) {
|
||||||
p.transform[2] = emission_points.get(random_idx);
|
p.transform[2] = emission_points.get(random_idx);
|
||||||
|
|
||||||
if (emission_shape == EMISSION_SHAPE_DIRECTED_POINTS && emission_normals.size() == pc) {
|
if (emission_shape == EMISSION_SHAPE_DIRECTED_POINTS && emission_normals.size() == pc) {
|
||||||
p.velocity = emission_normals.get(random_idx);
|
Vector2 normal = emission_normals.get(random_idx);
|
||||||
|
Transform2D m2;
|
||||||
|
m2.set_axis(0, normal);
|
||||||
|
m2.set_axis(1, normal.tangent());
|
||||||
|
p.velocity = m2.basis_xform(p.velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emission_colors.size() == pc) {
|
if (emission_colors.size() == pc) {
|
||||||
|
|
|
@ -761,13 +761,15 @@ void CPUParticles::_particles_process(float p_delta) {
|
||||||
|
|
||||||
if (emission_shape == EMISSION_SHAPE_DIRECTED_POINTS && emission_normals.size() == pc) {
|
if (emission_shape == EMISSION_SHAPE_DIRECTED_POINTS && emission_normals.size() == pc) {
|
||||||
if (flags[FLAG_DISABLE_Z]) {
|
if (flags[FLAG_DISABLE_Z]) {
|
||||||
/*
|
Vector3 normal = emission_normals.get(random_idx);
|
||||||
mat2 rotm;
|
Vector2 normal_2d(normal.x, normal.y);
|
||||||
";
|
Transform2D m2;
|
||||||
rotm[0] = texelFetch(emission_texture_normal, emission_tex_ofs, 0).xy;
|
m2.set_axis(0, normal_2d);
|
||||||
rotm[1] = rotm[0].yx * vec2(1.0, -1.0);
|
m2.set_axis(1, normal_2d.tangent());
|
||||||
VELOCITY.xy = rotm * VELOCITY.xy;
|
Vector2 velocity_2d(p.velocity.x, p.velocity.y);
|
||||||
*/
|
velocity_2d = m2.basis_xform(velocity_2d);
|
||||||
|
p.velocity.x = velocity_2d.x;
|
||||||
|
p.velocity.y = velocity_2d.y;
|
||||||
} else {
|
} else {
|
||||||
Vector3 normal = emission_normals.get(random_idx);
|
Vector3 normal = emission_normals.get(random_idx);
|
||||||
Vector3 v0 = Math::abs(normal.z) < 0.999 ? Vector3(0.0, 0.0, 1.0) : Vector3(0, 1.0, 0.0);
|
Vector3 v0 = Math::abs(normal.z) < 0.999 ? Vector3(0.0, 0.0, 1.0) : Vector3(0, 1.0, 0.0);
|
||||||
|
|
Loading…
Reference in New Issue