Blender
V3.3
|
#include "MEM_guardedalloc.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "BLI_edgehash.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
#include "BLI_polyfill_2d.h"
#include "BLI_utildefines.h"
#include "BKE_customdata.h"
#include "BKE_mesh.h"
#include "BKE_mesh_legacy_convert.h"
#include "BKE_multires.h"
Go to the source code of this file.
Macros | |
#define | ME_FGON (1 << 3) |
#define | ML(v1, v2) |
#define | USE_TESSFACE_SPEEDUP |
#define | USE_TESSFACE_QUADS |
#define | TESSFACE_IS_QUAD 1 |
#define | ML_TO_MF(i1, i2, i3) |
#define | ML_TO_MF_QUAD() |
#define | LAYER_CMP(l_a, t_a, l_b, t_b) |
Functions | |
NGon Tessellation (NGon to MFace Conversion) | |
static void | bm_corners_to_loops_ex (ID *id, CustomData *fdata, CustomData *ldata, MFace *mface, int totloop, int findex, int loopstart, int numTex, int numCol) |
static void | CustomData_to_bmeshpoly (CustomData *fdata, CustomData *ldata, int totloop) |
static void | convert_mfaces_to_mpolys (ID *id, CustomData *fdata, CustomData *ldata, CustomData *pdata, int totedge_i, int totface_i, int totloop_i, int totpoly_i, MEdge *medge, MFace *mface, int *r_totloop, int *r_totpoly, MLoop **r_mloop, MPoly **r_mpoly) |
void | BKE_mesh_convert_mfaces_to_mpolys (Mesh *mesh) |
static void | CustomData_bmesh_do_versions_update_active_layers (CustomData *fdata, CustomData *ldata) |
void | BKE_mesh_do_versions_convert_mfaces_to_mpolys (Mesh *mesh) |
MFace Tessellation | |
static void | mesh_loops_to_tessdata (CustomData *fdata, CustomData *ldata, MFace *mface, const int *polyindices, uint(*loopindices)[4], const int num_faces) |
int | BKE_mesh_mface_index_validate (MFace *mface, CustomData *fdata, int mfindex, int nr) |
static int | mesh_tessface_calc (CustomData *fdata, CustomData *ldata, CustomData *pdata, MVert *mvert, int totface, int totloop, int totpoly) |
void | BKE_mesh_tessface_calc (Mesh *mesh) |
void | BKE_mesh_tessface_ensure (struct Mesh *mesh) |
static bool | check_matching_legacy_layer_counts (CustomData *fdata, CustomData *ldata, bool fallback) |
void | BKE_mesh_add_mface_layers (CustomData *fdata, CustomData *ldata, int total) |
Functions to convert mesh data to and from legacy formats like MFace.
Definition in file mesh_legacy_convert.cc.
#define ME_FGON (1 << 3) |
#define ML_TO_MF_QUAD | ( | ) |
#define TESSFACE_IS_QUAD 1 |
#define USE_TESSFACE_QUADS |
#define USE_TESSFACE_SPEEDUP |
void BKE_mesh_add_mface_layers | ( | CustomData * | fdata, |
CustomData * | ldata, | ||
int | total | ||
) |
Definition at line 842 of file mesh_legacy_convert.cc.
References BLI_assert, CD_CALLOC, CD_MCOL, CD_MLOOPUV, CD_MTFACE, CD_NORMAL, CD_ORIGSPACE, CD_ORIGSPACE_MLOOP, CD_PREVIEW_MCOL, CD_PREVIEW_MLOOPCOL, CD_PROP_BYTE_COLOR, CD_TANGENT, CD_TESSLOOPNORMAL, check_matching_legacy_layer_counts(), CustomData_add_layer_named(), CustomData_bmesh_update_active_layers(), CustomData::layers, CustomDataLayer::name, CustomData::totlayer, and CustomDataLayer::type.
Referenced by mesh_ensure_tessellation_customdata(), and mesh_tessface_calc().
Definition at line 278 of file mesh_legacy_convert.cc.
References BKE_mesh_update_customdata_pointers(), convert_mfaces_to_mpolys(), Mesh::fdata, Mesh::id, Mesh::ldata, Mesh::medge, mesh, Mesh::mface, Mesh::mloop, Mesh::mpoly, Mesh::pdata, Mesh::totedge, Mesh::totface, Mesh::totloop, and Mesh::totpoly.
Referenced by cutEdges(), and explodeMesh().
The same as BKE_mesh_convert_mfaces_to_mpolys but oriented to be used in do_versions from readfile.c
the difference is how active/render/clone/stencil indices are handled here.
normally they're being set from pdata
which totally makes sense for meshes which are already converted to BMesh structures, but when loading older files indices shall be updated in other way around, so newly added pdata
and ldata
would have this indices set based on fdata
layer.
this is normally only needed when reading older files, in all other cases BKE_mesh_convert_mfaces_to_mpolys shall be always used.
Definition at line 337 of file mesh_legacy_convert.cc.
References BKE_mesh_update_customdata_pointers(), convert_mfaces_to_mpolys(), CustomData_bmesh_do_versions_update_active_layers(), Mesh::fdata, Mesh::id, Mesh::ldata, Mesh::medge, mesh, Mesh::mface, Mesh::mloop, Mesh::mpoly, Mesh::pdata, Mesh::totedge, Mesh::totface, Mesh::totloop, and Mesh::totpoly.
Referenced by do_versions_after_linking_280().
int BKE_mesh_mface_index_validate | ( | struct MFace * | mface, |
struct CustomData * | mfdata, | ||
int | mfindex, | ||
int | nr | ||
) |
Rotates the vertices of a face in case v[2] or v[3] (vertex index) is = 0. this is necessary to make the if MFace.v4 check for quads work.
Definition at line 470 of file mesh_legacy_convert.cc.
References CustomData_swap_corners(), SWAP, MFace::v1, MFace::v2, MFace::v3, and MFace::v4.
Referenced by cutEdges(), explodeMesh(), and mesh_tessface_calc().
Recreate MFace Tessellation.
Definition at line 781 of file mesh_legacy_convert.cc.
References BKE_mesh_update_customdata_pointers(), Mesh::fdata, Mesh::ldata, mesh, mesh_tessface_calc(), Mesh::mvert, Mesh::pdata, Mesh::totface, Mesh::totloop, and Mesh::totpoly.
Referenced by BKE_mesh_tessface_ensure(), and blender::ed::curves::convert_to_particle_system::try_convert_single_object().
Definition at line 794 of file mesh_legacy_convert.cc.
References BKE_mesh_tessface_calc(), mesh, Mesh::totface, and Mesh::totpoly.
Referenced by bc_get_mesh_copy(), deformVerts(), blender::io::alembic::ABCHairWriter::do_write(), modifyMesh(), particle_batch_cache_ensure_pos_and_seg(), particle_batch_cache_ensure_procedural_strand_data(), particle_intersect_mesh(), particle_system_update(), PE_mirror_x(), psys_thread_context_init_distribute(), and remap_hair_emitter().
|
static |
Definition at line 32 of file mesh_legacy_convert.cc.
References BLI_assert, CD_MCOL, CD_MDISPS, CD_MLOOPUV, CD_MTFACE, CD_NORMAL, CD_PROP_BYTE_COLOR, CD_TESSLOOPNORMAL, copy_v2_v2(), CustomData_external_add(), CustomData_external_test(), CustomData_get(), CustomData_get_n(), CustomData_has_layer(), MDisps::disps, CustomData::external, CustomDataExternal::filepath, float(), MDisps::level, logf, M_LN2, max, MEM_freeN, MEM_malloc_arrayN, MESH_MLOOPCOL_FROM_MCOL, multires_mdisp_corners(), normal_short_to_float_v3(), sqrtf, MDisps::totdisp, MLoopUV::uv, MTFace::uv, and MFace::v4.
Referenced by convert_mfaces_to_mpolys().
|
static |
Debug check, used to assert when we expect layers to be in/out of sync.
fallback | Use when there are no layers to handle, since callers may expect success or failure. |
Definition at line 808 of file mesh_legacy_convert.cc.
References CD_MCOL, CD_MLOOPUV, CD_MTFACE, CD_NORMAL, CD_ORIGSPACE, CD_ORIGSPACE_MLOOP, CD_PREVIEW_MCOL, CD_PREVIEW_MLOOPCOL, CD_PROP_BYTE_COLOR, CD_TANGENT, CD_TESSLOOPNORMAL, and LAYER_CMP.
Referenced by BKE_mesh_add_mface_layers().
|
static |
Definition at line 155 of file mesh_legacy_convert.cc.
References BLI_edgehash_free(), BLI_edgehash_insert(), BLI_edgehash_new_ex(), bm_corners_to_loops_ex(), CD_ASSIGN, CD_MASK_MDISPS, CD_MCOL, CD_MLOOP, CD_MPOLY, CD_MTFACE, CD_ORIGINDEX, CustomData_add_layer(), CustomData_external_read(), CustomData_free(), CustomData_get_layer(), CustomData_number_of_layers(), CustomData_to_bmeshpoly(), MEdge::flag, MPoly::flag, MFace::flag, MPoly::loopstart, MPoly::mat_nr, MFace::mat_nr, ME_FGON, MEM_calloc_arrayN, ML, POINTER_FROM_UINT, MPoly::totloop, v1, MEdge::v1, v2, MEdge::v2, and MFace::v4.
Referenced by BKE_mesh_convert_mfaces_to_mpolys(), and BKE_mesh_do_versions_convert_mfaces_to_mpolys().
|
static |
Update active indices for active/render/clone/stencil custom data layers based on indices from fdata layers used when creating pdata and ldata for pre-bmesh meshes and needed to preserve active/render/clone/stencil flags set in pre-bmesh files.
Definition at line 304 of file mesh_legacy_convert.cc.
References CD_MCOL, CD_MLOOPUV, CD_MTFACE, CD_PROP_BYTE_COLOR, CustomData_get_active_layer(), CustomData_get_clone_layer(), CustomData_get_render_layer(), CustomData_get_stencil_layer(), CustomData_has_layer(), CustomData_set_layer_active(), CustomData_set_layer_clone(), CustomData_set_layer_render(), and CustomData_set_layer_stencil().
Referenced by BKE_mesh_do_versions_convert_mfaces_to_mpolys().
|
static |
Definition at line 133 of file mesh_legacy_convert.cc.
References CD_CALLOC, CD_MCOL, CD_MDISPS, CD_MLOOPUV, CD_MTFACE, CD_NORMAL, CD_PROP_BYTE_COLOR, CD_TESSLOOPNORMAL, CustomData_add_layer_named(), CustomData::layers, CustomDataLayer::name, CustomData::totlayer, and CustomDataLayer::type.
Referenced by convert_mfaces_to_mpolys().
|
static |
Convert all CD layers from loop/poly to tessface data.
loopindices | is an array of an int[4] per tessface, mapping tessface's verts to loops indices. |
Definition at line 376 of file mesh_legacy_convert.cc.
References CD_MCOL, CD_MLOOPUV, CD_MTFACE, CD_NORMAL, CD_ORIGSPACE, CD_ORIGSPACE_MLOOP, CD_PREVIEW_MCOL, CD_PREVIEW_MLOOPCOL, CD_PROP_BYTE_COLOR, CD_TANGENT, CD_TESSLOOPNORMAL, copy_v2_v2(), copy_v4_v4(), CustomData_get_layer(), CustomData_get_layer_n(), CustomData_has_layer(), CustomData_number_of_layers(), float(), MESH_MLOOPCOL_TO_MCOL, normal_float_to_short_v3(), MLoopUV::uv, OrigSpaceLoop::uv, OrigSpaceFace::uv, MTFace::uv, and MFace::v4.
Referenced by mesh_tessface_calc().
|
static |
Definition at line 538 of file mesh_legacy_convert.cc.
References add_newell_cross_v3_v3v3(), axis_dominant_v3_to_m3_negate(), BKE_mesh_add_mface_layers(), BKE_mesh_mface_index_validate(), BLI_assert, BLI_memarena_alloc(), BLI_memarena_clear(), BLI_memarena_free(), BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, BLI_polyfill_calc_arena(), CD_ASSIGN, CD_MFACE, CD_MLOOP, CD_MPOLY, CD_ORIGINDEX, MVert::co, CustomData_add_layer(), CustomData_free(), CustomData_get_layer(), MFace::edcode, MPoly::flag, MFace::flag, float(), LIKELY, MPoly::loopstart, MPoly::mat_nr, MFace::mat_nr, MEM_freeN, MEM_malloc_arrayN, MEM_reallocN, mesh_loops_to_tessdata(), ML_TO_MF, ML_TO_MF_QUAD, mul_v2_m3v3(), normal, normalize_v3(), poly_to_tri_count(), TESSFACE_IS_QUAD, MPoly::totloop, UNLIKELY, MLoop::v, MFace::v1, MFace::v2, MFace::v3, MFace::v4, and zero_v3().
Referenced by BKE_mesh_tessface_calc().