144#define PROJ_BUCKET_BRUSH_DIV 4
146#define PROJ_BUCKET_RECT_MIN 4
147#define PROJ_BUCKET_RECT_MAX 256
149#define PROJ_BOUNDBOX_DIV 8
150#define PROJ_BOUNDBOX_SQUARED (PROJ_BOUNDBOX_DIV * PROJ_BOUNDBOX_DIV)
155#define PROJ_DEBUG_WINCLIP 1
157#ifndef PROJ_DEBUG_NOSEAMBLEED
163# define PROJ_FACE_SEAM0 (1 << 0)
164# define PROJ_FACE_SEAM1 (1 << 1)
165# define PROJ_FACE_SEAM2 (1 << 2)
167# define PROJ_FACE_NOSEAM0 (1 << 4)
168# define PROJ_FACE_NOSEAM1 (1 << 5)
169# define PROJ_FACE_NOSEAM2 (1 << 6)
172# define PROJ_FACE_SEAM_INIT0 (1 << 8)
173# define PROJ_FACE_SEAM_INIT1 (1 << 9)
174# define PROJ_FACE_SEAM_INIT2 (1 << 10)
176# define PROJ_FACE_DEGENERATE (1 << 12)
179# define PROJ_FACE_WINDING_INIT 1
180# define PROJ_FACE_WINDING_CW 2
185# define PROJ_FACE_SCALE_SEAM 0.99f
188#define PROJ_SRC_VIEW 1
189#define PROJ_SRC_IMAGE_CAM 2
190#define PROJ_SRC_IMAGE_VIEW 3
191#define PROJ_SRC_VIEW_FILL 4
193#define PROJ_VIEW_DATA_ID "view_data"
195#define PROJ_VIEW_DATA_SIZE (4 * 4 + 4 * 4 + 3)
197#define PROJ_BUCKET_NULL 0
198#define PROJ_BUCKET_INIT (1 << 0)
202#define PROJ_GEOM_TOLERANCE 0.00075f
203#define PROJ_PIXEL_TOLERANCE 0.01f
206#define PROJ_VERT_CULL 1
209#define TILE_PENDING POINTER_FROM_INT(-1)
211struct ProjPaintState;
389#ifndef PROJ_DEBUG_NOSEAMBLEED
429#define PROJ_PAINT_STATE_SHARED_MEMCPY(ps_dst, ps_src) \
430 MEMCPY_STRUCT_AFTER(ps_dst, ps_src, is_shared_user)
432#define PROJ_PAINT_STATE_SHARED_CLEAR(ps) MEMSET_STRUCT_AFTER(ps, 0, is_shared_user)
440#ifndef PROJ_DEBUG_NOSEAMBLEED
565#define PS_CORNER_TRI_AS_VERT_INDEX_3(ps, tri) \
566 ps->corner_verts_eval[tri[0]], ps->corner_verts_eval[tri[1]], ps->corner_verts_eval[tri[2]],
568#define PS_CORNER_TRI_AS_UV_3(uvlayer, face_i, tri) \
569 uvlayer[face_i][tri[0]], uvlayer[face_i][tri[1]], uvlayer[face_i][tri[2]],
571#define PS_CORNER_TRI_ASSIGN_UV_3(uv_tri, uvlayer, face_i, tri) \
573 (uv_tri)[0] = uvlayer[face_i][tri[0]]; \
574 (uv_tri)[1] = uvlayer[face_i][tri[1]]; \
575 (uv_tri)[2] = uvlayer[face_i][tri[2]]; \
592 return 1001 + 10 * ty + tx;
604 if (mat_nr >= 0 && mat_nr <= ps->ob->totcol) {
615 return ma ? ma->texpaintslot + ma->paint_active_slot :
nullptr;
626 TexPaintSlot *slot = ma ? ma->texpaintslot + ma->paint_active_slot :
nullptr;
634 return ma ? ma->texpaintslot + ma->paint_clone_slot :
nullptr;
641 TexPaintSlot *slot = ma ? ma->texpaintslot + ma->paint_clone_slot :
nullptr;
676 const float pt[2],
const float v1[3],
const float v2[3],
const float v3[3],
float w[3])
679 return (v1[2] *
w[0]) + (
v2[2] *
w[1]) + (v3[2] *
w[2]);
683 const float pt[2],
const float v1[4],
const float v2[4],
const float v3[4],
float w[3])
685 float wtot_inv, wtot;
695 w_tmp[0] =
w[0] * v1[3];
696 w_tmp[1] =
w[1] *
v2[3];
697 w_tmp[2] =
w[2] * v3[3];
699 wtot = w_tmp[0] + w_tmp[1] + w_tmp[2];
702 wtot_inv = 1.0f / wtot;
704 w_tmp[0] = w_tmp[0] * wtot_inv;
705 w_tmp[1] = w_tmp[1] * wtot_inv;
706 w_tmp[2] = w_tmp[2] * wtot_inv;
709 w_tmp[0] = w_tmp[1] = w_tmp[2] = 1.0f / 3.0f;
713 return (v1[2] * w_tmp[0]) + (
v2[2] * w_tmp[1]) + (v3[2] * w_tmp[2]);
722 int best_tri_index = -1;
723 float z_depth_best =
FLT_MAX, z_depth;
726 if (bucket_index == -1) {
736 const float *vtri_ss[3] = {
750 if (z_depth < z_depth_best) {
751 best_tri_index = tri_index;
752 z_depth_best = z_depth;
759 return best_tri_index;
767 const float *tri_uv[3];
775 if (tri_index == -1) {
801 iuser.
tile = tile_number;
802 iuser.
framenr = ima->lastframe;
804 if (ibuf ==
nullptr) {
808 float x = uv[0] * ibuf->
x;
809 float y = uv[1] * ibuf->
y;
820 memcpy(rgba_fp, &col,
sizeof(col));
830 memcpy(rgba, &col,
sizeof(col));
856 if (v1[2] > pt[2] &&
v2[2] > pt[2] && v3[2] > pt[2]) {
867 if (v1[2] < pt[2] &&
v2[2] < pt[2] && v3[2] < pt[2]) {
890 const float v1_3d[3],
891 const float v2_3d[3],
892 const float v3_3d[3],
930 const float pixelScreenCo[4])
938 for (; bucketFace; bucketFace = bucketFace->
next) {
941 if (orig_face != tri_index) {
943 const float *vtri_ss[3] = {
951 const float *vtri_co[3] = {
963 if (isect_ret >= 1) {
976#define ISECT_TRUE_P1 2
977#define ISECT_TRUE_P2 3
978static int line_isect_y(
const float p1[2],
const float p2[2],
const float y_level,
float *x_isect)
983 if (y_level == p1[1]) {
988 if (y_level == p2[1]) {
994 y_diff =
fabsf(p1[1] - p2[1]);
996 if (y_diff < 0.000001f) {
997 *x_isect = (p1[0] + p2[0]) * 0.5f;
1001 if (p1[1] > y_level && p2[1] < y_level) {
1003 *x_isect = (p2[0] * (p1[1] - y_level) + p1[0] * (y_level - p2[1])) / y_diff;
1006 if (p1[1] < y_level && p2[1] > y_level) {
1008 *x_isect = (p2[0] * (y_level - p1[1]) + p1[0] * (p2[1] - y_level)) / y_diff;
1014static int line_isect_x(
const float p1[2],
const float p2[2],
const float x_level,
float *y_isect)
1018 if (x_level == p1[0]) {
1022 if (x_level == p2[0]) {
1028 x_diff =
fabsf(p1[0] - p2[0]);
1031 if (x_diff < 0.000001f) {
1032 *y_isect = (p1[0] + p2[0]) * 0.5f;
1036 if (p1[0] > x_level && p2[0] < x_level) {
1038 *y_isect = (p2[1] * (p1[0] - x_level) + p1[1] * (x_level - p2[0])) / x_diff;
1041 if (p1[0] < x_level && p2[0] > x_level) {
1043 *y_isect = (p2[1] * (x_level - p1[0]) + p1[1] * (p2[0] - x_level)) / x_diff;
1053#ifndef PROJ_DEBUG_NOSEAMBLEED
1054static bool cmp_uv(
const float vec2a[2],
const float vec2b[2])
1057 float xa =
fmodf(vec2a[0], 1.0f);
1058 float ya =
fmodf(vec2a[1], 1.0f);
1060 float xb =
fmodf(vec2b[0], 1.0f);
1061 float yb =
fmodf(vec2b[1], 1.0f);
1085#ifndef PROJ_DEBUG_NOSEAMBLEED
1092 float min_uv[2], max_uv[2];
1101 r_bounds_px->
xmin = int(ibuf_x * min_uv[0]);
1102 r_bounds_px->
ymin = int(ibuf_y * min_uv[1]);
1104 r_bounds_px->
xmax = int(ibuf_x * max_uv[0]) + 1;
1105 r_bounds_px->
ymax = int(ibuf_y * max_uv[1]) + 1;
1110 return (r_bounds_px->
xmin == r_bounds_px->
xmax || r_bounds_px->
ymin == r_bounds_px->
ymax) ?
1117 float (*uv)[2],
const int ibuf_x,
const int ibuf_y,
int tot,
rcti *r_bounds_px)
1120 float min_uv[2], max_uv[2];
1133 r_bounds_px->
xmin = int(ibuf_x * min_uv[0]);
1134 r_bounds_px->
ymin = int(ibuf_y * min_uv[1]);
1136 r_bounds_px->
xmax = int(ibuf_x * max_uv[0]) + 1;
1137 r_bounds_px->
ymax = int(ibuf_y * max_uv[1]) + 1;
1142 return (r_bounds_px->
xmin == r_bounds_px->
xmax || r_bounds_px->
ymin == r_bounds_px->
ymax) ?
1147#ifndef PROJ_DEBUG_NOSEAMBLEED
1163 winding =
cross_tri_v2(tri_uv[0], tri_uv[1], tri_uv[2]);
1176 const int orig_face,
1177 const int orig_i1_fidx,
1178 const int orig_i2_fidx,
1184 const float *orig_tri_uv[3];
1193 int i1_fidx = -1, i2_fidx = -1;
1198 if (tri_index != orig_face) {
1212 if (i2_fidx != -1) {
1213 const float *tri_uv[3];
1236 *other_face = tri_index;
1239 *orig_fidx = (i1_fidx < i2_fidx && (i2_fidx - i1_fidx == 1)) ? i1_fidx : i2_fidx;
1246 bool has_same_image;
1248 has_same_image = (orig_tpage == tpage) && (orig_tile ==
tile);
1251 has_same_image = (orig_tpage == tpage) && (orig_tile ==
tile) &&
1252 cmp_uv(orig_tri_uv[orig_i1_fidx], tri_uv[i1_fidx]) &&
1253 cmp_uv(orig_tri_uv[orig_i2_fidx], tri_uv[i2_fidx]);
1257 if (has_same_image) {
1284 ListBaseT<VertSeam> *vert_seams = &ps->
vertSeams[vert_index];
1285 VertSeam *seam = vert_seams->first();
1288 while (seam->
loop != loop_index) {
1324 const float PI_2 =
M_PI * 2.0f;
1326 float angle_rel, angle_no;
1339 if (angle_rel < 0.0f) {
1345 angle_no = angle_rel +
angle[0];
1347 if (angle_no >
M_PI) {
1351 r_no[0] =
cosf(angle_no);
1352 r_no[1] =
sinf(angle_no);
1361 float (*orig_uv)[2],
1374 ibuf_inv[0] = 1.0f /
float(ibuf_x);
1375 ibuf_inv[1] = 1.0f /
float(ibuf_y);
1377 for (fidx[0] = 0; fidx[0] < 3; fidx[0]++) {
1379 float (*seam_uvs)[2];
1386 loop_index = tri[fidx[0]];
1391 if (seam_uvs[0][0] !=
FLT_MAX) {
1395 fidx[1] = (fidx[0] == 2) ? 0 : fidx[0] + 1;
1400 for (
uint i = 0; i < 2; i++) {
1408 tri_ang = ang[i] -
M_PI_2;
1410 if (tri_ang > 0.0f) {
1418 len_fact =
cosf(tri_ang);
1422 len_fact = std::min(len_fact, 10.0f);
1432 if ((ang[0] + ang[1]) <
M_PI) {
1437 orig_uv[fidx[0]], seam_uvs[0], orig_uv[fidx[1]], seam_uvs[1], isect_co);
1448 const int tri_index,
1455 const float *tri_uv[3];
1459 const int fidx[2] = {fidx1, ((fidx1 + 1) % 3)};
1464 vseam->
prev =
nullptr;
1465 vseam->
next =
nullptr;
1467 vseam->
tri = tri_index;
1468 vseam->
loop = tri[fidx[0]];
1474 sub_v2_v2v2(vec, tri_uv[fidx[1]], tri_uv[fidx[0]]);
1492 vseam[1] = vseam[0];
1502 for (
uint i = 0; i < 2; i++) {
1507 while (item && item->
angle < vseam[i].
angle) {
1523 const int tri_index,
1524 const uint vert_index,
1530 int other_face, other_fidx;
1532 int fidx[2] = {2, 0};
1548 if (
check_seam(ps, tri_index, fidx[0], fidx[1], &other_face, &other_fidx)) {
1552 if (other_face != -1) {
1565 if (other_face != -1) {
1575 }
while (fidx[0]--);
1578 char checked_verts = 0;
1585 for (
uint i = 0; i < 2; i++) {
1588 if ((checked_verts & (1 << fidx[i])) != 0) {
1600 checked_verts |= 1 << fidx[i];
1607 }
while (fidx[0]--);
1617 const float v1co[3],
1618 const float v2co[3],
1619 const float v3co[3],
1620 const float uv1co[2],
1621 const float uv2co[2],
1622 const float uv3co[2],
1623 float pixelScreenCo[4],
1633 const float v1co[4],
1634 const float v2co[4],
1635 const float v3co[4],
1636 const float uv1co[2],
1637 const float uv2co[2],
1638 const float uv3co[2],
1639 float pixelScreenCo[4],
1643 float wtot_inv, wtot;
1647 w_int[0] =
w[0] * v1co[3];
1648 w_int[1] =
w[1] * v2co[3];
1649 w_int[2] =
w[2] * v3co[3];
1651 wtot = w_int[0] + w_int[1] + w_int[2];
1654 wtot_inv = 1.0f / wtot;
1655 w_int[0] *= wtot_inv;
1656 w_int[1] *= wtot_inv;
1657 w_int[2] *= wtot_inv;
1661 w[0] =
w[1] =
w[2] = w_int[0] = w_int[1] = w_int[2] = 1.0f / 3.0f;
1679 const float projmat_inv[4][4],
1680 const float view_pos[3],
1681 const float co_px[2],
1684 r_dir[0] = 2.0f * (co_px[0] / winx) - 1.0f;
1685 r_dir[1] = 2.0f * (co_px[1] / winy) - 1.0f;
1704 const float zero[3] = {0};
1705 float v1_proj[3], v2_proj[3];
1720 const float *tri_uv[3],
ImBuf *ibuf_other,
const float w[3],
uchar rgba_ub[4],
float rgba_f[4])
1726 float x = uv_other[0] * ibuf_other->
x - 0.5f;
1727 float y = uv_other[1] * ibuf_other->
y - 0.5f;
1732 memcpy(rgba_f, &col,
sizeof(col));
1736 memcpy(rgba_ub, &col,
sizeof(col));
1742 const int tri_index,
1766 mask = ((rgba_f[0] + rgba_f[1] + rgba_f[2]) * (1.0f / 3.0f)) * rgba_f[3];
1769 mask = ((rgba_ub[0] + rgba_ub[1] + rgba_ub[2]) * (1.0f / (255.0f * 3.0f))) *
1770 (rgba_ub[3] * (1.0f / 255.0f));
1795 float ca1, ca2, ca3, ca_mask;
1800 ca_mask =
w[0] * ca1 +
w[1] * ca2 +
w[2] * ca3;
1802 CLAMP(ca_mask, 0.0f, 1.0f);
1810 float no[3], angle_cos;
1813 const float *no1, *no2, *no3;
1818 no[0] =
w[0] * no1[0] +
w[1] * no2[0] +
w[2] * no3[0];
1819 no[1] =
w[0] * no1[1] +
w[1] * no2[1] +
w[2] * no3[1];
1820 no[2] =
w[0] * no1[2] +
w[1] * no2[2] +
w[2] * no3[2];
1834 float viewDirPersp[3];
1835 const float *co1, *co2, *co3;
1841 viewDirPersp[0] = (ps->
viewPos[0] - (
w[0] * co1[0] +
w[1] * co2[0] +
w[2] * co3[0]));
1842 viewDirPersp[1] = (ps->
viewPos[1] - (
w[0] * co1[1] +
w[1] * co2[1] +
w[2] * co3[1]));
1843 viewDirPersp[2] = (ps->
viewPos[2] - (
w[0] * co1[2] +
w[1] * co2[2] +
w[2] * co3[2]));
1849 angle_cos =
dot_v3v3(viewDirPersp, no);
1854 angle_cos =
fabsf(angle_cos);
1857 if (angle_cos <= ps->normal_angle__cos) {
1861 if (angle_cos < ps->normal_angle_inner__cos) {
1885 bool generate_tile =
false;
1894 generate_tile =
true;
1901 if (generate_tile) {
1903 volatile const void *undorect =
nullptr;
1914 if (ibuf->float_data()) {
1915 undorect = ibuf->float_data();
1918 undorect = ibuf->byte_data();
1932 if (ibuf->float_data()) {
1933 undorect = ibuf->float_data();
1936 undorect = ibuf->byte_data();
1963 const int tri_index,
1964 const float pixelScreenCo[4],
1965 const float world_spaceCo[3],
1970 int x_round, y_round;
1979 x_px =
mod_i(x_px, ibuf->
x);
1980 y_px =
mod_i(y_px, ibuf->
y);
2029 projPixel->
x_px = x_px;
2030 projPixel->
y_px = y_px;
2054 const float *other_tri_uv[3] = {
2099 (
reinterpret_cast<ProjPixelClone *
>(projPixel))->clonepx.f[3] = 0;
2102 (
reinterpret_cast<ProjPixelClone *
>(projPixel))->clonepx.ch[3] = 0;
2114 ps, co, (
reinterpret_cast<ProjPixelClone *
>(projPixel))->clonepx.f,
nullptr,
true))
2117 (
reinterpret_cast<ProjPixelClone *
>(projPixel))->clonepx.f[3] = 0;
2128 (
reinterpret_cast<ProjPixelClone *
>(projPixel))->clonepx.ch[3] = 0;
2151 if (l1[1] < rect->
ymin || l1[1] > rect->
ymax) {
2155 if ((l1[0] < rect->
xmin && l2[0] < rect->
xmin) || (l1[0] > rect->
xmax && l2[0] > rect->
xmax)) {
2177 if (l1[0] < rect->
xmin || l1[0] > rect->
xmax) {
2182 if ((l1[1] < rect->
ymin && l2[1] < rect->
ymin) || (l1[1] > rect->
ymax && l2[1] > rect->
ymax)) {
2227 (isect <= cliprect->xmax))
2229 if (l1[1] < l2[1]) {
2231 l1_clip[1] = rect->
ymin;
2236 l2_clip[1] = rect->
ymin;
2246 (isect <= cliprect->xmax))
2248 if (l1[1] > l2[1]) {
2250 l1_clip[1] = rect->
ymax;
2255 l2_clip[1] = rect->
ymax;
2266 (isect <= cliprect->ymax))
2268 if (l1[0] < l2[0]) {
2269 l1_clip[0] = rect->
xmin;
2274 l2_clip[0] = rect->
xmin;
2285 (isect <= cliprect->ymax))
2287 if (l1[0] > l2[0]) {
2288 l1_clip[0] = rect->
xmax;
2293 l2_clip[0] = rect->
xmax;
2310#ifndef PROJ_DEBUG_NOSEAMBLEED
2312static void scale_tri(
float insetCos[3][3],
const float *origCos[3],
const float inset)
2315 cent[0] = (origCos[0][0] + origCos[1][0] + origCos[2][0]) * (1.0f / 3.0f);
2316 cent[1] = (origCos[0][1] + origCos[1][1] + origCos[2][1]) * (1.0f / 3.0f);
2317 cent[2] = (origCos[0][2] + origCos[1][2] + origCos[2][2]) * (1.0f / 3.0f);
2339 return x *
x +
y *
y;
2349 const float radius_squared,
2350 const rctf *bucket_bounds)
2364 if ((bucket_bounds->
xmin <= cent[0] && bucket_bounds->
xmax >= cent[0]) ||
2365 (bucket_bounds->
ymin <= cent[1] && bucket_bounds->
ymax >= cent[1]))
2371 if (cent[0] < bucket_bounds->
xmin) {
2373 if (cent[1] < bucket_bounds->
ymin) {
2380 if (cent[1] > bucket_bounds->
ymax) {
2387 else if (cent[0] > bucket_bounds->
xmax) {
2389 if (cent[1] < bucket_bounds->
ymin) {
2396 if (cent[1] > bucket_bounds->
ymax) {
2417 const float *v1coSS,
2418 const float *v2coSS,
2419 const float *v3coSS,
2423 float bucket_bounds_uv[4][2],
2430 uv[0] = bucket_bounds->
xmax;
2431 uv[1] = bucket_bounds->
ymin;
2436 uv[1] = bucket_bounds->
ymax;
2440 uv[0] = bucket_bounds->
xmin;
2446 uv[1] = bucket_bounds->
ymin;
2455 const float *v1coSS,
2456 const float *v2coSS,
2457 const float *v3coSS,
2461 float bucket_bounds_uv[4][2],
2468 uv[0] = bucket_bounds->
xmax;
2469 uv[1] = bucket_bounds->
ymin;
2474 uv[1] = bucket_bounds->
ymax;
2478 uv[0] = bucket_bounds->
xmin;
2484 uv[1] = bucket_bounds->
ymin;
2492static float angle_2d_clockwise(
const float p1[2],
const float p2[2],
const float p3[2])
2496 v1[0] = p1[0] - p2[0];
2497 v1[1] = p1[1] - p2[1];
2498 v2[0] = p3[0] - p2[0];
2499 v2[1] = p3[1] - p2[1];
2501 return -
atan2f(v1[0] *
v2[1] - v1[1] *
v2[0], v1[0] *
v2[0] + v1[1] *
v2[1]);
2506#define ISECT_2 (1 << 1)
2507#define ISECT_3 (1 << 2)
2508#define ISECT_4 (1 << 3)
2509#define ISECT_ALL3 ((1 << 3) - 1)
2510#define ISECT_ALL4 ((1 << 4) - 1)
2514 const float pt[2],
const float v1[2],
const float v2[2],
const float v3[2],
const float limit)
2526 return ((
static_cast<float *
>(
const_cast<void *
>(p1)))[2] <
2527 (
static_cast<float *
>(
const_cast<void *
>(p2)))[2] ?
2534 return ((
static_cast<float *
>(
const_cast<void *
>(p1)))[2] <
2535 (
static_cast<float *
>(
const_cast<void *
>(p2)))[2] ?
2550 float xlen = l2[0] - l1[0];
2551 float ylen = l2[1] - l1[1];
2555 if ((l1[0] - rect->
xmin) * (l2[0] - rect->
xmin) <= 0) {
2559 else if ((l1[0] - rect->
xmax) * (l2[0] - rect->
xmax) < 0) {
2566 if ((l1[1] - rect->
ymin) * (l2[1] - rect->
ymin) <= 0) {
2570 else if ((l1[1] - rect->
ymax) * (l2[1] - rect->
ymax) < 0) {
2580 tmp = (is_ortho) ? 1.0f : (l1[3] +
min * (l2[3] - l1[3]));
2582 uv[0] = (uv1[0] +
min / tmp * (uv2[0] - uv1[0]));
2583 uv[1] = (uv1[1] +
min / tmp * (uv2[1] - uv1[1]));
2589 const bool is_flip_object,
2590 const rctf *cliprect,
2591 const rctf *bucket_bounds,
2592 const float *v1coSS,
2593 const float *v2coSS,
2594 const float *v3coSS,
2598 float bucket_bounds_uv[8][2],
2602 int inside_bucket_flag = 0;
2603 int inside_face_flag = 0;
2605 bool collinear =
false;
2607 float bucket_bounds_ss[4][2];
2656 if (inside_bucket_flag &
ISECT_1) {
2664 bucket_bounds, v1coSS, v2coSS, uv1co, uv2co, bucket_bounds_uv[*tot], is_ortho))
2670 if (inside_bucket_flag &
ISECT_2) {
2678 bucket_bounds, v2coSS, v3coSS, uv2co, uv3co, bucket_bounds_uv[*tot], is_ortho))
2684 if (inside_bucket_flag &
ISECT_3) {
2692 bucket_bounds, v3coSS, v1coSS, uv3co, uv1co, bucket_bounds_uv[*tot], is_ortho))
2718 bucket_bounds_ss[0][0] = bucket_bounds->
xmax;
2719 bucket_bounds_ss[0][1] = bucket_bounds->
ymin;
2725 bucket_bounds_ss[1][0] = bucket_bounds->
xmax;
2726 bucket_bounds_ss[1][1] = bucket_bounds->
ymax;
2732 bucket_bounds_ss[2][0] = bucket_bounds->
xmin;
2733 bucket_bounds_ss[2][1] = bucket_bounds->
ymax;
2739 bucket_bounds_ss[3][0] = bucket_bounds->
xmin;
2740 bucket_bounds_ss[3][1] = bucket_bounds->
ymin;
2754 bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, bucket_bounds_uv, flip);
2758 bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, bucket_bounds_uv, flip);
2785 float isectVCosSS[8][3];
2786 float v1_clipSS[2], v2_clipSS[2];
2790 float cent[2] = {0.0f, 0.0f};
2796 if (inside_face_flag &
ISECT_1) {
2797 copy_v2_v2(isectVCosSS[*tot], bucket_bounds_ss[0]);
2800 if (inside_face_flag &
ISECT_2) {
2801 copy_v2_v2(isectVCosSS[*tot], bucket_bounds_ss[1]);
2804 if (inside_face_flag &
ISECT_3) {
2805 copy_v2_v2(isectVCosSS[*tot], bucket_bounds_ss[2]);
2808 if (inside_face_flag &
ISECT_4) {
2809 copy_v2_v2(isectVCosSS[*tot], bucket_bounds_ss[3]);
2813 if (inside_bucket_flag &
ISECT_1) {
2817 if (inside_bucket_flag &
ISECT_2) {
2821 if (inside_bucket_flag &
ISECT_3) {
2827 if (
line_clip_rect2f(cliprect, bucket_bounds, v1coSS, v2coSS, v1_clipSS, v2_clipSS)) {
2828 if ((inside_bucket_flag &
ISECT_1) == 0) {
2832 if ((inside_bucket_flag &
ISECT_2) == 0) {
2840 if (
line_clip_rect2f(cliprect, bucket_bounds, v2coSS, v3coSS, v1_clipSS, v2_clipSS)) {
2841 if ((inside_bucket_flag &
ISECT_2) == 0) {
2845 if ((inside_bucket_flag &
ISECT_3) == 0) {
2853 if (
line_clip_rect2f(cliprect, bucket_bounds, v3coSS, v1coSS, v1_clipSS, v2_clipSS)) {
2854 if ((inside_bucket_flag &
ISECT_3) == 0) {
2858 if ((inside_bucket_flag &
ISECT_1) == 0) {
2872 for (
int i = 0; i < (*tot); i++) {
2873 cent[0] += isectVCosSS[i][0];
2874 cent[1] += isectVCosSS[i][1];
2876 cent[0] = cent[0] /
float(*tot);
2877 cent[1] = cent[1] /
float(*tot);
2882 for (
int i = 0; i < (*tot); i++) {
2883 isectVCosSS[i][2] = angle_2d_clockwise(up, cent, isectVCosSS[i]);
2888 v1_clipSS[0] = cent[0];
2889 v1_clipSS[1] = cent[1] + 1.0f;
2891 for (
int i = 0; i < (*tot); i++) {
2892 v2_clipSS[0] = isectVCosSS[i][0] - cent[0];
2893 v2_clipSS[1] = isectVCosSS[i][1] - cent[1];
2894 isectVCosSS[i][2] =
atan2f(v1_clipSS[0] * v2_clipSS[1] - v1_clipSS[1] * v2_clipSS[0],
2895 v1_clipSS[0] * v2_clipSS[0] + v1_clipSS[1] * v2_clipSS[1]);
2902 qsort(isectVCosSS, *tot,
sizeof(
float[3]),
float_z_sort);
2906 while (doubles ==
true) {
2909 for (
int i = 0; i < (*tot); i++) {
2913 for (
int j = i; j < (*tot) - 1; j++) {
2914 isectVCosSS[j][0] = isectVCosSS[j + 1][0];
2915 isectVCosSS[j][1] = isectVCosSS[j + 1][1];
2932 for (
int i = 0; i < (*tot); i++) {
2938 for (
int i = 0; i < (*tot); i++) {
2945#ifdef PROJ_DEBUG_PRINT_CLIP
2950 float test_uv[4][2];
2954 bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, test_uv, flip);
2958 bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, test_uv, flip);
2960 printf(
"( [(%f,%f), (%f,%f), (%f,%f), (%f,%f)], ",
2970 printf(
" [(%f,%f), (%f,%f), (%f,%f)], ",
2979 for (
int i = 0; i < (*tot); i++) {
2980 printf(
"(%f, %f),", bucket_bounds_uv[i][0], bucket_bounds_uv[i][1]);
3044static bool IsectPoly2Df(
const float pt[2],
const float uv[][2],
const int tot)
3051 for (i = 1; i < tot; i++) {
3063 for (
int i = 1; i < tot; i++) {
3078 const int thread_index,
3079 const int bucket_index,
3080 const int tri_index,
3081 const int image_index,
3082 const rctf *clip_rect,
3083 const rctf *bucket_bounds,
3102 const float *tri_uv[3];
3115 const float *v1coSS, *v2coSS, *v3coSS;
3118 const float *vCo[3];
3123 float *uv1co, *uv2co, *uv3co;
3124 float pixelScreenCo[4];
3132 float tri_uv_pxoffset[3][2];
3133 float xhalfpx, yhalfpx;
3134 const float ibuf_xf =
float(ibuf->
x), ibuf_yf =
float(ibuf->
y);
3137 int has_x_isect = 0, has_isect = 0;
3139 float uv_clip[8][2];
3141 const bool is_ortho = ps->
is_ortho;
3172 tri_uv_pxoffset[0][0] = tri_uv[0][0] - xhalfpx;
3173 tri_uv_pxoffset[0][1] = tri_uv[0][1] - yhalfpx;
3175 tri_uv_pxoffset[1][0] = tri_uv[1][0] - xhalfpx;
3176 tri_uv_pxoffset[1][1] = tri_uv[1][1] - yhalfpx;
3178 tri_uv_pxoffset[2][0] = tri_uv[2][0] - xhalfpx;
3179 tri_uv_pxoffset[2][1] = tri_uv[2][1] - yhalfpx;
3183 uv1co = tri_uv_pxoffset[0];
3184 uv2co = tri_uv_pxoffset[1];
3185 uv3co = tri_uv_pxoffset[2];
3209 if (uv_clip_tot > 6) {
3210 printf(
"this should never happen! %d\n", uv_clip_tot);
3216 project_paint_undo_tiles_init(
3222 for (
y = bounds_px.
ymin;
y < bounds_px.
ymax;
y++) {
3225 uv[1] =
float(
y) / ibuf_yf;
3228 for (
x = bounds_px.
xmin;
x < bounds_px.
xmax;
x++) {
3231 uv[0] =
float(
x) / ibuf_xf;
3235 if ((do_backfacecull ==
true &&
IsectPoly2Df(uv, uv_clip, uv_clip_tot)) ||
3239 has_x_isect = has_isect = 1;
3243 uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo,
w);
3247 uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo,
w);
3252 if (do_clip || do_3d_mapping) {
3276 ps, arena, &tinf,
x,
y,
mask, tri_index, pixelScreenCo, wco,
w),
3282 else if (has_x_isect) {
3292 if (has_x_isect == 0 && has_isect) {
3300#ifndef PROJ_DEBUG_NOSEAMBLEED
3319 printf(
"seams - %d %d %d %d\n",
3340 float insetCos[3][3];
3343 const float *vCoSS[3];
3347 float bucket_clip_edges[2][2];
3348 float edge_verts_inset_clip[2][3];
3353 float seam_subsection[4][2];
3357 float tri_puv[3][2];
3359 tri_puv[0][0] = tri_uv_pxoffset[0][0] * ibuf->
x;
3360 tri_puv[0][1] = tri_uv_pxoffset[0][1] * ibuf->
y;
3362 tri_puv[1][0] = tri_uv_pxoffset[1][0] * ibuf->
x;
3363 tri_puv[1][1] = tri_uv_pxoffset[1][1] * ibuf->
y;
3365 tri_puv[2][0] = tri_uv_pxoffset[2][0] * ibuf->
x;
3366 tri_puv[2][1] = tri_uv_pxoffset[2][1] * ibuf->
y;
3393 for (fidx1 = 0; fidx1 < 3; fidx1++) {
3395 fidx2 = (fidx1 == 2) ? 0 : fidx1 + 1;
3397 if ((face_seam_flag & (1 << fidx1)) &&
3402 bucket_clip_edges[0],
3403 bucket_clip_edges[1]))
3417 ps, bucket_clip_edges[0], vCo[fidx1], vCo[fidx2]);
3419 ps, bucket_clip_edges[1], vCo[fidx1], vCo[fidx2]);
3423 seam_subsection[0], tri_uv_pxoffset[fidx1], tri_uv_pxoffset[fidx2], fac1);
3425 seam_subsection[1], tri_uv_pxoffset[fidx1], tri_uv_pxoffset[fidx2], fac2);
3427 interp_v2_v2v2(seam_subsection[2], seam_uvs[0], seam_uvs[1], fac2);
3428 interp_v2_v2v2(seam_subsection[3], seam_uvs[0], seam_uvs[1], fac1);
3432 interp_v3_v3v3(edge_verts_inset_clip[0], insetCos[fidx1], insetCos[fidx2], fac1);
3433 interp_v3_v3v3(edge_verts_inset_clip[1], insetCos[fidx1], insetCos[fidx2], fac2);
3439 for (
y = bounds_px.
ymin;
y < bounds_px.
ymax;
y++) {
3442 uv[1] =
float(
y) / ibuf_yf;
3445 for (
x = bounds_px.
xmin;
x < bounds_px.
xmax;
x++) {
3450 uv[0] =
float(
x) / ibuf_xf;
3478 float pixel_on_edge[4];
3483 uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo,
w);
3487 uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo,
w);
3493 pixel_on_edge, edge_verts_inset_clip[0], edge_verts_inset_clip[1], fac);
3496 pixel_on_edge[3] = 1.0f;
3499 pixel_on_edge[0] =
float(ps->
winx * 0.5f) +
3500 (ps->
winx * 0.5f) * pixel_on_edge[0] / pixel_on_edge[3];
3501 pixel_on_edge[1] =
float(ps->
winy * 0.5f) +
3502 (ps->
winy * 0.5f) * pixel_on_edge[1] / pixel_on_edge[3];
3504 pixel_on_edge[2] = pixel_on_edge[2] / pixel_on_edge[3];
3509 ps, bucketFaceNodes, tri_index, pixel_on_edge))
3513 if (do_clip || do_3d_mapping) {
3529 ps, arena, &tinf,
x,
y,
mask, tri_index, pixelScreenCo, wco,
w),
3534 else if (has_x_isect) {
3544 if (has_x_isect == 0 && has_isect) {
3598 rctf *r_bucket_bounds)
3617 const int thread_index,
3618 const int bucket_index,
3619 const rctf *clip_rect,
3620 const rctf *bucket_bounds)
3623 int tri_index, image_index = 0;
3624 ImBuf *ibuf =
nullptr;
3625 Image *tpage_last =
nullptr, *tpage;
3656 if (tpage_last != tpage || tile_last !=
tile) {
3661 for (image_index = 0; image_index < ps->
image_tot; image_index++) {
3664 ibuf = projIma->
ibuf;
3673 ps, thread_index, bucket_index, tri_index, image_index, clip_rect, bucket_bounds, ibuf);
3695 float p1[2], p2[2], p3[2], p4[2];
3696 const float *
v, *v1, *
v2, *v3;
3715 p1[0] = bucket_bounds.
xmin;
3716 p1[1] = bucket_bounds.
ymin;
3717 p2[0] = bucket_bounds.
xmin;
3718 p2[1] = bucket_bounds.
ymax;
3719 p3[0] = bucket_bounds.
xmax;
3720 p3[1] = bucket_bounds.
ymax;
3721 p4[0] = bucket_bounds.
xmax;
3722 p4[1] = bucket_bounds.
ymin;
3742 const int3 &corner_tri,
3743 const int tri_index)
3746 float min[2],
max[2], *vCoSS;
3748 int bucketMin[2], bucketMax[2];
3749 int fidx, bucket_x, bucket_y;
3751 int has_x_isect = -1, has_isect = 0;
3765 for (bucket_y = bucketMin[1]; bucket_y < bucketMax[1]; bucket_y++) {
3767 for (bucket_x = bucketMin[0]; bucket_x < bucketMax[0]; bucket_x++) {
3769 int bucket_index = bucket_x + (bucket_y * ps->
buckets_x);
3775 has_x_isect = has_isect = 1;
3777 else if (has_x_isect) {
3785 if (has_x_isect == 0 && has_isect) {
3790#ifndef PROJ_DEBUG_NOSEAMBLEED
3803 float viewmat[4][4];
3804 float viewinv[4][4];
3812 if (symmetry_flag) {
3814 for (i = 0; i < 3; i++) {
3815 if ((symmetry_flag >> i) & 1) {
3854 memcpy(winmat,
array,
sizeof(winmat));
3855 array +=
sizeof(winmat) /
sizeof(
float);
3856 memcpy(viewmat,
array,
sizeof(viewmat));
3857 array +=
sizeof(viewmat) /
sizeof(
float);
3869 copy_m4_m4(viewinv, cam_ob_eval->object_to_world().ptr());
3915 float *projScreenCo;
3922 "ProjectPaint ScreenVerts");
3926 for (a = 0; a < ps->
totvert_eval; a++, projScreenCo += 4) {
3930 projScreenCo[0] =
float(ps->
winx * 0.5f) + (ps->
winx * 0.5f) * projScreenCo[0];
3931 projScreenCo[1] =
float(ps->
winy * 0.5f) + (ps->
winy * 0.5f) * projScreenCo[1];
3936 for (a = 0; a < ps->
totvert_eval; a++, projScreenCo += 4) {
3938 projScreenCo[3] = 1.0f;
3944 projScreenCo[0] =
float(ps->
winx * 0.5f) +
3945 (ps->
winx * 0.5f) * projScreenCo[0] / projScreenCo[3];
3946 projScreenCo[1] =
float(ps->
winy * 0.5f) +
3947 (ps->
winy * 0.5f) * projScreenCo[1] / projScreenCo[3];
3949 projScreenCo[2] = projScreenCo[2] / projScreenCo[3];
3973#ifdef PROJ_DEBUG_WINCLIP
4014 if (counter[a] > 0) {
4024 MEM_delete(counter);
4029#ifndef PROJ_DEBUG_NOSEAMBLEED
4037 "paint-loopSeamUVs");
4055 if (reset_threads) {
4074 float viewDirPersp[3];
4110#ifndef PROJ_DEBUG_NOSEAMBLEED
4113 const int3 &corner_tri,
4114 const int tri_index)
4120 const float *tri_uv[3];
4129 float area_tri = 0.0f;
4133 if (area_tri > 0.0f) {
4160 if (ps->
mesh_eval->uv_map_names().is_empty()) {
4167 const int totmat = ob->
totcol + 1;
4172 for (
int i = 0; i < totmat - 1; i++) {
4189 if (attr.varray.is_single()) {
4192 else if (attr.varray.is_span()) {
4199 if (attr.varray.is_single()) {
4202 else if (attr.varray.is_span()) {
4209 if (attr.varray.is_single()) {
4212 else if (attr.varray.is_span()) {
4226 "proj_paint_mtfaces");
4239 const Mesh &mesh_orig = *id_cast<const Mesh *>(ps->
ob->
data);
4241 const float2 *uv_map_clone_base =
nullptr;
4246 "proj_paint_mtfaces");
4250 if (attr.varray.is_span()) {
4251 uv_map_clone_base = attr.varray.get_internal_span().typed<
float2>().
data();
4256 if (uv_map_clone_base ==
nullptr) {
4260 if (attr.varray.is_span()) {
4261 uv_map_clone_base = attr.varray.get_internal_span().typed<
float2>().
data();
4268 memset(layer_clone, 0,
sizeof(*layer_clone));
4276 const int tri_index)
4297 if (attr.varray.is_span()) {
4306 if (attr.varray.is_span()) {
4331 Mesh *orig_mesh = id_cast<Mesh *>(ps->
ob->
data);
4387 const int3 &corner_tri,
4407#ifdef PROJ_DEBUG_WINCLIP
4435 ListBaseT<PrepareImageEntry> *used_images)
4444 for (entry = used_images->first(); entry; entry = entry->
next, projIma++) {
4447 projIma->
ima = entry->
ima;
4448 projIma->
touch =
false;
4450 if (projIma->
ibuf ==
nullptr) {
4461 memset(
static_cast<void *
>(projIma->
undoRect), 0, size);
4463 memset(projIma->
maskRect, 0, size);
4465 memset(projIma->
valid, 0, size);
4481 ListBaseT<PrepareImageEntry> &used_images,
4487 return state.image_index;
4490 int image_index = 0;
4492 if (
e->ima == tpage &&
e->iuser.tile ==
tile) {
4502 iuser.
framenr = tpage->lastframe;
4517 state.image_index = image_index;
4525 const float2 *uv_map_base,
4526 const bool is_multi_view)
4531 ListBaseT<PrepareImageEntry> used_images = {
nullptr};
4543 std::optional<float2> single_value;
4547 for (tri_index = 0; tri_index < ps->
corner_tris_eval.size(); tri_index++) {
4548 bool is_face_paintable;
4549 bool skip_tri =
false;
4556 if (slot ==
nullptr) {
4559 if (attr.varray.is_span()) {
4560 uv_map_base = attr.varray.get_internal_span().typed<
float2>().
data();
4562 else if (attr.varray.is_single()) {
4563 single_value = attr.varray.typed<
float2>().get_internal_single();
4570 if (slot != slot_last) {
4574 if (attr.varray.is_span()) {
4575 uv_map_base = attr.varray.get_internal_span().typed<
float2>().
data();
4577 else if (attr.varray.is_single()) {
4578 single_value = attr.varray.typed<
float2>().get_internal_single();
4587 if (attr.varray.is_span()) {
4588 uv_map_base = attr.varray.get_internal_span().typed<
float2>().
data();
4590 else if (attr.varray.is_single()) {
4591 single_value = attr.varray.typed<
float2>().get_internal_single();
4600 if (slot->
ima !=
nullptr &&
4624 BLI_assert(uv_map_base !=
nullptr || single_value.has_value());
4626 if (single_value.has_value()) {
4635#ifndef PROJ_DEBUG_NOSEAMBLEED
4643 if (!is_face_paintable || !tpage) {
4647 int image_index = -1;
4651 if (is_multi_view) {
4665#ifdef PROJ_DEBUG_WINCLIP
4675 if (prev_poly != tri_faces[tri_index]) {
4678 prev_poly = tri_faces[tri_index];
4679 for (
const int corner : poly) {
4689 int poly_tri = poly.
size() - 3;
4690 tri_index += poly_tri;
4703 if (!is_multi_view) {
4707 if (image_index != -1) {
4720 used_images.free_no_destruct();
4726 const bool is_multi_view,
4727 const char symmetry_flag)
4731 const float2 *uv_map_base =
nullptr;
4738 bool reset_threads =
false;
4747 const Mesh &mesh_orig = *id_cast<const Mesh *>(ps->
ob->
data);
4767 if (attr.varray.is_span()) {
4777 if (attr.varray.is_span()) {
4811 reset_threads =
true;
4820 "paint-bucketRect");
4822 "paint-bucketFaces");
4825 "paint-bucketFaces");
4826#ifndef PROJ_DEBUG_NOSEAMBLEED
4838 ps, arena, &face_lookup, &layer_clone, uv_map_base, is_multi_view);
4852 (
float(ps->
winx * 0.5f) + (ps->
winx * 0.5f) * projCo[0] / projCo[3]);
4854 (
float(ps->
winy * 0.5f) + (ps->
winy * 0.5f) * projCo[1] / projCo[3]);
4865 for (a = 0, projIma = ps->
projImages; a < ps->image_tot; a++, projIma++) {
4904#ifndef PROJ_DEBUG_NOSEAMBLEED
4974 bool redraw =
false;
4976 for (a = 0, projIma = ps->
projImages; a < ps->image_tot; a++, projIma++) {
4977 if (projIma->
touch) {
4991 projIma->
touch =
false;
5002 float min_brush[2], max_brush[2];
5008 if (radius < 1.0f) {
5013 min_brush[0] = mval_f[0] - radius;
5014 min_brush[1] = mval_f[1] - radius;
5016 max_brush[0] = mval_f[0] + radius;
5017 max_brush[1] = mval_f[1] + radius;
5041 rctf *bucket_bounds,
5042 const float mval[2])
5051 const int bucket_y = bidx / ps->
buckets_x;
5052 const int bucket_x = bidx - (bucket_y * ps->
buckets_x);
5055 if (bucket_x >= ps->
bucketMin[0] && bucket_x < ps->bucketMax[0]) {
5062 *bucket_index = bidx;
5097 uchar clone_rgba[4];
5099 clone_rgba[0] = clone_pt[0];
5100 clone_rgba[1] = clone_pt[1];
5101 clone_rgba[2] = clone_pt[2];
5102 clone_rgba[3] =
uchar(clone_pt[3] *
mask);
5116 const float *clone_pt = (
reinterpret_cast<ProjPixelClone *
>(projPixel))->clonepx.f;
5119 float clone_rgba[4];
5184 float accum_tot = 0.0f;
5192 for (yk = 0; yk < kernel->
side; yk++) {
5193 for (xk = 0; xk < kernel->
side; xk++) {
5195 float co_ofs[2] = {2.0f * xk - 1.0f, 2.0f * yk - 1.0f};
5200 float weight = kernel->
wdata[xk + yk * kernel->
side];
5203 accum_tot += weight;
5208 if (accum_tot != 0) [[likely]] {
5219 float alpha =
data[3];
5245 float accum_tot = 0;
5254 for (yk = 0; yk < kernel->
side; yk++) {
5255 for (xk = 0; xk < kernel->
side; xk++) {
5257 float co_ofs[2] = {2.0f * xk - 1.0f, 2.0f * yk - 1.0f};
5262 float weight = kernel->
wdata[xk + yk * kernel->
side];
5265 accum_tot += weight;
5270 if (accum_tot != 0) [[likely]] {
5276 float rgba_pixel[4];
5286 float alpha = rgba_pixel[3];
5287 rgba[3] = rgba_pixel[3] =
mask;
5309 const float texrgb[3],
5335 if (dither > 0.0f) {
5353 const float texrgb[3],
5380 rgba_ub[0] = rgba_ub[1] = rgba_ub[2] = ps->
stencil_value * 255.0f;
5411 &rect_to_add, projPixel->
x_px, projPixel->
x_px + 1, projPixel->
y_px, projPixel->
y_px + 1);
5422 float rgb_straight[4];
5439 const float *lastpos = (
static_cast<ProjectHandle *
>(ph_v))->prevmval;
5440 const float *pos = (
static_cast<ProjectHandle *
>(ph_v))->mval;
5441 const int thread_index = (
static_cast<ProjectHandle *
>(ph_v))->thread_index;
5449 int last_index = -1;
5453 float dist_sq, dist;
5457 bool is_floatbuf =
false;
5462 float pos_ofs[2] = {0};
5468 const float brush_radius_sq = brush_radius * brush_radius;
5480 LinkNode *softenPixels_f =
nullptr;
5485 pos_ofs[0] = pos[0] - lastpos[0];
5486 pos_ofs[1] = pos[1] - lastpos[1];
5501 rctf clip_rect = bucket_bounds;
5520 last_projIma = projImages + last_index;
5522 last_projIma->
touch =
true;
5529 BLI_assert(byte_data !=
nullptr || float_data !=
nullptr);
5538 float line_len_sq_inv, line_len;
5541 const float p[2] = {
5542 projPixel->
projCoSS[0] - lastpos[0],
5543 projPixel->
projCoSS[1] - lastpos[1],
5548 line_len_sq_inv = 1.0f / line_len;
5549 line_len =
sqrtf(line_len);
5551 switch (
brush->gradient_fill_mode) {
5553 f =
dot_v2v2(p, tangent) * line_len_sq_inv;
5558 f =
len_v2(p) / line_len;
5563 color_f[3] *=
float(projPixel->
mask) * (1.0f / 65535.0f) * brush_alpha;
5598 float newColor_f[4];
5599 newColor_f[3] =
float(projPixel->
mask) * (1.0f / 65535.0f) * brush_alpha;
5673 if (dist_sq <= brush_radius_sq) {
5674 dist =
sqrtf(dist_sq);
5678 if (falloff > 0.0f) {
5683 float custom_mask =
float(projPixel->
mask) * (1.0f / 65535.0f);
5689 CLAMP(texmask, 0.0f, 1.0f);
5690 custom_mask *= texmask;
5706 samplecos[2] = 0.0f;
5712 ps->
paint,
brush, mtex, samplecos, texrgba, thread_index, pool);
5715 custom_mask *= texrgba[3];
5729 float max_mask = brush_alpha * custom_mask * falloff * 65535.0f;
5732 mask = mask_accum + max_mask;
5735 mask = mask_accum + (max_mask - mask_accum * falloff);
5743 mask = mask_short * (1.0f / 65535.0f);
5751 mask = brush_alpha * custom_mask * falloff;
5759 last_projIma = projImages + last_index;
5761 last_projIma->
touch =
true;
5767 *projPixel->
valid =
true;
5773 switch (brush_type) {
5885 bool touch_any =
false;
5906 bool float_dest =
false;
5907 bool uchar_dest =
false;
5958 memcpy(handles[a].projImages[i].partRedrawRect,
5963 handles[a].
pool = image_pool;
5965 if (task_pool !=
nullptr) {
5970 if (task_pool !=
nullptr) {
6002 if (tri_index != -1) {
6023 const float prev_pos[2],
6054 for (
int i = 0; i < ps->
image_tot; i++) {
6098 const float prev_pos[2],
6115 const int mval_i[2] = {int(pos[0]), int(pos[1])};
6227#ifndef PROJ_DEBUG_NOSEAMBLEED
6258 const float mouse[2],
6267 ps_handle = MEM_new<ProjStrokeHandle>(
"ProjStrokeHandle");
6268 ps_handle->
scene = scene;
6290 const bool is_multi_view = (ps_handle->
ps_views_tot != 1);
6293 ProjPaintState *ps = MEM_new<ProjPaintState>(
"ProjectionPaintState");
6308 BLI_assert(index <= ps_handle->ps_views_tot);
6320 if (ps->
ob ==
nullptr) {
6363 MEM_delete(ps_handle->
ps_views[i]);
6365 MEM_delete(ps_handle);
6394 MEM_delete(ps_handle);
6413 MEM_delete(ps_handle);
6427 int orig_brush_size;
6447 if (
image ==
nullptr) {
6468 if (view_data !=
nullptr &&
6483 if (scene.
camera ==
nullptr) {
6513 const float pos[2] = {0.0, 0.0};
6514 const float lastpos[2] = {0.0, 0.0};
6541 ot->
name =
"Project Image";
6542 ot->
idname =
"PAINT_OT_project_image";
6543 ot->
description =
"Project an edited render from the active camera back onto the object";
6584 char err_out[256] =
"unknown";
6603 w = std::min(
w, maxsize);
6604 h = std::min(h, maxsize);
6662 depsgraph, v3d, rv3d,
true, &clip_start, &clip_end);
6677 ot->
name =
"Image from View";
6678 ot->
idname =
"PAINT_OT_image_from_view";
6679 ot->
description =
"Make an image from biggest 3D view for reprojection";
6689 ot->
srna,
"filepath",
nullptr,
FILE_MAX,
"File Path",
"Name of the file");
6697 ReportList *reports,
bool has_uvs,
bool has_mat,
bool has_tex,
bool has_stencil)
6701 "Missing%s%s%s%s detected!",
6702 !has_uvs ?
RPT_(
" UVs,") :
"",
6703 !has_mat ?
RPT_(
" Materials,") :
"",
6704 !has_tex ?
RPT_(
" Textures (or linked),") :
"",
6705 !has_stencil ?
RPT_(
" Stencil,") :
"");
6713 bool *r_has_stencil)
6717 bool has_mat =
true;
6718 bool has_tex =
true;
6719 bool has_stencil =
true;
6720 bool has_uvs =
true;
6737 for (
int i = 1; i < ob.
totcol + 1; i++) {
6742 if (ma->texpaintslot ==
nullptr) {
6746 if (ma->texpaintslot !=
nullptr &&
6747 ma->texpaintslot[ma->paint_active_slot].ima !=
nullptr &&
6765 int layernum =
mesh->uv_map_names().size();
6767 if (layernum == 0) {
6775 if (imapaint.
stencil ==
nullptr) {
6776 has_stencil =
false;
6794 *r_has_uvs = has_uvs;
6797 *r_has_mat = has_mat;
6800 *r_has_tex = has_tex;
6802 if (r_has_stencil) {
6803 *r_has_stencil = has_stencil;
6806 return has_uvs && has_mat && has_tex && has_stencil;
6833 {0,
nullptr, 0,
nullptr,
nullptr},
6851 float color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
6852 char imagename[
MAX_ID_NAME - 2] =
"Material Diffuse Color";
6855 bool use_float =
false;
6856 bool use_tiled =
false;
6896 float color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
6911 if (!attributes.
add(unique_name,
6916 return std::nullopt;
6920 if (!
mesh->default_color_attribute) {
6938 switch (layer_type) {
6944 bNode *in_node =
nullptr;
6945 if (ma && ma->nodetree) {
6946 ma->nodetree->ensure_topology_cache();
6947 const Span<bNode *> nodes = ma->nodetree->nodes_by_type(
"ShaderNodeBsdfPrincipled"_ustr);
6959 switch (in_sock->
type) {
7004 Image *ima =
nullptr;
7023 ntree = ma->nodetree;
7032 switch (slot_type) {
7036 new_node->
id = &ima->id;
7053 ntree->ensure_topology_cache();
7054 const Span<bNode *> bsdf_nodes = ntree->nodes_by_type(
"ShaderNodeBsdfPrincipled"_ustr);
7056 bNode *out_node = new_node;
7058 if (in_node !=
nullptr) {
7075 out_node = nor_node;
7087 out_node = bump_node;
7091 const Span<bNode *> output_nodes = ntree->nodes_by_type(
"ShaderNodeOutputMaterial"_ustr);
7094 if (in_node !=
nullptr) {
7104 if (in_sock !=
nullptr && link ==
nullptr) {
7162 const char *base_name = ma ? &ma->id.name[2] : &ob->
id.
name[2];
7179 ob, type,
reinterpret_cast<char *
>(&imagename),
sizeof(imagename));
7207 switch (slot_type) {
7238#define IMA_DEF_NAME N_("Untitled")
7243 static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
7248 {0,
nullptr, 0,
nullptr,
nullptr},
7252 ot->
name =
"Add Paint Slot";
7254 ot->
idname =
"PAINT_OT_add_texture_paint_slot";
7270 "Material Layer Type",
7271 "Material layer type of new paint slot");
7275 ot->
srna,
"slot_type", slot_type_items, 0,
"Slot Type",
"Type of new paint slot");
7282 ot->
srna,
"color", 4,
nullptr, 0.0f,
FLT_MAX,
"Color",
"Default fill color", 0.0f, 1.0f);
7293 RNA_def_boolean(ot->
srna,
"alpha",
true,
"Alpha",
"Create an image with an alpha channel");
7300 "Fill the image with a grid for UV map testing");
7306 "Create image with 32-bit floating-point bit depth");
7316 "Type of element that attribute is stored on");
7323 "Type of data stored in attribute");
7362 ot->
name =
"Add Simple UVs";
7364 ot->
idname =
"PAINT_OT_add_simple_uvs";
Generic geometry attributes built on CustomData.
Camera data-block and utility functions.
CustomData interface, see also DNA_customdata_types.h.
#define IDP_array_float_get(prop)
#define IMA_SIGNAL_USER_NEW_IMAGE
General operations, lookup, etc. for materials.
#define BKE_MESH_TESSTRI_VINDEX_ORDER(_tri, _v)
#define SH_NODE_TEX_IMAGE
#define SH_NODE_BSDF_PRINCIPLED
#define SH_NODE_NORMAL_MAP
#define SH_NODE_ATTRIBUTE
General operations, lookup, etc. for blender objects.
#define LISTBASE_CIRCULAR_BACKWARD_END(type, lb, lb_iter, lb_init)
#define LISTBASE_CIRCULAR_FORWARD_BEGIN(type, lb, lb_iter, lb_init)
#define LISTBASE_CIRCULAR_BACKWARD_BEGIN(type, lb, lb_iter, lb_init)
#define LISTBASE_CIRCULAR_FORWARD_END(type, lb, lb_iter, lb_init)
#define STRNCPY_UTF8(dst, src)
#define BLENDER_MAX_THREADS
Compatibility-like things for windows.
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
Object is a sort of wrapper for general info.
#define IMAGEPAINT_MODE_IMAGE
#define IMAGEPAINT_MODE_MATERIAL
#define RV3D_CLIPPING_ENABLED(v3d, rv3d)
#define ED_IMAGE_UNDO_TILE_NUMBER(size)
#define ED_IMAGE_UNDO_TILE_SIZE
#define ED_IMAGE_UNDO_TILE_BITS
Read Blender memory allocation and freeing.
Provides wrapper around system-specific atomic primitives, and some extensions (faked-atomic operatio...
ATOMIC_INLINE int32_t atomic_fetch_and_add_int32(int32_t *p, int32_t x)
#define INIT_MINMAX2(min, max)
#define BLI_assert_unreachable()
#define POINTER_FROM_INT(i)
#define POINTER_AS_INT(i)
#define MEM_SIZE_OPTIMAL(size)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
void append(const array< T > &from)
static AttributeOwner from_id(ID *id)
constexpr int64_t size() const
constexpr const T & first() const
constexpr bool is_empty() const
StringRefNull ref() const
GAttributeReader lookup_or_default(StringRef name, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
GAttributeReader lookup(const StringRef name) const
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
float distance(float, float) RET
const ccl_global KernelWorkTile * tile
ccl_device_inline float interp(const float a, const float b, const float t)
#define unit_float_to_uchar_clamp_v3(v1, v2)
std::unique_ptr< IDProperty, IDPropertyDeleter > create(StringRef prop_name, int32_t value, eIDPropertyFlag flags={})
Allocate a new IDProperty of type IDP_INT, set its name and value.
void stroke_track_location(Paint &paint, float3 location)
void node_position_propagate(bNode &node)
void node_tree_free_tree(bNodeTree &ntree)
std::optional< AttrType > custom_data_type_to_attr_type(eCustomDataType data_type)
void node_position_relative(bNode &from_node, const bNode &to_node, const bNodeSocket *from_sock, const bNodeSocket &to_sock)
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
bNodeTree * node_tree_add_tree(Main *bmain, StringRef name, StringRef idname)
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, UString identifier)
void node_set_active(bNodeTree &ntree, bNode &node)
internal::ShallowDataConstRef< T > shallow_copy(const T &other)
Object * context_active_object(const bContext *C)
bool object_active_color_init(Object &ob, const float fill_color[4])
uchar4 interpolate_nearest_wrap_byte(const ImBuf *in, float u, float v)
uchar4 interpolate_bilinear_wrap_byte(const ImBuf *in, float u, float v)
uchar4 interpolate_cubic_bspline_byte(const ImBuf *in, float u, float v)
float4 interpolate_nearest_wrap_fl(const ImBuf *in, float u, float v)
float4 interpolate_cubic_bspline_fl(const ImBuf *in, float u, float v)
float4 interpolate_bilinear_wrap_fl(const ImBuf *in, float u, float v)
T clamp(const T &a, const T &min, const T &max)
void node_tree_shader_default(const bContext *C, Main *bmain, ID *id)
@ V3D_OVERLAY_HIDE_OBJECT_ORIGINS
@ V3D_OVERLAY_HIDE_MOTION_PATHS
@ V3D_OVERLAY_HIDE_OBJECT_XTRAS
@ V3D_OVERLAY_HIDE_CURSOR
MINLINE float min_ff(float a, float b)
void WM_main_add_notifier(uint type, void *reference)
static void do_projectpaint_smear_f(ProjPaintState *ps, ProjPixel *projPixel, float mask, MemArena *smearArena, LinkNode **smearPixels_f, const float co[2])
void * MEM_new_uninitialized(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
bool BLI_rcti_is_valid(const struct rcti *rect)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
ARegion * BKE_area_find_region_active_win(const ScrArea *area)
static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *ps)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
static bool pixel_bounds_array(float(*uv)[2], const int ibuf_x, const int ibuf_y, int tot, rcti *r_bounds_px)
void mul_m3_v3(const float M[3][3], float r[3])
size_t size_t size_t BLI_snprintf_utf8(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
VecBase< uint8_t, 4 > uchar4
MINLINE int mod_i(int i, int n)
ImBuf * ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph, Scene *scene, eDrawType drawtype, View3D *v3d, ARegion *region, int sizex, int sizey, ImBufFlags imbuf_flag, int alpha_mode, const char *viewname, bool restore_rv3d_mats, GPUOffScreen *ofs, GPUViewport *viewport, bool use_camera_view_bounds, char err_out[256])
ScrArea * CTX_wm_area(const bContext *C)
static bool line_rect_clip(const rctf *rect, const float l1[4], const float l2[4], const float uv1[2], const float uv2[2], float uv[2], bool is_ortho)
static void partial_redraw_single_init(ImagePaintPartialRedraw *pr)
static int project_bucket_offset_safe(const ProjPaintState *ps, const float projCoSS[2])
const MTex * BKE_brush_color_texture_get(const Brush *brush, PaintMode paint_mode)
MINLINE void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
int RNA_enum_get(PointerRNA *ptr, const char *name)
void IMB_free_byte_pixels(ImBuf *ibuf)
static int float_z_sort_flip(const void *p1, const void *p2)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
@ IMAGEPAINT_MISSING_STENCIL
@ IMAGEPAINT_MISSING_MATERIAL
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
static int float_z_sort(const void *p1, const void *p2)
static bool IsectPoly2Df(const float pt[2], const float uv[][2], const int tot)
void ED_view3d_clipping_local(RegionView3D *rv3d, const float mat[4][4])
static void project_paint_build_proj_ima(ProjPaintState *ps, MemArena *arena, ListBaseT< PrepareImageEntry > *used_images)
void BKE_id_attributes_default_color_set(struct ID *id, std::optional< StringRef > name)
MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
@ IMAGEPAINT_PROJECT_LAYER_STENCIL_INV
@ IMAGEPAINT_PROJECT_LAYER_STENCIL
@ IMAGEPAINT_PROJECT_FLAT
@ IMAGEPAINT_PROJECT_XRAY
@ IMAGEPAINT_PROJECT_LAYER_CLONE
@ IMAGEPAINT_PROJECT_BACKFACE
IDProperty * IDP_GetPropertyTypeFromGroup(const IDProperty *prop, StringRef name, char type) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2])
static void proj_paint_state_viewport_init(ProjPaintState *ps, const char symmetry_flag)
static bool add_simple_uvs_poll(bContext *C)
int BKE_scene_num_threads(const Scene *scene)
static void proj_paint_layer_clone_init(ProjPaintState *ps, ProjPaintLayerClone *layer_clone)
MINLINE void copy_v3_v3(float r[3], const float a[3])
pthread_spinlock_t SpinLock
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
static wmOperatorStatus texture_paint_camera_project_exec(bContext *C, wmOperator *op)
float BKE_brush_sample_tex_3d(const Paint *paint, const Brush *br, const MTex *mtex, const float3 &point, float4 &rgba, int thread, ImagePool *pool)
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void ED_uvedit_add_simple_uvs(Main *bmain, const Scene *scene, Object *ob)
void ED_space_image_sync(Main *bmain, Image *image, bool ignore_render_viewer)
static void project_face_seams_init(const ProjPaintState *ps, MemArena *arena, const int tri_index, const uint vert_index, bool init_all, const int ibuf_x, const int ibuf_y)
static void do_projectpaint_clone_f(ProjPaintState *ps, ProjPixel *projPixel, float mask)
static bool project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2])
bool IMB_colormanagement_space_is_srgb(const ColorSpace *colorspace)
void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
void PAINT_OT_project_image(wmOperatorType *ot)
static int project_paint_prepare_image_index(ProjPaintState *ps, ListBaseT< PrepareImageEntry > &used_images, Image *tpage, const int tile, PrepareImageState &state)
MINLINE void mul_v2_fl(float r[2], float f)
PropertyRNA * RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
static void screen_px_from_persp(const float uv[2], const float v1co[4], const float v2co[4], const float v3co[4], const float uv1co[2], const float uv2co[2], const float uv3co[2], float pixelScreenCo[4], float w[3])
void ED_image_undo_push_end()
float BKE_brush_sample_masktex(const Paint *paint, Brush *br, const float2 &point, int thread, ImagePool *pool)
void interp_v2_v2v2v2(float r[2], const float a[2], const float b[2], const float c[2], const float t[3])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
Material * BKE_object_material_get(Object *ob, short act)
void ED_image_undo_push_begin(const char *name, PaintMode paint_mode)
static bool project_paint_flt_max_cull(const ProjPaintState *ps, const ProjPaintFaceCoSS *coSS)
static int project_paint_occlude_ptv(const float pt[3], const float v1[4], const float v2[4], const float v3[4], float w[3], const bool is_ortho)
static void proj_paint_face_coSS_init(const ProjPaintState *ps, const int3 &corner_tri, ProjPaintFaceCoSS *coSS)
bool IDP_AddToGroup(IDProperty *group, IDProperty *prop) ATTR_NONNULL()
TaskPool * BLI_task_pool_create_suspended(void *userdata, eTaskPriority priority)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
MINLINE int count_bits_i(unsigned int n)
void mul_project_m4_v3(const float mat[4][4], float vec[3])
static void uv_image_outset(const ProjPaintState *ps, float(*orig_uv)[2], float(*puv)[2], uint tri_index, const int ibuf_x, const int ibuf_y)
static void proj_paint_face_lookup_init(const ProjPaintState *ps, ProjPaintFaceLookup *face_lookup)
static int project_paint_undo_subtiles(const TileInfo *tinf, int tx, int ty)
void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot)
IDProperty * IDP_GetPropertyFromGroup(const IDProperty *prop, StringRef name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
static wmOperatorStatus texture_paint_add_texture_paint_slot_invoke(bContext *C, wmOperator *op, const wmEvent *)
static std::optional< std::string > proj_paint_color_attribute_create(wmOperator *op, Object &ob)
void IMB_mark_dirty(ImBuf *ibuf)
MINLINE void mul_v4_v4fl(float r[4], const float a[4], float f)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
MINLINE float safe_acosf(float a)
MINLINE void blend_color_mix_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
static wmOperatorStatus add_simple_uvs_exec(bContext *C, wmOperator *)
void BLI_linklist_prepend_arena(LinkNode **listp, void *ptr, struct MemArena *ma) ATTR_NONNULL(1
void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float aspx, float aspy)
void BLI_rcti_init_minmax(struct rcti *rect)
void barycentric_weights_v2_persp(const float v1[4], const float v2[4], const float v3[4], const float co[2], float w[3])
int isect_seg_seg_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float r_vi[2])
static void paint_proj_stroke_ps(const bContext *, void *ps_handle_p, const float prev_pos[2], const float pos[2], const bool eraser, float pressure, float distance, float size, ProjPaintState *ps)
static wmOperatorStatus texture_paint_add_texture_paint_slot_exec(bContext *C, wmOperator *op)
int RNA_int_get(PointerRNA *ptr, const char *name)
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
static int line_isect_y(const float p1[2], const float p2[2], const float y_level, float *x_isect)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void view3d_operator_needs_gpu(const bContext *C)
void imapaint_image_update(ImBuf *ibuf)
static Image * proj_paint_image_create(wmOperator *op, Main *bmain, bool is_data)
MINLINE void straight_to_premul_v4_v4(float premul[4], const float straight[4])
void BKE_object_material_assign(Main *bmain, Object *ob, Material *ma, short act, int assign_type)
int isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
ATTR_WARN_UNUSED_RESULT const BMVert * v
static void get_default_texture_layer_name_for_object(Object *ob, int texture_type, char *dst, int dst_maxncpy)
void * paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], const BrushStrokeMode mode, const BrushSwitchMode brush_switch_mode)
std::string BKE_attribute_calc_unique_name(const AttributeOwner &owner, StringRef name)
static void proj_paint_state_cavity_init(ProjPaintState *ps)
MatBase< float, 4, 4 > float4x4
int isect_point_tri_v2(const float pt[2], const float v1[2], const float v2[2], const float v3[2])
static wmOperatorStatus texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
int GPU_max_texture_size()
MINLINE void rgb_float_to_uchar(unsigned char r_col[3], const float col_f[3])
void ED_region_tag_redraw(ARegion *region)
int RNA_enum_from_value(const EnumPropertyItem *item, const int value)
MINLINE float cross_tri_v2(const float v1[2], const float v2[2], const float v3[2])
void MEM_delete_void(void *vmemh)
constexpr std::enable_if_t< blenlib_internal::IsBoundedArray< T >::value, size_t > BOUNDED_ARRAY_TYPE_SIZE() noexcept
static void do_projectpaint_soften_f(ProjPaintState *ps, ProjPixel *projPixel, float mask, MemArena *softenArena, LinkNode **softenPixels)
static void project_paint_bucket_bounds(const ProjPaintState *ps, const float min[2], const float max[2], int bucketMin[2], int bucketMax[2])
PaintTileMap * ED_image_paint_tile_map_get()
BLI_INLINE uchar f_to_char(const float val)
ViewLayer * CTX_data_view_layer(const bContext *C)
static TexPaintSlot * project_paint_face_clone_slot(const ProjPaintState *ps, int tri_index)
static Image * project_paint_face_paint_image(const ProjPaintState *ps, int tri_index)
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
MINLINE void mul_v3_fl(float r[3], float f)
static bool project_paint_op(void *state, const float lastpos[2], const float pos[2])
static bool partial_redraw_array_merge(ImagePaintPartialRedraw *pr, ImagePaintPartialRedraw *pr_other, int tot)
void normalize_m4(float R[4][4]) ATTR_NONNULL()
static void texture_paint_add_texture_paint_slot_ui(bContext *C, wmOperator *op)
static bool line_clip_rect2f(const rctf *cliprect, const rctf *rect, const float l1[2], const float l2[2], float l1_clip[2], float l2_clip[2])
void BLI_task_pool_work_and_wait(TaskPool *pool)
static void do_projectpaint_thread(TaskPool *__restrict, void *ph_v)
void paint_proj_redraw(const bContext *C, void *ps_handle_p, bool final)
MINLINE void sub_v3_v3(float r[3], const float a[3])
VecBase< float, 4 > float4
MINLINE void zero_v4(float r[4])
void BKE_camera_params_compute_matrix(CameraParams *params)
void mul_m4_v3(const float M[4][4], float r[3])
void IMB_float_from_byte(ImBuf *ibuf)
const EnumPropertyItem * RNA_image_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
static int project_paint_PickFace(const ProjPaintState *ps, const float pt[2], float w[3])
static float VecZDepthOrtho(const float pt[2], const float v1[3], const float v2[3], const float v3[3], float w[3])
void BLI_spin_end(SpinLock *spin)
MINLINE void blend_color_interpolate_float(float dst[4], const float src1[4], const float src2[4], float t)
static void do_projectpaint_clone(ProjPaintState *ps, ProjPixel *projPixel, float mask)
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], const ColorSpace *colorspace)
bool ED_view3d_autodist(ARegion *region, View3D *v3d, const int mval[2], float mouse_worldloc[3], const float fallback_depth_pt[3])
MINLINE void blend_color_add_float(float dst[4], const float src1[4], const float src2[4])
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
static void image_paint_partial_redraw_expand(ImagePaintPartialRedraw *cell, const ProjPixel *projPixel)
static void partial_redraw_array_init(ImagePaintPartialRedraw *pr)
void IMB_freeImBuf(ImBuf *ibuf)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
MINLINE void mul_v3_v3(float r[3], const float a[3])
MINLINE void add_v2_v2(float r[2], const float a[2])
void paint_brush_color_get(const Paint *paint, Brush *br, std::optional< float3 > &initial_hsv_jitter, bool invert, float distance, float pressure, float r_color[3])
static void do_projectpaint_mask(ProjPaintState *ps, ProjPixel *projPixel, float mask)
static void project_face_pixel(const float *tri_uv[3], ImBuf *ibuf_other, const float w[3], uchar rgba_ub[4], float rgba_f[4])
MINLINE float area_tri_v2(const float v1[2], const float v2[2], const float v3[2])
void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], const ColorSpace *colorspace)
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma, const Object *ob)
static void project_bucket_bounds(const ProjPaintState *ps, const int bucket_x, const int bucket_y, rctf *r_bucket_bounds)
MINLINE void add_v4_v4(float r[4], const float a[4])
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
BMesh const char void * data
Mesh * BKE_mesh_from_object(Object *ob)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
static bool project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *bucketFace, const int orig_face, const float pixelScreenCo[4])
static bool texture_paint_image_from_view_poll(bContext *C)
float line_point_factor_v2(const float p[2], const float l1[2], const float l2[2])
static void project_face_winding_init(const ProjPaintState *ps, const int tri_index)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
static void project_paint_delayed_face_init(ProjPaintState *ps, const int3 &corner_tri, const int tri_index)
MINLINE void premul_to_straight_v4(float color[4])
static int project_bucket_offset(const ProjPaintState *ps, const float projCoSS[2])
static void proj_paint_state_thread_init(ProjPaintState *ps, const bool reset_threads)
void BKE_camera_params_from_object(CameraParams *params, const struct Object *cam_ob)
void BKE_main_ensure_invariants(Main &bmain, std::optional< Span< ID * > > modified_ids=std::nullopt)
float3 BKE_paint_seed_hsv_jitter()
@ BKE_MAT_ASSIGN_USERPREF
static int project_paint_face_paint_tile(Image *ima, const float *uv)
IDProperty * IDP_GetProperties(ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
static bool IsectPoly2Df_twoside(const float pt[2], const float uv[][2], const int tot)
static bool project_bucket_isect_circle(const float cent[2], const float radius_squared, const rctf *bucket_bounds)
static bool proj_paint_add_slot(bContext *C, wmOperator *op)
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
static Image * project_paint_face_clone_image(const ProjPaintState *ps, int tri_index)
@ IMAGE_PAINT_BRUSH_TYPE_SOFTEN
@ IMAGE_PAINT_BRUSH_TYPE_SMEAR
@ IMAGE_PAINT_BRUSH_TYPE_DRAW
@ IMAGE_PAINT_BRUSH_TYPE_FILL
@ IMAGE_PAINT_BRUSH_TYPE_MASK
@ IMAGE_PAINT_BRUSH_TYPE_CLONE
void paint_proj_stroke(const bContext *C, void *ps_handle_p, const float prev_pos[2], const float pos[2], const bool eraser, float pressure, float distance, float size)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
MINLINE void negate_v3(float r[3])
static void screen_px_to_vector_persp(int winx, int winy, const float projmat_inv[4][4], const float view_pos[3], const float co_px[2], float r_dir[3])
int BKE_brush_size_get(const Paint *paint, const Brush *brush)
bool ED_paint_proj_mesh_data_check(Scene &scene, Object &ob, bool *r_has_uvs, bool *r_has_mat, bool *r_has_tex, bool *r_has_stencil)
BlurKernel * paint_new_blur_kernel(Brush *br, bool proj)
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
void IMB_blend_color_float(float dst[4], const float src1[4], const float src2[4], IMB_BlendMode mode)
void IMB_partial_update_mark_full(ImBuf *ibuf)
Image * BKE_image_add_from_imbuf(Main *bmain, ImBuf *ibuf, const char *name)
static TexPaintSlot * project_paint_face_paint_slot(const ProjPaintState *ps, int tri_index)
void PAINT_OT_image_from_view(wmOperatorType *ot)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
wmOperatorStatus WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message, const bool show_icon)
int isect_point_quad_v2(const float p[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2])
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
static float VecZDepthPersp(const float pt[2], const float v1[4], const float v2[4], const float v3[4], float w[3])
static float screen_px_line_point_factor_v2_persp(const ProjPaintState *ps, const float p[2], const float v1[3], const float v2[3])
bool BLI_rcti_is_empty(const struct rcti *rect)
void paint_brush_exit_tex(Brush *brush)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void BKE_brush_size_set(Paint *paint, Brush *brush, int size)
static void paint_proj_begin_clone(ProjPaintState *ps, const float mouse[2])
float resolve_quad_u_v2(const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2])
const EnumPropertyItem rna_enum_dummy_NULL_items[]
MINLINE void copy_v4_v4_uchar(unsigned char r[4], const unsigned char a[4])
void BKE_image_pool_free(ImagePool *pool)
MINLINE void zero_v3(float r[3])
bool paint_use_opacity_masking(const Paint *paint, const Brush *brush)
void mul_m4_v4(const float mat[4][4], float r[4])
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
static bool project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int bucket_y, const int3 &tri)
bool isect_seg_seg_v2_simple(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
MINLINE bool equals_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
static void project_paint_begin(const bContext *C, ProjPaintState *ps, const bool is_multi_view, const char symmetry_flag)
void BLI_task_pool_free(TaskPool *pool)
static float len_squared_v2v2_alt(const float v1[2], const float v2_1, const float v2_2)
void project_plane_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
bool ED_view3d_clip_range_get(const Depsgraph *depsgraph, const View3D *v3d, const RegionView3D *rv3d, bool use_ortho_factor, float *r_clip_start, float *r_clip_end)
MINLINE void float_to_byte_dither_v3(unsigned char b[3], const float f[3], float dither, int x, int y)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
float BKE_brush_curve_strength_clamped(const Brush *br, float p, float len)
MINLINE void straight_uchar_to_premul_float(float result[4], const unsigned char color[4])
void * BLI_memarena_alloc(MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
static void do_projectpaint_draw(ProjPaintState *ps, ProjPixel *projPixel, const float texrgb[3], float mask, float dither, int u, int v)
static Material * get_or_create_current_material(bContext *C, Object *ob)
void BLI_spin_unlock(SpinLock *spin)
MINLINE float normalize_v3(float n[3])
BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3])
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3(float r[3], const float a[3])
struct bke::bNodeTreeType * ntreeType_Shader
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
int pow_i(int base, int exp)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void BLI_spin_init(SpinLock *spin)
bool ED_view3d_clipping_test(const RegionView3D *rv3d, const float co[3], bool is_local)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
static bool IsectPT2Df_limit(const float pt[2], const float v1[2], const float v2[2], const float v3[2], const float limit)
static void project_paint_prepare_all_faces(ProjPaintState *ps, MemArena *arena, const ProjPaintFaceLookup *face_lookup, ProjPaintLayerClone *layer_clone, const float2 *uv_map_base, const bool is_multi_view)
static void scale_tri(float insetCos[3][3], const float *origCos[3], const float inset)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void _DNA_internal_memzero(void *dst, size_t size)
Main * CTX_data_main(const bContext *C)
static void do_projectpaint_smear(ProjPaintState *ps, ProjPixel *projPixel, float mask, MemArena *smearArena, LinkNode **smearPixels, const float co[2])
ATTR_WARN_UNUSED_RESULT const BMVert * v2
MINLINE void copy_v3_fl(float r[3], float f)
void IMB_byte_from_float(ImBuf *ibuf)
const ImBuf * ED_image_paint_tile_push(PaintTileMap *paint_tile_map, Image *image, ImBuf *ibuf, ImageUser *iuser, int x_tile, int y_tile, unsigned short **r_mask, bool **r_valid)
static bool cmp_uv(const float vec2a[2], const float vec2b[2])
static void default_paint_slot_color_get(int layer_type, Material *ma, float color[4])
static void project_paint_face_init(const ProjPaintState *ps, const int thread_index, const int bucket_index, const int tri_index, const int image_index, const rctf *clip_rect, const rctf *bucket_bounds, ImBuf *ibuf)
void interp_v2_v2v2(float r[2], const float a[2], const float b[2], float t)
Paint * BKE_paint_get_active_from_context(const bContext *C)
void ED_view3d_depth_override(Depsgraph *depsgraph, ARegion *region, View3D *v3d, Object *obact, eV3DDepthOverrideMode mode, bool use_overlay, ViewDepths **r_depths)
@ PAINT_CANVAS_SOURCE_IMAGE
@ PAINT_CANVAS_SOURCE_MATERIAL
@ PAINT_CANVAS_SOURCE_COLOR_ATTRIBUTE
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< StringRef > name)
void paint_delete_blur_kernel(BlurKernel *kernel)
static float project_paint_uvpixel_mask(const ProjPaintState *ps, const int tri_index, const float w[3])
static void screen_px_from_ortho(const float uv[2], const float v1co[3], const float v2co[3], const float v3co[3], const float uv1co[2], const float uv2co[2], const float uv3co[2], float pixelScreenCo[4], float w[3])
static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, const BrushStrokeMode mode, const BrushSwitchMode brush_switch_mode)
bool BKE_image_has_ibuf(Image *ima, ImageUser *iuser)
const EnumPropertyItem rna_enum_color_attribute_domain_items[]
ScrArea * BKE_screen_find_big_area(const bScreen *screen, int spacetype, short min)
static VertSeam * find_adjacent_seam(const ProjPaintState *ps, uint loop_index, uint vert_index, VertSeam **r_seam)
MINLINE float square_f(float a)
float4x4 ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d, const float4x4 &obmat)
IDProperty * IDP_EnsureProperties(ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
std::optional< BrushColorJitterSettings > BKE_brush_color_jitter_get_settings(const Paint *paint, const Brush *brush)
MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const float pt[2]) ATTR_WARN_UNUSED_RESULT
Brush * BKE_paint_brush(Paint *paint)
wmOperatorStatus WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *)
MINLINE int square_s(short a)
static void proj_paint_state_seam_bleed_init(ProjPaintState *ps)
void DEG_relations_tag_update(Main *bmain)
static int line_isect_x(const float p1[2], const float p2[2], const float x_level, float *y_isect)
void ED_paint_data_warning(ReportList *reports, bool has_uvs, bool has_mat, bool has_tex, bool has_stencil)
Scene * CTX_data_scene(const bContext *C)
bScreen * CTX_wm_screen(const bContext *C)
PropertyRNA * RNA_def_string_file_name(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void IMB_blend_color_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4], IMB_BlendMode mode)
void PAINT_OT_add_simple_uvs(wmOperatorType *ot)
MINLINE void copy_v4_v4(float r[4], const float a[4])
ImagePool * BKE_image_pool_new()
MINLINE void mul_v2_v2v2(float r[2], const float a[2], const float b[2])
void paint_proj_stroke_done(void *ps_handle_p, wmPaintCursor *cursor)
static void project_paint_end(ProjPaintState *ps)
static void insert_seam_vert_array(const ProjPaintState *ps, MemArena *arena, const int tri_index, const int fidx1, const int ibuf_x, const int ibuf_y)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
MINLINE float len_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
Material * BKE_material_add(Main *bmain, const char *name)
static int project_paint_pixel_sizeof(const short brush_type)
MINLINE void mul_v4_fl(float r[4], float f)
static void rect_to_uvspace_persp(const rctf *bucket_bounds, const float *v1coSS, const float *v2coSS, const float *v3coSS, const float *uv1co, const float *uv2co, const float *uv3co, float bucket_bounds_uv[4][2], const int flip)
VecBase< float, 3 > float3
BLI_INLINE void IMB_colormanagement_scene_linear_to_srgb_v3(float srgb[3], const float scene_linear[3])
static bool project_image_refresh_tagged(ProjPaintState *ps)
void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3])
float dist_squared_to_line_v2(const float p[2], const float l1[2], const float l2[2])
void BKE_camera_params_init(CameraParams *params)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
MINLINE void mul_v3_v3v3(float r[3], const float v1[3], const float v2[3])
const EnumPropertyItem rna_enum_image_generated_type_items[]
void BLI_thread_unlock(int type)
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
bool ED_operator_object_active_editable_mesh(bContext *C)
Image * BKE_image_add_generated(Main *bmain, unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, const float color[4], bool stereo3d, bool is_data, bool tiled)
static int project_paint_occlude_ptv_clip(const float pt[3], const float v1[4], const float v2[4], const float v3[4], const float v1_3d[3], const float v2_3d[3], const float v3_3d[3], float w[3], const bool is_ortho, RegionView3D *rv3d)
static int get_texture_layer_type(wmOperator *op, const char *prop_name)
void BKE_imageuser_default(ImageUser *iuser)
static bool project_paint_winclip(const ProjPaintState *ps, const ProjPaintFaceCoSS *coSS)
void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3])
static bool pixel_bounds_uv(const float uv_quad[4][2], const int ibuf_x, const int ibuf_y, rcti *r_bounds_px)
MINLINE void premul_float_to_straight_uchar(unsigned char *result, const float color[4])
static ProjPixel * project_paint_uvpixel_init(const ProjPaintState *ps, MemArena *arena, const TileInfo *tinf, int x_px, int y_px, const float mask, const int tri_index, const float pixelScreenCo[4], const float world_spaceCo[3], const float w[3])
void BLI_spin_lock(SpinLock *spin)
static void proj_paint_state_vert_flags_init(ProjPaintState *ps)
static bool project_paint_PickColor(const ProjPaintState *ps, const float pt[2], float *rgba_fp, uchar *rgba, const bool interp)
Object * CTX_data_active_object(const bContext *C)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
static void project_bucket_clip_face(const bool is_ortho, const bool is_flip_object, const rctf *cliprect, const rctf *bucket_bounds, const float *v1coSS, const float *v2coSS, const float *v3coSS, const float *uv1co, const float *uv2co, const float *uv3co, float bucket_bounds_uv[8][2], int *tot, bool cull)
void BLI_task_pool_push(TaskPool *pool, TaskRunFunction run, void *taskdata, bool free_taskdata, TaskFreeFunction freedata)
static void rect_to_uvspace_ortho(const rctf *bucket_bounds, const float *v1coSS, const float *v2coSS, const float *v3coSS, const float *uv1co, const float *uv2co, const float *uv3co, float bucket_bounds_uv[4][2], const int flip)
void set_imapaintpartial(ImagePaintPartialRedraw *ippr)
static const EnumPropertyItem layer_type_items[]
ARegion * CTX_wm_region(const bContext *C)
MINLINE void blend_color_interpolate_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4], float ft)
static void proj_paint_state_screen_coords_init(ProjPaintState *ps, const int diameter)
float BKE_curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value)
static void copy_original_alpha_channel(ProjPaintState *ps, ProjPixel *pixel, bool is_floatbuf)
void IMB_free_float_pixels(ImBuf *ibuf)
static bool project_bucket_iter_next(ProjPaintState *ps, int *bucket_index, rctf *bucket_bounds, const float mval[2])
void BLI_rcti_do_minmax_rcti(struct rcti *rect, const struct rcti *other)
const EnumPropertyItem rna_enum_color_attribute_type_items[]
View3D * CTX_wm_view3d(const bContext *C)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, const float texrgb[3], float mask)
float BKE_brush_alpha_get(const Paint *paint, const Brush *brush)
static void project_bucket_init(const ProjPaintState *ps, const int thread_index, const int bucket_index, const rctf *clip_rect, const rctf *bucket_bounds)
void BLI_thread_lock(int type)
static Material * tex_get_material(const ProjPaintState *ps, int face_i)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
MINLINE void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
ocio::ColorSpace ColorSpace
static void do_projectpaint_mask_f(ProjPaintState *ps, ProjPixel *projPixel, float mask)
void BLI_memarena_free(MemArena *ma) ATTR_NONNULL(1)
void paint_brush_init_tex(Brush *brush)
static void do_projectpaint_soften(ProjPaintState *ps, ProjPixel *projPixel, float mask, MemArena *softenArena, LinkNode **softenPixels)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
void ED_area_tag_redraw(ScrArea *area)
static float compute_seam_normal(VertSeam *seam, VertSeam *adj, float r_no[2])
static bool project_paint_check_face_paintable(const ProjPaintState *ps, const ProjPaintFaceLookup *face_lookup, const int tri_i)
MINLINE void premul_to_straight_v4_v4(float straight[4], const float premul[4])
bool WM_paint_cursor_end(wmPaintCursor *handle)
static void project_paint_bleed_add_face_user(const ProjPaintState *ps, MemArena *arena, const int3 &corner_tri, const int tri_index)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
static bool check_seam(const ProjPaintState *ps, const int orig_face, const int orig_i1_fidx, const int orig_i2_fidx, int *other_face, int *orig_fidx)
MINLINE void rgba_float_args_set(float col[4], float r, float g, float b, float a)
static bool project_paint_clone_face_skip(ProjPaintState *ps, ProjPaintLayerClone *lc, const TexPaintSlot *slot, const int tri_index)
#define PS_CORNER_TRI_AS_UV_3(uvlayer, face_i, tri)
#define PROJ_SRC_VIEW_FILL
#define PROJ_VIEW_DATA_SIZE
#define PROJ_BOUNDBOX_DIV
#define PROJ_GEOM_TOLERANCE
#define PS_CORNER_TRI_ASSIGN_UV_3(uv_tri, uvlayer, face_i, tri)
#define PROJ_SRC_IMAGE_CAM
#define PROJ_FACE_NOSEAM0
#define PROJ_BUCKET_BRUSH_DIV
#define PS_CORNER_TRI_AS_VERT_INDEX_3(ps, tri)
#define PROJ_FACE_SEAM_INIT2
#define PROJ_BUCKET_RECT_MAX
#define PROJ_SRC_IMAGE_VIEW
#define PROJ_FACE_WINDING_INIT
#define PROJ_BUCKET_RECT_MIN
#define PROJ_FACE_WINDING_CW
#define PROJ_PIXEL_TOLERANCE
#define PROJ_VIEW_DATA_ID
#define PROJ_PAINT_STATE_SHARED_CLEAR(ps)
#define PROJ_PAINT_STATE_SHARED_MEMCPY(ps_dst, ps_src)
#define PROJ_BOUNDBOX_SQUARED
#define PROJ_FACE_SEAM_INIT0
#define PROJ_FACE_DEGENERATE
#define PROJ_FACE_SCALE_SEAM
#define PROJ_FACE_SEAM_INIT1
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eBrushImagePaintType image_brush_type
const ColorSpace * colorspace
ImBufByteBuffer byte_buffer
const uint8_t * byte_data() const
uint8_t * byte_data_for_write()
bool colorspace_is_data() const
const float * float_data() const
float * float_data_for_write()
eImagePaint_MissingData missing_data
short screen_grab_size[2]
eMTex_BrushMapMode brush_map_mode
ListBaseT< Image > images
const c_style_mat & ptr() const
char * stencil_uv_map_attribute
char * clone_uv_map_attribute
eObject_TransFlag transflag
struct CurveMapping * cavity_curve
VArray< bool > select_poly_orig
VArray< bool > hide_poly_orig
const int * index_mp_to_orig
volatile const void ** undoRect
float paint_color_byte[3]
ImagePaintPartialRedraw * partRedrawRect
const ColorSpace * byte_colorspace
const TexPaintSlot * slot_clone
const TexPaintSlot * slot_last_clone
const float2 * uv_map_clone_base
Span< float3 > vert_positions_eval
Span< int > corner_tri_faces_eval
const float2 ** poly_to_loop_uv_clone
LoopSeamData * loopSeamData
std::optional< bool > select_poly_single
const bool * select_poly_eval
Span< float3 > vert_normals
const float2 ** poly_to_loop_uv
MemArena * arena_mt[BLENDER_MAX_THREADS]
std::optional< float2 > poly_to_loop_uv_single
const float2 * uv_map_stencil_eval
CurveMapping * cavity_curve
OffsetIndices< int > faces_eval
ListBaseT< VertSeam > * vertSeams
bool reproject_ibuf_free_float
Span< int3 > corner_tris_eval
Span< float3 > corner_normals_eval
bool reproject_ibuf_free_uchar
const bool * hide_poly_eval
Span< int > corner_verts_eval
const int * material_indices
BrushSwitchMode brush_switch_mode
float paint_color_linear[3]
ProjPaintImage * projImages
float projectMatInv[4][4]
bool do_layer_stencil_inv
float normal_angle_inner__cos
std::optional< bool > hide_poly_single
std::optional< int > material_index_single
ProjPaintState * ps_views[8]
std::optional< float3 > initial_hsv_jitter
bool is_clone_cursor_pick
ProjPaintImage * projImages
struct ToolSettings * toolsettings
ListBaseT< SpaceLink > spacedata
float texture_paint_mode_opacity
void use_property_decorate_set(bool is_decorate)
void use_property_split_set(bool is_sep)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
Layout & column(bool align)
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(*) ui(bContext *C, wmOperator *op)
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
struct wmOperatorType * type