Force Fields: Fix Texture with both Use Coordinates and 2D enabled.
authorAlexander Gavrilov <angavrilov@gmail.com>
Mon, 18 Apr 2016 15:45:34 +0000 (18:45 +0300)
committerAlexander Gavrilov <angavrilov@gmail.com>
Fri, 6 May 2016 08:40:18 +0000 (11:40 +0300)
From description, Use Coordinates evaluates the texture using
target coordinates in the local space of the force field object.
2D is supposed to ignore the Z coordinate. Thus one would assume
that if both are enabled, the force field effect would move with
the force field object, and Z would be 0.

However, instead first the 2D option projects points onto a plane
passing through the global zero and orthogonal to the local Z,
and only then the resulting point is transformed into local space.
Z is not locked at 0, so procedural textures like Spherical Blend
don't work as expected.

To fix this, apply local transform first, and then just clear Z if 2D.

source/blender/blenkernel/intern/effect.c

index 12bce70594bcea628e263d2f170054984a358db3..6284b3a46fbc9d7ff379c29f00e9e1b4702af9ea 100644 (file)
@@ -746,13 +746,15 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
 
        copy_v3_v3(tex_co, point->loc);
 
-       if (eff->pd->flag & PFIELD_TEX_2D) {
-               float fac=-dot_v3v3(tex_co, efd->nor);
-               madd_v3_v3fl(tex_co, efd->nor, fac);
-       }
-
        if (eff->pd->flag & PFIELD_TEX_OBJECT) {
                mul_m4_v3(eff->ob->imat, tex_co);
+
+               if (eff->pd->flag & PFIELD_TEX_2D)
+                       tex_co[2] = 0.0f;
+       }
+       else if (eff->pd->flag & PFIELD_TEX_2D) {
+               float fac=-dot_v3v3(tex_co, efd->nor);
+               madd_v3_v3fl(tex_co, efd->nor, fac);
        }
 
        scene_color_manage = BKE_scene_check_color_management_enabled(eff->scene);