Blender V4.5
meshtools.cc File Reference
#include <algorithm>
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
#include "BLI_math_matrix.h"
#include "BLI_vector.hh"
#include "BLI_virtual_array.hh"
#include "DNA_key_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_view3d_types.h"
#include "BKE_attribute.hh"
#include "BKE_context.hh"
#include "BKE_customdata.hh"
#include "BKE_deform.hh"
#include "BKE_editmesh.hh"
#include "BKE_key.hh"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_material.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_iterators.hh"
#include "BKE_mesh_runtime.hh"
#include "BKE_multires.hh"
#include "BKE_object.hh"
#include "BKE_object_deform.h"
#include "BKE_report.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_build.hh"
#include "DEG_depsgraph_query.hh"
#include "DRW_select_buffer.hh"
#include "ED_mesh.hh"
#include "ED_object.hh"
#include "ED_view3d.hh"
#include "WM_api.hh"
#include "WM_types.hh"

Go to the source code of this file.

Classes

struct  VertPickData

Typedefs

using float3
using int2

Functions

static void join_mesh_single (Depsgraph *depsgraph, Main *bmain, Scene *scene, Object *ob_dst, Object *ob_src, const float imat[4][4], float3 **vert_positions_pp, blender::int2 **medge_pp, int **corner_verts_pp, int **corner_edges_pp, int *all_face_offsets, CustomData *vert_data, CustomData *edge_data, CustomData *ldata, CustomData *face_data, int totvert, int totedge, int totloop, int faces_num, Key *key, Key *nkey, blender::Vector< Material * > &matar, int *vertofs, int *edgeofs, int *loopofs, int *polyofs)
static void mesh_join_offset_face_sets_ID (Mesh *mesh, int *face_set_offset)
wmOperatorStatus ED_mesh_join_objects_exec (bContext *C, wmOperator *op)
static int mesh_get_x_mirror_vert_spatial (Object *ob, Mesh *mesh_eval, int index)
static int mesh_get_x_mirror_vert_topo (Object *ob, Mesh *mesh, int index)
int mesh_get_x_mirror_vert (Object *ob, Mesh *mesh_eval, int index, const bool use_topology)
static BMVerteditbmesh_get_x_mirror_vert_spatial (Object *ob, BMEditMesh *em, const float co[3])
static BMVerteditbmesh_get_x_mirror_vert_topo (Object *ob, BMEditMesh *em, BMVert *eve, int index)
BMVerteditbmesh_get_x_mirror_vert (Object *ob, BMEditMesh *em, BMVert *eve, const float co[3], int index, const bool use_topology)
int ED_mesh_mirror_get_vert (Object *ob, int index)
static uint mirror_facehash (const void *ptr)
static int mirror_facerotation (const MFace *a, const MFace *b)
static bool mirror_facecmp (const void *a, const void *b)
int * mesh_get_x_mirror_faces (Object *ob, BMEditMesh *em, Mesh *mesh_eval)
bool ED_mesh_pick_face (bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index)
static void ed_mesh_pick_face_vert__mpoly_find (ARegion *region, const float mval[2], const blender::IndexRange face, const Span< float3 > vert_positions, const int *corner_verts, float *r_len_best, int *r_v_idx_best)
bool ED_mesh_pick_face_vert (bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index)
bool ED_mesh_pick_edge (bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index)
static void ed_mesh_pick_vert__mapFunc (void *user_data, int index, const float co[3], const float[3])
bool ED_mesh_pick_vert (bContext *C, Object *ob, const int mval[2], uint dist_px, bool use_zbuf, uint *r_index)
MDeformVertED_mesh_active_dvert_get_em (Object *ob, BMVert **r_eve)
MDeformVertED_mesh_active_dvert_get_ob (Object *ob, int *r_index)
MDeformVertED_mesh_active_dvert_get_only (Object *ob)
void EDBM_mesh_stats_multi (const Span< Object * > objects, int totelem[3], int totelem_sel[3])
void EDBM_mesh_elem_index_ensure_multi (const Span< Object * > objects, const char htype)
Join as Shapes

Add vertex positions of selected meshes as shape keys to the active mesh.

wmOperatorStatus ED_mesh_shapes_join_objects_exec (bContext *C, const bool ensure_keys_exist, ReportList *reports)

Mesh Topology Mirror API

static MirrTopoStore_t mesh_topo_store = {nullptr, -1, -1, false}
BLI_INLINE void mesh_mirror_topo_table_get_meshes (Object *ob, Mesh *mesh_eval, Mesh **r_mesh_mirror, BMEditMesh **r_em_mirror)
void ED_mesh_mirror_topo_table_begin (Object *ob, Mesh *mesh_eval)
void ED_mesh_mirror_topo_table_end (Object *)
static bool ed_mesh_mirror_topo_table_update (Object *ob, Mesh *mesh_eval)

Detailed Description

meshtools.cc: no editmode (violated already :), mirror & join), tools operating on meshes

Definition in file meshtools.cc.

Typedef Documentation

◆ float3

Definition at line 619 of file BLI_math_vector_types.hh.

◆ int2

Definition at line 601 of file BLI_math_vector_types.hh.

Function Documentation

◆ ED_mesh_active_dvert_get_em()

◆ ED_mesh_active_dvert_get_ob()

◆ ED_mesh_active_dvert_get_only()

◆ ED_mesh_join_objects_exec()

wmOperatorStatus ED_mesh_join_objects_exec ( bContext * C,
wmOperator * op )

Definition at line 339 of file meshtools.cc.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::ed::object::base_free_and_unlink(), BKE_id_copy(), BKE_id_free_ex(), BKE_key_add(), BKE_key_sort(), BKE_keyblock_add(), BKE_keyblock_copy_settings(), BKE_keyblock_find_name(), BKE_mesh_clear_geometry(), BKE_mesh_from_object(), BKE_object_apply_mat4_ex(), BKE_object_defgroup_find_name(), BKE_object_free_derived_caches(), BKE_object_material_get(), BKE_objects_materials_sync_length_all(), BKE_report(), BKE_reportf(), BLI_addtail(), BLI_assert, BLI_findindex(), BLI_listbase_is_empty(), Key::block, C, CD_CONSTRUCT, CD_PROP_FLOAT3, CD_PROP_INT32, CD_PROP_INT32_2D, CD_SET_DEFAULT, blender::Vector< T, InlineBufferCapacity, Allocator >::clear(), Mesh::corner_data, Mesh::corners_num, CTX_data_active_object(), CTX_DATA_BEGIN, CTX_DATA_END, CTX_data_ensure_evaluated_depsgraph(), CTX_data_main(), CTX_data_scene(), CustomData_add_layer_named(), CustomData_reset(), blender::Vector< T, InlineBufferCapacity, Allocator >::data(), KeyBlock::data, Object::data, DEG_id_tag_update(), DEG_relations_tag_update(), depsgraph, Mesh::edge_data, Mesh::edges_num, ELEM, Mesh::face_data, Mesh::face_offset_indices, Mesh::faces_num, i, Key::id, Material::id, Object::id, Scene::id, ID_RECALC_GEOMETRY, ID_RECALC_SELECT, ID_RECALC_TRANSFORM, id_us_min(), id_us_plus(), blender::implicit_sharing::info_for_mem_free(), invert_m4_m4_safe_ortho(), join_mesh_single(), Mesh::key, KEY_RELATIVE, LIB_ID_FREE_NO_UI_USER, LIKELY, LISTBASE_FOREACH, LISTBASE_FOREACH_INDEX, Mesh::mat, Object::mat, Object::matbits, MEM_calloc_arrayN(), MEM_callocN(), MEM_freeN(), MEM_malloc_arrayN(), MEM_mallocN(), MEM_SAFE_FREE, mesh_join_offset_face_sets_ID(), MESH_MAX_VERTS, Object::mode, Node::name, NC_SCENE, ND_LAYER_CONTENT, ND_OB_ACTIVE, OB_MESH, OB_MODE_EDIT, OPERATOR_CANCELLED, OPERATOR_FINISHED, Object::parent, Object::parentinv, KeyBlock::relative, wmOperator::reports, RPT_WARNING, Mesh::runtime, blender::Vector< T, InlineBufferCapacity, Allocator >::size(), Mesh::totcol, Object::totcol, KeyBlock::totelem, Key::totkey, Key::type, Object::type, Mesh::vert_data, Mesh::vertex_group_active_index, Mesh::vertex_group_names, Mesh::verts_num, and WM_event_add_notifier().

Referenced by blender::ed::object::object_join_exec().

◆ ED_mesh_mirror_get_vert()

◆ ED_mesh_mirror_topo_table_begin()

void ED_mesh_mirror_topo_table_begin ( Object * ob,
Mesh * mesh_eval )

Mode is 's' start, or 'e' end, or 'u' use if end, ob can be NULL.

Note
This is supposed return -1 on error, which callers are currently checking for, but is not used so far.

Definition at line 858 of file meshtools.cc.

References ED_mesh_mirrtopo_init(), mesh_mirror_topo_table_get_meshes(), and mesh_topo_store.

Referenced by ed_mesh_mirror_topo_table_update().

◆ ED_mesh_mirror_topo_table_end()

◆ ed_mesh_mirror_topo_table_update()

bool ed_mesh_mirror_topo_table_update ( Object * ob,
Mesh * mesh_eval )
static

◆ ED_mesh_pick_edge()

bool ED_mesh_pick_edge ( bContext * C,
Object * ob,
const int mval[2],
uint dist_px,
uint * r_index )

◆ ED_mesh_pick_face()

bool ED_mesh_pick_face ( bContext * C,
Object * ob,
const int mval[2],
uint dist_px,
uint * r_index )

◆ ED_mesh_pick_face_vert()

bool ED_mesh_pick_face_vert ( bContext * C,
Object * ob,
const int mval[2],
uint dist_px,
uint * r_index )

◆ ed_mesh_pick_face_vert__mpoly_find()

void ed_mesh_pick_face_vert__mpoly_find ( ARegion * region,
const float mval[2],
const blender::IndexRange face,
const Span< float3 > vert_positions,
const int * corner_verts,
float * r_len_best,
int * r_v_idx_best )
static

◆ ED_mesh_pick_vert()

◆ ed_mesh_pick_vert__mapFunc()

void ed_mesh_pick_vert__mapFunc ( void * user_data,
int index,
const float co[3],
const float [3] )
static

◆ ED_mesh_shapes_join_objects_exec()

◆ EDBM_mesh_elem_index_ensure_multi()

void EDBM_mesh_elem_index_ensure_multi ( const Span< Object * > objects,
const char htype )

◆ EDBM_mesh_stats_multi()

void EDBM_mesh_stats_multi ( const Span< Object * > objects,
int totelem[3],
int totelem_sel[3] )

Definition at line 1513 of file meshtools.cc.

References BKE_editmesh_from_object(), bm, and BMEditMesh::bm.

◆ editbmesh_get_x_mirror_vert()

BMVert * editbmesh_get_x_mirror_vert ( Object * ob,
BMEditMesh * em,
BMVert * eve,
const float co[3],
int index,
const bool use_topology )

◆ editbmesh_get_x_mirror_vert_spatial()

BMVert * editbmesh_get_x_mirror_vert_spatial ( Object * ob,
BMEditMesh * em,
const float co[3] )
static

◆ editbmesh_get_x_mirror_vert_topo()

BMVert * editbmesh_get_x_mirror_vert_topo ( Object * ob,
BMEditMesh * em,
BMVert * eve,
int index )
static

◆ join_mesh_single()

void join_mesh_single ( Depsgraph * depsgraph,
Main * bmain,
Scene * scene,
Object * ob_dst,
Object * ob_src,
const float imat[4][4],
float3 ** vert_positions_pp,
blender::int2 ** medge_pp,
int ** corner_verts_pp,
int ** corner_edges_pp,
int * all_face_offsets,
CustomData * vert_data,
CustomData * edge_data,
CustomData * ldata,
CustomData * face_data,
int totvert,
int totedge,
int totloop,
int faces_num,
Key * key,
Key * nkey,
blender::Vector< Material * > & matar,
int * vertofs,
int * edgeofs,
int * loopofs,
int * polyofs )
static

◆ mesh_get_x_mirror_faces()

◆ mesh_get_x_mirror_vert()

int mesh_get_x_mirror_vert ( Object * ob,
Mesh * mesh_eval,
int index,
bool use_topology )

◆ mesh_get_x_mirror_vert_spatial()

int mesh_get_x_mirror_vert_spatial ( Object * ob,
Mesh * mesh_eval,
int index )
static

Definition at line 888 of file meshtools.cc.

References Object::data, and ED_mesh_mirror_spatial_table_lookup().

Referenced by mesh_get_x_mirror_vert().

◆ mesh_get_x_mirror_vert_topo()

int mesh_get_x_mirror_vert_topo ( Object * ob,
Mesh * mesh,
int index )
static

Definition at line 902 of file meshtools.cc.

References ed_mesh_mirror_topo_table_update(), and mesh_topo_store.

Referenced by mesh_get_x_mirror_vert().

◆ mesh_join_offset_face_sets_ID()

void mesh_join_offset_face_sets_ID ( Mesh * mesh,
int * face_set_offset )
static

◆ mesh_mirror_topo_table_get_meshes()

BLI_INLINE void mesh_mirror_topo_table_get_meshes ( Object * ob,
Mesh * mesh_eval,
Mesh ** r_mesh_mirror,
BMEditMesh ** r_em_mirror )

◆ mirror_facecmp()

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

Definition at line 1104 of file meshtools.cc.

References b, and mirror_facerotation().

Referenced by mesh_get_x_mirror_faces().

◆ mirror_facehash()

uint mirror_facehash ( const void * ptr)
static

Definition at line 1056 of file meshtools.cc.

References ptr, MFace::v1, MFace::v2, MFace::v3, and MFace::v4.

Referenced by mesh_get_x_mirror_faces().

◆ mirror_facerotation()

int mirror_facerotation ( const MFace * a,
const MFace * b )
static

Definition at line 1073 of file meshtools.cc.

References b, MFace::v1, MFace::v2, MFace::v3, and MFace::v4.

Referenced by mesh_get_x_mirror_faces(), and mirror_facecmp().

Variable Documentation

◆ mesh_topo_store