Particles: don't output nonsense UV data for Grid distribution particles.
authorAlexander Gavrilov <angavrilov@gmail.com>
Sun, 7 Aug 2016 10:48:25 +0000 (13:48 +0300)
committerAlexander Gavrilov <angavrilov@gmail.com>
Sun, 7 Aug 2016 10:48:25 +0000 (13:48 +0300)
As reported in T48928, From Dupli UV is not supported for grid
distribution, and running the normal code as usual simply produces
nonsense data, because fuv is used to hold orco instead of
interpolation factors for uv, and num is zero.

Since support won't be added in 2.78, just stop outputting nonsense.

source/blender/blenkernel/intern/particle.c

index 42b818b35a5960a307b958a03eca4925380c7270..4fb302c71ea574ab49ac196680f7b60fb23a1ec6 100644 (file)
@@ -4050,13 +4050,16 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part,
 
        uv[0] = uv[1] = 0.f;
 
+       /* Grid distribution doesn't support UV or emit from vertex mode */
+       bool is_grid = (part->distr == PART_DISTR_GRID && part->from != PART_FROM_VERT);
+
        if (cpa) {
                if ((part->childtype == PART_CHILD_FACES) && (psmd->dm_final != NULL)) {
                        CustomData *mtf_data = psmd->dm_final->getTessFaceDataLayout(psmd->dm_final);
                        const int uv_idx = CustomData_get_render_layer(mtf_data, CD_MTFACE);
                        mtface = CustomData_get_layer_n(mtf_data, CD_MTFACE, uv_idx);
 
-                       if (mtface) {
+                       if (mtface && !is_grid) {
                                mface = psmd->dm_final->getTessFaceData(psmd->dm_final, cpa->num, CD_MFACE);
                                mtface += cpa->num;
                                psys_interpolate_uvs(mtface, mface->v4, cpa->fuv, uv);
@@ -4070,7 +4073,7 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part,
                }
        }
 
-       if ((part->from == PART_FROM_FACE) && (psmd->dm_final != NULL)) {
+       if ((part->from == PART_FROM_FACE) && (psmd->dm_final != NULL) && !is_grid) {
                CustomData *mtf_data = psmd->dm_final->getTessFaceDataLayout(psmd->dm_final);
                const int uv_idx = CustomData_get_render_layer(mtf_data, CD_MTFACE);
                mtface = CustomData_get_layer_n(mtf_data, CD_MTFACE, uv_idx);