Blender V5.0
uvedit_smart_stitch.cc File Reference
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <fmt/format.h>
#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 "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 "BKE_screen.hh"
#include "DEG_depsgraph.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.

Macros

#define STITCH_NO_PREVIEW   -1

Functions

static StitchPreviewer * stitch_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 UvEdge * uv_edge_get (BMLoop *l, StitchState *state)
static StitchState * stitch_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 wmOperatorStatus 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 wmOperatorStatus stitch_exec (bContext *C, wmOperator *op)
static StitchState * stitch_select (bContext *C, Scene *scene, const wmEvent *event, StitchStateContainer *ssc)
static wmOperatorStatus stitch_modal (bContext *C, wmOperator *op, const wmEvent *event)
void UV_OT_stitch (wmOperatorType *ot)

Macro Definition Documentation

◆ STITCH_NO_PREVIEW

#define STITCH_NO_PREVIEW   -1

Function Documentation

◆ determine_uv_edge_stitchability()

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

Definition at line 756 of file uvedit_smart_stitch.cc.

References state, and stitch_check_edges_stitchable().

Referenced by stitch_process_data().

◆ determine_uv_stitchability()

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

◆ goto_next_island()

bool goto_next_island ( StitchStateContainer * ssc)
static

Definition at line 2148 of file uvedit_smart_stitch.cc.

References UvElementMap::total_islands.

Referenced by stitch_init_all(), and stitch_modal().

◆ state_delete()

void state_delete ( StitchState * state)
static

◆ state_delete_all()

void state_delete_all ( StitchStateContainer * ssc)
static

Definition at line 645 of file uvedit_smart_stitch.cc.

References MEM_freeN(), and state_delete().

Referenced by stitch_exit(), and stitch_init_all().

◆ stitch_calculate_edge_normal()

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

Definition at line 1642 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()

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

◆ stitch_cancel()

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

Definition at line 2448 of file uvedit_smart_stitch.cc.

References C, and stitch_exit().

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

◆ stitch_check_edges_state_stitchable()

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

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

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

◆ stitch_check_uvs_stitchable()

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

◆ stitch_init_all()

◆ stitch_invoke()

◆ stitch_island_calculate_edge_rotation()

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

◆ stitch_island_calculate_vert_rotation()

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

◆ stitch_modal()

◆ stitch_preview_delete()

void stitch_preview_delete ( StitchPreviewer * stitch_preview)
static

Definition at line 260 of file uvedit_smart_stitch.cc.

References MEM_freeN(), and MEM_SAFE_FREE.

Referenced by state_delete(), and stitch_process_data().

◆ stitch_preview_init()

StitchPreviewer * stitch_preview_init ( )
static

Definition at line 237 of file uvedit_smart_stitch.cc.

References MEM_mallocN().

Referenced by stitch_process_data().

◆ stitch_process_data()

◆ stitch_process_data_all()

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

Definition at line 1485 of file uvedit_smart_stitch.cc.

References stitch_process_data().

Referenced by stitch_exec(), and stitch_modal().

◆ stitch_propagate_uv_final_position()

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

◆ stitch_select()

◆ stitch_select_edge()

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

Definition at line 1518 of file uvedit_smart_stitch.cc.

References i, and state.

Referenced by stitch_init(), stitch_select(), and stitch_set_selection_mode().

◆ stitch_select_uv()

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

◆ stitch_set_face_preview_buffer_position()

void stitch_set_face_preview_buffer_position ( BMFace * efa,
StitchPreviewer * preview,
PreviewPosition * preview_position )
static

◆ stitch_set_selection_mode()

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

◆ stitch_setup_face_preview_for_uv_group()

void stitch_setup_face_preview_for_uv_group ( UvElement * element,
StitchStateContainer * ssc,
StitchState * state,
IslandStitchData * island_stitch_data,
PreviewPosition * preview_position )
static

◆ stitch_switch_selection_mode_all()

void stitch_switch_selection_mode_all ( StitchStateContainer * ssc)
static

Definition at line 1628 of file uvedit_smart_stitch.cc.

References stitch_set_selection_mode().

Referenced by stitch_modal().

◆ stitch_update_header()

void stitch_update_header ( StitchStateContainer * ssc,
bContext * C )
static

Definition at line 273 of file uvedit_smart_stitch.cc.

References C, IFACE_, and status.

Referenced by stitch_init_all(), and stitch_modal().

◆ stitch_uv_edge_generate_linked_edges()

void stitch_uv_edge_generate_linked_edges ( GHash * edge_hash,
StitchState * state )
static

◆ stitch_uv_rotate()

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

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

◆ stitch_validate_uv_stitchability()

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

◆ uv_edge_compare()

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

Definition at line 1504 of file uvedit_smart_stitch.cc.

References b, and BLI_assert.

◆ uv_edge_get()

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

Definition at line 1801 of file uvedit_smart_stitch.cc.

References BLI_ghash_lookup(), BM_uv_element_get(), l, and state.

Referenced by stitch_init(), and stitch_select().

◆ uv_edge_hash()

uint uv_edge_hash ( const void * key)
static

Definition at line 1497 of file uvedit_smart_stitch.cc.

References BLI_assert, and BLI_ghashutil_uinthash().

◆ UV_OT_stitch()