~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/editors/sculpt_paint/paint_vertex.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-05-12 20:02:22 UTC
  • mfrom: (14.2.16 sid)
  • Revision ID: package-import@ubuntu.com-20120512200222-lznjs2cxzaq96wua
Tags: 2.63a-1
* New upstream bugfix release
  + debian/patches/: re-worked since source code changed

Show diffs side-by-side

added added

removed removed

Lines of Context:
198
198
{
199
199
        /* if no mcol: do not do */
200
200
        /* if tface: only the involved faces, otherwise all */
 
201
        const int use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK);
201
202
        MFace *mface;
202
 
        MTFace *tface;
203
203
        int a;
204
204
        short *scolmain, *scol;
205
205
        char *mcol;
208
208
        
209
209
        scolmain = MEM_callocN(4 * sizeof(short) * me->totvert, "colmain");
210
210
        
211
 
        tface = me->mtface;
212
211
        mface = me->mface;
213
212
        mcol = (char *)me->mcol;
214
213
        for (a = me->totface; a > 0; a--, mface++, mcol += 16) {
215
 
                if ((tface && tface->mode & TF_SHAREDCOL) || (me->editflag & ME_EDIT_PAINT_MASK) == 0) {
 
214
                if ((use_face_sel == FALSE) || (mface->flag & ME_FACE_SEL)) {
216
215
                        scol = scolmain + 4 * mface->v1;
217
216
                        scol[0]++; scol[1] += mcol[1]; scol[2] += mcol[2]; scol[3] += mcol[3];
218
217
                        scol = scolmain + 4 * mface->v2;
224
223
                                scol[0]++; scol[1] += mcol[13]; scol[2] += mcol[14]; scol[3] += mcol[15];
225
224
                        }
226
225
                }
227
 
                if (tface) tface++;
228
226
        }
229
227
        
230
228
        a = me->totvert;
237
235
                }
238
236
                scol += 4;
239
237
        }
240
 
        
241
 
        tface = me->mtface;
 
238
 
242
239
        mface = me->mface;
243
240
        mcol = (char *)me->mcol;
244
241
        for (a = me->totface; a > 0; a--, mface++, mcol += 16) {
245
 
                if ((tface && tface->mode & TF_SHAREDCOL) || (me->editflag & ME_EDIT_PAINT_MASK) == 0) {
 
242
                if ((use_face_sel == FALSE)|| (mface->flag & ME_FACE_SEL)) {
246
243
                        scol = scolmain + 4 * mface->v1;
247
244
                        mcol[1] = scol[1]; mcol[2] = scol[2]; mcol[3] = scol[3];
248
245
                        scol = scolmain + 4 * mface->v2;
254
251
                                mcol[13] = scol[1]; mcol[14] = scol[2]; mcol[15] = scol[3];
255
252
                        }
256
253
                }
257
 
                if (tface) tface++;
258
254
        }
259
255
 
260
256
        MEM_freeN(scolmain);
262
258
 
263
259
void do_shared_vertexcol(Mesh *me, int do_tessface)
264
260
{
 
261
        const int use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK);
265
262
        MLoop *ml = me->mloop;
266
263
        MLoopCol *lcol = me->mloopcol;
267
 
        MTexPoly *mtp = me->mtpoly;
268
 
        MPoly *mp = me->mpoly;
269
 
        float (*scol)[5];
270
 
        int i, has_shared = 0;
 
264
        MPoly *mp;
 
265
        float (*scol)[4];
 
266
        int i, j, has_shared = 0;
271
267
 
272
268
        /* if no mloopcol: do not do */
273
269
        /* if mtexpoly: only the involved faces, otherwise all */
276
272
 
277
273
        scol = MEM_callocN(sizeof(float) * me->totvert * 5, "scol");
278
274
 
279
 
        for (i = 0; i < me->totloop; i++, ml++, lcol++) {
280
 
                if (i >= mp->loopstart + mp->totloop) {
281
 
                        mp++;
282
 
                        if (mtp) mtp++;
 
275
        for (i = 0, mp = me->mpoly; i < me->totpoly; i++, mp++) {
 
276
                if ((use_face_sel == FALSE) || (mp->flag & ME_FACE_SEL)) {
 
277
                        ml = me->mloop + mp->loopstart;
 
278
                        lcol = me->mloopcol + mp->loopstart;
 
279
                        for (j = 0; j < mp->totloop; j++, ml++, lcol++) {
 
280
                                scol[ml->v][0] += lcol->r;
 
281
                                scol[ml->v][1] += lcol->g;
 
282
                                scol[ml->v][2] += lcol->b;
 
283
                                scol[ml->v][3] += 1.0f;
 
284
                                has_shared = 1;
 
285
                        }
283
286
                }
284
 
 
285
 
                if (!(mtp && (mtp->mode & TF_SHAREDCOL)) && (me->editflag & ME_EDIT_PAINT_MASK) != 0)
286
 
                        continue;
287
 
 
288
 
                scol[ml->v][0] += lcol->r;
289
 
                scol[ml->v][1] += lcol->g;
290
 
                scol[ml->v][2] += lcol->b;
291
 
                scol[ml->v][3] += lcol->a;
292
 
                scol[ml->v][4] += 1.0;
293
 
                has_shared = 1;
294
287
        }
295
 
        
 
288
 
296
289
        if (has_shared) {
297
290
                for (i = 0; i < me->totvert; i++) {
298
 
                        if (!scol[i][4]) continue;
299
 
 
300
 
                        scol[i][0] /= scol[i][4];
301
 
                        scol[i][1] /= scol[i][4];
302
 
                        scol[i][2] /= scol[i][4];
303
 
                        scol[i][3] /= scol[i][4];
 
291
                        if (scol[i][3] != 0.0f) {
 
292
                                mul_v3_fl(scol[i], 1.0f / scol[i][3]);
 
293
                        }
304
294
                }
305
 
        
306
 
                ml = me->mloop;
307
 
                lcol = me->mloopcol;
308
 
                for (i = 0; i < me->totloop; i++, ml++, lcol++) {
309
 
                        if (!scol[ml->v][4]) continue;
310
295
 
311
 
                        lcol->r = scol[ml->v][0];
312
 
                        lcol->g = scol[ml->v][1];
313
 
                        lcol->b = scol[ml->v][2];
314
 
                        lcol->a = scol[ml->v][3];
 
296
                for (i = 0, mp = me->mpoly; i < me->totpoly; i++, mp++) {
 
297
                        if ((use_face_sel == FALSE) || (mp->flag & ME_FACE_SEL)) {
 
298
                                ml = me->mloop + mp->loopstart;
 
299
                                lcol = me->mloopcol + mp->loopstart;
 
300
                                for (j = 0; j < mp->totloop; j++, ml++, lcol++) {
 
301
                                        lcol->r = scol[ml->v][0];
 
302
                                        lcol->g = scol[ml->v][1];
 
303
                                        lcol->b = scol[ml->v][2];
 
304
                                }
 
305
                        }
315
306
                }
316
307
        }
317
308