Blender  V3.3
Classes | Variables
transform_convert_mesh.c File Reference
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_alloca.h"
#include "BLI_bitmap.h"
#include "BLI_linklist_stack.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
#include "BKE_context.h"
#include "BKE_crazyspace.h"
#include "BKE_editmesh.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_scene.h"
#include "ED_mesh.h"
#include "DEG_depsgraph_query.h"
#include "transform.h"
#include "transform_orientations.h"
#include "transform_snap.h"
#include "transform_convert.h"

Go to the source code of this file.

Classes

struct  TransCustomData_PartialUpdate
 
struct  PartialTypeState
 
struct  TransCustomDataMesh
 
struct  TransCustomDataMergeGroup
 
struct  TransCustomDataLayer
 

Functions

CustomData Layer Correction Apply
static const floattc_mesh_vert_orig_co_get (struct TransCustomDataLayer *tcld, BMVert *v)
 
static void tc_mesh_customdatacorrect_apply_vert (struct TransCustomDataLayer *tcld, struct TransDataBasic *td, struct TransCustomDataMergeGroup *merge_data, bool do_loop_mdisps)
 
static void tc_mesh_customdatacorrect_apply (TransDataContainer *tc, bool is_final)
 
CustomData Layer Correction Restore
static void tc_mesh_customdatacorrect_restore (struct TransInfo *t)
 
Island Creation
void transform_convert_mesh_islands_calc (struct BMEditMesh *em, const bool calc_single_islands, const bool calc_island_center, const bool calc_island_axismtx, struct TransIslandData *r_island_data)
 
void transform_convert_mesh_islanddata_free (struct TransIslandData *island_data)
 
Connectivity Distance for Proportional Editing
static bool bmesh_test_dist_add (BMVert *v0, BMVert *v1, BMVert *v2, float *dists, int *index, const float mtx[3][3])
 
static bool bmesh_test_loose_edge (BMEdge *edge)
 
void transform_convert_mesh_connectivity_distance (struct BMesh *bm, const float mtx[3][3], float *dists, int *index)
 
Crazy Space
void transform_convert_mesh_crazyspace_detect (TransInfo *t, struct TransDataContainer *tc, struct BMEditMesh *em, struct TransMeshDataCrazySpace *r_crazyspace_data)
 
void transform_convert_mesh_crazyspace_transdata_set (const float mtx[3][3], const float smtx[3][3], const float defmat[3][3], const float quat[4], struct TransData *r_td)
 
void transform_convert_mesh_crazyspace_free (struct TransMeshDataCrazySpace *r_crazyspace_data)
 
Edit Mesh Verts Transform Creation
static void tc_mesh_transdata_center_copy (const struct TransIslandData *island_data, const int island_index, const float iloc[3], float r_center[3])
 
static void VertsToTransData (TransInfo *t, TransData *td, TransDataExtension *tx, BMEditMesh *em, BMVert *eve, const struct TransIslandData *island_data, const int island_index)
 
static void createTransEditVerts (bContext *UNUSED(C), TransInfo *t)
 
Recalc Mesh Data (Partial Update)
static BMPartialUpdatetc_mesh_partial_ensure (TransInfo *t, TransDataContainer *tc, enum ePartialType partial_type)
 
static void tc_mesh_partial_types_calc (TransInfo *t, struct PartialTypeState *r_partial_state)
 
static void tc_mesh_partial_update (TransInfo *t, TransDataContainer *tc, const struct PartialTypeState *partial_state)
 
Recalc Mesh Data
static void tc_mesh_transdata_mirror_apply (TransDataContainer *tc)
 
static void recalcData_mesh (TransInfo *t)
 
Special After Transform Mesh
void special_aftertrans_update__mesh (bContext *UNUSED(C), TransInfo *t)
 

Variables

TransConvertTypeInfo TransConvertType_Mesh
 

Container TransCustomData Creation

#define PARTIAL_TYPE_MAX   2
 
enum  ePartialType { PARTIAL_NONE = -1 , PARTIAL_TYPE_GROUP = 0 , PARTIAL_TYPE_ALL = 1 }
 
static void tc_mesh_customdata_free_fn (struct TransInfo *t, struct TransDataContainer *tc, struct TransCustomData *custom_data)
 
static void tc_mesh_customdatacorrect_free (struct TransCustomDataLayer *tcld)
 
static struct TransCustomDataMeshtc_mesh_customdata_ensure (TransDataContainer *tc)
 
static void tc_mesh_customdata_free (struct TransCustomDataMesh *tcmd)
 
static void tc_mesh_customdata_free_fn (struct TransInfo *UNUSED(t), struct TransDataContainer *UNUSED(tc), struct TransCustomData *custom_data)
 

CustomData TransCustomDataLayer Creation

#define USE_FACE_SUBSTITUTE
 
#define FACE_SUBSTITUTE_INDEX   INT_MIN
 
static BMFacetc_mesh_customdatacorrect_find_best_face_substitute (BMFace *f)
 
static void tc_mesh_customdatacorrect_face_substitute_set (struct TransCustomDataLayer *tcld, BMFace *f, BMFace *f_copy)
 
static BMFacetc_mesh_customdatacorrect_face_substitute_get (BMFace *f_copy)
 
static void tc_mesh_customdatacorrect_init_vert (struct TransCustomDataLayer *tcld, struct TransDataBasic *td, const int index)
 
static void tc_mesh_customdatacorrect_init_container_generic (TransDataContainer *UNUSED(tc), struct TransCustomDataLayer *tcld)
 
static void tc_mesh_customdatacorrect_init_container_merge_group (TransDataContainer *tc, struct TransCustomDataLayer *tcld)
 
static struct TransCustomDataLayertc_mesh_customdatacorrect_create_impl (TransDataContainer *tc, const bool use_merge_group)
 
static void tc_mesh_customdatacorrect_create (TransDataContainer *tc, const bool use_merge_group)
 
void transform_convert_mesh_customdatacorrect_init (TransInfo *t)
 

TransDataMirror Creation

#define TRANSFORM_MAXDIST_MIRROR   0.00002f
 
static bool is_in_quadrant_v3 (const float co[3], const int quadrant[3], const float epsilon)
 
void transform_convert_mesh_mirrordata_calc (struct BMEditMesh *em, const bool use_select, const bool use_topology, const bool mirror_axis[3], struct TransMirrorData *r_mirror_data)
 
void transform_convert_mesh_mirrordata_free (struct TransMirrorData *mirror_data)
 

Macro Definition Documentation

◆ FACE_SUBSTITUTE_INDEX

#define FACE_SUBSTITUTE_INDEX   INT_MIN

Definition at line 173 of file transform_convert_mesh.c.

◆ PARTIAL_TYPE_MAX

#define PARTIAL_TYPE_MAX   2

Definition at line 78 of file transform_convert_mesh.c.

◆ TRANSFORM_MAXDIST_MIRROR

#define TRANSFORM_MAXDIST_MIRROR   0.00002f

Definition at line 1148 of file transform_convert_mesh.c.

◆ USE_FACE_SUBSTITUTE

#define USE_FACE_SUBSTITUTE

Definition at line 171 of file transform_convert_mesh.c.

Enumeration Type Documentation

◆ ePartialType

Note
It's important to order from least to greatest (which updates more data), since the larger values are used when values change between updates (which can happen when rotation is enabled with snapping).
Enumerator
PARTIAL_NONE 
PARTIAL_TYPE_GROUP 

Update only faces between tagged and non-tagged faces (affine transformations). Use when transforming is guaranteed not to change the relative locations of vertices.

This has the advantage that selecting the entire mesh or only isolated elements, can skip normal/tessellation updates entirely, so it's worth using when possible.

PARTIAL_TYPE_ALL 

Update for all tagged vertices (any kind of deformation). Use as a default since it can be used with any kind of deformation.

Definition at line 61 of file transform_convert_mesh.c.

Function Documentation

◆ bmesh_test_dist_add()

static bool bmesh_test_dist_add ( BMVert v0,
BMVert v1,
BMVert v2,
float dists,
int *  index,
const float  mtx[3][3] 
)
static

◆ bmesh_test_loose_edge()

static bool bmesh_test_loose_edge ( BMEdge edge)
static

◆ createTransEditVerts()

static void createTransEditVerts ( bContext UNUSEDC,
TransInfo t 
)
static

Quick check if we can transform.

Note
ignore modes here, even in edge/face modes, transform data is created by selected vertices.

Definition at line 1457 of file transform_convert_mesh.c.

References Freestyle::a, BKE_editmesh_from_object(), BLI_assert, BMEditMesh::bm, bm, BM_elem_flag_test, BM_ELEM_HIDDEN, BM_ELEM_SELECT, BM_ELEM_TAG, BM_ITER_MESH, BM_ITER_MESH_INDEX, BM_vert_at_index(), BM_VERTS_OF_MESH, BMVert::co, copy_m3_m4(), copy_v3_v3(), TransMeshDataCrazySpace::defmats, TransData::dist, Mesh::editflag, ELEM, fabsf, MirrorDataVert::flag, FOREACH_TRANS_DATA_CONTAINER, MirrorDataVert::index, TransIslandData::island_vert_map, TransDataMirror::loc_src, ME_EDIT_MIRROR_TOPO, MEM_callocN, MEM_freeN, MEM_mallocN, TransMirrorData::mirror_elem_len, NULL, PSEUDOINVERSE_EPSILON, pseudoinverse_m3_m3(), TransMeshDataCrazySpace::quats, SCE_SELECT_VERTEX, SCE_SNAP_ROTATE, BMEditMesh::selectmode, t, T_PROP_CONNECTED, T_PROP_EDIT, T_PROP_EDIT_ALL, tc_mesh_transdata_center_copy(), TD_MIRROR_EDGE_X, TD_MIRROR_EDGE_Y, TD_MIRROR_EDGE_Z, TD_NOTCONNECTED, TD_SELECTED, TFM_SHRINKFATTEN, TFM_TRANSLATION, BMesh::totvert, BMesh::totvertsel, transform_convert_mesh_connectivity_distance(), transform_convert_mesh_crazyspace_detect(), transform_convert_mesh_crazyspace_free(), transform_convert_mesh_crazyspace_transdata_set(), transform_convert_mesh_islanddata_free(), transform_convert_mesh_islands_calc(), transform_convert_mesh_mirrordata_calc(), transform_convert_mesh_mirrordata_free(), TRANSFORM_MAXDIST_MIRROR, usingSnappingNormal(), V3D_AROUND_LOCAL_ORIGINS, TransMirrorData::vert_map, and VertsToTransData().

◆ is_in_quadrant_v3()

static bool is_in_quadrant_v3 ( const float  co[3],
const int  quadrant[3],
const float  epsilon 
)
static

◆ recalcData_mesh()

static void recalcData_mesh ( TransInfo t)
static

◆ special_aftertrans_update__mesh()

void special_aftertrans_update__mesh ( bContext UNUSEDC,
TransInfo t 
)

◆ tc_mesh_customdata_ensure()

static struct TransCustomDataMesh* tc_mesh_customdata_ensure ( TransDataContainer tc)
static

◆ tc_mesh_customdata_free()

static void tc_mesh_customdata_free ( struct TransCustomDataMesh tcmd)
static

◆ tc_mesh_customdata_free_fn() [1/2]

static void tc_mesh_customdata_free_fn ( struct TransInfo t,
struct TransDataContainer tc,
struct TransCustomData custom_data 
)
static

◆ tc_mesh_customdata_free_fn() [2/2]

static void tc_mesh_customdata_free_fn ( struct TransInfo UNUSEDt,
struct TransDataContainer UNUSEDtc,
struct TransCustomData custom_data 
)
static

Definition at line 125 of file transform_convert_mesh.c.

References TransCustomData::data, NULL, and tc_mesh_customdata_free().

◆ tc_mesh_customdatacorrect_apply()

static void tc_mesh_customdatacorrect_apply ( TransDataContainer tc,
bool  is_final 
)
static

◆ tc_mesh_customdatacorrect_apply_vert()

static void tc_mesh_customdatacorrect_apply_vert ( struct TransCustomDataLayer tcld,
struct TransDataBasic td,
struct TransCustomDataMergeGroup merge_data,
bool  do_loop_mdisps 
)
static

◆ tc_mesh_customdatacorrect_create()

static void tc_mesh_customdatacorrect_create ( TransDataContainer tc,
const bool  use_merge_group 
)
static

◆ tc_mesh_customdatacorrect_create_impl()

static struct TransCustomDataLayer* tc_mesh_customdatacorrect_create_impl ( TransDataContainer tc,
const bool  use_merge_group 
)
static

◆ tc_mesh_customdatacorrect_face_substitute_get()

static BMFace* tc_mesh_customdatacorrect_face_substitute_get ( BMFace f_copy)
static

◆ tc_mesh_customdatacorrect_face_substitute_set()

static void tc_mesh_customdatacorrect_face_substitute_set ( struct TransCustomDataLayer tcld,
BMFace f,
BMFace f_copy 
)
static

◆ tc_mesh_customdatacorrect_find_best_face_substitute()

static BMFace* tc_mesh_customdatacorrect_find_best_face_substitute ( BMFace f)
static

Search for a neighboring face with area and preferably without selected vertex. Used to replace area-less faces in custom-data correction.

Definition at line 179 of file transform_convert_mesh.c.

References BM_elem_flag_test, BM_ELEM_SELECT, BM_ITER_ELEM, BM_LOOPS_OF_FACE, BMLoop::f, is_zero_v3(), l, BMLoop::next, BMFace::no, NULL, BMLoop::radial_next, and BMLoop::v.

Referenced by tc_mesh_customdatacorrect_face_substitute_set().

◆ tc_mesh_customdatacorrect_free()

static void tc_mesh_customdatacorrect_free ( struct TransCustomDataLayer tcld)
static

◆ tc_mesh_customdatacorrect_init_container_generic()

static void tc_mesh_customdatacorrect_init_container_generic ( TransDataContainer UNUSEDtc,
struct TransCustomDataLayer tcld 
)
static

◆ tc_mesh_customdatacorrect_init_container_merge_group()

static void tc_mesh_customdatacorrect_init_container_merge_group ( TransDataContainer tc,
struct TransCustomDataLayer tcld 
)
static

◆ tc_mesh_customdatacorrect_init_vert()

static void tc_mesh_customdatacorrect_init_vert ( struct TransCustomDataLayer tcld,
struct TransDataBasic td,
const int  index 
)
static

◆ tc_mesh_customdatacorrect_restore()

static void tc_mesh_customdatacorrect_restore ( struct TransInfo t)
static

◆ tc_mesh_partial_ensure()

static BMPartialUpdate* tc_mesh_partial_ensure ( TransInfo t,
TransDataContainer tc,
enum ePartialType  partial_type 
)
static

◆ tc_mesh_partial_types_calc()

static void tc_mesh_partial_types_calc ( TransInfo t,
struct PartialTypeState r_partial_state 
)
static

◆ tc_mesh_partial_update()

static void tc_mesh_partial_update ( TransInfo t,
TransDataContainer tc,
const struct PartialTypeState partial_state 
)
static

◆ tc_mesh_transdata_center_copy()

static void tc_mesh_transdata_center_copy ( const struct TransIslandData island_data,
const int  island_index,
const float  iloc[3],
float  r_center[3] 
)
static

Definition at line 1392 of file transform_convert_mesh.c.

References TransIslandData::center, and copy_v3_v3().

Referenced by createTransEditVerts(), and VertsToTransData().

◆ tc_mesh_transdata_mirror_apply()

static void tc_mesh_transdata_mirror_apply ( TransDataContainer tc)
static

◆ tc_mesh_vert_orig_co_get()

static const float* tc_mesh_vert_orig_co_get ( struct TransCustomDataLayer tcld,
BMVert v 
)
static

If we're sliding the vert, return its original location, if not, the current location is good.

Definition at line 494 of file transform_convert_mesh.c.

References BLI_ghash_lookup(), BMVert::co, TransCustomDataLayer::merge_group, TransCustomDataLayer::origverts, and v.

Referenced by tc_mesh_customdatacorrect_apply_vert().

◆ transform_convert_mesh_connectivity_distance()

void transform_convert_mesh_connectivity_distance ( struct BMesh bm,
const float  mtx[3][3],
float dists,
int *  index 
)

◆ transform_convert_mesh_crazyspace_detect()

void transform_convert_mesh_crazyspace_detect ( TransInfo t,
struct TransDataContainer tc,
struct BMEditMesh em,
struct TransMeshDataCrazySpace r_crazyspace_data 
)

◆ transform_convert_mesh_crazyspace_free()

void transform_convert_mesh_crazyspace_free ( struct TransMeshDataCrazySpace r_crazyspace_data)

◆ transform_convert_mesh_crazyspace_transdata_set()

void transform_convert_mesh_crazyspace_transdata_set ( const float  mtx[3][3],
const float  smtx[3][3],
const float  defmat[3][3],
const float  quat[4],
struct TransData r_td 
)

◆ transform_convert_mesh_customdatacorrect_init()

void transform_convert_mesh_customdatacorrect_init ( TransInfo t)

◆ transform_convert_mesh_islanddata_free()

void transform_convert_mesh_islanddata_free ( struct TransIslandData island_data)

◆ transform_convert_mesh_islands_calc()

void transform_convert_mesh_islands_calc ( struct BMEditMesh em,
const bool  calc_single_islands,
const bool  calc_island_center,
const bool  calc_island_axismtx,
struct TransIslandData r_island_data 
)

◆ transform_convert_mesh_mirrordata_calc()

void transform_convert_mesh_mirrordata_calc ( struct BMEditMesh em,
const bool  use_select,
const bool  use_topology,
const bool  mirror_axis[3],
struct TransMirrorData r_mirror_data 
)

◆ transform_convert_mesh_mirrordata_free()

void transform_convert_mesh_mirrordata_free ( struct TransMirrorData mirror_data)

◆ VertsToTransData()

static void VertsToTransData ( TransInfo t,
TransData td,
TransDataExtension tx,
BMEditMesh em,
BMVert eve,
const struct TransIslandData island_data,
const int  island_index 
)
static

Variable Documentation

◆ TransConvertType_Mesh

TransConvertTypeInfo TransConvertType_Mesh
Initial value:
= {
}
static void createTransEditVerts(bContext *UNUSED(C), TransInfo *t)
void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t)
static void recalcData_mesh(TransInfo *t)

Definition at line 2133 of file transform_convert_mesh.c.

Referenced by convert_type_get(), init_proportional_edit(), init_TransDataContainers(), initSnappingMode(), transform_mode_init(), and viewRedrawPost().