Blender
V3.3
|
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
#include "DNA_curve_types.h"
#include "DNA_key_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_meta_types.h"
#include "DNA_object_types.h"
#include "DNA_pointcloud_types.h"
#include "DNA_scene_types.h"
#include "BLI_edgehash.h"
#include "BLI_index_range.hh"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_DerivedMesh.h"
#include "BKE_curves.hh"
#include "BKE_deform.h"
#include "BKE_displist.h"
#include "BKE_editmesh.h"
#include "BKE_geometry_set.hh"
#include "BKE_key.h"
#include "BKE_lib_id.h"
#include "BKE_lib_query.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_mball.h"
#include "BKE_mesh.h"
#include "BKE_mesh_runtime.h"
#include "BKE_mesh_wrapper.h"
#include "BKE_modifier.h"
#include "BKE_curve.h"
#include "BKE_object.h"
#include "BKE_pointcloud.h"
#include "BKE_curve_to_mesh.hh"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
Go to the source code of this file.
Classes | |
struct | EdgeLink |
struct | VertLink |
Macros | |
#define | ASSERT_IS_VALID_MESH(mesh) |
Variables | |
static CLG_LogRef | LOG = {"bke.mesh_convert"} |
Definition at line 67 of file mesh_convert.cc.
Definition at line 1237 of file mesh_convert.cc.
References Key::block, CD_ASSIGN, CD_SHAPEKEY, CLOG_ERROR, CustomData_add_layer_named(), CustomData_get_layer_index_n(), KeyBlock::data, ListBase::first, Mesh::id, Mesh::key, CustomData::layers, LOG, MEM_calloc_arrayN, MEM_malloc_arrayN, KeyBlock::name, ID::name, KeyBlock::next, KeyBlock::totelem, Mesh::totvert, CustomDataLayer::uid, KeyBlock::uid, and Mesh::vdata.
Referenced by BKE_mesh_create_derived_for_modifier().
Definition at line 575 of file mesh_convert.cc.
References BLI_addtail(), and VertLink::index.
Referenced by BKE_mesh_to_curve_nurblist().
Mesh* BKE_mesh_create_derived_for_modifier | ( | struct Depsgraph * | depsgraph, |
struct Scene * | scene, | ||
struct Object * | ob_eval, | ||
struct ModifierData * | md_eval, | ||
bool | use_virtual_modifiers, | ||
bool | build_shapekey_layers | ||
) |
use_virtual_modifiers | When enabled calculate virtual-modifiers before applying md_eval support this since virtual-modifiers are not modifiers from a user perspective, allowing shape keys to be included with the modifier being applied, see: T91923. |
Definition at line 1283 of file mesh_convert.cc.
References add_shapekey_layers(), ASSERT_IS_VALID_MESH, BKE_id_copy_ex(), BKE_id_free(), BKE_keyblock_convert_to_mesh(), BKE_mesh_vert_coords_alloc(), BKE_mesh_vert_coords_apply(), BKE_modifier_get_info(), BKE_modifier_is_enabled(), BKE_modifiers_get_virtual_modifierlist(), BLI_assert, BLI_findlink(), Key::block, Object::data, Object_Runtime::data_orig, ModifierTypeInfo::deformVerts, depsgraph, eModifierMode_Realtime, eModifierTypeType_OnlyDeform, ListBase::first, float(), Mesh::id, ModifierTypeInfo::isDisabled, Mesh::key, LIB_ID_COPY_LOCALIZE, MEM_freeN, MOD_APPLY_TO_BASE_MESH, ModifierData::mode, Object::modifiers, ModifierTypeInfo::modifyMesh, Mesh::mvert, ModifierData::next, result, Object::runtime, scene, Object::shapenr, Mesh::totvert, ModifierTypeInfo::type, and ModifierData::type.
Referenced by modifier_apply_create_mesh_for_modifier().
Needed after converting a mesh with subsurf optimal display to mesh.
Definition at line 826 of file mesh_convert.cc.
References MEdge::flag, ME_EDGEDRAW, ME_EDGERENDER, Mesh::medge, mesh, and Mesh::totedge.
Referenced by object_convert_exec().
Definition at line 72 of file mesh_convert.cc.
References Freestyle::a, BKE_mesh_calc_edges(), BKE_mesh_update_customdata_pointers(), CD_CALLOC, CD_MLOOP, CD_MPOLY, CD_MVERT, MVert::co, copy_v3_v3(), count, CustomData_add_layer(), DL_INDEX4, ListBase::first, MPoly::flag, if(), DispList::index, Mesh::ldata, MPoly::loopstart, ME_SMOOTH, Mesh::mloop, Mesh::mpoly, Mesh::mvert, DispList::nr, DispList::parts, Mesh::pdata, Mesh::totloop, MPoly::totloop, Mesh::totpoly, Mesh::totvert, DispList::type, MLoop::v, Mesh::vdata, and DispList::verts.
Referenced by mesh_new_from_mball_object(), and object_convert_exec().
void BKE_mesh_from_pointcloud | ( | const PointCloud * | pointcloud, |
Mesh * | me | ||
) |
Definition at line 797 of file mesh_convert.cc.
References BLI_assert, CD_CALLOC, CD_DUPLICATE, CD_MASK_PROP_ALL, CD_MVERT, CD_PROP_FLOAT3, copy_v3_v3(), CustomData_add_layer(), CustomData_free_layer(), CustomData_get_named_layer_index(), CustomData_merge(), CustomData_update_typemap(), CustomDataLayer::data, float(), CustomData::layers, Mesh::mvert, PointCloud::pdata, POINTCLOUD_ATTR_POSITION, positions, PointCloud::totpoint, Mesh::totvert, and Mesh::vdata.
Referenced by BKE_pointcloud_to_mesh().
Mesh* BKE_mesh_new_from_object | ( | struct Depsgraph * | depsgraph, |
struct Object * | object, | ||
bool | preserve_all_data_layers, | ||
bool | preserve_origindex | ||
) |
Create new mesh from the given object at its current state. The owner of this mesh is unknown, it is up to the caller to decide.
If preserve_all_data_layers is truth then the modifier stack is re-evaluated to ensure it preserves all possible custom data layers.
Definition at line 1102 of file mesh_convert.cc.
References BLI_assert, depsgraph, Mesh::edit_mesh, Mesh::id, mesh_new_from_curve_type_object(), mesh_new_from_mball_object(), mesh_new_from_mesh_object(), OB_CURVES_LEGACY, OB_FONT, OB_MBALL, OB_MESH, OB_SURF, Object::type, and ID::us.
Referenced by bake(), bake_mesh_new_from_object(), BKE_mesh_new_from_object_to_bmain(), BKE_object_to_mesh(), bpy_bmesh_from_object(), blender::io::alembic::ABCMetaballWriter::get_export_mesh(), blender::io::usd::USDMetaballWriter::get_export_mesh(), lineart_object_load_single_instance(), and blender::io::obj::OBJMesh::OBJMesh().
Mesh* BKE_mesh_new_from_object_to_bmain | ( | struct Main * | bmain, |
struct Depsgraph * | depsgraph, | ||
struct Object * | object, | ||
bool | preserve_all_data_layers | ||
) |
This is a version of BKE_mesh_new_from_object() which stores mesh in the given main database. However, that function enforces object type to be a geometry one, and ensures a mesh is always generated, be it empty.
Definition at line 1177 of file mesh_convert.cc.
References BKE_library_foreach_ID_link(), BKE_mesh_add(), BKE_mesh_new_from_object(), BKE_mesh_nomain_to_mesh(), BLI_assert, CD_MASK_MESH, Object::data, depsgraph, ELEM, Mesh::flag, foreach_libblock_make_original_callback(), foreach_libblock_make_usercounts_callback(), Mesh::id, id_us_min(), IDWALK_NOP, Mesh::mat, mesh, blender::bke::mesh_attributes_for_write(), ID::name, OB_CURVES_LEGACY, OB_FONT, OB_MBALL, OB_MESH, OB_SURF, blender::bke::MutableAttributeAccessor::remove_anonymous(), Mesh::smoothresh, Mesh::totcol, Object::type, and ID::us.
Referenced by object_data_convert_curve_to_mesh().
Definition at line 547 of file mesh_convert.cc.
References BKE_mesh_new_nomain_from_curve_displist(), Object_Runtime::curve_cache, CurveCache::disp, and Object::runtime.
Definition at line 487 of file mesh_convert.cc.
References BKE_mesh_new_nomain(), CD_ASSIGN, CD_MLOOPUV, CustomData_add_layer_named(), Object::data, if(), Mesh::ldata, Curve::mat, Mesh::mat, Mesh::medge, MEM_dupallocN, MEM_freeN, mesh, mesh_copy_texture_space_from_curve_type(), mesh_nurbs_displist_to_mdata(), Mesh::mloop, Mesh::mpoly, Mesh::mvert, Curve::totcol, and Mesh::totcol.
Referenced by BKE_mesh_new_nomain_from_curve().
void BKE_mesh_nomain_to_mesh | ( | Mesh * | mesh_src, |
Mesh * | mesh_dst, | ||
Object * | ob, | ||
const CustomData_MeshMasks * | mask, | ||
bool | take_ownership | ||
) |
Definition at line 1436 of file mesh_convert.cc.
References BKE_defgroup_copy_list(), BKE_id_free(), BKE_mesh_assert_normals_dirty_or_calculated(), BKE_mesh_clear_derived_normals(), BKE_mesh_runtime_clear_geometry(), BKE_mesh_texspace_copy_from_object(), BKE_mesh_update_customdata_pointers(), BLI_assert, BLI_findlink(), BLI_freelistN(), Key::block, CD_ASSIGN, CD_DUPLICATE, Mesh::cd_flag, CD_MDISPS, CD_MEDGE, CD_MLOOP, CD_MPOLY, CD_MVERT, CD_SHAPEKEY, CLOG_ERROR, CustomData_add_layer(), CustomData_copy(), CustomData_free(), CustomData_free_typemask(), CustomData_get_layer(), CustomData_has_layer(), CustomData_has_referenced(), CustomData_reset(), CustomData_set_layer(), Mesh_Runtime::deformed_only, Mesh::edata, Mesh::fdata, Key::id, Mesh::id, id_us_min(), Mesh::key, Mesh::ldata, LIB_TAG_NO_MAIN, LOG, mask(), ME_AUTOSPACE_EVALUATED, Mesh::medge, MEM_dupallocN, MEM_SAFE_FREE, MEMCPY_STRUCT_AFTER, Mesh::mloop, Mesh::mpoly, Mesh::mselect, Mesh::mvert, ID::name, Mesh::pdata, blender::meshintersect::prev(), Mesh::runtime, shapekey_layers_to_keyblocks(), Object::shapenr, ID::tag, Mesh::texflag, Mesh::totedge, Mesh::totface, Mesh::totloop, Mesh::totpoly, Mesh::totselect, Mesh::totvert, KeyBlock::uid, Mesh::vdata, Mesh::vertex_group_active_index, and Mesh::vertex_group_names.
Referenced by BKE_mesh_new_from_object_to_bmain().
Definition at line 1611 of file mesh_convert.cc.
References Freestyle::a, BLI_assert, MVert::co, copy_v3_v3(), KeyBlock::data, Key::elemsize, Mesh::id, Mesh::key, LIB_TAG_NO_MAIN, MEM_freeN, MEM_malloc_arrayN, Mesh::mvert, ID::tag, KeyBlock::totelem, and Mesh::totvert.
Referenced by modifier_apply_shape().
Definition at line 727 of file mesh_convert.cc.
References BKE_curve_add(), BKE_mesh_to_curve_nurblist(), BKE_object_free_derived_caches(), CD_MASK_MESH, CU_3D, Object::data, DEG_get_evaluated_object(), DEG_get_evaluated_scene(), depsgraph, ListBase::first, Curve::flag, Object::id, id_us_min(), mesh_get_eval_final(), ID::name, Curve::nurb, OB_CURVES_LEGACY, and Object::type.
Definition at line 582 of file mesh_convert.cc.
References appendPolyLineVert(), BLI_addtail(), BLI_freelinkN(), BLI_freelistN(), Nurb::bp, MVert::co, copy_v3_v3(), CU_NURB_CYCLIC, CU_NURB_ENDPOINT, MLoop::e, EdgeLink::edge, BPoint::f1, ListBase::first, Nurb::flagu, if(), VertLink::index, ListBase::last, MPoly::loopstart, Mesh::medge, MEM_calloc_arrayN, MEM_freeN, Mesh::mloop, Mesh::mpoly, Mesh::mvert, VertLink::next, Nurb::orderu, Nurb::pntsu, Nurb::pntsv, prependPolyLineVert(), EdgeLink::prev, BPoint::radius, Nurb::resolu, SELECT, Mesh::totedge, MPoly::totloop, Mesh::totpoly, MEdge::v1, MEdge::v2, BPoint::vec, and BPoint::weight.
Referenced by BKE_mesh_to_curve().
void BKE_mesh_to_pointcloud | ( | Main * | bmain, |
Depsgraph * | depsgraph, | ||
Scene * | UNUSEDscene, | ||
Object * | ob | ||
) |
Definition at line 776 of file mesh_convert.cc.
References BKE_id_materials_copy(), BKE_object_free_derived_caches(), BKE_pointcloud_add(), BKE_pointcloud_from_mesh(), BLI_assert, CD_MASK_MESH, Object::data, DEG_get_evaluated_object(), DEG_get_evaluated_scene(), depsgraph, Object::id, id_us_min(), mesh_get_eval_final(), ID::name, OB_MESH, OB_POINTCLOUD, and Object::type.
void BKE_pointcloud_from_mesh | ( | Mesh * | me, |
PointCloud * | pointcloud | ||
) |
Definition at line 752 of file mesh_convert.cc.
References ATTR_DOMAIN_POINT, BLI_assert, CD_DUPLICATE, CD_MASK_PROP_ALL, CustomData_merge(), CustomData_realloc(), blender::bke::AttributeAccessor::lookup_or_default(), blender::VArrayCommon< T >::materialize(), blender::bke::mesh_attributes(), PointCloud::pdata, point_attributes, blender::bke::pointcloud_attributes_for_write(), PointCloud::totpoint, Mesh::totvert, and Mesh::vdata.
Referenced by BKE_mesh_to_pointcloud().
void BKE_pointcloud_to_mesh | ( | Main * | bmain, |
Depsgraph * | depsgraph, | ||
Scene * | UNUSEDscene, | ||
Object * | ob | ||
) |
Definition at line 834 of file mesh_convert.cc.
References BKE_id_materials_copy(), BKE_mesh_add(), BKE_mesh_from_pointcloud(), BKE_object_free_derived_caches(), BLI_assert, Object::data, Object_Runtime::data_eval, DEG_get_evaluated_object(), depsgraph, Object::id, id_us_min(), ID::name, OB_MESH, OB_POINTCLOUD, Object::runtime, and Object::type.
Populate object->runtime.curve_cache
which is then used to create the mesh.
Definition at line 911 of file mesh_convert.cc.
References Curve::bevobj, BKE_displist_make_curveTypes(), BKE_object_runtime_free_data(), BKE_object_runtime_reset(), BLI_assert, BLI_listbase_clear(), curve, data, GS, ID_CU_LEGACY, Object::modifiers, and Curve::taperobj.
Referenced by mesh_new_from_curve_type_object().
|
static |
Definition at line 1147 of file mesh_convert.cc.
References DEG_get_original_id(), LibraryIDLinkCallbackData::id_pointer, and IDWALK_RET_NOP.
Referenced by BKE_mesh_new_from_object_to_bmain().
|
static |
Definition at line 1158 of file mesh_convert.cc.
References LibraryIDLinkCallbackData::cb_flag, LibraryIDLinkCallbackData::id_pointer, id_us_ensure_real(), id_us_plus(), IDWALK_CB_USER, IDWALK_CB_USER_ONE, and IDWALK_RET_NOP.
Referenced by BKE_mesh_new_from_object_to_bmain().
Definition at line 951 of file mesh_convert.cc.
References Object_Runtime::geometry_set_eval, and Object::runtime.
Referenced by mesh_new_from_evaluated_curve_type_object().
|
static |
Specialized function to use when we know existing edges don't overlap with poly edges.
Definition at line 130 of file mesh_convert.cc.
References BKE_mesh_poly_edgehash_insert(), BLI_assert, BLI_edgehash_free(), BLI_edgehash_haskey(), BLI_edgehash_len(), BLI_edgehash_lookup(), BLI_edgehash_new_ex(), BLI_EDGEHASH_SIZE_GUESS_FROM_POLYS, BLI_edgehashIterator_free(), BLI_edgehashIterator_getKey(), BLI_edgehashIterator_isDone(), BLI_edgehashIterator_new(), BLI_edgehashIterator_setValue(), BLI_edgehashIterator_step(), MEdge::bweight, MEdge::crease, MLoop::e, MEdge::flag, l, MPoly::loopstart, max_ii(), ME_EDGEDRAW, ME_EDGERENDER, MEM_calloc_arrayN, MEM_reallocN, POINTER_AS_UINT, POINTER_FROM_UINT, MPoly::totloop, BMLoop::v, MLoop::v, MEdge::v1, and MEdge::v2.
Referenced by mesh_nurbs_displist_to_mdata().
Copy evaluated texture space from curve to mesh.
Definition at line 479 of file mesh_convert.cc.
References BKE_mesh_texspace_calc(), copy_v3_v3(), CU_AUTOSPACE, Curve::loc, Mesh::loc, Curve::size, Mesh::size, Curve::texflag, and Mesh::texflag.
Referenced by BKE_mesh_new_nomain_from_curve_displist().
Definition at line 970 of file mesh_convert.cc.
References BKE_id_free(), curve, curve_to_mesh_eval_ensure(), Object::data, DEG_is_evaluated_object(), Curve::editfont, Curve::editnurb, GS, ID_CU_LEGACY, mesh, mesh_new_from_evaluated_curve_type_object(), ID::name, object_for_curve_to_mesh_create(), and object_for_curve_to_mesh_free().
Referenced by BKE_mesh_new_from_object().
Definition at line 959 of file mesh_convert.cc.
References BKE_mesh_copy_for_eval(), BKE_object_get_evaluated_mesh(), blender::bke::curve_to_wire_mesh(), curves, get_evaluated_curves_from_object(), mesh, and blender::bke::CurvesGeometry::wrap().
Referenced by mesh_new_from_curve_type_object().
Definition at line 1004 of file mesh_convert.cc.
References BKE_id_new_nomain(), BKE_mesh_from_metaball(), BKE_mesh_texspace_copy_from_object(), BKE_object_material_get(), BLI_listbase_is_empty(), Object_Runtime::curve_cache, Object::data, DEG_is_evaluated_object(), CurveCache::disp, ID_ME, if(), Mesh::mat, MetaBall::mat, MEM_dupallocN, Object::runtime, Mesh::totcol, and MetaBall::totcol.
Referenced by BKE_mesh_new_from_object().
Definition at line 1034 of file mesh_convert.cc.
References BKE_id_copy_ex(), BKE_mesh_wrapper_ensure_mdata(), BKE_mesh_wrapper_ensure_subdivision(), BLI_strncpy(), Object::data, Mesh::id, LIB_ID_CREATE_NO_MAIN, LIB_ID_CREATE_NO_USER_REFCOUNT, ME_WRAPPER_TYPE_BMESH, mesh, ID::name, Mesh::runtime, and Mesh_Runtime::wrapper_type.
Referenced by mesh_new_from_mesh_object(), and mesh_new_from_mesh_object_with_layers().
|
static |
Definition at line 1082 of file mesh_convert.cc.
References BKE_object_get_editmesh_eval_final(), Object::data, depsgraph, Mesh::edit_mesh, if(), mesh_new_from_mesh(), and mesh_new_from_mesh_object_with_layers().
Referenced by BKE_mesh_new_from_object().
|
static |
Definition at line 1053 of file mesh_convert.cc.
References BKE_mesh_wrapper_ensure_subdivision(), CD_MASK_MESH, CD_MASK_ORIGINDEX, Object::data, Object_Runtime::data_orig, DEG_get_evaluated_scene(), DEG_is_original_id(), depsgraph, Object::id, mask(), mesh_create_eval_final(), mesh_new_from_mesh(), result, Object::runtime, and scene.
Referenced by mesh_new_from_mesh_object().
|
static |
Definition at line 202 of file mesh_convert.cc.
References Freestyle::a, usdtokens::b(), BKE_curve_type_get(), MVert::co, copy_v3_v3(), CU_DO_2DFILL, CU_SMOOTH, data, DL_CYCL_U, DL_CYCL_V, DL_INDEX3, DL_POLY, DL_SEGM, DL_SURF, ELEM, MEdge::flag, MPoly::flag, LISTBASE_FOREACH, MPoly::loopstart, make_edges_mdata_extend(), MPoly::mat_nr, ME_EDGEDRAW, ME_EDGERENDER, ME_LOOSEEDGE, ME_SMOOTH, MEM_calloc_arrayN, OB_SURF, MPoly::totloop, MLoopUV::uv, v, MLoop::v, MEdge::v1, and MEdge::v2.
Referenced by BKE_mesh_new_nomain_from_curve_displist().
Definition at line 855 of file mesh_convert.cc.
References BKE_curve_texspace_calc(), BKE_id_copy_ex(), BKE_object_free_modifiers(), curve, Object::data, Curve::editfont, Curve::editnurb, Object::id, LIB_ID_COPY_LOCALIZE, LIB_ID_COPY_SET_COPIED_ON_WRITE, and LIB_ID_CREATE_NO_USER_REFCOUNT.
Referenced by mesh_new_from_curve_type_object().
Definition at line 887 of file mesh_convert.cc.
References BKE_id_free(), curve, Object::data, Object_Runtime::data_eval, Curve::editfont, Curve::editnurb, GS, ID_CU_LEGACY, ID::name, and Object::runtime.
Referenced by mesh_new_from_curve_type_object().
Definition at line 568 of file mesh_convert.cc.
References BLI_addhead(), and VertLink::index.
Referenced by BKE_mesh_to_curve_nurblist().
|
static |
Definition at line 1374 of file mesh_convert.cc.
References BKE_keyblock_add(), Key::block, CD_SHAPEKEY, CLOG_ERROR, MVert::co, copy_v3_v3(), KDL::cos(), CustomData_get_layer_index_n(), CustomData_get_layer_n(), CustomData_number_of_layers(), KeyBlock::data, ListBase::first, float(), Mesh::key, CustomData::layers, LOG, MEM_calloc_arrayN, MEM_freeN, MEM_malloc_arrayN, Mesh::mvert, CustomDataLayer::name, KeyBlock::name, KeyBlock::next, KeyBlock::totelem, Mesh::totvert, CustomDataLayer::uid, KeyBlock::uid, and Mesh::vdata.
Referenced by BKE_mesh_nomain_to_mesh().
|
static |
Definition at line 70 of file mesh_convert.cc.
Referenced by add_shapekey_layers(), BKE_mesh_nomain_to_mesh(), and shapekey_layers_to_keyblocks().