Blender
V3.3
|
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_ghash.h"
#include "BLI_linklist_stack.h"
#include "BLI_math.h"
#include "BLI_math_vector.h"
#include "BLI_utildefines.h"
#include "DNA_image_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "BKE_context.h"
#include "BKE_customdata.h"
#include "BKE_editmesh.h"
#include "BKE_layer.h"
#include "BKE_report.h"
#include "DEG_depsgraph.h"
#include "ED_screen.h"
#include "ED_transform.h"
#include "ED_uvedit.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "WM_api.h"
#include "WM_types.h"
#include "UI_view2d.h"
#include "uvedit_intern.h"
Go to the source code of this file.
Classes | |
struct | ULData |
struct | UVRipSingle |
struct | UVRipPairs |
Macros | |
#define | UV_SET_SIDE_AND_REMOVE_FROM_RAIL(loop, side_value) |
Functions | |
UV Utilities | |
static BMLoop * | bm_loop_find_other_radial_loop_with_visible_face (BMLoop *l_src, const int cd_loop_uv_offset) |
static BMLoop * | bm_loop_find_other_fan_loop_with_visible_face (BMLoop *l_src, BMVert *v_src, const int cd_loop_uv_offset) |
static BMLoop * | bm_vert_step_fan_loop_uv (BMLoop *l, BMEdge **e_step, const int cd_loop_uv_offset) |
static void | bm_loop_uv_select_single_vert_validate (BMLoop *l_init, const int cd_loop_uv_offset) |
static void | bm_loop_calc_uv_angle_from_dir (BMLoop *l, const float dir[2], const float aspect_y, const int cd_loop_uv_offset, float *r_corner_angle, float *r_edge_angle, int *r_edge_index) |
UV Rip Main Function | |
static bool | uv_rip_object (Scene *scene, Object *obedit, const float co[2], const float aspect_y) |
UV Rip Operator | |
static int | uv_rip_exec (bContext *C, wmOperator *op) |
static int | uv_rip_invoke (bContext *C, wmOperator *op, const wmEvent *event) |
void | UV_OT_rip (wmOperatorType *ot) |
UV Loop Rip Data Struct | |
typedef struct ULData | ULData |
BLI_STATIC_ASSERT (sizeof(ULData)<=sizeof(int), "") | |
BLI_INLINE ULData * | UL (BMLoop *l) |
UV Rip Single | |
typedef struct UVRipSingle | UVRipSingle |
static UVRipSingle * | uv_rip_single_from_loop (BMLoop *l_init_orig, const float co[2], const float aspect_y, const int cd_loop_uv_offset) |
static void | uv_rip_single_free (UVRipSingle *rip) |
UV Rip Loop Pairs | |
typedef struct UVRipPairs | UVRipPairs |
static void | uv_rip_pairs_add (UVRipPairs *rip, BMLoop *l) |
static void | uv_rip_pairs_remove (UVRipPairs *rip, BMLoop *l) |
static float | uv_rip_pairs_calc_uv_angle (BMLoop *l_init, uint side, const float aspect_y, const int cd_loop_uv_offset) |
static int | uv_rip_pairs_loop_count_on_side (BMLoop *l_init, uint side, const int cd_loop_uv_offset) |
static bool | uv_rip_pairs_loop_change_sides_test (BMLoop *l_switch, BMLoop *l_target, const float aspect_y, const int cd_loop_uv_offset) |
static UVRipPairs * | uv_rip_pairs_from_loop (BMLoop *l_init, const float aspect_y, const int cd_loop_uv_offset) |
static void | uv_rip_pairs_free (UVRipPairs *rip) |
static bool | uv_rip_pairs_calc_center_and_direction (UVRipPairs *rip, const int cd_loop_uv_offset, float r_center[2], float r_dir_side[2][2]) |
#define UV_SET_SIDE_AND_REMOVE_FROM_RAIL | ( | loop, | |
side_value | |||
) |
typedef struct UVRipPairs UVRipPairs |
typedef struct UVRipSingle UVRipSingle |
BLI_STATIC_ASSERT | ( | sizeof(ULData)<=sizeof(int) | , |
"" | |||
) |
Ensure this fits in an int (loop index).
|
static |
The corner return values calculate the angle between both loops, the edge values pick the closest to the either edge (ignoring the center).
dir | Direction to calculate the angle to (normalized and aspect corrected). |
Definition at line 220 of file uvedit_rip.c.
References angle_v2v2(), BM_ELEM_CD_GET_VOID_P, BM_face_uv_calc_cross(), BMLoop::f, l, negate_v2(), BMLoop::next, normalize_v2(), BMLoop::prev, sub_v2_v2v2(), SWAP, and MLoopUV::uv.
Referenced by uv_rip_single_from_loop().
|
static |
Definition at line 124 of file uvedit_rip.c.
References BLI_assert, BLI_assert_unreachable, BM_elem_flag_test, BM_ELEM_TAG, BM_loop_uv_share_edge_check(), BM_vert_in_edge(), BMLoop::e, BMLoop::f, BMLoop::next, NULL, BMLoop::prev, BMLoop::radial_next, and BMLoop::v.
Referenced by bm_vert_step_fan_loop_uv().
|
static |
Definition at line 100 of file uvedit_rip.c.
References BM_elem_flag_test, BM_ELEM_TAG, BM_loop_uv_share_edge_check(), BMLoop::f, NULL, BMLoop::radial_next, and UL().
Referenced by uv_rip_pairs_from_loop().
|
static |
Definition at line 187 of file uvedit_rip.c.
References BM_ELEM_CD_GET_VOID_P, BM_ITER_ELEM, BM_LOOPS_OF_VERT, equals_v2v2(), ULData::is_select_edge, ULData::is_select_vert_single, l, BMLoop::prev, UL(), MLoopUV::uv, and BMLoop::v.
Referenced by uv_rip_object().
|
static |
A version of BM_vert_step_fan_loop that checks UV's.
Definition at line 167 of file uvedit_rip.c.
References BLI_assert_unreachable, bm_loop_find_other_fan_loop_with_visible_face(), BMLoop::e, l, NULL, BMLoop::prev, and BMLoop::v.
Referenced by uv_rip_single_from_loop().
BLI_INLINE ULData* UL | ( | BMLoop * | l | ) |
Definition at line 89 of file uvedit_rip.c.
References BMLoop::head, BMHeader::index, and l.
Referenced by bm_loop_find_other_radial_loop_with_visible_face(), bm_loop_uv_select_single_vert_validate(), uv_rip_object(), uv_rip_pairs_add(), uv_rip_pairs_calc_center_and_direction(), uv_rip_pairs_calc_uv_angle(), uv_rip_pairs_from_loop(), uv_rip_pairs_loop_change_sides_test(), uv_rip_pairs_loop_count_on_side(), uv_rip_pairs_remove(), and uv_rip_single_from_loop().
void UV_OT_rip | ( | wmOperatorType * | ot | ) |
Definition at line 945 of file uvedit_rip.c.
References wmOperatorType::description, ED_operator_uvedit(), wmOperatorType::exec, wmOperatorType::flag, wmOperatorType::idname, wmOperatorType::invoke, wmOperatorType::name, NULL, OPTYPE_DEPENDS_ON_CURSOR, OPTYPE_REGISTER, OPTYPE_UNDO, ot, P_MIRROR_DUMMY, wmOperatorType::poll, RNA_def_float_vector(), wmOperatorType::srna, Transform_Properties(), uv_rip_exec(), and uv_rip_invoke().
Referenced by ED_operatortypes_uvedit().
|
static |
Definition at line 892 of file uvedit_rip.c.
References BKE_report(), BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs, C, CTX_data_edit_object(), CTX_data_scene(), CTX_data_view_layer(), CTX_wm_space_image(), Object::data, DEG_id_tag_update(), ED_uvedit_get_aspect(), MEM_freeN, NC_GEOM, ND_DATA, NULL, OPERATOR_CANCELLED, OPERATOR_FINISHED, wmOperator::ptr, wmOperator::reports, RNA_float_get_array(), RPT_ERROR, scene, uv_rip_object(), uvedit_live_unwrap_update(), and WM_event_add_notifier().
Referenced by UV_OT_rip(), and uv_rip_invoke().
|
static |
Definition at line 934 of file uvedit_rip.c.
References C, CTX_wm_region(), wmEvent::mval, wmOperator::ptr, RNA_float_set_array(), UI_view2d_region_to_view(), uv_rip_exec(), and ARegion::v2d.
Referenced by UV_OT_rip().
|
static |
Definition at line 733 of file uvedit_rip.c.
References BLI_gsetIterator_getKey(), bm, BM_ELEM_CD_GET_VOID_P, BM_elem_flag_set, BM_elem_flag_test, BM_ELEM_TAG, BM_FACES_OF_MESH, BM_ITER_ELEM, BM_ITER_MESH, BM_LOOP, bm_loop_uv_select_single_vert_validate(), BM_LOOPS_OF_FACE, CD_MLOOPUV, center, CustomData_get_offset(), Object::data, dot_v2v2(), Mesh::edit_mesh, BMesh::elem_index_dirty, MLoopUV::flag, GSET_ITER, ULData::is_select_all, ULData::is_select_edge, ULData::is_select_vert_single, l, UVRipSingle::loops, UVRipPairs::loops, MLOOPUV_EDGESEL, MLOOPUV_VERTSEL, normalize_v2(), BMLoop::prev, scene, ULData::side, sub_v2_v2v2(), UL(), uv_rip_pairs_calc_center_and_direction(), uv_rip_pairs_free(), uv_rip_pairs_from_loop(), uv_rip_single_free(), uv_rip_single_from_loop(), uvedit_deselect_flush(), uvedit_face_visible_test(), and uvedit_uv_select_disable().
Referenced by uv_rip_exec().
|
static |
Definition at line 437 of file uvedit_rip.c.
References BLI_assert, BLI_gset_add(), BLI_gset_haskey(), ULData::in_rip_pairs, l, UVRipPairs::loops, and UL().
Referenced by uv_rip_pairs_from_loop().
|
static |
This is an approximation, it's easily good enough for our purpose.
Definition at line 681 of file uvedit_rip.c.
References add_v2_v2(), BLI_gset_len(), BLI_gsetIterator_getKey(), BM_ELEM_CD_GET_VOID_P, GSET_ITER, ULData::is_select_edge, l, UVRipPairs::loops, mul_v2_fl(), BMLoop::next, normalize_v2(), BMLoop::prev, ULData::side, sub_v2_v2v2(), UL(), MLoopUV::uv, and zero_v2().
Referenced by uv_rip_object().
|
static |
Definition at line 459 of file uvedit_rip.c.
References angle_v2v2(), BM_ELEM_CD_GET_VOID_P, BM_ITER_ELEM, BM_LOOPS_OF_VERT, equals_v2v2(), CCL_NAMESPACE_BEGIN::isfinite(), l, LIKELY, BMLoop::next, BMLoop::prev, sub_v2_v2v2(), UL(), MLoopUV::uv, and BMLoop::v.
Referenced by uv_rip_pairs_loop_change_sides_test().
|
static |
Definition at line 672 of file uvedit_rip.c.
References BLI_gset_free(), UVRipPairs::loops, MEM_freeN, and NULL.
Referenced by uv_rip_object().
|
static |
Create 2x sides of a UV rip-pairs, the result is unordered, supporting non-contiguous rails.
l_init | A loop on a boundary which can be used to initialize flood-filling. This will always be added to the first side. Other loops will be added to the second side. |
Definition at line 553 of file uvedit_rip.c.
References BLI_assert, BLI_gset_ptr_new(), BLI_SMALLSTACK_DECLARE, BLI_SMALLSTACK_POP, BLI_SMALLSTACK_PUSH, BM_edge_uv_share_vert_check(), BM_elem_flag_test, BM_ELEM_TAG, bm_loop_find_other_radial_loop_with_visible_face(), BMLoop::e, BMLoop::f, ULData::in_rip_pairs, ULData::in_stack, UVRipPairs::loops, MEM_callocN, BMLoop::next, NULL, BMLoop::prev, BMLoop::radial_next, ULData::side, UL(), uv_rip_pairs_add(), uv_rip_pairs_loop_change_sides_test(), UV_SET_SIDE_AND_REMOVE_FROM_RAIL, and BMLoop::v.
Referenced by uv_rip_object().
|
static |
Definition at line 510 of file uvedit_rip.c.
References BLI_assert, fabsf, ULData::side, UL(), uv_rip_pairs_calc_uv_angle(), and uv_rip_pairs_loop_count_on_side().
Referenced by uv_rip_pairs_from_loop().
|
static |
Definition at line 491 of file uvedit_rip.c.
References BM_ELEM_CD_GET_VOID_P, BM_ITER_ELEM, BM_LOOPS_OF_VERT, count, equals_v2v2(), l, UL(), MLoopUV::uv, and BMLoop::v.
Referenced by uv_rip_pairs_loop_change_sides_test().
|
static |
Definition at line 446 of file uvedit_rip.c.
References BLI_assert, BLI_gset_haskey(), BLI_gset_remove(), ULData::in_rip_pairs, l, UVRipPairs::loops, NULL, and UL().
|
static |
Definition at line 420 of file uvedit_rip.c.
References BLI_gset_free(), UVRipSingle::loops, MEM_freeN, and NULL.
Referenced by uv_rip_object().
|
static |
Handle single loop, the following cases:
Definition at line 299 of file uvedit_rip.c.
References BLI_assert, BLI_gset_add(), BLI_gset_ptr_new(), BLI_gsetIterator_getKey(), BM_ELEM_CD_GET_VOID_P, BM_elem_flag_test, BM_ELEM_TAG, BM_ITER_ELEM, bm_loop_calc_uv_angle_from_dir(), BM_loop_uv_share_edge_check(), BM_LOOPS_OF_VERT, bm_vert_step_fan_loop_uv(), BMLoop::e, equals_v2v2(), BMLoop::f, GSET_ITER, if(), ULData::is_select_vert_single, l, UVRipSingle::loops, MEM_callocN, min_ff(), BMLoop::next, normalize_v2(), NULL, BMLoop::prev, ULData::side, sub_v2_v2v2(), UL(), UNLIKELY, MLoopUV::uv, and BMLoop::v.
Referenced by uv_rip_object().