Merge branch 'master' into blender2.8
authorBastien Montagne <montagne29@wanadoo.fr>
Thu, 11 Jan 2018 19:19:18 +0000 (20:19 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Thu, 11 Jan 2018 19:19:18 +0000 (20:19 +0100)
Conflicts:
source/blender/blenkernel/intern/multires.c

1  2 
source/blender/blenkernel/intern/multires.c

index 7ef4b588dcd74f9b4c1a20ae2a4800f2b8a3f4de,3fc052414eb75869e89b53a76aaa495b821771ad..b6e3d048f0b456d29abfa5236cad51178f4c8be7
@@@ -2174,7 -2221,57 +2221,57 @@@ static void multires_sync_levels(Scene 
        }
  }
  
 -static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
+ static void multires_apply_smat_cb(
+         void *__restrict userdata,
+         const int pidx,
+         const ParallelRangeTLS *__restrict UNUSED(tls))
+ {
+       MultiresThreadedData *tdata = userdata;
+       CCGElem **gridData = tdata->gridData;
+       CCGElem **subGridData = tdata->subGridData;
+       CCGKey *dm_key = tdata->key;
+       CCGKey *subdm_key = tdata->sub_key;
+       MPoly *mpoly = tdata->mpoly;
+       MDisps *mdisps = tdata->mdisps;
+       int *gridOffset = tdata->gridOffset;
+       int gridSize = tdata->gridSize;
+       int dGridSize = tdata->dGridSize;
+       int dSkip = tdata->dSkip;
+       float (*smat)[3] = tdata->smat;
+       const int numVerts = mpoly[pidx].totloop;
+       MDisps *mdisp = &mdisps[mpoly[pidx].loopstart];
+       int S, x, y, gIndex = gridOffset[pidx];
+       for (S = 0; S < numVerts; ++S, ++gIndex, mdisp++) {
+               CCGElem *grid = gridData[gIndex];
+               CCGElem *subgrid = subGridData[gIndex];
+               float (*dispgrid)[3] = mdisp->disps;
+               for (y = 0; y < gridSize; y++) {
+                       for (x = 0; x < gridSize; x++) {
+                               float *co = CCG_grid_elem_co(dm_key, grid, x, y);
+                               float *sco = CCG_grid_elem_co(subdm_key, subgrid, x, y);
+                               float *data = dispgrid[dGridSize * y * dSkip + x * dSkip];
+                               float mat[3][3], disp[3];
+                               /* construct tangent space matrix */
+                               grid_tangent_matrix(mat, dm_key, x, y, grid);
+                               /* scale subgrid coord and calculate displacement */
+                               mul_m3_v3(smat, sco);
+                               sub_v3_v3v3(disp, sco, co);
+                               /* convert difference to tangent space */
+                               invert_m3(mat);
+                               mul_v3_m3v3(data, mat, disp);
+                       }
+               }
+       }
+ }
 +static void multires_apply_smat(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float smat[3][3])
  {
        DerivedMesh *dm = NULL, *cddm = NULL, *subdm = NULL;
        CCGElem **gridData, **subGridData;