Merge branch 'master' into blender2.8
[blender.git] / source / blender / makesrna / intern / rna_particle.c
index 29f33907d395b59d6af832acb536441fabf4c502..b40519386cc9e1745784ba89132aca446671ea52 100644 (file)
@@ -448,10 +448,12 @@ static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesys
        int totpart;
        int totchild = 0;
        int totface;
+       int totvert;
        int num = -1;
 
        DM_ensure_tessface(modifier->dm_final); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
        totface = modifier->dm_final->getNumTessFaces(modifier->dm_final);
+       totvert = modifier->dm_final->getNumVerts(modifier->dm_final);
 
        /* 1. check that everything is ok & updated */
        if (!particlesystem || !totface) {
@@ -486,13 +488,26 @@ static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesys
                                return num;
                        }
                }
+               else if (part->from == PART_FROM_VERT) {
+                       if (num != DMCACHE_NOTFOUND && num < totvert) {
+                               MFace *mface = modifier->dm_final->getTessFaceDataArray(modifier->dm_final, CD_MFACE);
+
+                               *r_fuv = &particle->fuv;
+
+                               for (int i = 0; i < totface; i++, mface++) {
+                                       if (ELEM(num, mface->v1, mface->v2, mface->v3, mface->v4)) {
+                                               return i;
+                                       }
+                               }
+                       }
+               }
        }
        else {
                ChildParticle *cpa = particlesystem->child + particle_no - totpart;
                num = cpa->num;
 
                if (part->childtype == PART_CHILD_FACES) {
-                       if (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME)) {
+                       if (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME, PART_FROM_VERT)) {
                                if (num != DMCACHE_NOTFOUND && num < totface) {
                                        *r_fuv = &cpa->fuv;
                                        return num;
@@ -512,6 +527,19 @@ static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesys
                                        return num;
                                }
                        }
+                       else if (part->from == PART_FROM_VERT) {
+                               if (num != DMCACHE_NOTFOUND && num < totvert) {
+                                       MFace *mface = modifier->dm_final->getTessFaceDataArray(modifier->dm_final, CD_MFACE);
+
+                                       *r_fuv = &parent->fuv;
+
+                                       for (int i = 0; i < totface; i++, mface++) {
+                                               if (ELEM(num, mface->v1, mface->v2, mface->v3, mface->v4)) {
+                                                       return i;
+                                               }
+                                       }
+                               }
+                       }
                }
        }