Blender V4.3
mesh_convert.cc File Reference
#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_meta_types.h"
#include "DNA_object_types.h"
#include "DNA_pointcloud_types.h"
#include "DNA_scene_types.h"
#include "BLI_index_range.hh"
#include "BLI_listbase.h"
#include "BLI_span.hh"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLT_translation.hh"
#include "BKE_curves.hh"
#include "BKE_deform.hh"
#include "BKE_displist.h"
#include "BKE_editmesh.hh"
#include "BKE_geometry_set.hh"
#include "BKE_geometry_set_instances.hh"
#include "BKE_key.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_query.hh"
#include "BKE_main.hh"
#include "BKE_material.h"
#include "BKE_mball.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_runtime.hh"
#include "BKE_mesh_wrapper.hh"
#include "BKE_modifier.hh"
#include "BKE_object_types.hh"
#include "BKE_curve.hh"
#include "BKE_object.hh"
#include "BKE_pointcloud.hh"
#include "BKE_curve_to_mesh.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"

Go to the source code of this file.

Classes

struct  EdgeLink
 
struct  VertLink
 

Functions

static Meshmesh_nurbs_displist_to_mesh (const Curve *cu, const ListBase *dispbase)
 
static void mesh_copy_texture_space_from_curve_type (const Curve *cu, Mesh *mesh)
 
MeshBKE_mesh_new_nomain_from_curve_displist (const Object *ob, const ListBase *dispbase)
 
MeshBKE_mesh_new_nomain_from_curve (const Object *ob)
 
static void prependPolyLineVert (ListBase *lb, uint index)
 
static void appendPolyLineVert (ListBase *lb, uint index)
 
void BKE_mesh_to_curve_nurblist (const Mesh *mesh, ListBase *nurblist, const int edge_users_test)
 
void BKE_mesh_to_curve (Main *bmain, Depsgraph *depsgraph, Scene *, Object *ob)
 
void BKE_mesh_to_pointcloud (Main *bmain, Depsgraph *depsgraph, Scene *, Object *ob)
 
void BKE_pointcloud_to_mesh (Main *bmain, Depsgraph *depsgraph, Scene *, Object *ob)
 
static Objectobject_for_curve_to_mesh_create (const Object *object)
 
static void object_for_curve_to_mesh_free (Object *temp_object)
 
static void curve_to_mesh_eval_ensure (Object &object)
 
static const Curvesget_evaluated_curves_from_object (const Object *object)
 
static Meshmesh_new_from_evaluated_curve_type_object (const Object *evaluated_object)
 
static Meshmesh_new_from_curve_type_object (const Object *object)
 
static Meshmesh_new_from_mball_object (Object *object)
 
static Meshmesh_new_from_mesh (Object *object, const Mesh *mesh)
 
static Meshmesh_new_from_mesh_object_with_layers (Depsgraph *depsgraph, Object *object, const bool preserve_origindex)
 
static Meshmesh_new_from_mesh_object (Depsgraph *depsgraph, Object *object, const bool preserve_all_data_layers, const bool preserve_origindex)
 
MeshBKE_mesh_new_from_object (Depsgraph *depsgraph, Object *object, const bool preserve_all_data_layers, const bool preserve_origindex)
 
static int foreach_libblock_make_original_callback (LibraryIDLinkCallbackData *cb_data)
 
static int foreach_libblock_make_usercounts_callback (LibraryIDLinkCallbackData *cb_data)
 
MeshBKE_mesh_new_from_object_to_bmain (Main *bmain, Depsgraph *depsgraph, Object *object, bool preserve_all_data_layers)
 
static void copy_loose_vert_hint (const Mesh &src, Mesh &dst)
 
static void copy_loose_edge_hint (const Mesh &src, Mesh &dst)
 
static void copy_overlapping_hint (const Mesh &src, Mesh &dst)
 
static KeyBlockkeyblock_ensure_from_uid (Key &key, const int uid, const StringRefNull name)
 
static int find_object_active_key_uid (const Key &key, const Object &object)
 
static void move_shapekey_layers_to_keyblocks (const Mesh &mesh, const CustomData &custom_data, Key &key_dst, const int actshape_uid)
 
void BKE_mesh_nomain_to_mesh (Mesh *mesh_src, Mesh *mesh_dst, Object *ob)
 
void BKE_mesh_nomain_to_meshkey (Mesh *mesh_src, Mesh *mesh_dst, KeyBlock *kb)
 

Variables

static CLG_LogRef LOG = {"bke.mesh_convert"}
 

Function Documentation

◆ appendPolyLineVert()

static void appendPolyLineVert ( ListBase * lb,
uint index )
static

Definition at line 367 of file mesh_convert.cc.

References BLI_addtail(), and VertLink::index.

Referenced by BKE_mesh_to_curve_nurblist().

◆ BKE_mesh_new_from_object()

Mesh * BKE_mesh_new_from_object ( Depsgraph * depsgraph,
Object * object,
bool preserve_all_data_layers,
bool preserve_origindex )

Create new mesh from the given object at its current state. The caller owns the result mesh.

If preserve_all_data_layers is true then the modifier stack is re-evaluated to ensure it preserves all possible custom data layers.

Note
Dependency graph argument is required when preserve_all_data_layers is true, and is ignored otherwise.

Definition at line 845 of file mesh_convert.cc.

References BLI_assert, depsgraph, 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, Mesh::runtime, and ID::us.

Referenced by blender::ed::object::bake(), blender::ed::object::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().

◆ BKE_mesh_new_from_object_to_bmain()

Mesh * BKE_mesh_new_from_object_to_bmain ( Main * bmain,
Depsgraph * depsgraph,
Object * object,
bool preserve_all_data_layers )

◆ BKE_mesh_new_nomain_from_curve()

Mesh * BKE_mesh_new_nomain_from_curve ( const Object * ob)

These functions construct a new Mesh, contrary to BKE_mesh_to_curve_nurblist which modifies ob itself.

Definition at line 339 of file mesh_convert.cc.

References BKE_mesh_new_nomain_from_curve_displist(), and Object::runtime.

Referenced by blender::io::alembic::ABCCurveMeshWriter::get_export_mesh(), and knifeproject_poly_from_object().

◆ BKE_mesh_new_nomain_from_curve_displist()

Mesh * BKE_mesh_new_nomain_from_curve_displist ( const Object * ob,
const ListBase * dispbase )

◆ BKE_mesh_nomain_to_mesh()

void BKE_mesh_nomain_to_mesh ( Mesh * mesh_src,
Mesh * mesh_dst,
Object * ob )

Move data from a mesh outside of the main data-base into a mesh in the data-base. Takes ownership of the source mesh.

Definition at line 1055 of file mesh_convert.cc.

References Mesh::active_color_attribute, BKE_id_free(), BKE_mesh_clear_geometry_and_metadata(), BKE_mesh_copy_parameters(), BLI_assert, CD_MASK_MESH, CD_SHAPEKEY, CLOG_WARN, copy_loose_edge_hint(), copy_loose_vert_hint(), copy_overlapping_hint(), Mesh::corner_data, Mesh::corners_num, CustomData_has_layer(), CustomData_init_from(), Object::data, Mesh::default_color_attribute, Mesh::edge_data, Mesh::edges_num, Mesh::face_data, Mesh::face_offset_indices, Mesh::faces_num, find_object_active_key_uid(), Key::id, Mesh::id, ID_TAG_NO_MAIN, id_us_min(), Mesh::key, LOG, move_shapekey_layers_to_keyblocks(), ID::name, Mesh::runtime, ID::tag, Mesh::vert_data, Mesh::vertex_group_names, and Mesh::verts_num.

Referenced by blender::ed::sculpt_paint::trim::apply_trim(), BKE_mesh_new_from_object_to_bmain(), blender::io::obj::MeshFromGeometry::create_mesh_object(), geometry_extract_apply(), blender::io::ply::importer_main(), blender::io::stl::importer_main(), blender::ed::object::modifier_apply_obdata(), multiresModifier_rebuild_subdiv(), blender::ed::object::object_convert_exec(), paint_mask_slice_exec(), blender::ed::object::quadriflow_start_job(), blender::io::usd::USDMeshReader::read_object_data(), blender::io::usd::USDShapeReader::read_object_data(), blender::io::alembic::AbcMeshReader::readObjectData(), blender::io::alembic::AbcSubDReader::readObjectData(), blender::ed::geometry::store_result_geometry(), and blender::ed::object::voxel_remesh_exec().

◆ BKE_mesh_nomain_to_meshkey()

◆ BKE_mesh_to_curve()

◆ BKE_mesh_to_curve_nurblist()

◆ BKE_mesh_to_pointcloud()

◆ BKE_pointcloud_to_mesh()

◆ copy_loose_edge_hint()

static void copy_loose_edge_hint ( const Mesh & src,
Mesh & dst )
static

◆ copy_loose_vert_hint()

static void copy_loose_vert_hint ( const Mesh & src,
Mesh & dst )
static

◆ copy_overlapping_hint()

static void copy_overlapping_hint ( const Mesh & src,
Mesh & dst )
static

◆ curve_to_mesh_eval_ensure()

static void curve_to_mesh_eval_ensure ( Object & object)
static

Populate object->runtime->curve_cache which is then used to create the mesh.

Definition at line 646 of file mesh_convert.cc.

References BKE_displist_make_curveTypes(), BKE_object_runtime_free_data(), BKE_object_runtime_reset(), BLI_assert, BLI_listbase_clear(), GS, ID_CU_LEGACY, Object::modifiers, and Object::runtime.

Referenced by mesh_new_from_curve_type_object().

◆ find_object_active_key_uid()

static int find_object_active_key_uid ( const Key & key,
const Object & object )
static

Definition at line 1010 of file mesh_convert.cc.

References BLI_findlink(), Key::block, CLOG_ERROR, LOG, and KeyBlock::uid.

Referenced by BKE_mesh_nomain_to_mesh().

◆ foreach_libblock_make_original_callback()

static int foreach_libblock_make_original_callback ( LibraryIDLinkCallbackData * cb_data)
static

◆ foreach_libblock_make_usercounts_callback()

◆ get_evaluated_curves_from_object()

static const Curves * get_evaluated_curves_from_object ( const Object * object)
static

Definition at line 698 of file mesh_convert.cc.

Referenced by mesh_new_from_evaluated_curve_type_object().

◆ keyblock_ensure_from_uid()

static KeyBlock * keyblock_ensure_from_uid ( Key & key,
const int uid,
const StringRefNull name )
static

◆ mesh_copy_texture_space_from_curve_type()

static void mesh_copy_texture_space_from_curve_type ( const Curve * cu,
Mesh * mesh )
static

Copy evaluated texture space from curve to mesh.

Note
We disable auto texture space feature since that will cause texture space to evaluate differently for curve and mesh, since curves use control points and handles to calculate the bounding box, and mesh uses the tessellated curve.

Definition at line 319 of file mesh_convert.cc.

References BKE_mesh_texspace_calc(), copy_v3_v3(), Curve::texspace_flag, Mesh::texspace_flag, Curve::texspace_location, and Curve::texspace_size.

Referenced by BKE_mesh_new_nomain_from_curve_displist().

◆ mesh_new_from_curve_type_object()

◆ mesh_new_from_evaluated_curve_type_object()

static Mesh * mesh_new_from_evaluated_curve_type_object ( const Object * evaluated_object)
static

◆ mesh_new_from_mball_object()

static Mesh * mesh_new_from_mball_object ( Object * object)
static

◆ mesh_new_from_mesh()

◆ mesh_new_from_mesh_object()

static Mesh * mesh_new_from_mesh_object ( Depsgraph * depsgraph,
Object * object,
const bool preserve_all_data_layers,
const bool preserve_origindex )
static

◆ mesh_new_from_mesh_object_with_layers()

static Mesh * mesh_new_from_mesh_object_with_layers ( Depsgraph * depsgraph,
Object * object,
const bool preserve_origindex )
static

◆ mesh_nurbs_displist_to_mesh()

◆ move_shapekey_layers_to_keyblocks()

◆ object_for_curve_to_mesh_create()

◆ object_for_curve_to_mesh_free()

static void object_for_curve_to_mesh_free ( Object * temp_object)
static

◆ prependPolyLineVert()

static void prependPolyLineVert ( ListBase * lb,
uint index )
static

Definition at line 360 of file mesh_convert.cc.

References BLI_addhead(), and VertLink::index.

Referenced by BKE_mesh_to_curve_nurblist().

Variable Documentation

◆ LOG

CLG_LogRef LOG = {"bke.mesh_convert"}
static