Fix T50141: Nabla zero division on texture force field

This sets forces to zero, when Nabla is zero and a grayscale texture is
used or texture mode is Gradient or Curl.

Nabla equal to zero was causing a zero division, and forces ended up
being set to `nan`.

Reviewed By: mont29

Differential Revision: http://developer.blender.org/D2393
This commit is contained in:
Luca Rood 2016-12-03 14:05:56 -02:00
parent dfca1e1460
commit b18f83bcf4
Notes: blender-bot 2023-02-14 07:53:51 +01:00
Referenced by issue #50640, Movie Clip Editor not honoring right click select
Referenced by issue #50141, ForceField Texture not working for hair particles in 2.78a
1 changed files with 4 additions and 1 deletions

View File

@ -770,7 +770,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
force[1] = (0.5f - result->tg) * strength;
force[2] = (0.5f - result->tb) * strength;
}
else {
else if (nabla != 0) {
strength/=nabla;
tex_co[0] += nabla;
@ -810,6 +810,9 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
force[2] = (dgdx - drdy) * strength;
}
}
else {
zero_v3(force);
}
if (eff->pd->flag & PFIELD_TEX_2D) {
float fac = -dot_v3v3(force, efd->nor);