Blender  V2.93
paint_vertex_color_utils.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
23 #include "DNA_mesh_types.h"
24 #include "DNA_meshdata_types.h"
25 #include "DNA_object_types.h"
26 
27 #include "BLI_math_base.h"
28 #include "BLI_math_color.h"
29 
30 #include "IMB_colormanagement.h"
31 #include "IMB_imbuf.h"
32 
33 #include "BKE_context.h"
34 #include "BKE_mesh.h"
35 
36 #include "DEG_depsgraph.h"
37 
38 #include "ED_mesh.h"
39 
40 #include "paint_intern.h" /* own include */
41 
42 #define EPS_SATURATION 0.0005f
43 
48  VPaintTransform_Callback vpaint_tx_fn,
49  const void *user_data)
50 {
51  Mesh *me;
52  const MPoly *mp;
53  int i, j;
54 
55  if (((me = BKE_mesh_from_object(ob)) == NULL) || (ED_mesh_color_ensure(me, NULL) == false)) {
56  return false;
57  }
58 
59  const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
60  const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
61 
62  mp = me->mpoly;
63  for (i = 0; i < me->totpoly; i++, mp++) {
64  MLoopCol *lcol = me->mloopcol + mp->loopstart;
65 
66  if (use_face_sel && !(mp->flag & ME_FACE_SEL)) {
67  continue;
68  }
69 
70  j = 0;
71  do {
72  uint vidx = me->mloop[mp->loopstart + j].v;
73  if (!(use_vert_sel && !(me->mvert[vidx].flag & SELECT))) {
74  float col_mix[3];
75  rgb_uchar_to_float(col_mix, &lcol->r);
76 
77  vpaint_tx_fn(col_mix, user_data, col_mix);
78 
79  rgb_float_to_uchar(&lcol->r, col_mix);
80  }
81  lcol++;
82  j++;
83  } while (j < mp->totloop);
84  }
85 
86  /* remove stale me->mcol, will be added later */
88 
89  DEG_id_tag_update(&me->id, 0);
90 
91  return true;
92 }
93 
94 /* -------------------------------------------------------------------- */
98 BLI_INLINE uint mcol_blend(uint col_src, uint col_dst, int fac)
99 {
100  uchar *cp_src, *cp_dst, *cp_mix;
101  int mfac;
102  uint col_mix = 0;
103 
104  if (fac == 0) {
105  return col_src;
106  }
107 
108  if (fac >= 255) {
109  return col_dst;
110  }
111 
112  mfac = 255 - fac;
113 
114  cp_src = (uchar *)&col_src;
115  cp_dst = (uchar *)&col_dst;
116  cp_mix = (uchar *)&col_mix;
117 
118  /* Updated to use the rgb squared color model which blends nicer. */
119  int r1 = cp_src[0] * cp_src[0];
120  int g1 = cp_src[1] * cp_src[1];
121  int b1 = cp_src[2] * cp_src[2];
122  int a1 = cp_src[3] * cp_src[3];
123 
124  int r2 = cp_dst[0] * cp_dst[0];
125  int g2 = cp_dst[1] * cp_dst[1];
126  int b2 = cp_dst[2] * cp_dst[2];
127  int a2 = cp_dst[3] * cp_dst[3];
128 
129  cp_mix[0] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * r1 + fac * r2), 255)));
130  cp_mix[1] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * g1 + fac * g2), 255)));
131  cp_mix[2] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * b1 + fac * b2), 255)));
132  cp_mix[3] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * a1 + fac * a2), 255)));
133 
134  return col_mix;
135 }
136 
137 BLI_INLINE uint mcol_add(uint col_src, uint col_dst, int fac)
138 {
139  uchar *cp_src, *cp_dst, *cp_mix;
140  int temp;
141  uint col_mix = 0;
142 
143  if (fac == 0) {
144  return col_src;
145  }
146 
147  cp_src = (uchar *)&col_src;
148  cp_dst = (uchar *)&col_dst;
149  cp_mix = (uchar *)&col_mix;
150 
151  temp = cp_src[0] + divide_round_i((fac * cp_dst[0]), 255);
152  cp_mix[0] = (temp > 254) ? 255 : temp;
153  temp = cp_src[1] + divide_round_i((fac * cp_dst[1]), 255);
154  cp_mix[1] = (temp > 254) ? 255 : temp;
155  temp = cp_src[2] + divide_round_i((fac * cp_dst[2]), 255);
156  cp_mix[2] = (temp > 254) ? 255 : temp;
157  temp = cp_src[3] + divide_round_i((fac * cp_dst[3]), 255);
158  cp_mix[3] = (temp > 254) ? 255 : temp;
159 
160  return col_mix;
161 }
162 
163 BLI_INLINE uint mcol_sub(uint col_src, uint col_dst, int fac)
164 {
165  uchar *cp_src, *cp_dst, *cp_mix;
166  int temp;
167  uint col_mix = 0;
168 
169  if (fac == 0) {
170  return col_src;
171  }
172 
173  cp_src = (uchar *)&col_src;
174  cp_dst = (uchar *)&col_dst;
175  cp_mix = (uchar *)&col_mix;
176 
177  temp = cp_src[0] - divide_round_i((fac * cp_dst[0]), 255);
178  cp_mix[0] = (temp < 0) ? 0 : temp;
179  temp = cp_src[1] - divide_round_i((fac * cp_dst[1]), 255);
180  cp_mix[1] = (temp < 0) ? 0 : temp;
181  temp = cp_src[2] - divide_round_i((fac * cp_dst[2]), 255);
182  cp_mix[2] = (temp < 0) ? 0 : temp;
183  temp = cp_src[3] - divide_round_i((fac * cp_dst[3]), 255);
184  cp_mix[3] = (temp < 0) ? 0 : temp;
185 
186  return col_mix;
187 }
188 
189 BLI_INLINE uint mcol_mul(uint col_src, uint col_dst, int fac)
190 {
191  uchar *cp_src, *cp_dst, *cp_mix;
192  int mfac;
193  uint col_mix = 0;
194 
195  if (fac == 0) {
196  return col_src;
197  }
198 
199  mfac = 255 - fac;
200 
201  cp_src = (uchar *)&col_src;
202  cp_dst = (uchar *)&col_dst;
203  cp_mix = (uchar *)&col_mix;
204 
205  /* first mul, then blend the fac */
206  cp_mix[0] = divide_round_i(mfac * cp_src[0] * 255 + fac * cp_dst[0] * cp_src[0], 255 * 255);
207  cp_mix[1] = divide_round_i(mfac * cp_src[1] * 255 + fac * cp_dst[1] * cp_src[1], 255 * 255);
208  cp_mix[2] = divide_round_i(mfac * cp_src[2] * 255 + fac * cp_dst[2] * cp_src[2], 255 * 255);
209  cp_mix[3] = divide_round_i(mfac * cp_src[3] * 255 + fac * cp_dst[3] * cp_src[3], 255 * 255);
210 
211  return col_mix;
212 }
213 
214 BLI_INLINE uint mcol_lighten(uint col_src, uint col_dst, int fac)
215 {
216  uchar *cp_src, *cp_dst, *cp_mix;
217  int mfac;
218  uint col_mix = 0;
219 
220  if (fac == 0) {
221  return col_src;
222  }
223  if (fac >= 255) {
224  return col_dst;
225  }
226 
227  mfac = 255 - fac;
228 
229  cp_src = (uchar *)&col_src;
230  cp_dst = (uchar *)&col_dst;
231  cp_mix = (uchar *)&col_mix;
232 
233  /* See if we're lighter, if so mix, else don't do anything.
234  * if the paint color is darker then the original, then ignore */
237  return col_src;
238  }
239 
240  cp_mix[0] = divide_round_i(mfac * cp_src[0] + fac * cp_dst[0], 255);
241  cp_mix[1] = divide_round_i(mfac * cp_src[1] + fac * cp_dst[1], 255);
242  cp_mix[2] = divide_round_i(mfac * cp_src[2] + fac * cp_dst[2], 255);
243  cp_mix[3] = divide_round_i(mfac * cp_src[3] + fac * cp_dst[3], 255);
244 
245  return col_mix;
246 }
247 
248 BLI_INLINE uint mcol_darken(uint col_src, uint col_dst, int fac)
249 {
250  uchar *cp_src, *cp_dst, *cp_mix;
251  int mfac;
252  uint col_mix = 0;
253 
254  if (fac == 0) {
255  return col_src;
256  }
257  if (fac >= 255) {
258  return col_dst;
259  }
260 
261  mfac = 255 - fac;
262 
263  cp_src = (uchar *)&col_src;
264  cp_dst = (uchar *)&col_dst;
265  cp_mix = (uchar *)&col_mix;
266 
267  /* See if we're darker, if so mix, else don't do anything.
268  * if the paint color is brighter then the original, then ignore */
271  return col_src;
272  }
273 
274  cp_mix[0] = divide_round_i((mfac * cp_src[0] + fac * cp_dst[0]), 255);
275  cp_mix[1] = divide_round_i((mfac * cp_src[1] + fac * cp_dst[1]), 255);
276  cp_mix[2] = divide_round_i((mfac * cp_src[2] + fac * cp_dst[2]), 255);
277  cp_mix[3] = divide_round_i((mfac * cp_src[3] + fac * cp_dst[3]), 255);
278  return col_mix;
279 }
280 
281 BLI_INLINE uint mcol_colordodge(uint col_src, uint col_dst, int fac)
282 {
283  uchar *cp_src, *cp_dst, *cp_mix;
284  int mfac, temp;
285  uint col_mix = 0;
286 
287  if (fac == 0) {
288  return col_src;
289  }
290 
291  mfac = 255 - fac;
292 
293  cp_src = (uchar *)&col_src;
294  cp_dst = (uchar *)&col_dst;
295  cp_mix = (uchar *)&col_mix;
296 
297  temp = (cp_dst[0] == 255) ? 255 : min_ii((cp_src[0] * 225) / (255 - cp_dst[0]), 255);
298  cp_mix[0] = (mfac * cp_src[0] + temp * fac) / 255;
299  temp = (cp_dst[1] == 255) ? 255 : min_ii((cp_src[1] * 225) / (255 - cp_dst[1]), 255);
300  cp_mix[1] = (mfac * cp_src[1] + temp * fac) / 255;
301  temp = (cp_dst[2] == 255) ? 255 : min_ii((cp_src[2] * 225) / (255 - cp_dst[2]), 255);
302  cp_mix[2] = (mfac * cp_src[2] + temp * fac) / 255;
303  temp = (cp_dst[3] == 255) ? 255 : min_ii((cp_src[3] * 225) / (255 - cp_dst[3]), 255);
304  cp_mix[3] = (mfac * cp_src[3] + temp * fac) / 255;
305  return col_mix;
306 }
307 
308 BLI_INLINE uint mcol_difference(uint col_src, uint col_dst, int fac)
309 {
310  uchar *cp_src, *cp_dst, *cp_mix;
311  int mfac, temp;
312  uint col_mix = 0;
313 
314  if (fac == 0) {
315  return col_src;
316  }
317 
318  mfac = 255 - fac;
319 
320  cp_src = (uchar *)&col_src;
321  cp_dst = (uchar *)&col_dst;
322  cp_mix = (uchar *)&col_mix;
323 
324  temp = abs(cp_src[0] - cp_dst[0]);
325  cp_mix[0] = (mfac * cp_src[0] + temp * fac) / 255;
326  temp = abs(cp_src[1] - cp_dst[1]);
327  cp_mix[1] = (mfac * cp_src[1] + temp * fac) / 255;
328  temp = abs(cp_src[2] - cp_dst[2]);
329  cp_mix[2] = (mfac * cp_src[2] + temp * fac) / 255;
330  temp = abs(cp_src[3] - cp_dst[3]);
331  cp_mix[3] = (mfac * cp_src[3] + temp * fac) / 255;
332  return col_mix;
333 }
334 
335 BLI_INLINE uint mcol_screen(uint col_src, uint col_dst, int fac)
336 {
337  uchar *cp_src, *cp_dst, *cp_mix;
338  int mfac, temp;
339  uint col_mix = 0;
340 
341  if (fac == 0) {
342  return col_src;
343  }
344 
345  mfac = 255 - fac;
346 
347  cp_src = (uchar *)&col_src;
348  cp_dst = (uchar *)&col_dst;
349  cp_mix = (uchar *)&col_mix;
350 
351  temp = max_ii(255 - (((255 - cp_src[0]) * (255 - cp_dst[0])) / 255), 0);
352  cp_mix[0] = (mfac * cp_src[0] + temp * fac) / 255;
353  temp = max_ii(255 - (((255 - cp_src[1]) * (255 - cp_dst[1])) / 255), 0);
354  cp_mix[1] = (mfac * cp_src[1] + temp * fac) / 255;
355  temp = max_ii(255 - (((255 - cp_src[2]) * (255 - cp_dst[2])) / 255), 0);
356  cp_mix[2] = (mfac * cp_src[2] + temp * fac) / 255;
357  temp = max_ii(255 - (((255 - cp_src[3]) * (255 - cp_dst[3])) / 255), 0);
358  cp_mix[3] = (mfac * cp_src[3] + temp * fac) / 255;
359  return col_mix;
360 }
361 
362 BLI_INLINE uint mcol_hardlight(uint col_src, uint col_dst, int fac)
363 {
364  uchar *cp_src, *cp_dst, *cp_mix;
365  int mfac, temp;
366  uint col_mix = 0;
367 
368  if (fac == 0) {
369  return col_src;
370  }
371 
372  mfac = 255 - fac;
373 
374  cp_src = (uchar *)&col_src;
375  cp_dst = (uchar *)&col_dst;
376  cp_mix = (uchar *)&col_mix;
377 
378  int i = 0;
379 
380  for (i = 0; i < 4; i++) {
381  if (cp_dst[i] > 127) {
382  temp = 255 - ((255 - 2 * (cp_dst[i] - 127)) * (255 - cp_src[i]) / 255);
383  }
384  else {
385  temp = (2 * cp_dst[i] * cp_src[i]) >> 8;
386  }
387  cp_mix[i] = min_ii((mfac * cp_src[i] + temp * fac) / 255, 255);
388  }
389  return col_mix;
390 }
391 
392 BLI_INLINE uint mcol_overlay(uint col_src, uint col_dst, int fac)
393 {
394  uchar *cp_src, *cp_dst, *cp_mix;
395  int mfac, temp;
396  uint col_mix = 0;
397 
398  if (fac == 0) {
399  return col_src;
400  }
401 
402  mfac = 255 - fac;
403 
404  cp_src = (uchar *)&col_src;
405  cp_dst = (uchar *)&col_dst;
406  cp_mix = (uchar *)&col_mix;
407 
408  int i = 0;
409 
410  for (i = 0; i < 4; i++) {
411  if (cp_src[i] > 127) {
412  temp = 255 - ((255 - 2 * (cp_src[i] - 127)) * (255 - cp_dst[i]) / 255);
413  }
414  else {
415  temp = (2 * cp_dst[i] * cp_src[i]) >> 8;
416  }
417  cp_mix[i] = min_ii((mfac * cp_src[i] + temp * fac) / 255, 255);
418  }
419  return col_mix;
420 }
421 
422 BLI_INLINE uint mcol_softlight(uint col_src, uint col_dst, int fac)
423 {
424  uchar *cp_src, *cp_dst, *cp_mix;
425  int mfac, temp;
426  uint col_mix = 0;
427 
428  if (fac == 0) {
429  return col_src;
430  }
431 
432  mfac = 255 - fac;
433 
434  cp_src = (uchar *)&col_src;
435  cp_dst = (uchar *)&col_dst;
436  cp_mix = (uchar *)&col_mix;
437 
438  for (int i = 0; i < 4; i++) {
439  if (cp_src[i] < 127) {
440  temp = ((2 * ((cp_dst[i] / 2) + 64)) * cp_src[i]) / 255;
441  }
442  else {
443  temp = 255 - (2 * (255 - ((cp_dst[i] / 2) + 64)) * (255 - cp_src[i]) / 255);
444  }
445  cp_mix[i] = (temp * fac + cp_src[i] * mfac) / 255;
446  }
447  return col_mix;
448 }
449 
450 BLI_INLINE uint mcol_exclusion(uint col_src, uint col_dst, int fac)
451 {
452  uchar *cp_src, *cp_dst, *cp_mix;
453  int mfac, temp;
454  uint col_mix = 0;
455 
456  if (fac == 0) {
457  return col_src;
458  }
459 
460  mfac = 255 - fac;
461 
462  cp_src = (uchar *)&col_src;
463  cp_dst = (uchar *)&col_dst;
464  cp_mix = (uchar *)&col_mix;
465 
466  int i = 0;
467 
468  for (i = 0; i < 4; i++) {
469  temp = 127 - ((2 * (cp_src[i] - 127) * (cp_dst[i] - 127)) / 255);
470  cp_mix[i] = (temp * fac + cp_src[i] * mfac) / 255;
471  }
472  return col_mix;
473 }
474 
475 BLI_INLINE uint mcol_luminosity(uint col_src, uint col_dst, int fac)
476 {
477  uchar *cp_src, *cp_dst, *cp_mix;
478  int mfac;
479  uint col_mix = 0;
480 
481  if (fac == 0) {
482  return col_src;
483  }
484 
485  mfac = 255 - fac;
486 
487  cp_src = (uchar *)&col_src;
488  cp_dst = (uchar *)&col_dst;
489  cp_mix = (uchar *)&col_mix;
490 
491  float h1, s1, v1;
492  float h2, s2, v2;
493  float r, g, b;
494  rgb_to_hsv(cp_src[0] / 255.0f, cp_src[1] / 255.0f, cp_src[2] / 255.0f, &h1, &s1, &v1);
495  rgb_to_hsv(cp_dst[0] / 255.0f, cp_dst[1] / 255.0f, cp_dst[2] / 255.0f, &h2, &s2, &v2);
496 
497  v1 = v2;
498 
499  hsv_to_rgb(h1, s1, v1, &r, &g, &b);
500 
501  cp_mix[0] = ((int)(r * 255.0f) * fac + mfac * cp_src[0]) / 255;
502  cp_mix[1] = ((int)(g * 255.0f) * fac + mfac * cp_src[1]) / 255;
503  cp_mix[2] = ((int)(b * 255.0f) * fac + mfac * cp_src[2]) / 255;
504  cp_mix[3] = ((int)(cp_dst[3]) * fac + mfac * cp_src[3]) / 255;
505  return col_mix;
506 }
507 
508 BLI_INLINE uint mcol_saturation(uint col_src, uint col_dst, int fac)
509 {
510  uchar *cp_src, *cp_dst, *cp_mix;
511  int mfac;
512  uint col_mix = 0;
513 
514  if (fac == 0) {
515  return col_src;
516  }
517 
518  mfac = 255 - fac;
519 
520  cp_src = (uchar *)&col_src;
521  cp_dst = (uchar *)&col_dst;
522  cp_mix = (uchar *)&col_mix;
523 
524  float h1, s1, v1;
525  float h2, s2, v2;
526  float r, g, b;
527  rgb_to_hsv(cp_src[0] / 255.0f, cp_src[1] / 255.0f, cp_src[2] / 255.0f, &h1, &s1, &v1);
528  rgb_to_hsv(cp_dst[0] / 255.0f, cp_dst[1] / 255.0f, cp_dst[2] / 255.0f, &h2, &s2, &v2);
529 
530  if (s1 > EPS_SATURATION) {
531  s1 = s2;
532  }
533 
534  hsv_to_rgb(h1, s1, v1, &r, &g, &b);
535 
536  cp_mix[0] = ((int)(r * 255.0f) * fac + mfac * cp_src[0]) / 255;
537  cp_mix[1] = ((int)(g * 255.0f) * fac + mfac * cp_src[1]) / 255;
538  cp_mix[2] = ((int)(b * 255.0f) * fac + mfac * cp_src[2]) / 255;
539  return col_mix;
540 }
541 
542 BLI_INLINE uint mcol_hue(uint col_src, uint col_dst, int fac)
543 {
544  uchar *cp_src, *cp_dst, *cp_mix;
545  int mfac;
546  uint col_mix = 0;
547 
548  if (fac == 0) {
549  return col_src;
550  }
551 
552  mfac = 255 - fac;
553 
554  cp_src = (uchar *)&col_src;
555  cp_dst = (uchar *)&col_dst;
556  cp_mix = (uchar *)&col_mix;
557 
558  float h1, s1, v1;
559  float h2, s2, v2;
560  float r, g, b;
561  rgb_to_hsv(cp_src[0] / 255.0f, cp_src[1] / 255.0f, cp_src[2] / 255.0f, &h1, &s1, &v1);
562  rgb_to_hsv(cp_dst[0] / 255.0f, cp_dst[1] / 255.0f, cp_dst[2] / 255.0f, &h2, &s2, &v2);
563 
564  h1 = h2;
565 
566  hsv_to_rgb(h1, s1, v1, &r, &g, &b);
567 
568  cp_mix[0] = ((int)(r * 255.0f) * fac + mfac * cp_src[0]) / 255;
569  cp_mix[1] = ((int)(g * 255.0f) * fac + mfac * cp_src[1]) / 255;
570  cp_mix[2] = ((int)(b * 255.0f) * fac + mfac * cp_src[2]) / 255;
571  cp_mix[3] = ((int)(cp_dst[3]) * fac + mfac * cp_src[3]) / 255;
572  return col_mix;
573 }
574 
576 {
577  uchar *cp_src, *cp_mix;
578  int temp;
579  uint col_mix = col_src;
580 
581  if (fac == 0) {
582  return col_src;
583  }
584 
585  cp_src = (uchar *)&col_src;
586  cp_mix = (uchar *)&col_mix;
587 
588  temp = cp_src[3] + fac;
589  cp_mix[3] = (temp > 254) ? 255 : temp;
590 
591  return col_mix;
592 }
593 
595 {
596  uchar *cp_src, *cp_mix;
597  int temp;
598  uint col_mix = col_src;
599 
600  if (fac == 0) {
601  return col_src;
602  }
603 
604  cp_src = (uchar *)&col_src;
605  cp_mix = (uchar *)&col_mix;
606 
607  temp = cp_src[3] - fac;
608  cp_mix[3] = temp < 0 ? 0 : temp;
609 
610  return col_mix;
611 }
612 
616 uint ED_vpaint_blend_tool(const int tool, const uint col, const uint paintcol, const int alpha_i)
617 {
618  switch ((IMB_BlendMode)tool) {
619  case IMB_BLEND_MIX:
620  return mcol_blend(col, paintcol, alpha_i);
621  case IMB_BLEND_ADD:
622  return mcol_add(col, paintcol, alpha_i);
623  case IMB_BLEND_SUB:
624  return mcol_sub(col, paintcol, alpha_i);
625  case IMB_BLEND_MUL:
626  return mcol_mul(col, paintcol, alpha_i);
627  case IMB_BLEND_LIGHTEN:
628  return mcol_lighten(col, paintcol, alpha_i);
629  case IMB_BLEND_DARKEN:
630  return mcol_darken(col, paintcol, alpha_i);
632  return mcol_colordodge(col, paintcol, alpha_i);
634  return mcol_difference(col, paintcol, alpha_i);
635  case IMB_BLEND_SCREEN:
636  return mcol_screen(col, paintcol, alpha_i);
637  case IMB_BLEND_HARDLIGHT:
638  return mcol_hardlight(col, paintcol, alpha_i);
639  case IMB_BLEND_OVERLAY:
640  return mcol_overlay(col, paintcol, alpha_i);
641  case IMB_BLEND_SOFTLIGHT:
642  return mcol_softlight(col, paintcol, alpha_i);
643  case IMB_BLEND_EXCLUSION:
644  return mcol_exclusion(col, paintcol, alpha_i);
646  return mcol_luminosity(col, paintcol, alpha_i);
648  return mcol_saturation(col, paintcol, alpha_i);
649  case IMB_BLEND_HUE:
650  return mcol_hue(col, paintcol, alpha_i);
651  /* non-color */
653  return mcol_alpha_sub(col, alpha_i);
654  case IMB_BLEND_ADD_ALPHA:
655  return mcol_alpha_add(col, alpha_i);
656  default:
657  BLI_assert(0);
658  return 0;
659  }
660 }
661 
void BKE_mesh_tessface_clear(struct Mesh *mesh)
Definition: mesh.c:1567
struct Mesh * BKE_mesh_from_object(struct Object *ob)
Definition: mesh.c:1271
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define BLI_INLINE
MINLINE unsigned char round_fl_to_uchar(float a)
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
MINLINE int divide_round_i(int a, int b)
void rgb_to_hsv(float r, float g, float b, float *r_h, float *r_s, float *r_v)
Definition: math_color.c:229
void hsv_to_rgb(float h, float s, float v, float *r_r, float *r_g, float *r_b)
Definition: math_color.c:31
void rgb_uchar_to_float(float r_col[3], const unsigned char col_ub[3])
Definition: math_color.c:407
void rgb_float_to_uchar(unsigned char r_col[3], const float col_f[3])
Definition: math_color.c:422
unsigned char uchar
Definition: BLI_sys_types.h:86
unsigned int uint
Definition: BLI_sys_types.h:83
void DEG_id_tag_update(struct ID *id, int flag)
@ ME_EDIT_PAINT_VERT_SEL
@ ME_EDIT_PAINT_FACE_SEL
@ ME_FACE_SEL
Object is a sort of wrapper for general info.
bool ED_mesh_color_ensure(struct Mesh *me, const char *name)
Definition: mesh_data.c:433
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
BLI_INLINE unsigned char IMB_colormanagement_get_luminance_byte(const unsigned char[3])
IMB_BlendMode
Definition: IMB_imbuf.h:197
@ IMB_BLEND_EXCLUSION
Definition: IMB_imbuf.h:217
@ IMB_BLEND_DIFFERENCE
Definition: IMB_imbuf.h:216
@ IMB_BLEND_HARDLIGHT
Definition: IMB_imbuf.h:207
@ IMB_BLEND_COLORDODGE
Definition: IMB_imbuf.h:210
@ IMB_BLEND_ERASE_ALPHA
Definition: IMB_imbuf.h:204
@ IMB_BLEND_SCREEN
Definition: IMB_imbuf.h:211
@ IMB_BLEND_HUE
Definition: IMB_imbuf.h:218
@ IMB_BLEND_MUL
Definition: IMB_imbuf.h:201
@ IMB_BLEND_ADD_ALPHA
Definition: IMB_imbuf.h:205
@ IMB_BLEND_DARKEN
Definition: IMB_imbuf.h:203
@ IMB_BLEND_OVERLAY
Definition: IMB_imbuf.h:206
@ IMB_BLEND_SATURATION
Definition: IMB_imbuf.h:219
@ IMB_BLEND_LUMINOSITY
Definition: IMB_imbuf.h:220
@ IMB_BLEND_LIGHTEN
Definition: IMB_imbuf.h:202
@ IMB_BLEND_SOFTLIGHT
Definition: IMB_imbuf.h:212
@ IMB_BLEND_MIX
Definition: IMB_imbuf.h:198
@ IMB_BLEND_ADD
Definition: IMB_imbuf.h:199
@ IMB_BLEND_SUB
Definition: IMB_imbuf.h:200
ATTR_WARN_UNUSED_RESULT const BMVert * v2
#define SELECT
void * user_data
uint col
#define sqrtf(x)
void(* VPaintTransform_Callback)(const float col[3], const void *user_data, float r_col[3])
Definition: paint_intern.h:102
BLI_INLINE uint mcol_alpha_add(uint col_src, int fac)
BLI_INLINE uint mcol_colordodge(uint col_src, uint col_dst, int fac)
#define EPS_SATURATION
BLI_INLINE uint mcol_difference(uint col_src, uint col_dst, int fac)
BLI_INLINE uint mcol_darken(uint col_src, uint col_dst, int fac)
BLI_INLINE uint mcol_softlight(uint col_src, uint col_dst, int fac)
BLI_INLINE uint mcol_hue(uint col_src, uint col_dst, int fac)
BLI_INLINE uint mcol_blend(uint col_src, uint col_dst, int fac)
BLI_INLINE uint mcol_alpha_sub(uint col_src, int fac)
BLI_INLINE uint mcol_screen(uint col_src, uint col_dst, int fac)
BLI_INLINE uint mcol_lighten(uint col_src, uint col_dst, int fac)
BLI_INLINE uint mcol_luminosity(uint col_src, uint col_dst, int fac)
uint ED_vpaint_blend_tool(const int tool, const uint col, const uint paintcol, const int alpha_i)
BLI_INLINE uint mcol_add(uint col_src, uint col_dst, int fac)
BLI_INLINE uint mcol_overlay(uint col_src, uint col_dst, int fac)
BLI_INLINE uint mcol_saturation(uint col_src, uint col_dst, int fac)
BLI_INLINE uint mcol_exclusion(uint col_src, uint col_dst, int fac)
bool ED_vpaint_color_transform(struct Object *ob, VPaintTransform_Callback vpaint_tx_fn, const void *user_data)
BLI_INLINE uint mcol_sub(uint col_src, uint col_dst, int fac)
BLI_INLINE uint mcol_mul(uint col_src, uint col_dst, int fac)
BLI_INLINE uint mcol_hardlight(uint col_src, uint col_dst, int fac)
unsigned char r
unsigned int v
struct MVert * mvert
struct MLoopCol * mloopcol
char editflag
struct MLoop * mloop
int totpoly
struct MPoly * mpoly
__forceinline const avxi abs(const avxi &a)
Definition: util_avxi.h:186