50 luv->
uv[1] *= scale_y;
51 }
while ((l_iter = l_iter->
next) != l_first);
58 const int cd_loop_uv_offset)
65 for (
int i = 0; i < 2; i++) {
66 luv->
uv[i] =
offset[i] + (((luv->
uv[i] - pivot[i]) * scale[i]) + pivot[i]);
68 }
while ((l_iter = l_iter->
next) != l_first);
79 const uint cd_loop_uv_offset,
82 float bounds_min[2], bounds_max[2];
84 for (
int i = 0; i < faces_len; i++) {
88 r_bounds_rect->
xmin = bounds_min[0];
89 r_bounds_rect->
ymin = bounds_min[1];
90 r_bounds_rect->
xmax = bounds_max[0];
91 r_bounds_rect->
ymax = bounds_max[1];
99 BMFace **
faces,
int faces_len,
const uint cd_loop_uv_offset,
int *r_coords_len))[2]
101 int coords_len_alloc = 0;
102 for (
int i = 0; i < faces_len; i++) {
108 }
while ((l_iter = l_iter->
next) != l_first);
109 coords_len_alloc += f->
len;
112 float(*coords)[2] =
MEM_mallocN(
sizeof(*coords) * coords_len_alloc, __func__);
115 for (
int i = 0; i < faces_len; i++) {
139 if (l_radial->
v == l_iter->
v) {
151 }
while ((l_iter = l_iter->
next) != l_first);
153 coords =
MEM_reallocN(coords,
sizeof(*coords) * coords_len);
154 *r_coords_len = coords_len;
167 const uint cd_loop_uv_offset)
172 faces, faces_len, cd_loop_uv_offset, &coords_len);
176 if (align_to_axis != -1) {
180 for (
int i = 0; i < coords_len; i++) {
185 float bounds_min[2], bounds_max[2];
187 for (
int i = 0; i < coords_len; i++) {
203 for (
int i = 0; i < faces_len; i++) {
212 const uint cd_loop_uv_offset)
214 for (
int i = 0; i < faces_len; i++) {
228 const float coords_floor[2] = {
floorf(coords[0]),
floorf(coords[1])};
231 if (coords[0] < udim_grid[0] && coords[0] > 0 && coords[1] < udim_grid[1] && coords[1] > 0) {
235 if (is_tiled_image) {
240 if (coords_floor[0] == target_x && coords_floor[1] == target_y) {
246 else if (
image && !is_tiled_image) {
259 const float coords[2],
260 float nearest_tile_co[2])
266 float nearest_tile_center_co[2] = {nearest_tile_co[0], nearest_tile_co[1]};
277 float nearest_tile_co[2])
279 const float coords_floor[2] = {
floorf(coords[0]),
floorf(coords[1])};
281 if (coords[0] > udim_grid[0]) {
282 nearest_tile_co[0] = udim_grid[0] - 1;
284 else if (coords[0] < 0) {
285 nearest_tile_co[0] = 0;
288 nearest_tile_co[0] = coords_floor[0];
291 if (coords[1] > udim_grid[1]) {
292 nearest_tile_co[1] = udim_grid[1] - 1;
294 else if (coords[1] < 0) {
295 nearest_tile_co[1] = 0;
298 nearest_tile_co[1] = coords_floor[1];
302 float nearest_tile_center_co[2] = {nearest_tile_co[0], nearest_tile_co[1]};
338 if (
data->use_seams) {
353 const bool only_selected_faces,
354 const bool only_selected_uvs,
356 const float aspect_y,
359 int island_added = 0;
369 int(*group_index)[2];
372 uchar hflag_face_test = 0;
373 if (only_selected_faces) {
374 if (only_selected_uvs) {
401 for (
int i = 0; i < group_len; i++) {
402 const int faces_start = group_index[i][0];
403 const int faces_len = group_index[i][1];
406 float bounds_min[2], bounds_max[2];
409 for (
int j = 0; j < faces_len; j++) {
437 const uint objects_len,
442 const int rotate_align_axis = 1;
444 int island_list_len = 0;
446 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
447 Object *obedit = objects[ob_index];
457 if (
params->correct_aspect) {
468 params->only_selected_faces,
469 params->only_selected_uvs,
475 if (island_list_len == 0) {
488 float selection_min_co[2], selection_max_co[2];
495 float bounds_min[2], bounds_max[2];
497 for (
int i = 0; i < island->faces_len; i++) {
498 BMFace *f = island->faces[i];
502 selection_min_co[0] =
MIN2(bounds_min[0], selection_min_co[0]);
503 selection_min_co[1] =
MIN2(bounds_min[1], selection_min_co[1]);
504 selection_max_co[0] =
MAX2(bounds_max[0], selection_max_co[0]);
505 selection_max_co[1] =
MAX2(bounds_max[1], selection_max_co[1]);
509 if (island->aspect_y != 1.0f) {
511 island->faces, island->faces_len, 1.0f / island->aspect_y, island->cd_loop_uv_offset);
515 island->faces, island->faces_len, rotate_align_axis, island->cd_loop_uv_offset);
517 if (island->aspect_y != 1.0f) {
519 island->faces, island->faces_len, island->aspect_y, island->cd_loop_uv_offset);
524 island->faces, island->faces_len, island->cd_loop_uv_offset, &island->bounds_rect);
526 BoxPack *box = &boxarray[index];
533 island_array[index] = island;
541 float selection_center[2];
543 selection_center[0] = (selection_min_co[0] + selection_max_co[0]) / 2.0f;
544 selection_center[1] = (selection_min_co[1] + selection_max_co[1]) / 2.0f;
552 for (
int i = 0; i < island_list_len; i++) {
562 float boxarray_size[2];
563 BLI_box_pack_2d(boxarray, island_list_len, &boxarray_size[0], &boxarray_size[1]);
566 boxarray_size[0] = boxarray_size[1] =
max_ff(boxarray_size[0], boxarray_size[1]);
568 const float scale[2] = {1.0f / boxarray_size[0], 1.0f / boxarray_size[1]};
571 float base_offset[2] = {0.0f, 0.0f};
574 if (udim_params ==
NULL) {
581 base_offset[0] = (udim_params->
target_udim - 1001) % 10;
582 base_offset[1] = (udim_params->
target_udim - 1001) / 10;
588 const int *udim_grid = udim_params->
grid_shape;
592 base_offset[0] =
floorf(selection_center[0]);
593 base_offset[1] =
floorf(selection_center[1]);
597 float nearest_image_tile_co[2] = {FLT_MAX, FLT_MAX};
598 float nearest_image_tile_dist = FLT_MAX, nearest_grid_tile_dist = FLT_MAX;
601 image, selection_center, nearest_image_tile_co);
604 float nearest_grid_tile_co[2] = {0.0f, 0.0f};
606 udim_grid, selection_center, nearest_grid_tile_co);
608 base_offset[0] = (nearest_image_tile_dist < nearest_grid_tile_dist) ?
609 nearest_image_tile_co[0] :
610 nearest_grid_tile_co[0];
611 base_offset[1] = (nearest_image_tile_dist < nearest_grid_tile_dist) ?
612 nearest_image_tile_co[1] :
613 nearest_grid_tile_co[1];
617 for (
int i = 0; i < island_list_len; i++) {
619 const float pivot[2] = {
624 ((boxarray[i].x * scale[0]) - island->
bounds_rect.
xmin) + base_offset[0],
625 ((boxarray[i].y * scale[1]) - island->
bounds_rect.
ymin) + base_offset[1],
627 for (
int j = 0; j < island->
faces_len; j++) {
634 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
635 Object *obedit = objects[ob_index];
640 for (
int i = 0; i < island_list_len; i++) {
typedef float(TangentPoint)[2]
CustomData interface, see also DNA_customdata_types.h.
int CustomData_get_offset(const struct CustomData *data, int type)
BMEditMesh * BKE_editmesh_from_object(struct Object *ob)
Return the BMEditMesh for a given object.
int BKE_image_find_nearest_tile_with_offset(const struct Image *image, const float co[2], float r_uv_offset[2]) ATTR_NONNULL(1
void BLI_box_pack_2d(BoxPack *boxarray, unsigned int len, float *r_tot_x, float *r_tot_y)
float BLI_convexhull_aabb_fit_points_2d(const float(*points)[2], unsigned int n)
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE float max_ff(float a, float b)
void mul_m2_v2(const float M[2][2], float v[2])
void angle_to_mat2(float R[2][2], float angle)
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v2_v2(float r[2], const float a[2])
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
MINLINE void add_v2_fl(float r[2], float f)
MINLINE bool equals_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void zero_v2(float r[2])
MINLINE bool is_zero_v2(const float a[2]) ATTR_WARN_UNUSED_RESULT
void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
#define INIT_MINMAX2(min, max)
typedef double(DMatrix)[4][4]
void DEG_id_tag_update(struct ID *id, int flag)
bool uvedit_face_select_test(const struct Scene *scene, struct BMFace *efa, int cd_loop_uv_offset)
void ED_uvedit_get_aspect(struct Object *obedit, float *r_aspx, float *r_aspy)
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
#define BM_DISK_EDGE_NEXT(e, v)
#define BM_FACE_FIRST_LOOP(p)
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
#define BM_elem_flag_disable(ele, hflag)
#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_MESH(ele, iter, bm, itype)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_elem_table_ensure(BMesh *bm, const char htype)
BLI_INLINE BMFace * BM_face_at_index(BMesh *bm, const int index)
int BM_mesh_calc_face_groups(BMesh *bm, int *r_groups_array, int(**r_group_index)[2], BMLoopFilterFunc filter_fn, BMLoopPairFilterFunc filter_pair_fn, void *user_data, const char hflag_test, const char htype_step)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMLoop * l_b
void BM_face_uv_transform(BMFace *f, const float matrix[2][2], const int cd_loop_uv_offset)
bool BM_loop_uv_share_edge_check(BMLoop *l_a, BMLoop *l_b, const int cd_loop_uv_offset)
void BM_face_uv_minmax(const BMFace *f, float min[2], float max[2], const int cd_loop_uv_offset)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
ccl_global const KernelWorkTile * tile
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
static void area(int d1, int d2, int e1, int e2, float weights[2])
struct BMLoop * radial_next
struct ToolSettings * toolsettings
const struct Image * image
static void bm_face_array_uv_rotate_fit_aabb(BMFace **faces, int faces_len, int align_to_axis, const uint cd_loop_uv_offset)
void ED_uvedit_pack_islands_multi(const Scene *scene, Object **objects, const uint objects_len, const struct UVMapUDIM_Params *udim_params, const struct UVPackIsland_Params *params)
static float uv_nearest_image_tile_distance(const Image *image, const float coords[2], float nearest_tile_co[2])
static void bm_face_uv_scale_y(BMFace *f, const float scale_y, const int cd_loop_uv_offset)
static void bm_face_array_uv_scale_y(BMFace **faces, int faces_len, const float scale_y, const uint cd_loop_uv_offset)
bool uv_coords_isect_udim(const Image *image, const int udim_grid[2], const float coords[2])
static float uv_nearest_grid_tile_distance(const int udim_grid[2], float coords[2], float nearest_tile_co[2])
static bool bm_loop_uv_shared_edge_check(const BMLoop *l_a, const BMLoop *l_b, void *user_data)
static void bm_face_uv_translate_and_scale_around_pivot(BMFace *f, const float offset[2], const float scale[2], const float pivot[2], const int cd_loop_uv_offset)
static void bm_face_array_calc_bounds(BMFace **faces, int faces_len, const uint cd_loop_uv_offset, rctf *r_bounds_rect)
static int bm_mesh_calc_uv_islands(const Scene *scene, BMesh *bm, ListBase *island_list, const bool only_selected_faces, const bool only_selected_uvs, const bool use_seams, const float aspect_y, const uint cd_loop_uv_offset)
static float(* bm_face_array_calc_unique_uv_coords(BMFace **faces, int faces_len, const uint cd_loop_uv_offset, int *r_coords_len))[2]
void WM_main_add_notifier(unsigned int type, void *reference)