137 "Map UVs taking aspect ratio of the image associated with the material into account");
231 bool subsurf =
options->use_subsurf;
254 *r_use_subsurf = subsurf;
262 options.topology_from_uvs =
false;
263 options.topology_from_uvs_use_seams =
false;
264 options.only_selected_faces =
false;
265 options.only_selected_uvs =
false;
266 options.pin_unselected =
false;
268 options.slim.skip_init =
false;
269 options.use_original_bounds =
false;
308 if (
options.weight_group[0] ==
'\0' ||
options.use_weights ==
false) {
309 options.slim.weight_influence = 0.0f;
321 bool use_subsurf_final;
323 options.use_subsurf = use_subsurf_final;
336 PointerRNA *ptr,
const char *prop_name,
T flag,
bool flipped,
T *value_p)
372 int value_i = int(*value_p);
374 *value_p =
T(value_i);
453 if (offsets.
uv == -1) {
475 if (
options->only_selected_uvs && !
l) {
489 bool have_select =
false;
490 for (
Object *obedit : objects) {
501 const int material_index,
505 if (material_index < 0 || material_index >= ob->
totcol) [[unlikely]] {
520 bool selected =
false;
535 return aspect[0] / aspect[1];
552 if (
options->only_selected_uvs) {
579 if (
options->pin_unselected && !pin) {
597 const int cd_weight_offset,
598 const int cd_weight_index)
627 if (cd_weight_offset >= 0 && cd_weight_index >= 0) {
652 if (
options->topology_from_uvs && !
options->topology_from_uvs_use_seams) {
657 if (offsets.
uv == -1) {
692 int *r_count_failed =
nullptr)
721 handle, scene,
bm, efa, i,
options, offsets, cd_weight_offset, cd_weight_index);
728 handle,
options->fill_holes,
options->topology_from_uvs, r_count_failed);
756 for (
Object *obedit : objects) {
759 if (offsets.
uv == -1) {
792 handle,
options->fill_holes,
options->topology_from_uvs,
nullptr);
831 bm,
nullptr, id_cast<const Mesh *>(
object->data));
840 if (settings.
level == 1) {
866 int *r_count_failed =
nullptr)
900 const Span<float3> subsurf_positions = subdiv_mesh->vert_positions();
901 const Span<int2> subsurf_edges = subdiv_mesh->edges();
903 const Span<int> subsurf_corner_verts = subdiv_mesh->corner_verts();
906 const int *origVertIndices =
static_cast<const int *
>(
908 const int *origEdgeIndices =
static_cast<const int *
>(
910 const int *origPolyIndices =
static_cast<const int *
>(
919 for (
int i = 0; i < subdiv_mesh->
faces_num; i++) {
926 for (
int i = 0; i < subdiv_mesh->
edges_num; i++) {
955 const Span<int> poly_corner_verts = subsurf_corner_verts.
slice(subsurf_facess[i]);
960 vkeys[0] =
ParamKey(poly_corner_verts[0]);
961 vkeys[1] =
ParamKey(poly_corner_verts[1]);
962 vkeys[2] =
ParamKey(poly_corner_verts[2]);
963 vkeys[3] =
ParamKey(poly_corner_verts[3]);
965 co[0] = subsurf_positions[poly_corner_verts[0]];
966 co[1] = subsurf_positions[poly_corner_verts[1]];
967 co[2] = subsurf_positions[poly_corner_verts[2]];
968 co[3] = subsurf_positions[poly_corner_verts[3]];
971 if (cd_weight_index >= 0) {
995 origVertIndices[poly_corner_verts[0]],
1003 origVertIndices[poly_corner_verts[1]],
1011 origVertIndices[poly_corner_verts[2]],
1019 origVertIndices[poly_corner_verts[3]],
1030 const int2 &edge = subsurf_edges[i];
1039 handle,
options->fill_holes,
options->topology_from_uvs, r_count_failed);
1043 MEM_delete(edgeMap);
1072 options.topology_from_uvs =
true;
1074 options.only_selected_faces =
true;
1075 options.only_selected_uvs =
true;
1076 options.correct_aspect =
true;
1085 MinStretch *ms = MEM_new<MinStretch>(__func__);
1095 if (ms->
blend != 0.0f) {
1191 for (i = 0; i < iterations; i++) {
1220 switch (event->
type) {
1233 if (ms->
blend < 0.95f) {
1244 if (ms->
blend > 0.05f) {
1282 ot->
name =
"Minimize Stretch";
1283 ot->
idname =
"UV_OT_minimize_stretch";
1285 ot->
description =
"Reduce UV stretching by relaxing angles";
1299 "Virtually fill holes in mesh before unwrapping, to better avoid overlaps and "
1300 "preserve symmetry");
1307 "Blend factor between stretch minimized and original",
1316 "Number of iterations to run, 0 is unlimited when run interactively",
1324 const float matrix[2][2],
1325 const float pre_translate[2]
1339 const int cd_loop_uv_offset = island->
offsets.
uv;
1340 const int faces_len = island->
faces_len;
1341 for (
int i = 0; i < faces_len; i++) {
1356 const float coords[2],
1357 float nearest_tile_co[2])
1362 float nearest_tile_center_co[2] = {nearest_tile_co[0], nearest_tile_co[1]};
1363 add_v2_fl(nearest_tile_center_co, 0.5f);
1372 const float coords[2],
1373 float nearest_tile_co[2])
1375 const float coords_floor[2] = {
floorf(coords[0]),
floorf(coords[1])};
1377 if (coords[0] > udim_grid[0]) {
1378 nearest_tile_co[0] = udim_grid[0] - 1;
1380 else if (coords[0] < 0) {
1381 nearest_tile_co[0] = 0;
1384 nearest_tile_co[0] = coords_floor[0];
1387 if (coords[1] > udim_grid[1]) {
1388 nearest_tile_co[1] = udim_grid[1] - 1;
1390 else if (coords[1] < 0) {
1391 nearest_tile_co[1] = 0;
1394 nearest_tile_co[1] = coords_floor[1];
1398 float nearest_tile_center_co[2] = {nearest_tile_co[0], nearest_tile_co[1]};
1399 add_v2_fl(nearest_tile_center_co, 0.5f);
1414 for (
int i = 0; i < island->
faces_len; i++) {
1446 BMesh **bmesh_override,
1448 const bool original_selection,
1449 const bool notify_wm,
1450 const rctf *custom_region,
1456 for (
const int ob_index : objects.
index_range()) {
1457 Object *obedit = objects[ob_index];
1459 if (bmesh_override) {
1461 bm = bmesh_override[ob_index];
1469 if (offsets.
uv == -1) {
1479 only_selected_faces =
false;
1480 only_selected_uvs =
false;
1482 ListBaseT<FaceIsland> island_list = {
nullptr};
1486 only_selected_faces,
1493 for (
FaceIsland &island : island_list.items_mutable()) {
1496 if (ignore_pinned && pinned) {
1497 MEM_delete(island.faces);
1498 MEM_delete(&island);
1501 island_vector.
append(&island);
1502 pinned_vector.
append(pinned);
1511 float selection_min_co[2], selection_max_co[2];
1517 for (
int i = 0; i < island->
faces_len; i++) {
1524 float selection_center[2];
1525 mid_v2_v2v2(selection_center, selection_min_co, selection_max_co);
1527 if (original_selection) {
1529 if ((selection_max_co[0] - selection_min_co[0]) * (selection_max_co[1] - selection_min_co[1]) >
1533 params->
target_extent = selection_max_co[1] - selection_min_co[1];
1534 params->
target_aspect_y = (selection_max_co[0] - selection_min_co[0]) /
1535 (selection_max_co[1] - selection_min_co[1]);
1538 else if (custom_region) {
1540 const float2 custom_region_size = {
1546 params->
target_aspect_y = custom_region_size.x / custom_region_size.y;
1554 for (
int i = 0; i < island_vector.
size(); i++) {
1559 pack_island->
pinned = pinned_vector[i];
1560 pack_island_vector.
append(pack_island);
1562 for (
int i = 0; i < face_island->
faces_len; i++) {
1587 float base_offset[2] = {0.0f, 0.0f};
1590 if (udim_source_closest) {
1595 if (is_valid_udim) {
1596 base_offset[0] =
floorf(selection_center[0]);
1597 base_offset[1] =
floorf(selection_center[1]);
1602 float nearest_image_tile_dist =
FLT_MAX, nearest_grid_tile_dist =
FLT_MAX;
1605 image, selection_center, nearest_image_tile_co);
1608 float nearest_grid_tile_co[2] = {0.0f, 0.0f};
1610 udim_grid, selection_center, nearest_grid_tile_co);
1612 base_offset[0] = (nearest_image_tile_dist < nearest_grid_tile_dist) ?
1613 nearest_image_tile_co[0] :
1614 nearest_grid_tile_co[0];
1615 base_offset[1] = (nearest_image_tile_dist < nearest_grid_tile_dist) ?
1616 nearest_image_tile_co[1] :
1617 nearest_grid_tile_co[1];
1622 float matrix_inverse[2][2];
1623 float pre_translate[2];
1630 const float island_scale = pack_island->
can_scale_(*params) ?
scale : 1.0f;
1636 mul_v2_m2v2(pre_translate, matrix_inverse, base_offset);
1650 pack_island_vector[i] =
nullptr;
1654 if (notify_wm && !is_cancelled) {
1655 for (
Object *obedit : objects) {
1662 MEM_delete(island->faces);
1754 options.topology_from_uvs =
true;
1755 options.only_selected_faces =
true;
1756 options.only_selected_uvs =
true;
1758 options.correct_aspect =
true;
1780 pid->
objects = std::move(objects);
1802 pack_island_params = default_params;
1869 "Use scale of existing UVs to multiply margin"},
1875 "Specify a precise fraction of final UV output"},
1876 {0,
nullptr, 0,
nullptr,
nullptr},
1885 "Only 90 degree rotations are allowed"},
1888#define PACK_ROTATE_METHOD_AXIS_ALIGNED_OFFSET 3
1893 "Rotated to a minimal rectangle, either vertical or horizontal"},
1897 "Axis-aligned (Horizontal)",
1898 "Rotate islands to be aligned horizontally"},
1902 "Axis-aligned (Vertical)",
1903 "Rotate islands to be aligned vertically"},
1904 {0,
nullptr, 0,
nullptr,
nullptr},
1912 {0,
nullptr, 0,
nullptr,
nullptr},
1927 "Rotation and Scale",
1928 "Pinned islands will translate only"},
1930 {0,
nullptr, 0,
nullptr,
nullptr},
1975 "Pack islands to active UDIM image tile or UDIM grid tile where 2D cursor is located"},
1979 "Original bounding box",
1980 "Pack to starting bounding box of islands"},
1981 {
PACK_CUSTOM_REGION,
"CUSTOM_REGION", 0,
"Custom Region",
"Pack islands to custom region"},
1982 {0,
nullptr, 0,
nullptr,
nullptr},
1985 ot->
name =
"Pack Islands";
1986 ot->
idname =
"UV_OT_pack_islands";
1988 "Transform all islands so that they fill up the UV/UDIM space as much as possible";
1990#ifdef USE_INTERACTIVE_PACK
2000#ifdef USE_INTERACTIVE_PACK
2019 ot->
srna,
"merge_overlap",
false,
"Merge Overlapping",
"Overlapping islands stick together");
2027 ot->
srna,
"margin", 0.001f, 0.0f, 1.0f,
"Margin",
"Space between islands", 0.0f, 1.0f);
2031 "Lock Pinned Islands",
2032 "Constrain islands containing any pinned UV's");
2062 options.topology_from_uvs =
true;
2063 options.only_selected_faces =
true;
2064 options.only_selected_uvs =
true;
2066 options.correct_aspect =
true;
2084 for (
Object *obedit : objects) {
2099 ot->
name =
"Average Islands Scale";
2100 ot->
idname =
"UV_OT_average_islands_scale";
2101 ot->
description =
"Average the size of separate UV islands, based on their area in 3D space";
2110 RNA_def_boolean(ot->
srna,
"scale_uv",
false,
"Non-Uniform",
"Scale U and V independently");
2159 options.topology_from_uvs =
false;
2160 options.only_selected_faces =
false;
2161 options.only_selected_uvs =
false;
2172 options.slim.skip_init =
true;
2259#define VIEW_ON_EQUATOR 0
2260#define VIEW_ON_POLES 1
2261#define ALIGN_TO_OBJECT 2
2287 uint center_accum_num = 0;
2294 center_accum_num += 1;
2297 mul_v3_fl(r_center, 1.0f /
float(center_accum_num));
2305 float r_bounds[2][3])
2313 bool is_minmax_set =
false;
2319 is_minmax_set =
true;
2349 if (!is_minmax_set) {
2363 const float offset[4])
2365 float rotup[4][4], rotside[4][4], viewmatrix[4][4], rotobj[4][4];
2366 float sideangle = 0.0f, upangle = 0.0f;
2380 copy_m4_m4(rotobj, ob->object_to_world().ptr());
2385 rotobj[3][3] = 0.0f;
2393 sideangle =
float(
M_PI) * (sideangledeg + 180.0f) / 180.0f;
2394 rotside[0][0] =
cosf(sideangle);
2395 rotside[0][1] = -
sinf(sideangle);
2396 rotside[1][0] =
sinf(sideangle);
2397 rotside[1][1] =
cosf(sideangle);
2398 rotside[2][2] = 1.0f;
2400 upangle =
float(
M_PI) * upangledeg / 180.0f;
2401 rotup[1][1] =
cosf(upangle) / radius;
2402 rotup[1][2] = -
sinf(upangle) / radius;
2403 rotup[2][1] =
sinf(upangle) / radius;
2404 rotup[2][2] =
cosf(upangle) / radius;
2405 rotup[0][0] = 1.0f / radius;
2427 rotmat[0][0] = 0.0f;
2428 rotmat[0][1] = 1.0f;
2429 rotmat[1][0] = -1.0f;
2430 rotmat[1][1] = 0.0f;
2435 const float up_angle_deg = (direction ==
VIEW_ON_EQUATOR) ? 90.0f : 0.0f;
2438 const float offset[4] = {0};
2439 float rotmat4[4][4];
2447 {
VIEW_ON_EQUATOR,
"VIEW_ON_EQUATOR", 0,
"View on Equator",
"3D view is on the equator"},
2448 {
VIEW_ON_POLES,
"VIEW_ON_POLES", 0,
"View on Poles",
"3D view is on the poles"},
2453 "Align according to object transform"},
2454 {0,
nullptr, 0,
nullptr,
nullptr},
2457 {
POLAR_ZX,
"POLAR_ZX", 0,
"Polar ZX",
"Polar 0 is X"},
2458 {
POLAR_ZY,
"POLAR_ZY", 0,
"Polar ZY",
"Polar 0 is Y"},
2459 {0,
nullptr, 0,
nullptr,
nullptr},
2463 {
PINCH,
"PINCH", 0,
"Pinch",
"UVs are pinched at the poles"},
2464 {
FAN,
"FAN", 0,
"Fan",
"UVs are fanned at the poles"},
2465 {0,
nullptr, 0,
nullptr,
nullptr},
2473 "Direction of the sphere or cylinder");
2479 "How to determine rotation around the pole");
2485 "Separate projections by islands isolated by seams");
2494 "Radius of the sphere or cylinder",
2501 const int cd_loop_uv_offset,
2502 const float aspect_y)
2511 if (aspect_y > 1.0f) {
2513 luv[0] = luv[0] / aspect_y + (0.5f - 0.5f / aspect_y);
2517 luv[1] = luv[1] * aspect_y + (0.5f - 0.5f * aspect_y);
2526 if (aspect_y == 1.0f) {
2541 const int materials_num = ob->
totcol;
2542 if (materials_num == 0) {
2559 const int material_index = efa->
mat_nr;
2560 if (material_index < 0 || material_index >= materials_num) [[unlikely]] {
2565 float aspect_y = material_aspect_y[material_index];
2566 if (aspect_y == -1.0f) {
2570 aspect_y = aspx / aspy;
2571 material_aspect_y[material_index] = aspect_y;
2574 if (aspect_y == 1.0f) {
2582#undef VIEW_ON_EQUATOR
2584#undef ALIGN_TO_OBJECT
2599 if (clip_to_bounds) {
2604 "Clip UV coordinates to bounds after unwrapping");
2610 "Scale UV coordinates to bounds after unwrapping");
2628 bool per_face_aspect,
2629 bool only_selected_uvs)
2634 float dx, dy,
min[2],
max[2];
2642 for (
Object *ob : objects) {
2647 if (correct_aspect) {
2648 if (per_face_aspect) {
2656 if (scale_to_bounds) {
2673 else if (clip_to_bounds) {
2692 if (scale_to_bounds) {
2704 if (dx == 1.0f && dy == 1.0f &&
min[0] == 0.0f &&
min[1] == 0.0f) {
2709 for (
Object *ob : objects) {
2725 luv[0] = (luv[0] -
min[0]) * dx;
2726 luv[1] = (luv[1] -
min[1]) * dy;
2743 int *r_count_changed,
2744 int *r_count_failed)
2764 handle, &
options->slim,
options->use_original_bounds, r_count_changed, r_count_failed);
2772 if (
options->use_original_bounds) {
2787 int *r_count_changed =
nullptr,
2788 int *r_count_failed =
nullptr)
2790 for (
Object *obedit : objects) {
2801 options.topology_from_uvs =
false;
2802 options.only_selected_faces =
false;
2803 options.only_selected_uvs =
false;
2815 scene, objects,
nullptr,
nullptr,
false,
true,
nullptr, &pack_island_params);
2831 int reported_errors = 0;
2839 options.topology_from_uvs =
false;
2840 options.only_selected_faces =
true;
2841 options.only_selected_uvs =
false;
2845 bool subsurf_error =
options.use_subsurf;
2849 if (sync_selection) {
2853 options.only_selected_faces =
false;
2855 options.only_selected_uvs =
true;
2856 options.pin_unselected =
true;
2864 for (
Object *obedit : objects) {
2866 bool use_subsurf_final;
2872 if (subsurf_error) {
2876 if (use_subsurf_final) {
2877 subsurf_error =
false;
2886 if (!(
fabsf(obsize[0] - obsize[1]) < 1e-4f &&
fabsf(obsize[1] - obsize[2]) < 1e-4f)) {
2890 "Object has non-uniform scale, unwrap will operate on a non-scaled version of "
2900 "Object has negative scale, unwrap will operate on a non-flipped version of the mesh");
2906 if (subsurf_error) {
2909 "Subdivision Surface modifier needs to be first to work with unwrap");
2913 int count_changed = 0;
2914 int count_failed = 0;
2916 if (
options.use_original_bounds) {
2920 options.use_original_bounds =
false;
2932 if (!
options.use_original_bounds) {
2934 scene, objects,
nullptr,
nullptr,
false,
true,
nullptr, &pack_island_params);
2937 if (count_failed == 0 && count_changed == 0) {
2940 "Unwrap could not solve any island(s), edge seams may need to be added");
2942 else if (count_failed) {
2945 "Unwrap failed to solve %d of %d island(s), edge seams may need to be added",
2947 count_changed + count_failed);
2975 col = &layout.
column(
true);
2985 col->
prop(&ptr,
"use_subsurf_data",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
2986 col->
prop(&ptr,
"use_original_bounds",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
3004 tool_settings_default_uvcalc_weight_group[
sizeof(tool_settings_default.
uvcalc_weight_group)];
3005 STRNCPY_UTF8(tool_settings_default_uvcalc_weight_group,
3012 {0,
nullptr, 0,
nullptr,
nullptr},
3016 ot->
name =
"Unwrap";
3017 ot->
description =
"Unwrap the mesh of the object being edited";
3018 ot->
idname =
"UV_OT_unwrap";
3035 "Unwrapping method (Angle Based usually gives better results than Conformal, while "
3036 "being somewhat slower)");
3041 "Virtually fill holes in mesh before unwrapping, to better avoid overlaps and "
3042 "preserve symmetry");
3050 "Use Subdivision Surface",
3051 "Map UVs taking vertex position after Subdivision Surface modifier has been applied");
3053 "use_original_bounds",
3056 "Unwrap islands into their original bounds, instead of re-packing");
3065 ot->
srna,
"margin", 0.001f, 0.0f, 1.0f,
"Margin",
"Space between islands", 0.0f, 1.0f);
3072 "Prevent flipping UV's, "
3073 "flipping may lower distortion depending on the position of pins");
3081 "Number of iterations when \"Minimum Stretch\" method is used",
3088 "Importance Weights",
3089 "Whether to take into account per-vertex importance weights");
3092 tool_settings_default_uvcalc_weight_group,
3095 "Vertex group name for importance weights (modulating the deform)");
3103 "How much influence the weightmap has for weighted parameterization, 0 being no influence",
3146 const uint thick_faces_len,
3148 const float project_angle_limit_half_cos,
3149 const float project_angle_limit_cos,
3150 const float area_weight)
3152 if (thick_faces_len == 0) [[unlikely]] {
3156 const float *project_normal = thick_faces[0].
efa->
no;
3164 for (
int f_index = thick_faces_len - 1; f_index >= 0; f_index--) {
3169 if (
dot_v3v3(thick_faces[f_index].efa->no, project_normal) > project_angle_limit_half_cos) {
3170 project_thick_faces.
append(&thick_faces[f_index]);
3175 float average_normal[3] = {0.0f, 0.0f, 0.0f};
3177 if (area_weight <= 0.0f) {
3178 for (
int f_proj_index = 0; f_proj_index < project_thick_faces.
size(); f_proj_index++) {
3179 const ThickFace *tf = project_thick_faces[f_proj_index];
3183 else if (area_weight >= 1.0f) {
3184 for (
int f_proj_index = 0; f_proj_index < project_thick_faces.
size(); f_proj_index++) {
3185 const ThickFace *tf = project_thick_faces[f_proj_index];
3190 for (
int f_proj_index = 0; f_proj_index < project_thick_faces.
size(); f_proj_index++) {
3191 const ThickFace *tf = project_thick_faces[f_proj_index];
3192 const float area_blend = (tf->
area * area_weight) + (1.0f - area_weight);
3199 project_normal_array.
append(average_normal);
3203 float anble_best = 1.0f;
3204 uint angle_best_index = 0;
3206 for (
int f_index = thick_faces_len - 1; f_index >= 0; f_index--) {
3211 float angle_test = -1.0f;
3212 for (
int p_index = 0; p_index < project_normal_array.
size(); p_index++) {
3213 angle_test =
max_ff(angle_test,
3214 dot_v3v3(project_normal_array[p_index], thick_faces[f_index].efa->no));
3217 if (angle_test < anble_best) {
3218 anble_best = angle_test;
3219 angle_best_index = f_index;
3223 if (anble_best < project_angle_limit_cos) {
3224 project_normal = thick_faces[angle_best_index].
efa->
no;
3225 project_thick_faces.
clear();
3226 project_thick_faces.
append(&thick_faces[angle_best_index]);
3230 if (project_normal_array.
size() >= 1) {
3238 return project_normal_array;
3250 bool only_selected_uvs =
false;
3253 only_selected_uvs =
true;
3260 const float project_angle_limit_cos =
cosf(project_angle_limit);
3261 const float project_angle_limit_half_cos =
cosf(project_angle_limit / 2);
3267 *bmain, scene, view_layer, v3d);
3274 for (
const int ob_index : objects.
index_range()) {
3275 Object *obedit = objects[ob_index];
3277 bool changed =
false;
3287 uint thick_faces_len = 0;
3293 if (only_selected_uvs) {
3301 thick_faces[thick_faces_len].
efa = efa;
3308 while ((thick_faces_len > 0) &&
3321 thick_faces_len -= 1;
3328 project_angle_limit_half_cos,
3329 project_angle_limit_cos,
3332 if (project_normal_array.
is_empty()) {
3333 MEM_delete(thick_faces);
3339 project_normal_array.
size(), __func__);
3343 for (
int f_index = thick_faces_len - 1; f_index >= 0; f_index--) {
3344 const float *f_normal = thick_faces[f_index].
efa->
no;
3346 float angle_best =
dot_v3v3(f_normal, project_normal_array[0]);
3347 uint angle_best_index = 0;
3349 for (
int p_index = 1; p_index < project_normal_array.
size(); p_index++) {
3350 const float angle_test =
dot_v3v3(f_normal, project_normal_array[p_index]);
3351 if (angle_test > angle_best) {
3352 angle_best = angle_test;
3353 angle_best_index = p_index;
3358 &thickface_project_groups[angle_best_index], &thick_faces[f_index], arena);
3361 for (
int p_index = 0; p_index < project_normal_array.
size(); p_index++) {
3362 if (thickface_project_groups[p_index] ==
nullptr) {
3366 float axis_mat[3][3];
3381 MEM_delete(thick_faces);
3384 MEM_delete(thickface_project_groups);
3387 objects_changed.
append(obedit);
3411 scene, objects_changed,
nullptr,
nullptr,
false,
true,
nullptr, ¶ms);
3414 const bool per_face_aspect =
false;
3424 C, op, event,
IFACE_(
"Smart UV Project"),
IFACE_(
"Unwrap"));
3432 ot->
name =
"Smart UV Project";
3433 ot->
idname =
"UV_OT_smart_project";
3434 ot->
description =
"Projection unwraps the selected faces of mesh objects";
3451 "Lower for more projection groups, higher for less distortion",
3476 "Margin to reduce bleed from adjacent islands",
3485 "Weight projection's vector by faces with larger areas",
3533 float objects_pos_offset[4];
3539 *bmain, scene, view_layer, v3d);
3541 if (use_orthographic) {
3543 float objects_pos_avg[4] = {0};
3545 for (
Object *
object : objects) {
3549 mul_v4_fl(objects_pos_avg, 1.0f / objects.size());
3556 for (
Object *obedit : objects) {
3558 bool changed =
false;
3570 depsgraph, scene_eval, obedit_eval, vert_positions_storage);
3576 if (use_orthographic) {
3586 const float *v_co = vert_positions.
is_empty() ?
3598 obedit->object_to_world().ptr(),
3599 camera_bounds ? (scene->
r.
xsch * scene->
r.
xasp) : 1.0f,
3600 camera_bounds ? (scene->
r.
ysch * scene->
r.
yasp) : 1.0f);
3610 const float *v_co = vert_positions.
is_empty() ?
3622 copy_m4_m4(rotmat, obedit->object_to_world().ptr());
3631 const float *v_co = vert_positions.
is_empty() ?
3641 changed_objects.
append(obedit);
3651 const bool per_face_aspect =
true;
3652 const bool only_selected_uvs =
false;
3665 return (rv3d !=
nullptr);
3671 ot->
name =
"Project from View";
3672 ot->
idname =
"UV_OT_project_from_view";
3673 ot->
description =
"Project the UV vertices of the mesh as seen in current 3D view";
3683 RNA_def_boolean(ot->
srna,
"orthographic",
false,
"Orthographic",
"Use orthographic projection");
3688 "Map UVs to the camera region taking resolution and aspect into account");
3706 *bmain, scene, view_layer, v3d);
3707 for (
Object *obedit : objects) {
3708 Mesh *
mesh = id_cast<Mesh *>(obedit->data);
3732 ot->
idname =
"UV_OT_reset";
3749 const bool *regular,
3751 const int cd_loop_uv_offset)
3765 float right_u = -1.0e30f;
3773 if (luv[0] >= 1.0f) {
3776 right_u =
max_ff(right_u, luv[0]);
3779 float left_u = 1.0e30f;
3782 if (right_u <= luv[0] + 0.5f) {
3783 left_u =
min_ff(left_u, luv[0]);
3789 if (luv[0] + 0.5f < right_u) {
3790 if (2 * luv[0] + 1.0f < left_u + right_u) {
3804 float minmax_u[2] = {1.0e30f, -1.0e30f};
3806 for (
int i = 0; i < efa->
len; i++) {
3808 minmax_u[0] =
min_ff(minmax_u[0], uvs[i][0]);
3809 minmax_u[1] =
max_ff(minmax_u[1], uvs[i][0]);
3815 if (
ELEM(pole_count, 0, efa->
len)) {
3818 for (
int i = 0; i < efa->
len; i++) {
3824 const int i_plus = (i + 1) % efa->
len;
3825 const int i_minus = (i + efa->
len - 1) % efa->
len;
3826 if (regular[i_plus]) {
3827 u += uvs[i_plus][0];
3830 if (regular[i_minus]) {
3831 u += uvs[i_minus][0];
3835 u += minmax_u[0] + minmax_u[1];
3838 uvs[i][0] = u / sum;
3873 const float center[3],
3874 const float rotmat[3][3],
3877 const bool only_selected_uvs,
3878 const bool use_seams,
3879 const float branch_init)
3888 stack.
append({efa_init, branch_init});
3890 while (stack.
size()) {
3906 if (only_selected_uvs) {
3924 regular[i] =
map_to_sphere(&luv[0], &luv[1], pv[0], pv[1], pv[2]);
3930 luv[0] = luv[0] +
ceilf(face_branch.
branch - 0.5f - luv[0]);
3931 max_u =
max_ff(max_u, luv[0]);
3943 stack.
append({efa2, luv[0]});
3959 bool only_selected_uvs =
false;
3962 only_selected_uvs =
true;
3967 *bmain, scene, view_layer, v3d);
3968 for (
Object *obedit : objects) {
3983 float center[3], rotmat[3][3];
3995 float island_offset = 0.0f;
4006 island_offset + 0.5f);
4007 island_offset =
ceilf(
max_ff(max_u, island_offset));
4010 const bool per_face_aspect =
true;
4023 ot->
name =
"Sphere Projection";
4024 ot->
idname =
"UV_OT_sphere_project";
4025 ot->
description =
"Project the UV vertices of the mesh over the curved surface of a sphere";
4048 const float center[3],
4049 const float rotmat[3][3],
4052 const bool only_selected_uvs,
4053 const bool use_seams,
4054 const float branch_init)
4065 stack.
append({efa_init, branch_init});
4067 while (stack.
size()) {
4083 if (only_selected_uvs) {
4101 regular[i] =
map_to_tube(&luv[0], &luv[1], pv[0], pv[1], pv[2]);
4108 luv[0] = luv[0] +
ceilf(face_branch.
branch - 0.5f - luv[0]);
4109 max_u =
max_ff(max_u, luv[0]);
4121 stack.
append({efa2, luv[0]});
4138 bool only_selected_uvs =
false;
4141 only_selected_uvs =
true;
4146 *bmain, scene, view_layer, v3d);
4147 for (
Object *obedit : objects) {
4162 float center[3], rotmat[3][3];
4174 float island_offset = 0.0f;
4195 island_offset + 0.5f);
4196 island_offset =
ceilf(
max_ff(max_u, island_offset));
4199 const bool per_face_aspect =
true;
4212 ot->
name =
"Cylinder Projection";
4213 ot->
idname =
"UV_OT_cylinder_project";
4214 ot->
description =
"Project the UV vertices of the mesh over the curved wall of a cylinder";
4236 const bool use_select,
4237 const bool only_selected_uvs,
4238 const float center[3])
4255 if (cube_size == 0.0f) [[unlikely]] {
4275 luv[0] = 0.5f + ((
l->
v->
co[cox] - loc[cox]) / cube_size);
4276 luv[1] = 0.5f + ((
l->
v->
co[coy] - loc[coy]) / cube_size);
4287 bool only_selected_uvs =
false;
4290 only_selected_uvs =
true;
4298 *bmain, scene, view_layer, v3d);
4299 for (
const int ob_index : objects.
index_range()) {
4300 Object *obedit = objects[ob_index];
4312 float (*bounds_buf)[3] =
nullptr;
4322 float cube_size = cube_size_init;
4326 cube_size = std::max({
UNPACK3(dims)});
4327 if (ob_index == 0) {
4335 const bool per_face_aspect =
true;
4348 ot->
name =
"Cube Projection";
4349 ot->
idname =
"UV_OT_cube_project";
4350 ot->
description =
"Project the UV vertices of the mesh over the six faces of a cube";
4365 "Size of the cube to project on",
4422 if (sync_selection) {
CustomData interface, see also DNA_customdata_types.h.
#define mul_m4_series(...)
#define BLI_MEMARENA_STD_BUFSIZE
#define SNPRINTF_UTF8(dst, format,...)
#define STRNCPY_UTF8(dst, src)
Platform independent time functions.
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define RNA_ENUM_ITEM_SEPR
#define INIT_MINMAX2(min, max)
#define INIT_MINMAX(min, max)
#define BLI_assert_unreachable()
#define ARRAY_SET_ITEMS(...)
#define BM_ELEM_CD_GET_BOOL(ele, offset)
#define BM_ELEM_SELECT_UV_EDGE
#define BM_ELEM_CD_GET_FLOAT_P(ele, offset)
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
#define BM_elem_index_get(ele)
#define BM_elem_flag_set(ele, hflag, val)
#define BM_elem_flag_test(ele, hflag)
#define BM_elem_flag_enable(ele, hflag)
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar)
#define BM_ITER_ELEM_INDEX(ele, iter, data, itype, indexvar)
#define MEM_realloc_uninitialized(vmemh, len)
constexpr Span slice(int64_t start, int64_t size) const
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
void append(const T &value)
IndexRange index_range() const
bool can_scale_(const UVPackIsland_Params ¶ms) const
void add_polygon(Span< float2 > uvs, MemArena *arena, Heap *heap)
void build_transformation(float scale, double angle, float r_matrix[2][2]) const
eUVPackIsland_RotationMethod rotate_method
eUVPackIsland_MarginMethod margin_method
eUVPackIsland_ShapeMethod shape_method
void setUDIMOffsetFromSpaceImage(const SpaceImage *sima)
eUVPackIsland_PinMethod pin_method
void setFromUnwrapOptions(const UnwrapOptions &options)
float udim_base_offset[2]
IndexRange index_range() const
CCL_NAMESPACE_BEGIN struct Options options
void camera(KernelGlobals &kg, const ShadingData &sd, float3 &outview, float &outdepth, float &outdist)
float3x3 scale(float3x3 mat, float2 scale)
void free(Subdiv *subdiv)
Subdiv * new_from_mesh(const Settings *settings, const Mesh *mesh)
Mesh * subdiv_to_mesh(Subdiv *subdiv, const ToMeshSettings *settings, const Mesh *coarse_mesh)
bool uv_parametrizer_is_slim(const ParamHandle *phandle)
void uv_parametrizer_construct_end(ParamHandle *phandle, bool fill_holes, bool topology_from_uvs, int *r_count_failed=nullptr)
void uv_parametrizer_edge_set_seam(ParamHandle *phandle, const ParamKey *vkeys)
void uv_parametrizer_average(ParamHandle *handle, bool ignore_pinned, bool scale_uv, bool shear)
void uv_parametrizer_flush(ParamHandle *handle)
void uv_parametrizer_lscm_begin(ParamHandle *handle, bool live, bool abf, bool use_original_bounds)
void uv_parametrizer_slim_live_begin(ParamHandle *phandle, const ParamSlimOptions *slim_options)
void uv_parametrizer_slim_live_solve_iteration(ParamHandle *phandle)
ParamKey uv_find_pin_index(ParamHandle *handle, const int bmvertindex, const float uv[2])
void uv_prepare_pin_index(ParamHandle *handle, const int bmvertindex, const float uv[2])
void uv_parametrizer_slim_live_end(ParamHandle *phandle)
void uv_parametrizer_stretch_blend(ParamHandle *handle, float blend)
void mul_v2_m2_add_v2v2(float r[2], const float mat[2][2], const float a[2], const float b[2])
void uv_parametrizer_lscm_end(ParamHandle *handle)
void uv_parametrizer_aspect_ratio(ParamHandle *handle, float aspect_y)
void uv_parametrizer_stretch_begin(ParamHandle *handle)
void uv_parametrizer_flush_restore(ParamHandle *handle)
float pack_islands(Span< PackIsland * > islands, const UVPackIsland_Params ¶ms)
void uv_parametrizer_lscm_solve(ParamHandle *handle, int *count_changed, int *count_failed)
void uv_parametrizer_stretch_iter(ParamHandle *handle)
void uv_parametrizer_slim_solve(ParamHandle *phandle, const ParamSlimOptions *slim_options, bool use_original_bounds, int *count_changed, int *count_failed)
void uv_parametrizer_original_bounds(ParamHandle *phandle)
void uv_parametrizer_stretch_end(ParamHandle *handle)
void uv_parametrizer_face_add(ParamHandle *handle, const ParamKey key, const int nverts, const ParamKey *vkeys, const float **co, float **uv, const float *weight, const bool *pin, const bool *select)
MINLINE float min_ff(float a, float b)
void WM_main_add_notifier(uint type, void *reference)
static ParamHandle * construct_param_handle_subsurfed(const Scene *scene, Object *ob, const UnwrapOptions *options, int *r_count_failed=nullptr)
static const EnumPropertyItem pack_rotate_method_items[]
void BM_face_calc_center_median(const BMFace *f, float r_cent[3])
int CustomData_get_offset(const CustomData *data, eCustomDataType type)
void EDBM_mesh_elem_index_ensure_multi(Span< Object * > objects, char htype)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void mul_m3_v3(const float M[3][3], float r[3])
@ UVCALC_UNWRAP_USE_WEIGHTS
@ UVCALC_NO_ASPECT_CORRECT
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
bool ED_operator_uvedit(bContext *C)
void UV_OT_minimize_stretch(wmOperatorType *ot)
ScrArea * CTX_wm_area(const bContext *C)
static wmOperatorStatus cube_project_exec(bContext *C, wmOperator *op)
static void unwrap_options_sync_toolsettings(wmOperator *op, ToolSettings *ts)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void ED_uvedit_get_aspect_from_material(Object *ob, const int material_index, float *r_aspx, float *r_aspy)
static wmOperatorStatus cylinder_project_exec(bContext *C, wmOperator *op)
static void uvedit_unwrap(const Scene *scene, Object *obedit, const UnwrapOptions *options, int *r_count_changed, int *r_count_failed)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void UV_OT_project_from_view(wmOperatorType *ot)
bool map_to_tube(float *r_u, float *r_v, float x, float y, float z)
int bm_mesh_calc_uv_islands(const Scene *scene, BMesh *bm, ListBaseT< FaceIsland > *island_list, const bool only_selected_faces, const bool only_selected_uvs, const bool use_seams, const float aspect_y, const BMUVOffsets &offsets)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
static void uv_map_operator_property_correct_aspect(wmOperatorType *ot)
MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
void BM_mesh_free(BMesh *bm)
BMesh Free Mesh.
bool uv_stitch_selected_islands_for_original_bounds(const Scene *scene, Span< Object * > objects)
void ED_uvedit_get_aspect(Object *obedit, float *r_aspx, float *r_aspy)
static void pack_islands_freejob(void *pidv)
static float uv_sphere_project(const Scene *scene, BMesh *bm, BMFace *efa_init, const float center[3], const float rotmat[3][3], const bool fan, const BMUVOffsets &offsets, const bool only_selected_uvs, const bool use_seams, const float branch_init)
BMesh * BKE_editmesh_bmesh_get_for_write(Mesh *mesh)
void WM_jobs_callbacks(wmJob *wm_job, wm_jobs_start_callback startjob, void(*initjob)(void *), void(*update)(void *), void(*endjob)(void *))
void UV_OT_pack_islands(wmOperatorType *ot)
static wmOperatorStatus reset_exec(bContext *C, wmOperator *)
Span< float3 > BKE_editmesh_vert_coords_when_deformed(Depsgraph *depsgraph, Scene *scene, Object *obedit, Array< float3 > &r_alloc)
MINLINE void copy_v3_v3(float r[3], const float a[3])
static void uv_map_transform_center(const Scene *scene, View3D *v3d, Object *ob, BMesh *bm, float r_center[3], float r_bounds[2][3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
static struct blender::@105341326230115065046224055270215277364215147174 g_live_unwrap
void BM_editselection_center(BMEditSelection *ese, float r_center[3])
void copy_m3_m4(float m1[3][3], const float m2[4][4])
float ED_uvedit_get_aspect_y(Object *obedit)
@ REGION_DRAW_LOCK_RENDER
void ED_uvedit_add_simple_uvs(Main *bmain, const Scene *scene, Object *ob)
static void uvedit_unwrap_multi(const Scene *scene, const Span< Object * > objects, const UnwrapOptions *options, int *r_count_changed=nullptr, int *r_count_failed=nullptr)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
static Vector< float3 > smart_uv_project_calculate_project_normals(const ThickFace *thick_faces, const uint thick_faces_len, BMesh *bm, const float project_angle_limit_half_cos, const float project_angle_limit_cos, const float area_weight)
static UnwrapOptions unwrap_options_get(wmOperator *op, Object *ob, const ToolSettings *ts)
BLI_INLINE BMEdge * BM_edge_at_index(BMesh *bm, const int index)
static void uv_map_transform_calc_bounds(BMesh *bm, float r_min[3], float r_max[3])
void BM_mesh_elem_table_ensure(BMesh *bm, const char htype)
static void uv_map_clip_correct_properties_ex(wmOperatorType *ot, bool clip_to_bounds)
static void pack_islands_endjob(void *pidv)
bool CustomData_has_layer(const CustomData *data, eCustomDataType type)
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
static void uvedit_prepare_pinned_indices(ParamHandle *handle, const Scene *scene, const BMesh *bm, BMFace *efa, const UnwrapOptions *options, const BMUVOffsets &offsets)
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])
void uvedit_select_prepare_custom_data(const Scene *scene, BMesh *bm)
bool uv_coords_isect_udim(const Image *image, const int udim_grid[2], const float coords[2])
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
static void uv_map_mirror(BMFace *efa, const bool *regular, const bool fan, const int cd_loop_uv_offset)
void uvedit_face_select_disable(const Scene *scene, BMesh *bm, BMFace *efa)
@ ED_UVPACK_PIN_LOCK_ROTATION
@ ED_UVPACK_PIN_LOCK_SCALE
@ ED_UVPACK_PIN_LOCK_ROTATION_SCALE
void BKE_uvproject_from_view(float target[2], const float source[3], const float persmat[4][4], const float rotmat[4][4], float winx, float winy)
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void mul_v2_m3v3(float r[2], const float M[3][3], const float a[3])
@ V3D_AROUND_CENTER_BOUNDS
@ V3D_AROUND_LOCAL_ORIGINS
@ V3D_AROUND_CENTER_MEDIAN
bool ED_uvedit_live_unwrap_timer_check(const wmTimer *timer)
static void island_uv_transform(FaceIsland *island, const float matrix[2][2], const float pre_translate[2])
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void BLI_linklist_prepend_arena(LinkNode **listp, void *ptr, struct MemArena *ma) ATTR_NONNULL(1
void ED_mesh_uv_ensure(Mesh *mesh, const char *name)
void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp) ATTR_NONNULL(1)
std::string RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop)
int RNA_int_get(PointerRNA *ptr, const char *name)
static wmOperatorStatus minimize_stretch_exec(bContext *C, wmOperator *op)
bool is_negative_m4(const float mat[4][4])
wmWindow * CTX_wm_window(const bContext *C)
void BKE_uvproject_from_camera(float target[2], const float source[3], const struct ProjCameraInfo *uci)
void BM_mesh_elem_hflag_disable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
static Mesh * subdivide_edit_mesh(const Object *object, BMesh *bm, const SubsurfModifierData *smd)
static const EnumPropertyItem pack_shape_method_items[]
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *customdata))
static wmOperatorStatus minimize_stretch_invoke(bContext *C, wmOperator *op, const wmEvent *)
bool map_to_sphere(float *r_u, float *r_v, float x, float y, float z)
void ED_mesh_uv_loop_reset(bContext *C, Mesh *mesh)
static void uv_map_transform(bContext *C, wmOperator *op, float rotmat[3][3])
void ED_uvedit_live_unwrap_re_solve()
static float uv_cylinder_project(const Scene *scene, BMesh *bm, BMFace *efa_init, const float center[3], const float rotmat[3][3], const bool fan, const BMUVOffsets &offsets, const bool only_selected_uvs, const bool use_seams, const float branch_init)
static bool minimize_stretch_init(bContext *C, wmOperator *op)
static void uv_map_transform_calc_center_median(BMesh *bm, float r_center[3])
static bool rna_property_sync_flag(PointerRNA *ptr, const char *prop_name, T flag, bool flipped, T *value_p)
void BKE_uvproject_camera_info_free(ProjCameraInfo *uci)
ViewLayer * CTX_data_view_layer(const bContext *C)
static void modifier_unwrap_state(Object *obedit, const UnwrapOptions *options, bool *r_use_subsurf)
MINLINE void mul_v3_fl(float r[3], float f)
static void uv_pack_islands_ui(bContext *, wmOperator *op)
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
void RNA_def_property_float_default(PropertyRNA *prop, float value)
static void uv_transform_properties(wmOperatorType *ot, int radius)
static wmOperatorStatus uv_from_view_invoke(bContext *C, wmOperator *op, const wmEvent *)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
bool uvedit_uv_select_test(const Scene *scene, const BMesh *bm, const BMLoop *l, const BMUVOffsets &offsets)
static wmOperatorStatus smart_project_exec(bContext *C, wmOperator *op)
void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
void WM_locked_interface_set(wmWindowManager *wm, bool lock)
void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams *params)
Mesh -> BMesh.
PropertyRNA * RNA_def_float_factor(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
eUVPackIsland_MarginMethod
@ ED_UVPACK_MARGIN_FRACTION
@ ED_UVPACK_MARGIN_SCALED
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
void UV_OT_sphere_project(wmOperatorType *ot)
float BKE_defvert_find_weight(const MDeformVert *dvert, int defgroup)
int BKE_image_find_nearest_tile_with_offset(const Image *image, const float co[2], float r_uv_offset[2]) ATTR_NONNULL(2
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
wmOperatorStatus WM_operator_props_popup_call(bContext *C, wmOperator *op, const wmEvent *)
void ED_uvedit_live_unwrap(const Scene *scene, Span< Object * > objects)
static const EnumPropertyItem pinned_islands_method_items[]
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void WM_locked_interface_set_with_flags(wmWindowManager *wm, short lock_flags)
void BKE_uvproject_from_view_ortho(float target[2], const float source[3], const float rotmat[4][4])
static void construct_param_handle_face_add(ParamHandle *handle, const Scene *scene, const BMesh *bm, BMFace *efa, geometry::ParamKey face_index, const UnwrapOptions *options, const BMUVOffsets &offsets, const int cd_weight_offset, const int cd_weight_index)
bool BLI_rctf_is_empty(const struct rctf *rect)
@ UVCALC_UNWRAP_METHOD_ANGLE
@ UVCALC_UNWRAP_METHOD_CONFORMAL
@ UVCALC_UNWRAP_METHOD_MINIMUM_STRETCH
static const float smart_uv_project_area_ignore
@ eSubsurfModifierFlag_ControlEdges
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
static float uv_nearest_grid_tile_distance(const int udim_grid[2], const float coords[2], float nearest_tile_co[2])
float BM_face_calc_area(const BMFace *f)
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
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)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
void ED_image_get_uv_aspect(Image *ima, ImageUser *iuser, float *r_aspx, float *r_aspy)
static ParamHandle * construct_param_handle(const Scene *scene, Object *ob, const UnwrapOptions *options, int *r_count_failed=nullptr)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
wmWindowManager * CTX_wm_manager(const bContext *C)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
void BLI_memarena_clear(MemArena *ma) ATTR_NONNULL(1)
void UV_OT_unwrap(wmOperatorType *ot)
static void correct_uv_aspect_per_face(Object *ob, BMesh *bm)
Object * CTX_data_edit_object(const bContext *C)
void ED_undo_push(bContext *C, const char *str, UndoEncodeHints hints=UndoEncodeHints(0))
static const EnumPropertyItem pack_margin_method_items[]
static void pack_islands_startjob(void *pidv, wmJobWorkerStatus *worker_status)
bool uvedit_face_select_test(const Scene *scene, const BMesh *bm, const BMFace *efa)
int BKE_object_defgroup_name_index(const Object *ob, StringRef name)
void mul_v2_m2v2(float r[2], const float mat[2][2], const float vec[2])
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
static bool rna_property_sync_string(PointerRNA *ptr, const char *prop_name, char value_p[])
const BMAllocTemplate bm_mesh_allocsize_default
void unit_m4(float m[4][4])
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void ED_area_status_text(ScrArea *area, const char *str)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
static void unwrap_draw(bContext *, wmOperator *op)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
static bool rna_property_sync_float(PointerRNA *ptr, const char *prop_name, float *value_p)
MINLINE void zero_v3(float r[3])
void BKE_id_free(Main *bmain, void *idv)
static int smart_uv_project_thickface_area_cmp_fn(const void *tf_a_p, const void *tf_b_p)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
static bool uvedit_is_face_affected(const Scene *scene, const BMesh *bm, BMFace *efa, const UnwrapOptions *options, const BMUVOffsets &offsets)
void ED_uvedit_select_all(const ToolSettings *ts, BMesh *bm)
Camera * ED_view3d_camera_data_get(View3D *v3d, RegionView3D *rv3d)
void ED_uvedit_live_unwrap_end(bool cancel)
void mat4_to_size(float size[3], const float M[4][4])
void UV_OT_cube_project(wmOperatorType *ot)
bool ED_operator_uvmap(bContext *C)
void BM_face_calc_bounds_expand(const BMFace *f, float min[3], float max[3])
static void uvedit_unwrap_cube_project(const Scene *scene, BMesh *bm, float cube_size, const bool use_select, const bool only_selected_uvs, const float center[3])
static wmOperatorStatus uv_pack_islands_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus WM_operator_props_popup_confirm_ex(bContext *C, wmOperator *op, const wmEvent *, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message)
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
MINLINE float normalize_v3(float n[3])
SpaceImage * CTX_wm_space_image(const bContext *C)
void UV_OT_average_islands_scale(wmOperatorType *ot)
static wmOperatorStatus average_islands_scale_exec(bContext *C, wmOperator *op)
static void uv_map_clip_correct_properties(wmOperatorType *ot)
MINLINE void add_v3_v3(float r[3], const float a[3])
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void UV_OT_cylinder_project(wmOperatorType *ot)
static bool uvedit_ensure_uvs(Object *obedit)
static void shrink_loop_uv_by_aspect_ratio(BMFace *efa, const int cd_loop_uv_offset, const float aspect_y)
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 mid_v3_v3v3(float r[3], const float a[3], const float b[3])
static void construct_param_edge_set_seams(ParamHandle *handle, BMesh *bm, const UnwrapOptions *options)
static bool uv_from_view_poll(bContext *C)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Main * CTX_data_main(const bContext *C)
static bool island_has_pins(const Scene *scene, const BMesh *bm, FaceIsland *island, const geometry::UVPackIsland_Params *params)
void unit_m3(float m[3][3])
BMFace * BM_mesh_active_face_get(BMesh *bm, const bool is_sloppy, const bool is_selected)
static wmOperatorStatus minimize_stretch_modal(bContext *C, wmOperator *op, const wmEvent *event)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, const void *owner, const char *name, const eWM_JobFlag flag, const eWM_JobType job_type)
PropertyRNA * RNA_def_float_rotation(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 correct_uv_aspect(Object *ob, BMesh *bm)
MINLINE void clamp_v2(float vec[2], float min, float max)
Mesh * BKE_mesh_from_bmesh_for_eval_nomain(BMesh *bm, const CustomData_MeshMasks *cd_mask_extra, const Mesh *me_settings)
MINLINE float max_ff(float a, float b)
MINLINE void axis_dominant_v3(int *r_axis_a, int *r_axis_b, const float axis[3])
static void minimize_stretch_iteration(bContext *C, wmOperator *op, bool interactive)
void mid_v2_v2v2(float r[2], const float a[2], const float b[2])
void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit, struct wmWindow *win_modal)
void BM_face_uv_minmax(const BMFace *f, float min[2], float max[2], const int cd_loop_uv_offset)
@ UNWRAP_ERROR_NONUNIFORM
static float uv_nearest_image_tile_distance(const Image *image, const float coords[2], float nearest_tile_co[2])
Vector< Object * > BKE_view_layer_array_from_objects_in_edit_mode_unique_data(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
void UV_OT_reset(wmOperatorType *ot)
Heap * BLI_heap_new() ATTR_WARN_UNUSED_RESULT
void BKE_mesh_ensure_default_orig_index_customdata(Mesh *mesh)
double BLI_time_now_seconds()
std::optional< std::string > ED_mesh_uv_add(Mesh *mesh, const char *name, bool active_set, bool do_init, ReportList *reports)
void zero_m4(float m[4][4])
static bool uvedit_have_selection_multi(const Scene *scene, const Span< Object * > objects, const UnwrapOptions *options)
bool ED_uvedit_test(Object *obedit)
static wmOperatorStatus sphere_project_exec(bContext *C, wmOperator *op)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
static bool rna_property_sync_enum_char(PointerRNA *ptr, const char *prop_name, T *value_p)
Scene * CTX_data_scene(const bContext *C)
static bool uvedit_have_selection(const Scene *scene, BMesh *bm, const UnwrapOptions *options)
void WM_event_timer_remove(wmWindowManager *wm, wmWindow *, wmTimer *timer)
static void minimize_stretch_cancel(bContext *C, wmOperator *op)
eUVPackIsland_RotationMethod
@ ED_UVPACK_ROTATION_CARDINAL
@ ED_UVPACK_ROTATION_AXIS_ALIGNED_Y
@ ED_UVPACK_ROTATION_AXIS_ALIGNED
@ ED_UVPACK_ROTATION_NONE
@ ED_UVPACK_ROTATION_AXIS_ALIGNED_X
static ParamHandle * construct_param_handle_multi(const Scene *scene, const Span< Object * > objects, const UnwrapOptions *options)
void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *mesh, const BMeshToMeshParams *params)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
wmTimer * WM_event_timer_add(wmWindowManager *wm, wmWindow *win, const wmEventType event_type, const double time_step)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
BLI_INLINE BMFace * BM_face_at_index(BMesh *bm, const int index)
BMUVOffsets BM_uv_map_offsets_get(const BMesh *bm)
static void uvedit_pack_islands_multi(const Scene *scene, const Span< Object * > objects, BMesh **bmesh_override, const SpaceImage *udim_source_closest, const bool original_selection, const bool notify_wm, const rctf *custom_region, geometry::UVPackIsland_Params *params)
MINLINE void mul_v4_fl(float r[4], float f)
Vector< Object * > BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
MINLINE void negate_v4_v4(float r[4], const float a[4])
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
MINLINE void add_v2_fl(float r[2], float f)
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
bool BM_select_history_active_get(BMesh *bm, BMEditSelection *ese)
static void minimize_stretch_exit(bContext *C, wmOperator *op, bool cancel)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
bool invert_m2_m2(float inverse[2][2], const float mat[2][2])
eUVPackIsland_ShapeMethod
@ ED_UVPACK_SHAPE_CONCAVE
void WM_cursor_wait(bool val)
BMesh * BM_mesh_create(const BMAllocTemplate *allocsize, const BMeshCreateParams *params)
BMesh Make Mesh.
static wmOperatorStatus smart_project_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void uv_map_rotation_matrix_ex(float result[4][4], RegionView3D *rv3d, Object *ob, float upangledeg, float sideangledeg, float radius, const float offset[4])
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v2(float r[2])
ARegion * CTX_wm_region(const bContext *C)
void WM_jobs_timer(wmJob *wm_job, double time_step, uint note, uint endnote, void(*timer_step)(void *))
void ED_workspace_status_text(bContext *C, const char *str)
static void texface_from_original_index(const Scene *scene, const BMesh *bm, const BMUVOffsets &offsets, BMFace *efa, int index, float **r_uv, bool *r_pin, bool *r_select)
struct ProjCameraInfo * BKE_uvproject_camera_info(const struct Object *ob, const float rotmat[4][4], float winx, float winy)
float RNA_float_get(PointerRNA *ptr, const char *name)
static void uv_map_clip_correct(const Scene *scene, const Span< Object * > objects, wmOperator *op, bool per_face_aspect, bool only_selected_uvs)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
static bool uvedit_live_unwrap_timer_validate(const wmWindowManager *wm)
static wmOperatorStatus pack_islands_exec(bContext *C, wmOperator *op)
View3D * CTX_wm_view3d(const bContext *C)
void UV_OT_smart_project(wmOperatorType *ot)
static wmOperatorStatus uv_from_view_exec(bContext *C, wmOperator *op)
void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3])
Normal to x,y matrix.
void BLI_memarena_free(MemArena *ma) ATTR_NONNULL(1)
static bool rna_property_sync_int(PointerRNA *ptr, const char *prop_name, int *value_p)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
bke::subdiv::Settings BKE_subsurf_modifier_settings_init(const SubsurfModifierData *smd, bool use_render_params)
static wmOperatorStatus unwrap_exec(bContext *C, wmOperator *op)
static bool rna_property_sync_enum(PointerRNA *ptr, const char *prop_name, int *value_p)
bool ED_object_get_active_image(Object *ob, int mat_nr, Image **r_ima, ImageUser **r_iuser, const bNode **r_node, const bNodeTree **r_ntree)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
const c_style_mat & ptr() const
Vector< Object * > objects_edit
ListBaseT< ModifierData > modifiers
bke::ObjectRuntime * runtime
struct ToolSettings * toolsettings
SubsurfModifierFlag flags
geometry::UVPackIsland_Params pack_island_params
Vector< Object * > objects
char weight_group[MAX_VGROUP_NAME]
bool topology_from_uvs_use_seams
bool uv_select_sync_valid
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)
void active_set(bool active)
Layout & column(bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(*) cancel(bContext *C, wmOperator *op)
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
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
struct wmOperatorType * type
#define PACK_ROTATE_METHOD_AXIS_ALIGNED_OFFSET