Blender V4.3
uvedit_smart_stitch.cc File Reference
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_ghash.h"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLT_translation.hh"
#include "BKE_context.hh"
#include "BKE_customdata.hh"
#include "BKE_editmesh.hh"
#include "BKE_layer.hh"
#include "BKE_mesh_mapping.hh"
#include "BKE_report.hh"
#include "DEG_depsgraph.hh"
#include "UI_interface.hh"
#include "ED_mesh.hh"
#include "ED_screen.hh"
#include "ED_space_api.hh"
#include "ED_uvedit.hh"
#include "GPU_batch.hh"
#include "GPU_state.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "RNA_prototypes.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "UI_resources.hh"
#include "UI_view2d.hh"
#include "uvedit_intern.hh"

Go to the source code of this file.

Classes

struct  StitchPreviewer
 
struct  IslandStitchData
 
struct  UVVertAverage
 
struct  UvEdge
 
struct  StitchState
 
struct  StitchStateContainer
 
struct  PreviewPosition
 
struct  UvElementID
 
struct  StitchStateInit
 

Macros

#define STITCH_NO_PREVIEW   -1
 

Enumerations

enum  {
  STITCH_SELECTED = 1 , STITCH_STITCHABLE = 2 , STITCH_PROCESSED = 4 , STITCH_BOUNDARY = 8 ,
  STITCH_STITCHABLE_CANDIDATE = 16
}
 
enum  StitchModes { STITCH_VERT , STITCH_EDGE }
 

Functions

static StitchPreviewerstitch_preview_init ()
 
static void stitch_preview_delete (StitchPreviewer *stitch_preview)
 
static void stitch_update_header (StitchStateContainer *ssc, bContext *C)
 
static void stitch_uv_rotate (const float mat[2][2], const float medianPoint[2], float uv[2], float aspect)
 
static bool stitch_check_uvs_stitchable (const int cd_loop_uv_offset, UvElement *element, UvElement *element_iter, StitchStateContainer *ssc)
 
static bool stitch_check_edges_stitchable (const int cd_loop_uv_offset, UvEdge *edge, UvEdge *edge_iter, StitchStateContainer *ssc, StitchState *state)
 
static bool stitch_check_uvs_state_stitchable (const int cd_loop_uv_offset, UvElement *element, UvElement *element_iter, StitchStateContainer *ssc)
 
static bool stitch_check_edges_state_stitchable (const int cd_loop_uv_offset, UvEdge *edge, UvEdge *edge_iter, StitchStateContainer *ssc, StitchState *state)
 
static void stitch_calculate_island_snapping (const int cd_loop_uv_offset, StitchState *state, PreviewPosition *preview_position, StitchPreviewer *preview, IslandStitchData *island_stitch_data, int final)
 
static void stitch_island_calculate_edge_rotation (const int cd_loop_uv_offset, UvEdge *edge, StitchStateContainer *ssc, StitchState *state, UVVertAverage *uv_average, const uint *uvfinal_map, IslandStitchData *island_stitch_data)
 
static void stitch_island_calculate_vert_rotation (const int cd_loop_uv_offset, UvElement *element, StitchStateContainer *ssc, StitchState *state, IslandStitchData *island_stitch_data)
 
static void state_delete (StitchState *state)
 
static void state_delete_all (StitchStateContainer *ssc)
 
static void stitch_uv_edge_generate_linked_edges (GHash *edge_hash, StitchState *state)
 
static void determine_uv_stitchability (const int cd_loop_uv_offset, UvElement *element, StitchStateContainer *ssc, StitchState *state, IslandStitchData *island_stitch_data)
 
static void determine_uv_edge_stitchability (const int cd_loop_uv_offset, UvEdge *edge, StitchStateContainer *ssc, StitchState *state, IslandStitchData *island_stitch_data)
 
static void stitch_set_face_preview_buffer_position (BMFace *efa, StitchPreviewer *preview, PreviewPosition *preview_position)
 
static void stitch_setup_face_preview_for_uv_group (UvElement *element, StitchStateContainer *ssc, StitchState *state, IslandStitchData *island_stitch_data, PreviewPosition *preview_position)
 
static void stitch_validate_uv_stitchability (const int cd_loop_uv_offset, UvElement *element, StitchStateContainer *ssc, StitchState *state, IslandStitchData *island_stitch_data, PreviewPosition *preview_position)
 
static void stitch_validate_edge_stitchability (const int cd_loop_uv_offset, UvEdge *edge, StitchStateContainer *ssc, StitchState *state, IslandStitchData *island_stitch_data, PreviewPosition *preview_position)
 
static void stitch_propagate_uv_final_position (Scene *scene, UvElement *element, int index, PreviewPosition *preview_position, UVVertAverage *final_position, StitchStateContainer *ssc, StitchState *state, const bool final)
 
static int stitch_process_data (StitchStateContainer *ssc, StitchState *state, Scene *scene, int final)
 
static int stitch_process_data_all (StitchStateContainer *ssc, Scene *scene, int final)
 
static uint uv_edge_hash (const void *key)
 
static bool uv_edge_compare (const void *a, const void *b)
 
static void stitch_select_edge (UvEdge *edge, StitchState *state, int always_select)
 
static void stitch_select_uv (UvElement *element, StitchState *state, int always_select)
 
static void stitch_set_selection_mode (StitchState *state, const char from_stitch_mode)
 
static void stitch_switch_selection_mode_all (StitchStateContainer *ssc)
 
static void stitch_calculate_edge_normal (const int cd_loop_uv_offset, UvEdge *edge, float *normal, float aspect)
 
static void stitch_draw_vbo (blender::gpu::VertBuf *vbo, GPUPrimType prim_type, const float col[4])
 
static void stitch_draw (const bContext *, ARegion *, void *arg)
 
static UvEdgeuv_edge_get (BMLoop *l, StitchState *state)
 
static StitchStatestitch_init (bContext *C, wmOperator *op, StitchStateContainer *ssc, Object *obedit, StitchStateInit *state_init)
 
static bool goto_next_island (StitchStateContainer *ssc)
 
static int stitch_init_all (bContext *C, wmOperator *op)
 
static int stitch_invoke (bContext *C, wmOperator *op, const wmEvent *)
 
static void stitch_exit (bContext *C, wmOperator *op, int finished)
 
static void stitch_cancel (bContext *C, wmOperator *op)
 
static int stitch_exec (bContext *C, wmOperator *op)
 
static StitchStatestitch_select (bContext *C, Scene *scene, const wmEvent *event, StitchStateContainer *ssc)
 
static int stitch_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
void UV_OT_stitch (wmOperatorType *ot)
 

Macro Definition Documentation

◆ STITCH_NO_PREVIEW

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
STITCH_SELECTED 
STITCH_STITCHABLE 
STITCH_PROCESSED 
STITCH_BOUNDARY 
STITCH_STITCHABLE_CANDIDATE 

Definition at line 207 of file uvedit_smart_stitch.cc.

◆ StitchModes

Enumerator
STITCH_VERT 
STITCH_EDGE 

Definition at line 217 of file uvedit_smart_stitch.cc.

Function Documentation

◆ determine_uv_edge_stitchability()

static void determine_uv_edge_stitchability ( const int cd_loop_uv_offset,
UvEdge * edge,
StitchStateContainer * ssc,
StitchState * state,
IslandStitchData * island_stitch_data )
static

◆ determine_uv_stitchability()

static void determine_uv_stitchability ( const int cd_loop_uv_offset,
UvElement * element,
StitchStateContainer * ssc,
StitchState * state,
IslandStitchData * island_stitch_data )
static

◆ goto_next_island()

◆ state_delete()

static void state_delete ( StitchState * state)
static

◆ state_delete_all()

◆ stitch_calculate_edge_normal()

static void stitch_calculate_edge_normal ( const int cd_loop_uv_offset,
UvEdge * edge,
float * normal,
float aspect )
static

Definition at line 1643 of file uvedit_smart_stitch.cc.

References BM_ELEM_CD_GET_FLOAT_P, BMLoop::next, normalize_v2(), and sub_v2_v2v2().

Referenced by stitch_init().

◆ stitch_calculate_island_snapping()

◆ stitch_cancel()

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

Definition at line 2457 of file uvedit_smart_stitch.cc.

References stitch_exit().

Referenced by stitch_exec(), stitch_modal(), and UV_OT_stitch().

◆ stitch_check_edges_state_stitchable()

static bool stitch_check_edges_state_stitchable ( const int cd_loop_uv_offset,
UvEdge * edge,
UvEdge * edge_iter,
StitchStateContainer * ssc,
StitchState * state )
static

◆ stitch_check_edges_stitchable()

static bool stitch_check_edges_stitchable ( const int cd_loop_uv_offset,
UvEdge * edge,
UvEdge * edge_iter,
StitchStateContainer * ssc,
StitchState * state )
static

◆ stitch_check_uvs_state_stitchable()

static bool stitch_check_uvs_state_stitchable ( const int cd_loop_uv_offset,
UvElement * element,
UvElement * element_iter,
StitchStateContainer * ssc )
static

◆ stitch_check_uvs_stitchable()

static bool stitch_check_uvs_stitchable ( const int cd_loop_uv_offset,
UvElement * element,
UvElement * element_iter,
StitchStateContainer * ssc )
static

◆ stitch_draw()

◆ stitch_draw_vbo()

◆ stitch_exec()

◆ stitch_exit()

◆ stitch_init()

static StitchState * stitch_init ( bContext * C,
wmOperator * op,
StitchStateContainer * ssc,
Object * obedit,
StitchStateInit * state_init )
static

◆ stitch_init_all()

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

◆ stitch_invoke()

◆ stitch_island_calculate_edge_rotation()

◆ stitch_island_calculate_vert_rotation()

◆ stitch_modal()

◆ stitch_preview_delete()

◆ stitch_preview_init()

◆ stitch_process_data()

static int stitch_process_data ( StitchStateContainer * ssc,
StitchState * state,
Scene * scene,
int final )
static

Definition at line 948 of file uvedit_smart_stitch.cc.

References StitchStateContainer::active_object_index, add_v2_v2(), BLI_assert, bm, BM_ELEM_CD_GET_FLOAT_P, BM_elem_flag_disable, BM_elem_index_get, BM_ELEM_SEAM, BM_FACE, BM_FACE_FIRST_LOOP, BM_FACES_OF_MESH, BM_ITER_ELEM_INDEX, BM_ITER_MESH, BM_LOOPS_OF_FACE, BM_mesh_elem_index_ensure(), BM_uv_element_get(), BM_VERT, CD_PROP_FLOAT2, StitchStateContainer::clear_seams, copy_v2_v2(), UVVertAverage::count, CustomData_get_offset(), PreviewPosition::data_position, determine_uv_edge_stitchability(), determine_uv_stitchability(), UvEdge::element, UvEdge::first, UvElement::island, l, UvElement::l, BMesh::ldata, BMFace::len, IslandStitchData::medianPoint, MEM_callocN, MEM_freeN(), MEM_mallocN, StitchStateContainer::midpoints, StitchStateContainer::mode, BMLoop::next, UvEdge::next, UvElement::next, StitchPreviewer::num_polys, StitchPreviewer::num_static_tris, StitchPreviewer::num_stitchable, StitchPreviewer::num_unstitchable, IslandStitchData::numOfElements, PreviewPosition::polycount_position, StitchPreviewer::preview_polys, StitchPreviewer::preview_stitchable, StitchPreviewer::preview_unstitchable, StitchPreviewer::preview_uvs, UvElement::separate, StitchStateContainer::snap_islands, state, StitchStateContainer::states, StitchStateContainer::static_island, StitchPreviewer::static_tris, STITCH_BOUNDARY, stitch_calculate_island_snapping(), stitch_check_edges_state_stitchable(), stitch_check_uvs_state_stitchable(), STITCH_EDGE, stitch_island_calculate_edge_rotation(), stitch_island_calculate_vert_rotation(), STITCH_NO_PREVIEW, stitch_preview_delete(), stitch_preview_init(), stitch_propagate_uv_final_position(), STITCH_SELECTED, stitch_set_face_preview_buffer_position(), STITCH_STITCHABLE, STITCH_STITCHABLE_CANDIDATE, stitch_validate_edge_stitchability(), stitch_validate_uv_stitchability(), STITCH_VERT, IslandStitchData::stitchableCandidate, BMesh::totface, IslandStitchData::translation, true, IslandStitchData::use_edge_rotation, UVVertAverage::uv, UvEdge::uv1, UvEdge::uv2, StitchPreviewer::uvs_per_polygon, and BMLoop::v.

Referenced by stitch_init(), stitch_init_all(), stitch_modal(), and stitch_process_data_all().

◆ stitch_process_data_all()

static int stitch_process_data_all ( StitchStateContainer * ssc,
Scene * scene,
int final )
static

◆ stitch_propagate_uv_final_position()

◆ stitch_select()

◆ stitch_select_edge()

static void stitch_select_edge ( UvEdge * edge,
StitchState * state,
int always_select )
static

◆ stitch_select_uv()

static void stitch_select_uv ( UvElement * element,
StitchState * state,
int always_select )
static

◆ stitch_set_face_preview_buffer_position()

◆ stitch_set_selection_mode()

static void stitch_set_selection_mode ( StitchState * state,
const char from_stitch_mode )
static

◆ stitch_setup_face_preview_for_uv_group()

◆ stitch_switch_selection_mode_all()

static void stitch_switch_selection_mode_all ( StitchStateContainer * ssc)
static

◆ stitch_update_header()

◆ stitch_uv_edge_generate_linked_edges()

◆ stitch_uv_rotate()

static void stitch_uv_rotate ( const float mat[2][2],
const float medianPoint[2],
float uv[2],
float aspect )
static

Definition at line 298 of file uvedit_smart_stitch.cc.

References add_v2_v2v2(), mul_v2_m2v2(), and sub_v2_v2().

Referenced by stitch_calculate_island_snapping().

◆ stitch_validate_edge_stitchability()

◆ stitch_validate_uv_stitchability()

◆ uv_edge_compare()

static bool uv_edge_compare ( const void * a,
const void * b )
static

Definition at line 1505 of file uvedit_smart_stitch.cc.

References b, BLI_assert, UvEdge::uv1, and UvEdge::uv2.

Referenced by stitch_init().

◆ uv_edge_get()

static UvEdge * uv_edge_get ( BMLoop * l,
StitchState * state )
static

◆ uv_edge_hash()

static uint uv_edge_hash ( const void * key)
static

Definition at line 1498 of file uvedit_smart_stitch.cc.

References BLI_assert, and BLI_ghashutil_uinthash().

Referenced by stitch_init().

◆ UV_OT_stitch()