Blender V4.3
uvedit_unwrap_ops.cc File Reference
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h"
#include "DNA_defaults.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_defaults.h"
#include "DNA_scene_types.h"
#include "BKE_global.hh"
#include "BLI_array.hh"
#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_memarena.h"
#include "BLI_string.h"
#include "BLI_time.h"
#include "BLI_utildefines.h"
#include "BLI_uvproject.h"
#include "BLI_vector.hh"
#include "BLT_translation.hh"
#include "BKE_context.hh"
#include "BKE_customdata.hh"
#include "BKE_deform.hh"
#include "BKE_editmesh.hh"
#include "BKE_image.hh"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_main.hh"
#include "BKE_mesh.hh"
#include "BKE_object_types.hh"
#include "BKE_report.hh"
#include "BKE_subdiv.hh"
#include "BKE_subdiv_mesh.hh"
#include "BKE_subdiv_modifier.hh"
#include "DEG_depsgraph.hh"
#include "GEO_uv_pack.hh"
#include "GEO_uv_parametrizer.hh"
#include "UI_interface.hh"
#include "UI_resources.hh"
#include "ED_image.hh"
#include "ED_mesh.hh"
#include "ED_screen.hh"
#include "ED_undo.hh"
#include "ED_uvedit.hh"
#include "ED_view3d.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "uvedit_intern.hh"

Go to the source code of this file.

Classes

struct  UnwrapOptions
 
struct  MinStretch
 
struct  UVPackIslandsData
 
struct  ThickFace
 
struct  UV_FaceBranch
 

Macros

#define PACK_ROTATE_METHOD_AXIS_ALIGNED_OFFSET   3
 

Functions

static void island_uv_transform (FaceIsland *island, const float matrix[2][2], const float pre_translate[2])
 
static float uv_nearest_image_tile_distance (const Image *image, const float coords[2], float nearest_tile_co[2])
 
static float uv_nearest_grid_tile_distance (const int udim_grid[2], const float coords[2], float nearest_tile_co[2])
 
static bool island_has_pins (const Scene *scene, FaceIsland *island, const blender::geometry::UVPackIsland_Params *params)
 
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, blender::geometry::UVPackIsland_Params *params)
 
Utility Functions
static bool ED_uvedit_ensure_uvs (Object *obedit)
 
Parametrizer Conversion
static void modifier_unwrap_state (Object *obedit, const UnwrapOptions *options, bool *r_use_subsurf)
 
static UnwrapOptions unwrap_options_get (wmOperator *op, Object *ob, const ToolSettings *ts)
 
static bool rna_property_sync_flag (PointerRNA *ptr, const char *prop_name, char flag, bool flipped, char *value_p)
 
static bool rna_property_sync_enum (PointerRNA *ptr, const char *prop_name, int *value_p)
 
static bool rna_property_sync_enum_char (PointerRNA *ptr, const char *prop_name, char *value_p)
 
static bool rna_property_sync_int (PointerRNA *ptr, const char *prop_name, int *value_p)
 
static bool rna_property_sync_float (PointerRNA *ptr, const char *prop_name, float *value_p)
 
static bool rna_property_sync_string (PointerRNA *ptr, const char *prop_name, char value_p[])
 
static void unwrap_options_sync_toolsettings (wmOperator *op, ToolSettings *ts)
 
static bool uvedit_have_selection (const Scene *scene, BMEditMesh *em, const UnwrapOptions *options)
 
static bool uvedit_have_selection_multi (const Scene *scene, const Span< Object * > objects, const UnwrapOptions *options)
 
void ED_uvedit_get_aspect_from_material (Object *ob, const int material_index, float *r_aspx, float *r_aspy)
 
void ED_uvedit_get_aspect (Object *ob, float *r_aspx, float *r_aspy)
 
float ED_uvedit_get_aspect_y (Object *ob)
 
static bool uvedit_is_face_affected (const Scene *scene, BMFace *efa, const UnwrapOptions *options, const BMUVOffsets offsets)
 
static void uvedit_prepare_pinned_indices (ParamHandle *handle, const Scene *scene, BMFace *efa, const UnwrapOptions *options, const BMUVOffsets offsets)
 
static void construct_param_handle_face_add (ParamHandle *handle, const Scene *scene, BMFace *efa, blender::geometry::ParamKey face_index, const UnwrapOptions *options, const BMUVOffsets offsets, const int cd_weight_offset, const int cd_weight_index)
 
static void construct_param_edge_set_seams (ParamHandle *handle, BMesh *bm, const UnwrapOptions *options)
 
static ParamHandleconstruct_param_handle (const Scene *scene, Object *ob, BMesh *bm, const UnwrapOptions *options, int *r_count_failed=nullptr)
 
static ParamHandleconstruct_param_handle_multi (const Scene *scene, const Span< Object * > objects, const UnwrapOptions *options)
 
static void texface_from_original_index (const Scene *scene, const BMUVOffsets offsets, BMFace *efa, int index, float **r_uv, bool *r_pin, bool *r_select)
 
static Meshsubdivide_edit_mesh (const Object *object, const BMEditMesh *em, const SubsurfModifierData *smd)
 
static ParamHandleconstruct_param_handle_subsurfed (const Scene *scene, Object *ob, BMEditMesh *em, const UnwrapOptions *options, int *r_count_failed=nullptr)
 
Minimize Stretch Operator
static bool minimize_stretch_init (bContext *C, wmOperator *op)
 
static void minimize_stretch_iteration (bContext *C, wmOperator *op, bool interactive)
 
static void minimize_stretch_exit (bContext *C, wmOperator *op, bool cancel)
 
static int minimize_stretch_exec (bContext *C, wmOperator *op)
 
static int minimize_stretch_invoke (bContext *C, wmOperator *op, const wmEvent *)
 
static int minimize_stretch_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
static void minimize_stretch_cancel (bContext *C, wmOperator *op)
 
void UV_OT_minimize_stretch (wmOperatorType *ot)
 
Average UV Islands Scale Operator
static int average_islands_scale_exec (bContext *C, wmOperator *op)
 
void UV_OT_average_islands_scale (wmOperatorType *ot)
 
UV Map Clip & Correct
static void uv_map_clip_correct_properties_ex (wmOperatorType *ot, bool clip_to_bounds)
 
static void uv_map_clip_correct_properties (wmOperatorType *ot)
 
static void uv_map_clip_correct (const Scene *scene, const Span< Object * > objects, wmOperator *op, bool per_face_aspect, bool only_selected_uvs)
 
Project UV From View Operator
static int uv_from_view_exec (bContext *C, wmOperator *op)
 
static int uv_from_view_invoke (bContext *C, wmOperator *op, const wmEvent *)
 
static bool uv_from_view_poll (bContext *C)
 
void UV_OT_project_from_view (wmOperatorType *ot)
 
Reset UV Operator
static int reset_exec (bContext *C, wmOperator *)
 
void UV_OT_reset (wmOperatorType *ot)
 
Sphere UV Project Operator
static void uv_map_mirror (BMFace *efa, const bool *regular, const bool fan, const int cd_loop_uv_offset)
 
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)
 
static int sphere_project_exec (bContext *C, wmOperator *op)
 
void UV_OT_sphere_project (wmOperatorType *ot)
 
Cylinder UV Project Operator
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 int cylinder_project_exec (bContext *C, wmOperator *op)
 
void UV_OT_cylinder_project (wmOperatorType *ot)
 
Cube UV Project Operator
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 int cube_project_exec (bContext *C, wmOperator *op)
 
void UV_OT_cube_project (wmOperatorType *ot)
 
Simple UVs for Texture Painting
void ED_uvedit_add_simple_uvs (Main *bmain, const Scene *scene, Object *ob)
 

UV Map Common Transforms

#define VIEW_ON_EQUATOR   0
 
#define VIEW_ON_POLES   1
 
#define ALIGN_TO_OBJECT   2
 
#define POLAR_ZX   0
 
#define POLAR_ZY   1
 
enum  { PINCH = 0 , FAN = 1 }
 
static void uv_map_transform_calc_bounds (BMEditMesh *em, float r_min[3], float r_max[3])
 
static void uv_map_transform_calc_center_median (BMEditMesh *em, float r_center[3])
 
static void uv_map_transform_center (const Scene *scene, View3D *v3d, Object *ob, BMEditMesh *em, float r_center[3], float r_bounds[2][3])
 
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])
 
static void uv_map_transform (bContext *C, wmOperator *op, float rotmat[3][3])
 
static void uv_transform_properties (wmOperatorType *ot, int radius)
 
static void shrink_loop_uv_by_aspect_ratio (BMFace *efa, const int cd_loop_uv_offset, const float aspect_y)
 
static void correct_uv_aspect (Object *ob, BMEditMesh *em)
 
static void correct_uv_aspect_per_face (Object *ob, BMEditMesh *em)
 

Pack UV Islands Operator

enum  { PACK_UDIM_SRC_CLOSEST = 0 , PACK_UDIM_SRC_ACTIVE , PACK_ORIGINAL_AABB }
 
static const EnumPropertyItem pack_margin_method_items []
 
static const EnumPropertyItem pack_rotate_method_items []
 
static const EnumPropertyItem pack_shape_method_items []
 
static const EnumPropertyItem pinned_islands_method_items []
 
static void pack_islands_startjob (void *pidv, wmJobWorkerStatus *worker_status)
 
static void pack_islands_endjob (void *pidv)
 
static void pack_islands_freejob (void *pidv)
 
static int pack_islands_exec (bContext *C, wmOperator *op)
 
static void uv_pack_islands_ui (bContext *, wmOperator *op)
 
static int uv_pack_islands_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void UV_OT_pack_islands (wmOperatorType *ot)
 

UV Unwrap Operator

enum  { UNWRAP_ERROR_NONUNIFORM = (1 << 0) , UNWRAP_ERROR_NEGATIVE = (1 << 1) }
 
static void uvedit_unwrap (const Scene *scene, Object *obedit, const UnwrapOptions *options, int *r_count_changed, int *r_count_failed)
 
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)
 
void ED_uvedit_live_unwrap (const Scene *scene, const Span< Object * > objects)
 
static int unwrap_exec (bContext *C, wmOperator *op)
 
static void unwrap_draw (bContext *, wmOperator *op)
 
void UV_OT_unwrap (wmOperatorType *ot)
 

Live UV Unwrap

struct { 
 
   ParamHandle **   handles 
 
   uint   len 
 
   uint   len_alloc 
 
   wmTimer *   timer 
 
g_live_unwrap = {nullptr} 
 
bool ED_uvedit_live_unwrap_timer_check (const wmTimer *timer)
 
static bool uvedit_live_unwrap_timer_validate (const wmWindowManager *wm)
 
void ED_uvedit_live_unwrap_begin (Scene *scene, Object *obedit, wmWindow *win_modal)
 
void ED_uvedit_live_unwrap_re_solve ()
 
void ED_uvedit_live_unwrap_end (const bool cancel)
 

Smart UV Project Operator

static const float smart_uv_project_area_ignore = 1e-12f
 
static int smart_uv_project_thickface_area_cmp_fn (const void *tf_a_p, const void *tf_b_p)
 
static blender::Vector< blender::float3smart_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 int smart_project_exec (bContext *C, wmOperator *op)
 
static int smart_project_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void UV_OT_smart_project (wmOperatorType *ot)
 

Macro Definition Documentation

◆ ALIGN_TO_OBJECT

#define ALIGN_TO_OBJECT   2

Definition at line 2199 of file uvedit_unwrap_ops.cc.

Referenced by uv_map_transform(), and uv_transform_properties().

◆ PACK_ROTATE_METHOD_AXIS_ALIGNED_OFFSET

#define PACK_ROTATE_METHOD_AXIS_ALIGNED_OFFSET   3

Referenced by UV_OT_smart_project().

◆ POLAR_ZX

#define POLAR_ZX   0

Definition at line 2201 of file uvedit_unwrap_ops.cc.

Referenced by uv_transform_properties().

◆ POLAR_ZY

#define POLAR_ZY   1

Definition at line 2202 of file uvedit_unwrap_ops.cc.

Referenced by uv_map_transform(), and uv_transform_properties().

◆ VIEW_ON_EQUATOR

#define VIEW_ON_EQUATOR   0

Definition at line 2197 of file uvedit_unwrap_ops.cc.

Referenced by uv_map_transform(), and uv_transform_properties().

◆ VIEW_ON_POLES

#define VIEW_ON_POLES   1

Definition at line 2198 of file uvedit_unwrap_ops.cc.

Referenced by uv_transform_properties().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PACK_UDIM_SRC_CLOSEST 
PACK_UDIM_SRC_ACTIVE 
PACK_ORIGINAL_AABB 

Definition at line 1635 of file uvedit_unwrap_ops.cc.

◆ anonymous enum

anonymous enum
Enumerator
PINCH 
FAN 

Definition at line 2204 of file uvedit_unwrap_ops.cc.

◆ anonymous enum

anonymous enum
Enumerator
UNWRAP_ERROR_NONUNIFORM 
UNWRAP_ERROR_NEGATIVE 

Definition at line 2754 of file uvedit_unwrap_ops.cc.

Function Documentation

◆ average_islands_scale_exec()

◆ construct_param_edge_set_seams()

◆ construct_param_handle()

◆ construct_param_handle_face_add()

◆ construct_param_handle_multi()

◆ construct_param_handle_subsurfed()

static ParamHandle * construct_param_handle_subsurfed ( const Scene * scene,
Object * ob,
BMEditMesh * em,
const UnwrapOptions * options,
int * r_count_failed = nullptr )
static

◆ correct_uv_aspect()

◆ correct_uv_aspect_per_face()

◆ cube_project_exec()

◆ cylinder_project_exec()

◆ ED_uvedit_add_simple_uvs()

◆ ED_uvedit_ensure_uvs()

◆ ED_uvedit_get_aspect()

void ED_uvedit_get_aspect ( Object * ob,
float * r_aspx,
float * r_aspy )

◆ ED_uvedit_get_aspect_from_material()

void ED_uvedit_get_aspect_from_material ( Object * ob,
const int material_index,
float * r_aspx,
float * r_aspy )

◆ ED_uvedit_get_aspect_y()

float ED_uvedit_get_aspect_y ( Object * obedit)

Return the X / Y aspect (wider aspects are over 1, taller are below 1). Apply this aspect by multiplying with the Y axis (X aspect is always 1 & unchanged).

Definition at line 513 of file uvedit_unwrap_ops.cc.

References ED_uvedit_get_aspect().

Referenced by construct_param_handle(), construct_param_handle_multi(), construct_param_handle_subsurfed(), correct_uv_aspect(), stitch_init(), uv_shortest_path_pick_exec(), uv_shortest_path_pick_invoke(), uv_shortest_path_select_exec(), and uvedit_pack_islands_multi().

◆ ED_uvedit_live_unwrap()

◆ ED_uvedit_live_unwrap_begin()

◆ ED_uvedit_live_unwrap_end()

◆ ED_uvedit_live_unwrap_re_solve()

◆ ED_uvedit_live_unwrap_timer_check()

bool ED_uvedit_live_unwrap_timer_check ( const wmTimer * timer)

Return true if the timer is managed by live-unwrap.

Definition at line 2064 of file uvedit_unwrap_ops.cc.

References g_live_unwrap, and timer.

Referenced by transformEvent().

◆ island_has_pins()

◆ island_uv_transform()

static void island_uv_transform ( FaceIsland * island,
const float matrix[2][2],
const float pre_translate[2] )
static

◆ minimize_stretch_cancel()

static void minimize_stretch_cancel ( bContext * C,
wmOperator * op )
static

Definition at line 1247 of file uvedit_unwrap_ops.cc.

References minimize_stretch_exit().

Referenced by UV_OT_minimize_stretch().

◆ minimize_stretch_exec()

◆ minimize_stretch_exit()

◆ minimize_stretch_init()

◆ minimize_stretch_invoke()

◆ minimize_stretch_iteration()

◆ minimize_stretch_modal()

◆ modifier_unwrap_state()

static void modifier_unwrap_state ( Object * obedit,
const UnwrapOptions * options,
bool * r_use_subsurf )
static

◆ pack_islands_endjob()

◆ pack_islands_exec()

static int pack_islands_exec ( bContext * C,
wmOperator * op )
static

Definition at line 1701 of file uvedit_unwrap_ops.cc.

References BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(), C, CTX_data_scene(), CTX_data_view_layer(), CTX_wm_manager(), CTX_wm_space_image(), CTX_wm_view3d(), CTX_wm_window(), ED_UVPACK_PIN_NONE, ED_UVPACK_ROTATION_NONE, wmOperator::flag, G, blender::geometry::UVPackIsland_Params::margin, blender::geometry::UVPackIsland_Params::margin_method, blender::geometry::UVPackIsland_Params::merge_overlap, wmOperatorType::name, UVPackIslandsData::objects, OP_IS_INVOKE, wmWindowManager::op_undo_depth, OPERATOR_CANCELLED, OPERATOR_FINISHED, options, UVPackIslandsData::pack_island_params, pack_islands_endjob(), pack_islands_freejob(), pack_islands_startjob(), PACK_UDIM_SRC_ACTIVE, blender::geometry::UVPackIsland_Params::pin_method, wmOperator::ptr, RNA_boolean_get(), RNA_enum_get(), RNA_float_get(), RNA_float_set(), RNA_struct_property_is_set(), blender::geometry::UVPackIsland_Params::rotate_method, blender::geometry::UVPackIsland_Params::scale_to_fit, scene, UVPackIslandsData::scene, blender::geometry::UVPackIsland_Params::setFromUnwrapOptions(), blender::geometry::UVPackIsland_Params::setUDIMOffsetFromSpaceImage(), blender::geometry::UVPackIsland_Params::shape_method, UVPackIslandsData::sima, wmOperator::type, UVPackIslandsData::udim_source, UVPackIslandsData::undo_context, UVPackIslandsData::undo_str, unwrap_options_get(), UVPackIslandsData::use_job, uvedit_have_selection_multi(), UVPackIslandsData::wm, WM_cursor_wait(), WM_JOB_PROGRESS, WM_JOB_TYPE_UV_PACK, WM_jobs_callbacks(), WM_jobs_customdata_set(), WM_jobs_get(), WM_jobs_start(), WM_jobs_timer(), and WM_set_locked_interface().

Referenced by UV_OT_pack_islands().

◆ pack_islands_freejob()

static void pack_islands_freejob ( void * pidv)
static

◆ pack_islands_startjob()

◆ reset_exec()

◆ rna_property_sync_enum()

static bool rna_property_sync_enum ( PointerRNA * ptr,
const char * prop_name,
int * value_p )
static

◆ rna_property_sync_enum_char()

static bool rna_property_sync_enum_char ( PointerRNA * ptr,
const char * prop_name,
char * value_p )
static

Definition at line 352 of file uvedit_unwrap_ops.cc.

References ptr, and rna_property_sync_enum().

Referenced by unwrap_options_sync_toolsettings().

◆ rna_property_sync_flag()

static bool rna_property_sync_flag ( PointerRNA * ptr,
const char * prop_name,
char flag,
bool flipped,
char * value_p )
static

◆ rna_property_sync_float()

static bool rna_property_sync_float ( PointerRNA * ptr,
const char * prop_name,
float * value_p )
static

◆ rna_property_sync_int()

static bool rna_property_sync_int ( PointerRNA * ptr,
const char * prop_name,
int * value_p )
static

◆ rna_property_sync_string()

static bool rna_property_sync_string ( PointerRNA * ptr,
const char * prop_name,
char value_p[] )
static

◆ shrink_loop_uv_by_aspect_ratio()

static void shrink_loop_uv_by_aspect_ratio ( BMFace * efa,
const int cd_loop_uv_offset,
const float aspect_y )
static

◆ smart_project_exec()

◆ smart_project_invoke()

static int smart_project_invoke ( bContext * C,
wmOperator * op,
const wmEvent * event )
static

Definition at line 3323 of file uvedit_unwrap_ops.cc.

References IFACE_, and WM_operator_props_popup_confirm_ex().

Referenced by UV_OT_smart_project().

◆ smart_uv_project_calculate_project_normals()

◆ smart_uv_project_thickface_area_cmp_fn()

static int smart_uv_project_thickface_area_cmp_fn ( const void * tf_a_p,
const void * tf_b_p )
static

Definition at line 3025 of file uvedit_unwrap_ops.cc.

References ThickFace::area, and smart_uv_project_area_ignore.

Referenced by smart_project_exec().

◆ sphere_project_exec()

◆ subdivide_edit_mesh()

◆ texface_from_original_index()

static void texface_from_original_index ( const Scene * scene,
const BMUVOffsets offsets,
BMFace * efa,
int index,
float ** r_uv,
bool * r_pin,
bool * r_select )
static

◆ unwrap_draw()

◆ unwrap_exec()

◆ unwrap_options_get()

◆ unwrap_options_sync_toolsettings()

◆ uv_cylinder_project()

◆ uv_from_view_exec()

◆ uv_from_view_invoke()

◆ uv_from_view_poll()

static bool uv_from_view_poll ( bContext * C)
static

Definition at line 3539 of file uvedit_unwrap_ops.cc.

References CTX_wm_region_view3d(), and ED_operator_uvmap().

Referenced by UV_OT_project_from_view().

◆ uv_map_clip_correct()

static void uv_map_clip_correct ( const Scene * scene,
const Span< Object * > objects,
wmOperator * op,
bool per_face_aspect,
bool only_selected_uvs )
static
Parameters
per_face_aspectCalculate the aspect ratio per-face, otherwise use a single aspect for all UVs based on the material of the active face. TODO: using per-face aspect may split UV islands so more advanced UV projection methods such as "Unwrap" & "Smart UV Projections" will need to handle aspect correction themselves. For now keep using a single aspect for all faces in this case.

Definition at line 2567 of file uvedit_unwrap_ops.cc.

References BKE_editmesh_from_object(), BMEditMesh::bm, BM_ELEM_CD_GET_FLOAT_P, BM_elem_flag_test, BM_ELEM_SELECT, BM_FACES_OF_MESH, BM_ITER_ELEM, BM_ITER_MESH, BM_LOOPS_OF_FACE, BM_uv_map_get_offsets(), clamp_v2(), correct_uv_aspect(), correct_uv_aspect_per_face(), INIT_MINMAX2, l, min, minmax_v2v2_v2(), wmOperator::ptr, RNA_boolean_get(), RNA_struct_find_property(), BMUVOffsets::uv, and uvedit_face_select_test().

Referenced by cube_project_exec(), cylinder_project_exec(), smart_project_exec(), sphere_project_exec(), and uv_from_view_exec().

◆ uv_map_clip_correct_properties()

static void uv_map_clip_correct_properties ( wmOperatorType * ot)
static

◆ uv_map_clip_correct_properties_ex()

static void uv_map_clip_correct_properties_ex ( wmOperatorType * ot,
bool clip_to_bounds )
static

◆ uv_map_mirror()

static void uv_map_mirror ( BMFace * efa,
const bool * regular,
const bool fan,
const int cd_loop_uv_offset )
static

◆ uv_map_rotation_matrix_ex()

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] )
static

◆ uv_map_transform()

◆ uv_map_transform_calc_bounds()

static void uv_map_transform_calc_bounds ( BMEditMesh * em,
float r_min[3],
float r_max[3] )
static

◆ uv_map_transform_calc_center_median()

static void uv_map_transform_calc_center_median ( BMEditMesh * em,
float r_center[3] )
static

◆ uv_map_transform_center()

◆ uv_nearest_grid_tile_distance()

static float uv_nearest_grid_tile_distance ( const int udim_grid[2],
const float coords[2],
float nearest_tile_co[2] )
static

Calculates distance to nearest UDIM grid tile in UV space and its UDIM tile number.

Definition at line 1344 of file uvedit_unwrap_ops.cc.

References add_v2_fl(), floorf, and len_squared_v2v2().

Referenced by uvedit_pack_islands_multi().

◆ uv_nearest_image_tile_distance()

static float uv_nearest_image_tile_distance ( const Image * image,
const float coords[2],
float nearest_tile_co[2] )
static

Calculates distance to nearest UDIM image tile in UV space and its UDIM tile number.

Definition at line 1328 of file uvedit_unwrap_ops.cc.

References add_v2_fl(), BKE_image_find_nearest_tile_with_offset(), and len_squared_v2v2().

Referenced by uvedit_pack_islands_multi().

◆ UV_OT_average_islands_scale()

◆ UV_OT_cube_project()

◆ UV_OT_cylinder_project()

◆ UV_OT_minimize_stretch()

◆ UV_OT_pack_islands()

◆ UV_OT_project_from_view()

◆ UV_OT_reset()

◆ UV_OT_smart_project()

◆ UV_OT_sphere_project()

◆ UV_OT_unwrap()

◆ uv_pack_islands_invoke()

static int uv_pack_islands_invoke ( bContext * C,
wmOperator * op,
const wmEvent * event )
static

Definition at line 1901 of file uvedit_unwrap_ops.cc.

References IFACE_, and WM_operator_props_popup_confirm_ex().

Referenced by UV_OT_pack_islands().

◆ uv_pack_islands_ui()

◆ uv_sphere_project()

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 )
static

◆ uv_transform_properties()

static void uv_transform_properties ( wmOperatorType * ot,
int radius )
static

◆ uvedit_have_selection()

◆ uvedit_have_selection_multi()

static bool uvedit_have_selection_multi ( const Scene * scene,
const Span< Object * > objects,
const UnwrapOptions * options )
static

◆ uvedit_is_face_affected()

static bool uvedit_is_face_affected ( const Scene * scene,
BMFace * efa,
const UnwrapOptions * options,
const BMUVOffsets offsets )
static

◆ uvedit_live_unwrap_timer_validate()

static bool uvedit_live_unwrap_timer_validate ( const wmWindowManager * wm)
static

In practice the timer should practically always be valid. Use this to prevent the unlikely case of a stale timer being set.

Loading a new file while unwrapping is running could cause this for example.

Definition at line 2076 of file uvedit_unwrap_ops.cc.

References BLI_findindex(), g_live_unwrap, and wmWindowManager::timers.

Referenced by ED_uvedit_live_unwrap_begin(), and ED_uvedit_live_unwrap_end().

◆ uvedit_pack_islands_multi()

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,
blender::geometry::UVPackIsland_Params * params )
static

Pack UV islands from multiple objects.

Parameters
sceneScene containing the objects to be packed.
objectsArray of Objects to pack.
objects_lenLength of objects array.
bmesh_overrideBMesh array aligned with objects. Optional, when non-null this overrides object's BMesh. This is needed to perform UV packing on objects that aren't in edit-mode.
udim_source_closestUDIM source SpaceImage.
original_selectionPack to original selection.
notify_wmNotify the WM of any changes. (UI thread only.)
paramsParameters and options to pass to the packing engine.

Definition at line 1417 of file uvedit_unwrap_ops.cc.

References blender::geometry::PackIsland::add_polygon(), blender::geometry::PackIsland::angle, blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::geometry::PackIsland::aspect_y, FaceIsland::aspect_y, BKE_editmesh_from_object(), BLI_assert, BLI_heap_free(), BLI_heap_new(), BLI_memarena_clear(), BLI_memarena_free(), BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, BLI_remlink(), bm, BMEditMesh::bm, BM_ELEM_CD_GET_FLOAT_P, BM_face_uv_minmax(), BM_ITER_ELEM_INDEX, BM_LOOPS_OF_FACE, bm_mesh_calc_uv_islands(), BM_uv_map_get_offsets(), blender::geometry::PackIsland::build_transformation(), blender::geometry::PackIsland::caller_index, blender::geometry::PackIsland::can_scale_(), copy_v2_v2(), DEG_id_tag_update(), ED_uvedit_get_aspect_y(), ED_UVPACK_PIN_IGNORE, FaceIsland::faces, FaceIsland::faces_len, floorf, FLT_MAX, ID_RECALC_GEOMETRY, SpaceImage::image, blender::Vector< T, InlineBufferCapacity, Allocator >::index_range(), INIT_MINMAX2, invert_m2_m2(), blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty(), island_has_pins(), island_uv_transform(), l, BMFace::len, LISTBASE_FOREACH_MUTABLE, MEM_freeN(), mid_v2_v2v2(), mul_v2_m2v2(), NC_GEOM, ND_DATA, FaceIsland::offsets, blender::geometry::pack_islands(), params, blender::geometry::PackIsland::pinned, blender::geometry::PackIsland::pre_translate, blender::Vector< T, InlineBufferCapacity, Allocator >::size(), SpaceImage::tile_grid_shape, BMUVOffsets::uv, uv_coords_isect_udim(), uv_nearest_grid_tile_distance(), uv_nearest_image_tile_distance(), and WM_main_add_notifier().

Referenced by ED_uvedit_add_simple_uvs(), ED_uvedit_live_unwrap(), pack_islands_startjob(), smart_project_exec(), and unwrap_exec().

◆ uvedit_prepare_pinned_indices()

static void uvedit_prepare_pinned_indices ( ParamHandle * handle,
const Scene * scene,
BMFace * efa,
const UnwrapOptions * options,
const BMUVOffsets offsets )
static

◆ uvedit_unwrap()

◆ uvedit_unwrap_cube_project()

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

◆ uvedit_unwrap_multi()

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 )
static

Variable Documentation

◆ [struct]

◆ handles

◆ len

uint len

Definition at line 2060 of file uvedit_unwrap_ops.cc.

◆ len_alloc

uint len_alloc

◆ pack_margin_method_items

const EnumPropertyItem pack_margin_method_items[]
static
Initial value:
= {
"SCALED",
0,
"Scaled",
"Use scale of existing UVs to multiply margin"},
{ED_UVPACK_MARGIN_ADD, "ADD", 0, "Add", "Just add the margin, ignoring any UV scale"},
"FRACTION",
0,
"Fraction",
"Specify a precise fraction of final UV output"},
{0, nullptr, 0, nullptr, nullptr},
}
@ ED_UVPACK_MARGIN_FRACTION
@ ED_UVPACK_MARGIN_SCALED
@ ED_UVPACK_MARGIN_ADD

Definition at line 1803 of file uvedit_unwrap_ops.cc.

Referenced by UV_OT_pack_islands(), UV_OT_smart_project(), and UV_OT_unwrap().

◆ pack_rotate_method_items

const EnumPropertyItem pack_rotate_method_items[]
static
Initial value:
= {
{ED_UVPACK_ROTATION_ANY, "ANY", 0, "Any", "Any angle is allowed for rotation"},
"CARDINAL",
0,
"Cardinal",
"Only 90 degree rotations are allowed"},
#define PACK_ROTATE_METHOD_AXIS_ALIGNED_OFFSET
"AXIS_ALIGNED",
0,
"Axis-aligned",
"Rotated to a minimal rectangle, either vertical or horizontal"},
"AXIS_ALIGNED_X",
0,
"Axis-aligned (Horizontal)",
"Rotate islands to be aligned horizontally"},
"AXIS_ALIGNED_Y",
0,
"Axis-aligned (Vertical)",
"Rotate islands to be aligned vertically"},
{0, nullptr, 0, nullptr, nullptr},
}
@ ED_UVPACK_ROTATION_ANY
@ ED_UVPACK_ROTATION_AXIS_ALIGNED_X
@ ED_UVPACK_ROTATION_AXIS_ALIGNED
@ ED_UVPACK_ROTATION_CARDINAL
@ ED_UVPACK_ROTATION_AXIS_ALIGNED_Y
#define RNA_ENUM_ITEM_SEPR
Definition RNA_types.hh:528

Definition at line 1818 of file uvedit_unwrap_ops.cc.

Referenced by UV_OT_pack_islands(), and UV_OT_smart_project().

◆ pack_shape_method_items

const EnumPropertyItem pack_shape_method_items[]
static
Initial value:
= {
{ED_UVPACK_SHAPE_CONCAVE, "CONCAVE", 0, "Exact Shape (Concave)", "Uses exact geometry"},
{ED_UVPACK_SHAPE_CONVEX, "CONVEX", 0, "Boundary Shape (Convex)", "Uses convex hull"},
{ED_UVPACK_SHAPE_AABB, "AABB", 0, "Bounding Box", "Uses bounding boxes"},
{0, nullptr, 0, nullptr, nullptr},
}
@ ED_UVPACK_SHAPE_AABB
@ ED_UVPACK_SHAPE_CONCAVE
@ ED_UVPACK_SHAPE_CONVEX

Definition at line 1846 of file uvedit_unwrap_ops.cc.

Referenced by UV_OT_pack_islands().

◆ pinned_islands_method_items

const EnumPropertyItem pinned_islands_method_items[]
static
Initial value:
= {
{ED_UVPACK_PIN_LOCK_SCALE, "SCALE", 0, "Scale", "Pinned islands won't rescale"},
{ED_UVPACK_PIN_LOCK_ROTATION, "ROTATION", 0, "Rotation", "Pinned islands won't rotate"},
"ROTATION_SCALE",
0,
"Rotation and Scale",
"Pinned islands will translate only"},
{ED_UVPACK_PIN_LOCK_ALL, "LOCKED", 0, "All", "Pinned islands are locked in place"},
{0, nullptr, 0, nullptr, nullptr},
}
@ ED_UVPACK_PIN_LOCK_ROTATION_SCALE
@ ED_UVPACK_PIN_LOCK_SCALE
@ ED_UVPACK_PIN_LOCK_ROTATION
@ ED_UVPACK_PIN_LOCK_ALL
Note
ED_UVPACK_PIN_NONE is exposed as a boolean "pin".
ED_UVPACK_PIN_IGNORE is intentionally not exposed as it is confusing from the UI level (users can simply not select these islands). The option is kept internally because it's used for live unwrap.

Definition at line 1860 of file uvedit_unwrap_ops.cc.

Referenced by UV_OT_pack_islands().

◆ smart_uv_project_area_ignore

const float smart_uv_project_area_ignore = 1e-12f
static

◆ timer