Blender V4.3
transform_convert_mesh.cc File Reference
#include "DNA_mesh_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_alloca.h"
#include "BLI_bitmap.h"
#include "BLI_linklist_stack.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_utildefines_stack.h"
#include "BKE_context.hh"
#include "BKE_crazyspace.hh"
#include "BKE_editmesh.hh"
#include "BKE_mesh.hh"
#include "BKE_modifier.hh"
#include "BKE_scene.hh"
#include "ED_mesh.hh"
#include "ED_object.hh"
#include "DEG_depsgraph_query.hh"
#include "transform.hh"
#include "transform_orientations.hh"
#include "transform_snap.hh"
#include "transform_convert.hh"

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 floatmesh_vert_orig_co_get (TransCustomDataLayer *tcld, BMVert *v)
 
static void mesh_customdatacorrect_apply_vert (TransCustomDataLayer *tcld, TransDataBasic *td, TransCustomDataMergeGroup *merge_data, bool do_loop_mdisps)
 
static void mesh_customdatacorrect_apply (TransDataContainer *tc, bool is_final)
 
CustomData Layer Correction Restore
static void mesh_customdatacorrect_restore (TransInfo *t)
 
Island Creation
void transform_convert_mesh_islands_calc (BMEditMesh *em, const bool calc_single_islands, const bool calc_island_center, const bool calc_island_axismtx, TransIslandData *r_island_data)
 
void transform_convert_mesh_islanddata_free (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 (BMesh *bm, const float mtx[3][3], float *dists, int *index)
 
Crazy Space
void transform_convert_mesh_crazyspace_detect (TransInfo *t, TransDataContainer *tc, BMEditMesh *em, 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], TransData *r_td)
 
void transform_convert_mesh_crazyspace_free (TransMeshDataCrazySpace *r_crazyspace_data)
 
Edit Mesh Verts Transform Creation
static void mesh_transdata_center_copy (const 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 TransIslandData *island_data, const int island_index)
 
static void createTransEditVerts (bContext *, TransInfo *t)
 
Recalc Mesh Data (Partial Update)
static BMPartialUpdatemesh_partial_ensure (TransInfo *t, TransDataContainer *tc, enum ePartialType partial_type)
 
static void mesh_partial_types_calc (TransInfo *t, PartialTypeState *r_partial_state)
 
static void mesh_partial_update (TransInfo *t, TransDataContainer *tc, const PartialTypeState *partial_state)
 
Recalc Mesh Data
static void mesh_transdata_mirror_apply (TransDataContainer *tc)
 
static void recalcData_mesh (TransInfo *t)
 
Special After Transform Mesh
static void special_aftertrans_update__mesh (bContext *, TransInfo *t)
 
API for Vert Slide
Array< TransDataVertSlideVerttransform_mesh_vert_slide_data_create (const TransDataContainer *tc, Vector< float3 > &r_loc_dst_buffer)
 
API for Edge Slide
static bool mesh_vert_is_inner (BMVert *v)
 
static bool bm_loop_calc_opposite_co (const BMLoop *l_tmp, const float plane_no[3], float r_co[3])
 
static float3 isect_face_dst (const BMLoop *l)
 
Array< TransDataEdgeSlideVerttransform_mesh_edge_slide_data_create (const TransDataContainer *tc, int *r_group_len)
 

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 mesh_customdata_free_fn (TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data)
 
static void mesh_customdatacorrect_free (TransCustomDataLayer *tcld)
 
static TransCustomDataMeshmesh_customdata_ensure (TransDataContainer *tc)
 
static void mesh_customdata_free (TransCustomDataMesh *tcmd)
 

CustomData TransCustomDataLayer Creation

#define USE_FACE_SUBSTITUTE
 
#define FACE_SUBSTITUTE_INDEX   INT_MIN
 
static BMFacemesh_customdatacorrect_find_best_face_substitute (BMFace *f)
 
static void mesh_customdatacorrect_face_substitute_set (TransCustomDataLayer *tcld, BMFace *f, BMFace *f_copy)
 
static BMFacemesh_customdatacorrect_face_substitute_get (BMFace *f_copy)
 
static void mesh_customdatacorrect_init_vert (TransCustomDataLayer *tcld, TransDataBasic *td, const int index)
 
static void mesh_customdatacorrect_init_container_generic (TransDataContainer *, TransCustomDataLayer *tcld)
 
static void mesh_customdatacorrect_init_container_merge_group (TransDataContainer *tc, TransCustomDataLayer *tcld)
 
static TransCustomDataLayermesh_customdatacorrect_create_impl (TransDataContainer *tc, const bool use_merge_group)
 
static void 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 (BMEditMesh *em, const bool use_select, const bool use_topology, const bool mirror_axis[3], TransMirrorData *r_mirror_data)
 
void transform_convert_mesh_mirrordata_free (TransMirrorData *mirror_data)
 

Macro Definition Documentation

◆ FACE_SUBSTITUTE_INDEX

◆ PARTIAL_TYPE_MAX

#define PARTIAL_TYPE_MAX   2

Definition at line 85 of file transform_convert_mesh.cc.

◆ TRANSFORM_MAXDIST_MIRROR

#define TRANSFORM_MAXDIST_MIRROR   0.00002f

◆ USE_FACE_SUBSTITUTE

#define USE_FACE_SUBSTITUTE

Definition at line 178 of file transform_convert_mesh.cc.

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 68 of file transform_convert_mesh.cc.

Function Documentation

◆ bm_loop_calc_opposite_co()

static bool bm_loop_calc_opposite_co ( const BMLoop * l_tmp,
const float plane_no[3],
float r_co[3] )
static

Find the closest point on the ngon on the opposite side. used to set the edge slide distance for ngons.

Definition at line 2253 of file transform_convert_mesh.cc.

References BMVert::co, copy_v3_v3(), FLT_MAX, isect_line_plane_v3(), len_squared_v3v3(), line_point_factor_v3(), BMLoop::next, BMLoop::prev, and BMLoop::v.

Referenced by isect_face_dst().

◆ bmesh_test_dist_add()

◆ bmesh_test_loose_edge()

static bool bmesh_test_loose_edge ( BMEdge * edge)
static

◆ createTransEditVerts()

static void createTransEditVerts ( bContext * ,
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 1491 of file transform_convert_mesh.cc.

References TransInfo::around, BKE_editmesh_from_object(), BKE_editmesh_looptris_calc(), BLI_assert, bm, BMEditMesh::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, ELEM, fabsf, MirrorDataVert::flag, TransInfo::flag, FLT_MAX, FOREACH_TRANS_DATA_CONTAINER, MirrorDataVert::index, TransIslandData::island_vert_map, TransDataMirror::loc_src, BMEditMesh::looptris, ME_EDIT_MIRROR_TOPO, MEM_callocN, MEM_freeN(), MEM_mallocN, mesh_transdata_center_copy(), TransMirrorData::mirror_elem_len, TransInfo::mode, poly_to_tri_count(), PSEUDOINVERSE_EPSILON, pseudoinverse_m3_m3(), TransMeshDataCrazySpace::quats, TransInfo::reports, SCE_SELECT_VERTEX, SCE_SNAP_ROTATE, BMEditMesh::selectmode, TransInfo::settings, blender::ed::object::shape_key_report_if_locked(), blender::Array< T, InlineBufferCapacity, Allocator >::size(), ToolSettings::snap_flag, T_PROP_CONNECTED, T_PROP_EDIT, T_PROP_EDIT_ALL, TD_MIRROR_EDGE_X, TD_MIRROR_EDGE_Y, TD_MIRROR_EDGE_Z, TD_SELECTED, TFM_DUMMY, TFM_SHRINKFATTEN, TFM_TRANSLATION, BMesh::totface, BMesh::totloop, 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

Definition at line 1189 of file transform_convert_mesh.cc.

Referenced by transform_convert_mesh_mirrordata_calc().

◆ isect_face_dst()

◆ mesh_customdata_ensure()

◆ mesh_customdata_free()

◆ mesh_customdata_free_fn()

static void mesh_customdata_free_fn ( TransInfo * t,
TransDataContainer * tc,
TransCustomData * custom_data )
static

Definition at line 132 of file transform_convert_mesh.cc.

References TransCustomData::data, and mesh_customdata_free().

Referenced by mesh_customdata_ensure().

◆ mesh_customdatacorrect_apply()

◆ mesh_customdatacorrect_apply_vert()

◆ mesh_customdatacorrect_create()

static void mesh_customdatacorrect_create ( TransDataContainer * tc,
const bool use_merge_group )
static

◆ mesh_customdatacorrect_create_impl()

◆ mesh_customdatacorrect_face_substitute_get()

static BMFace * mesh_customdatacorrect_face_substitute_get ( BMFace * f_copy)
static

◆ mesh_customdatacorrect_face_substitute_set()

◆ mesh_customdatacorrect_find_best_face_substitute()

static BMFace * 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 186 of file transform_convert_mesh.cc.

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, BMLoop::radial_next, and BMLoop::v.

Referenced by mesh_customdatacorrect_face_substitute_set().

◆ mesh_customdatacorrect_free()

◆ mesh_customdatacorrect_init_container_generic()

◆ mesh_customdatacorrect_init_container_merge_group()

◆ mesh_customdatacorrect_init_vert()

◆ mesh_customdatacorrect_restore()

◆ mesh_partial_ensure()

◆ mesh_partial_types_calc()

◆ mesh_partial_update()

◆ mesh_transdata_center_copy()

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

Definition at line 1426 of file transform_convert_mesh.cc.

References TransIslandData::center, and copy_v3_v3().

Referenced by createTransEditVerts(), and VertsToTransData().

◆ mesh_transdata_mirror_apply()

◆ mesh_vert_is_inner()

static bool mesh_vert_is_inner ( BMVert * v)
static

◆ mesh_vert_orig_co_get()

static const float * mesh_vert_orig_co_get ( 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 520 of file transform_convert_mesh.cc.

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

Referenced by mesh_customdatacorrect_apply_vert().

◆ recalcData_mesh()

◆ special_aftertrans_update__mesh()

◆ transform_convert_mesh_connectivity_distance()

◆ transform_convert_mesh_crazyspace_detect()

◆ transform_convert_mesh_crazyspace_free()

void transform_convert_mesh_crazyspace_free ( 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],
TransData * r_td )

◆ transform_convert_mesh_customdatacorrect_init()

◆ transform_convert_mesh_islanddata_free()

void transform_convert_mesh_islanddata_free ( TransIslandData * island_data)

◆ transform_convert_mesh_islands_calc()

◆ transform_convert_mesh_mirrordata_calc()

◆ transform_convert_mesh_mirrordata_free()

void transform_convert_mesh_mirrordata_free ( TransMirrorData * mirror_data)

Definition at line 1321 of file transform_convert_mesh.cc.

References MEM_freeN(), and TransMirrorData::vert_map.

Referenced by createTransEditVerts(), and createTransMeshSkin().

◆ transform_mesh_edge_slide_data_create()

Array< TransDataEdgeSlideVert > transform_mesh_edge_slide_data_create ( const TransDataContainer * tc,
int * r_group_len )

We need at least 3 points to calculate the intersection of prev-curr and next-curr destinations. next_next is only required to identify the edge in next.e.

| | | | | prev.e | curr.e | next.e | prev.v -— curr.v -— next.v -— next_next.v

Find the best direction to slide among the ones already computed.

Parameters
curr_side_otherprevious state of the #SlideTempDataMesh where the faces are linked to the previous edge.
l_srcthe source corner in the edge to slide.
l_dstthe current destination corner.

Definition at line 2306 of file transform_convert_mesh.cc.

References BKE_editmesh_from_object(), bm, BMEditMesh::bm, BM_edge_exists(), BM_edge_is_boundary(), BM_edge_is_manifold(), BM_EDGES_OF_MESH, BM_EDGES_OF_VERT, BM_elem_flag_test, BM_elem_index_get, BM_elem_index_set, BM_ELEM_SELECT, BM_ITER_ELEM, BM_iter_elem_count_flag(), BM_ITER_MESH, BM_LOOPS_OF_EDGE, BM_VERT, BM_VERTS_OF_MESH, BMVert::co, TransDataContainer::data, TransDataContainer::data_len, TransDataEdgeSlideVert::dir_side, blender::math::distance(), blender::math::dot(), BMLoop::e, e, ELEM, BMesh::elem_index_dirty, BMLoop::f, blender::Array< T, InlineBufferCapacity, Allocator >::index_range(), int, isect_face_dst(), isect_line_line_epsilon_v3(), l, TransDataEdgeSlideVert::loop_nr, mesh_vert_is_inner(), blender::math::midpoint(), BMLoop::next, next, blender::math::normalize(), TransDataContainer::obedit, BMLoop::prev, BMLoop::radial_next, TransDataEdgeSlideVert::td, TD_SELECTED, BMLoop::v, and v.

Referenced by createEdgeSlideVerts().

◆ transform_mesh_vert_slide_data_create()

◆ VertsToTransData()

Variable Documentation

◆ TransConvertType_Mesh

TransConvertTypeInfo TransConvertType_Mesh
Initial value:
= {
}
@ T_POINTS
Definition transform.hh:93
@ T_EDIT
Definition transform.hh:91
static void createTransEditVerts(bContext *, TransInfo *t)
static void special_aftertrans_update__mesh(bContext *, TransInfo *t)
static void recalcData_mesh(TransInfo *t)

Definition at line 2651 of file transform_convert_mesh.cc.

Referenced by convert_type_get(), init_proportional_edit(), init_TransDataContainers(), snap_object_context_init(), transform_modal_item_poll(), transform_mode_init(), transform_mode_snap_source_init(), transformEvent(), and viewRedrawPost().