|
Blender
V2.93
|
#include <limits.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "CLG_log.h"#include "DNA_mesh_types.h"#include "DNA_meshdata_types.h"#include "DNA_object_types.h"#include "BLI_sys_types.h"#include "BLI_edgehash.h"#include "BLI_math_base.h"#include "BLI_math_vector.h"#include "BLI_utildefines.h"#include "BKE_customdata.h"#include "BKE_deform.h"#include "BKE_mesh.h"#include "DEG_depsgraph.h"#include "MEM_guardedalloc.h"Go to the source code of this file.
Classes | |
| union | EdgeUUID |
| struct | SortFace |
| struct | SortPoly |
| struct | EdgeSort |
Macros | |
| #define | INVALID_LOOP_EDGE_MARKER 4294967295u |
| #define | REMOVE_EDGE_TAG(_me) |
| #define | IS_REMOVED_EDGE(_me) (_me->v2 == _me->v1) |
| #define | REMOVE_LOOP_TAG(_ml) |
| #define | REMOVE_POLY_TAG(_mp) |
| #define | REMOVE_FACE_TAG(_mf) |
| #define | CHECK_FACE_VERT_INDEX(a, b) |
| #define | CHECK_FACE_EDGE(a, b) |
Functions | |
Mesh Stripping (removing invalid data) | |
| void | BKE_mesh_strip_loose_faces (Mesh *me) |
| void | BKE_mesh_strip_loose_polysloops (Mesh *me) |
| void | BKE_mesh_strip_loose_edges (Mesh *me) |
Mesh Edge Calculation | |
| static void | to_edgesort (struct EdgeSort *ed, unsigned int v1, unsigned int v2, char is_loose, short is_draw) |
| static int | vergedgesort (const void *v1, const void *v2) |
| static void | mesh_calc_edges_mdata (MVert *UNUSED(allvert), MFace *allface, MLoop *allloop, MPoly *allpoly, int UNUSED(totvert), int totface, int UNUSED(totloop), int totpoly, const bool use_old, MEdge **r_medge, int *r_totedge) |
| void | BKE_mesh_calc_edges_legacy (Mesh *me, const bool use_old) |
| void | BKE_mesh_calc_edges_loose (Mesh *mesh) |
| void | BKE_mesh_calc_edges_tessface (Mesh *mesh) |
Variables | |
| static CLG_LogRef | LOG = {"bke.mesh"} |
Mesh Validation | |
| #define | PRINT_MSG(...) |
| #define | PRINT_ERR(...) |
| bool | BKE_mesh_validate_arrays (Mesh *mesh, MVert *mverts, unsigned int totvert, MEdge *medges, unsigned int totedge, MFace *mfaces, unsigned int totface, MLoop *mloops, unsigned int totloop, MPoly *mpolys, unsigned int totpoly, MDeformVert *dverts, const bool do_verbose, const bool do_fixes, bool *r_changed) |
| static bool | mesh_validate_customdata (CustomData *data, CustomDataMask mask, const uint totitems, const bool do_verbose, const bool do_fixes, bool *r_change) |
| bool | BKE_mesh_validate_all_customdata (CustomData *vdata, const uint totvert, CustomData *edata, const uint totedge, CustomData *ldata, const uint totloop, CustomData *pdata, const uint totpoly, const bool check_meshmask, const bool do_verbose, const bool do_fixes, bool *r_change) |
| bool | BKE_mesh_validate (Mesh *me, const bool do_verbose, const bool cddata_check_mask) |
| bool | BKE_mesh_is_valid (Mesh *me) |
| bool | BKE_mesh_validate_material_indices (Mesh *me) |
Internal functions | |
| typedef struct SortFace | SortFace |
| typedef struct SortPoly | SortPoly |
| static void | edge_store_assign (uint32_t verts[2], const uint32_t v1, const uint32_t v2) |
| static void | edge_store_from_mface_quad (EdgeUUID es[4], MFace *mf) |
| static void | edge_store_from_mface_tri (EdgeUUID es[4], MFace *mf) |
| static int | int64_cmp (const void *v1, const void *v2) |
| static int | search_face_cmp (const void *v1, const void *v2) |
| static int | int_cmp (const void *v1, const void *v2) |
| static int | search_poly_cmp (const void *v1, const void *v2) |
| static int | search_polyloop_cmp (const void *v1, const void *v2) |
| #define CHECK_FACE_EDGE | ( | a, | |
| b | |||
| ) |
| #define CHECK_FACE_VERT_INDEX | ( | a, | |
| b | |||
| ) |
| #define INVALID_LOOP_EDGE_MARKER 4294967295u |
Definition at line 51 of file mesh_validate.c.
| #define PRINT_ERR | ( | ... | ) |
Definition at line 208 of file mesh_validate.c.
| #define PRINT_MSG | ( | ... | ) |
Definition at line 202 of file mesh_validate.c.
| #define REMOVE_EDGE_TAG | ( | _me | ) |
| #define REMOVE_FACE_TAG | ( | _mf | ) |
| #define REMOVE_LOOP_TAG | ( | _ml | ) |
| #define REMOVE_POLY_TAG | ( | _mp | ) |
| void BKE_mesh_calc_edges_legacy | ( | Mesh * | me, |
| const bool | use_old | ||
| ) |
If the mesh is from a very old blender version, convert mface->edcode to edge drawflags
Definition at line 1499 of file mesh_validate.c.
References BKE_mesh_strip_loose_faces(), CD_ASSIGN, CD_MEDGE, CustomData_add_layer(), Mesh::medge, mesh_calc_edges_mdata(), Mesh::mface, Mesh::mloop, Mesh::mpoly, Mesh::mvert, Mesh::totedge, Mesh::totface, Mesh::totloop, Mesh::totpoly, and Mesh::totvert.
Referenced by blo_do_versions_pre250().
| void BKE_mesh_calc_edges_loose | ( | Mesh * | mesh | ) |
Definition at line 1530 of file mesh_validate.c.
References MLoop::e, MEdge::flag, ME_EDGEDRAW, ME_LOOSEEDGE, Mesh::medge, mesh, Mesh::mloop, Mesh::totedge, and Mesh::totloop.
Referenced by blo_do_versions_280(), ED_mesh_update(), and modifyMesh().
| void BKE_mesh_calc_edges_tessface | ( | Mesh * | mesh | ) |
Calculate/create edges from tessface data
| mesh | The mesh to add edges into |
Definition at line 1554 of file mesh_validate.c.
References BLI_EDGEHASH_SIZE_GUESS_FROM_POLYS, BLI_edgeset_add(), BLI_edgeset_free(), BLI_edgeset_len(), BLI_edgeset_new_ex(), BLI_edgesetIterator_free(), BLI_edgesetIterator_getKey(), BLI_edgesetIterator_isDone(), BLI_edgesetIterator_new(), BLI_edgesetIterator_step(), CD_CALLOC, CD_MEDGE, CD_ORIGINDEX, CustomData_add_layer(), CustomData_free(), CustomData_get_layer(), CustomData_reset(), MEdge::flag, ME_EDGEDRAW, ME_EDGERENDER, Mesh::medge, mesh, Mesh::mface, NULL, ORIGINDEX_NONE, Mesh::totedge, Mesh::totface, MEdge::v1, MFace::v1, MEdge::v2, MFace::v2, MFace::v3, and MFace::v4.
Referenced by cutEdges(), and explodeMesh().
| bool BKE_mesh_is_valid | ( | Mesh * | me | ) |
Checks if a Mesh is valid without any modification. This is always verbose.
Definition at line 1101 of file mesh_validate.c.
References BKE_mesh_validate_all_customdata(), BKE_mesh_validate_arrays(), BLI_assert, Mesh::dvert, is_valid, Mesh::ldata, Mesh::medge, Mesh::mface, Mesh::mloop, Mesh::mpoly, Mesh::mvert, Mesh::totedge, Mesh::totface, Mesh::totloop, Mesh::totpoly, and Mesh::totvert.
Referenced by blender::nodes::create_cylinder_or_cone_mesh(), blender::nodes::create_uv_sphere_mesh(), blender::nodes::geo_node_mesh_primitive_circle_exec(), and blender::nodes::geo_node_mesh_primitive_grid_exec().
| void BKE_mesh_strip_loose_edges | ( | Mesh * | me | ) |
Definition at line 1277 of file mesh_validate.c.
References Freestyle::a, CustomData_copy_data(), CustomData_free_elem(), BMLoop::e, e, INVALID_LOOP_EDGE_MARKER, l, Mesh::medge, MEM_freeN, MEM_mallocN, Mesh::mloop, and Mesh::totedge.
Referenced by BKE_mesh_validate_arrays().
| void BKE_mesh_strip_loose_faces | ( | Mesh * | me | ) |
Definition at line 1179 of file mesh_validate.c.
References Freestyle::a, CustomData_copy_data(), CustomData_free_elem(), Mesh::fdata, Mesh::mface, Mesh::totface, and MFace::v3.
Referenced by BKE_mesh_calc_edges_legacy(), BKE_mesh_validate_arrays(), and blo_do_versions_pre250().
| void BKE_mesh_strip_loose_polysloops | ( | Mesh * | me | ) |
Works on both loops and polys!
Definition at line 1206 of file mesh_validate.c.
References Freestyle::a, CustomData_copy_data(), CustomData_free_elem(), BMLoop::e, INVALID_LOOP_EDGE_MARKER, l, Mesh::ldata, MPoly::loopstart, MEM_freeN, MEM_mallocN, Mesh::mloop, Mesh::mpoly, Mesh::totloop, MPoly::totloop, and Mesh::totpoly.
Referenced by BKE_mesh_validate_arrays().
| bool BKE_mesh_validate | ( | Mesh * | me, |
| const bool | do_verbose, | ||
| const bool | cddata_check_mask | ||
| ) |
Validates and corrects a Mesh.
Definition at line 1048 of file mesh_validate.c.
References BKE_mesh_validate_all_customdata(), BKE_mesh_validate_arrays(), CLOG_INFO, DEG_id_tag_update(), Mesh::dvert, Mesh::id, ID_RECALC_GEOMETRY, is_valid, Mesh::ldata, LOG, Mesh::medge, Mesh::mface, Mesh::mloop, Mesh::mpoly, Mesh::mvert, ID::name, Mesh::totedge, Mesh::totface, Mesh::totloop, Mesh::totpoly, and Mesh::totvert.
Referenced by BKE_mesh_split_faces(), MeshImporter::create_mesh_object(), Freestyle::BlenderStrokeRenderer::GenerateStrokeMesh(), blender::io::alembic::read_mpolys(), blender::io::alembic::AbcSubDReader::readObjectData(), blender::io::alembic::AbcPointsReader::readObjectData(), and blender::io::alembic::AbcMeshReader::readObjectData().
| bool BKE_mesh_validate_all_customdata | ( | CustomData * | vdata, |
| const uint | totvert, | ||
| CustomData * | edata, | ||
| const uint | totedge, | ||
| CustomData * | ldata, | ||
| const uint | totloop, | ||
| CustomData * | pdata, | ||
| const uint | totpoly, | ||
| const bool | check_meshmask, | ||
| const bool | do_verbose, | ||
| const bool | do_fixes, | ||
| bool * | r_change | ||
| ) |
Definition at line 982 of file mesh_validate.c.
References CD_MASK_MESH, CD_MLOOPCOL, CD_MLOOPUV, CustomData_get_clone_layer(), CustomData_get_stencil_layer(), CustomData_number_of_layers(), CustomData_set_layer_clone(), CustomData_set_layer_stencil(), is_valid, mask(), MAX_MCOL, MAX_MTFACE, mesh_validate_customdata(), and PRINT_ERR.
Referenced by BKE_mesh_is_valid(), BKE_mesh_runtime_is_valid(), BKE_mesh_validate(), and DM_is_valid().
| bool BKE_mesh_validate_arrays | ( | Mesh * | mesh, |
| MVert * | mverts, | ||
| unsigned int | totvert, | ||
| MEdge * | medges, | ||
| unsigned int | totedge, | ||
| MFace * | mfaces, | ||
| unsigned int | totface, | ||
| MLoop * | mloops, | ||
| unsigned int | totloop, | ||
| MPoly * | mpolys, | ||
| unsigned int | totpoly, | ||
| MDeformVert * | dverts, | ||
| const bool | do_verbose, | ||
| const bool | do_fixes, | ||
| bool * | r_changed | ||
| ) |
Validate the mesh, do_fixes requires mesh to be non-null.
Definition at line 222 of file mesh_validate.c.
References BKE_defvert_remove_group(), BKE_mesh_calc_edges(), BKE_mesh_strip_loose_edges(), BKE_mesh_strip_loose_faces(), BKE_mesh_strip_loose_polysloops(), BLI_assert, BLI_edgehash_free(), BLI_edgehash_haskey(), BLI_edgehash_insert(), BLI_edgehash_lookup(), BLI_edgehash_new_ex(), CHECK_FACE_EDGE, CHECK_FACE_VERT_INDEX, CLAMP, MDeformWeight::def_nr, MDeformVert::dw, MLoop::e, edge_store_from_mface_quad(), edge_store_from_mface_tri(), SortFace::es, faces, MVert::flag, if(), SortFace::index, SortPoly::index, MSelect::index, int64_cmp(), int_cmp(), SortPoly::invalid, IS_REMOVED_EDGE, is_valid, CCL_NAMESPACE_BEGIN::isfinite(), SortPoly::loopstart, ME_ESEL, ME_FSEL, ME_VERT_TMP_TAG, ME_VSEL, MEM_callocN, MEM_freeN, MEM_mallocN, mesh, Mesh::mselect, NULL, SortPoly::numverts, POINTER_AS_INT, POINTER_FROM_INT, PRINT_ERR, PRINT_MSG, REMOVE_EDGE_TAG, REMOVE_FACE_TAG, REMOVE_LOOP_TAG, REMOVE_POLY_TAG, search_face_cmp(), search_poly_cmp(), search_polyloop_cmp(), Mesh::totedge, Mesh::totpoly, Mesh::totselect, Mesh::totvert, MSelect::type, v, MLoop::v, v1, MEdge::v1, MFace::v1, v2, MEdge::v2, MFace::v2, MFace::v3, MFace::v4, SortPoly::verts, verts, MDeformWeight::weight, and zero_v3().
Referenced by BKE_mesh_is_valid(), BKE_mesh_runtime_is_valid(), BKE_mesh_validate(), blo_do_versions_290(), and DM_is_valid().
| bool BKE_mesh_validate_material_indices | ( | Mesh * | me | ) |
Check all material indices of polygons are valid, invalid ones are set to 0.
Definition at line 1148 of file mesh_validate.c.
References DEG_id_tag_update(), Mesh::id, ID_RECALC_GEOMETRY, is_valid, MPoly::mat_nr, max_ii(), Mesh::mpoly, Mesh::totcol, and Mesh::totpoly.
Definition at line 79 of file mesh_validate.c.
Referenced by edge_store_from_mface_quad(), and edge_store_from_mface_tri().
Definition at line 91 of file mesh_validate.c.
References edge_store_assign(), MFace::v1, MFace::v2, MFace::v3, MFace::v4, and verts.
Referenced by BKE_mesh_validate_arrays().
Definition at line 99 of file mesh_validate.c.
References edge_store_assign(), UINT_MAX, MFace::v1, MFace::v2, MFace::v3, EdgeUUID::verts, and verts.
Referenced by BKE_mesh_validate_arrays().
|
static |
Definition at line 107 of file mesh_validate.c.
Referenced by BKE_mesh_validate_arrays().
|
static |
Definition at line 158 of file mesh_validate.c.
Referenced by BKE_mesh_validate_arrays().
|
static |
Definition at line 1363 of file mesh_validate.c.
References Freestyle::a, BLI_edgehash_free(), BLI_edgehash_insert(), BLI_edgehash_lookup(), BLI_edgehash_new_ex(), MLoop::e, MFace::edcode, MEdge::flag, hash, EdgeSort::is_draw, EdgeSort::is_loose, MPoly::loopstart, ME_EDGEDRAW, ME_EDGERENDER, ME_LOOSEEDGE, ME_V1V2, ME_V2V3, ME_V3V1, ME_V3V4, ME_V4V1, MEM_callocN, MEM_freeN, MEM_mallocN, NULL, POINTER_AS_UINT, POINTER_FROM_UINT, SWAP, to_edgesort(), MPoly::totloop, MLoop::v, EdgeSort::v1, MEdge::v1, MFace::v1, EdgeSort::v2, MEdge::v2, MFace::v2, MFace::v3, MFace::v4, and vergedgesort().
Referenced by BKE_mesh_calc_edges_legacy().
|
static |
Definition at line 921 of file mesh_validate.c.
References CD_TYPE_AS_MASK, CustomData_free_layer(), CustomData_layer_validate(), CustomData_layertype_is_singleton(), CustomData_number_of_layers(), data, is_valid, mask(), PRINT_ERR, PRINT_MSG, and CustomDataLayer::type.
Referenced by BKE_mesh_validate_all_customdata().
|
static |
Definition at line 122 of file mesh_validate.c.
References EdgeUUID::edval, SortFace::es, v1, and v2.
Referenced by BKE_mesh_validate_arrays().
|
static |
Definition at line 163 of file mesh_validate.c.
References SortPoly::invalid, SortPoly::numverts, v1, v2, and SortPoly::verts.
Referenced by BKE_mesh_validate_arrays().
|
static |
Definition at line 184 of file mesh_validate.c.
References SortPoly::invalid, SortPoly::loopstart, v1, and v2.
Referenced by BKE_mesh_validate_arrays().
|
static |
Definition at line 1325 of file mesh_validate.c.
References EdgeSort::is_draw, EdgeSort::is_loose, EdgeSort::v1, v1, EdgeSort::v2, and v2.
Referenced by mesh_calc_edges_mdata().
|
static |
Definition at line 1340 of file mesh_validate.c.
References EdgeSort::v1, v1, EdgeSort::v2, v2, and x2.
Referenced by mesh_calc_edges_mdata().
|
static |
Definition at line 53 of file mesh_validate.c.
Referenced by BKE_mesh_validate().