Blender  V3.3
Macros | Functions | Variables
data_transfer.c File Reference
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
#include "DNA_customdata_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BKE_attribute.h"
#include "BKE_customdata.h"
#include "BKE_data_transfer.h"
#include "BKE_deform.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_mesh_remap.h"
#include "BKE_mesh_runtime.h"
#include "BKE_mesh_wrapper.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_object_deform.h"
#include "BKE_report.h"
#include "data_transfer_intern.h"

Go to the source code of this file.

Macros

#define VDATA   0
 
#define EDATA   1
 
#define LDATA   2
 
#define PDATA   3
 
#define DATAMAX   4
 

Functions

void BKE_object_data_transfer_dttypes_to_cdmask (const int dtdata_types, CustomData_MeshMasks *r_data_masks)
 
bool BKE_object_data_transfer_get_dttypes_capacity (const int dtdata_types, bool *r_advanced_mixing, bool *r_threshold)
 
int BKE_object_data_transfer_get_dttypes_item_types (const int dtdata_types)
 
int BKE_object_data_transfer_dttype_to_cdtype (const int dtdata_type)
 
int BKE_object_data_transfer_dttype_to_srcdst_index (const int dtdata_type)
 
static void data_transfer_dtdata_type_preprocess (Mesh *me_src, Mesh *me_dst, const int dtdata_type, const bool dirty_nors_dst)
 
static void data_transfer_dtdata_type_postprocess (Object *UNUSED(ob_src), Object *UNUSED(ob_dst), Mesh *UNUSED(me_src), Mesh *me_dst, const int dtdata_type, const bool changed)
 
static MeshRemapIslandsCalc data_transfer_get_loop_islands_generator (const int cddata_type)
 
float data_transfer_interp_float_do (const int mix_mode, const float val_dst, const float val_src, const float mix_factor)
 
static void data_transfer_interp_char (const CustomDataTransferLayerMap *laymap, void *dest, const void **sources, const float *weights, const int count, const float mix_factor)
 
void data_transfer_layersmapping_add_item (ListBase *r_map, const int cddata_type, const int mix_mode, const float mix_factor, const float *mix_weights, const void *data_src, void *data_dst, const int data_src_n, const int data_dst_n, const size_t elem_size, const size_t data_size, const size_t data_offset, const uint64_t data_flag, cd_datatransfer_interp interp, void *interp_data)
 
static void data_transfer_layersmapping_add_item_cd (ListBase *r_map, const int cddata_type, const int mix_mode, const float mix_factor, const float *mix_weights, const void *data_src, void *data_dst, cd_datatransfer_interp interp, void *interp_data)
 
static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst (ListBase *r_map, const int cddata_type, const int mix_mode, const float mix_factor, const float *mix_weights, const int num_elem_dst, const bool use_create, const bool use_delete, CustomData *cd_src, CustomData *cd_dst, const bool use_dupref_dst, const int tolayers, const bool *use_layers_src, const int num_layers_src, cd_datatransfer_interp interp, void *interp_data)
 
static bool data_transfer_layersmapping_cdlayers (ListBase *r_map, const int cddata_type, const int mix_mode, const float mix_factor, const float *mix_weights, const int num_elem_dst, const bool use_create, const bool use_delete, CustomData *cd_src, CustomData *cd_dst, const bool use_dupref_dst, const int fromlayers, const int tolayers, cd_datatransfer_interp interp, void *interp_data)
 
static bool data_transfer_layersmapping_generate (ListBase *r_map, Object *ob_src, Object *ob_dst, Mesh *me_src, Mesh *me_dst, const int elem_type, int cddata_type, int mix_mode, float mix_factor, const float *mix_weights, const int num_elem_dst, const bool use_create, const bool use_delete, const int fromlayers, const int tolayers, SpaceTransform *space_transform)
 
void BKE_object_data_transfer_layout (struct Depsgraph *depsgraph, Scene *scene, Object *ob_src, Object *ob_dst, const int data_types, const bool use_delete, const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX])
 
bool BKE_object_data_transfer_ex (struct Depsgraph *depsgraph, Scene *scene, Object *ob_src, Object *ob_dst, Mesh *me_dst, const int data_types, bool use_create, const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode, SpaceTransform *space_transform, const bool auto_transform, const float max_distance, const float ray_radius, const float islands_handling_precision, const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX], const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup, ReportList *reports)
 
bool BKE_object_data_transfer_mesh (struct Depsgraph *depsgraph, Scene *scene, Object *ob_src, Object *ob_dst, const int data_types, const bool use_create, const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode, SpaceTransform *space_transform, const bool auto_transform, const float max_distance, const float ray_radius, const float islands_handling_precision, const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX], const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup, ReportList *reports)
 

Variables

static CLG_LogRef LOG = {"bke.data_transfer"}
 

Macro Definition Documentation

◆ DATAMAX

#define DATAMAX   4

◆ EDATA

#define EDATA   1

◆ LDATA

#define LDATA   2

◆ PDATA

#define PDATA   3

◆ VDATA

#define VDATA   0

Function Documentation

◆ BKE_object_data_transfer_dttype_to_cdtype()

int BKE_object_data_transfer_dttype_to_cdtype ( const int  dtdata_type)

◆ BKE_object_data_transfer_dttype_to_srcdst_index()

int BKE_object_data_transfer_dttype_to_srcdst_index ( const int  dtdata_type)

◆ BKE_object_data_transfer_dttypes_to_cdmask()

void BKE_object_data_transfer_dttypes_to_cdmask ( const int  dtdata_types,
CustomData_MeshMasks r_data_masks 
)

◆ BKE_object_data_transfer_ex()

bool BKE_object_data_transfer_ex ( struct Depsgraph depsgraph,
Scene scene,
Object ob_src,
Object ob_dst,
Mesh me_dst,
const int  data_types,
bool  use_create,
const int  map_vert_mode,
const int  map_edge_mode,
const int  map_loop_mode,
const int  map_poly_mode,
SpaceTransform space_transform,
const bool  auto_transform,
const float  max_distance,
const float  ray_radius,
const float  islands_handling_precision,
const int  fromlayers_select[DT_MULTILAYER_INDEX_MAX],
const int  tolayers_select[DT_MULTILAYER_INDEX_MAX],
const int  mix_mode,
const float  mix_factor,
const char *  vgroup_name,
const bool  invert_vgroup,
ReportList reports 
)

Definition at line 1340 of file data_transfer.c.

References BKE_defvert_extract_vgroup_to_edgeweights(), BKE_defvert_extract_vgroup_to_loopweights(), BKE_defvert_extract_vgroup_to_polyweights(), BKE_defvert_extract_vgroup_to_vertweights(), BKE_id_defgroup_name_index(), BKE_mesh_remap_calc_edges_from_mesh(), BKE_mesh_remap_calc_loops_from_mesh(), BKE_mesh_remap_calc_polys_from_mesh(), BKE_mesh_remap_calc_source_cddata_masks_from_map_modes(), BKE_mesh_remap_calc_verts_from_mesh(), BKE_mesh_remap_find_best_match_from_mesh(), BKE_mesh_remap_free(), BKE_mesh_vertex_normals_are_dirty(), BKE_mesh_wrapper_ensure_mdata(), BKE_modifier_get_evaluated_mesh_from_evaluated_object(), BKE_object_data_transfer_dttype_to_cdtype(), BKE_object_data_transfer_dttype_to_srcdst_index(), BKE_object_data_transfer_dttypes_to_cdmask(), BKE_report(), BLI_assert, BLI_freelistN(), CD_MASK_BAREMESH, CD_MDEFORMVERT, CLOG_WARN, CustomData_data_transfer(), CustomData_get_layer(), CustomData_MeshMasks_are_matching(), Object::data, data_transfer_dtdata_type_postprocess(), data_transfer_dtdata_type_preprocess(), data_transfer_get_loop_islands_generator(), data_transfer_layersmapping_generate(), DATAMAX, depsgraph, DT_DATATYPE_IS_EDGE, DT_DATATYPE_IS_LOOP, DT_DATATYPE_IS_POLY, DT_DATATYPE_IS_VERT, DT_MULTILAYER_INDEX_INVALID, DT_TYPE_MAX, EDATA, ELEM, ListBase::first, Mesh::flag, Mesh::id, Object_Runtime::last_data_mask, LDATA, Mesh::ldata, LOG, ME_AUTOSMOOTH, ME_EDGE, ME_LOOP, ME_POLY, ME_VERT, Mesh::medge, MEM_mallocN, MEM_SAFE_FREE, mesh_get_eval_final(), Mesh::mloop, Mesh::mpoly, MREMAP_MODE_TOPOLOGY, MREMAP_USE_EDGE, MREMAP_USE_POLY, Mesh::mvert, CustomDataTransferLayerMap::next, NULL, OB_MESH, PDATA, RPT_ERROR, Object::runtime, scene, Mesh::smoothresh, Mesh::totedge, Mesh::totloop, Mesh::totpoly, Mesh::totvert, Object::type, VDATA, and Mesh::vdata.

Referenced by BKE_object_data_transfer_mesh(), and modifyMesh().

◆ BKE_object_data_transfer_get_dttypes_capacity()

bool BKE_object_data_transfer_get_dttypes_capacity ( int  dtdata_types,
bool r_advanced_mixing,
bool r_threshold 
)

◆ BKE_object_data_transfer_get_dttypes_item_types()

int BKE_object_data_transfer_get_dttypes_item_types ( const int  dtdata_types)

◆ BKE_object_data_transfer_layout()

void BKE_object_data_transfer_layout ( struct Depsgraph depsgraph,
struct Scene scene,
struct Object ob_src,
struct Object ob_dst,
int  data_types,
bool  use_delete,
const int  fromlayers_select[DT_MULTILAYER_INDEX_MAX],
const int  tolayers_select[DT_MULTILAYER_INDEX_MAX] 
)

Transfer data layout of selected types from source to destination object. By default, it only creates new data layers if needed on ob_dst. If use_delete is true, it will also delete data layers on ob_dst that do not match those from ob_src, to get (as much as possible) exact copy of source data layout.

Definition at line 1208 of file data_transfer.c.

References BKE_object_data_transfer_dttype_to_cdtype(), BKE_object_data_transfer_dttype_to_srcdst_index(), BKE_object_data_transfer_dttypes_to_cdmask(), BLI_assert, CD_MASK_BAREMESH, Object::data, data_transfer_layersmapping_generate(), depsgraph, DT_DATATYPE_IS_EDGE, DT_DATATYPE_IS_LOOP, DT_DATATYPE_IS_POLY, DT_DATATYPE_IS_VERT, DT_MULTILAYER_INDEX_INVALID, DT_TYPE_MAX, ME_EDGE, ME_LOOP, ME_POLY, ME_VERT, mesh_get_eval_final(), NULL, OB_MESH, scene, Mesh::totedge, Mesh::totloop, Mesh::totpoly, Mesh::totvert, and Object::type.

Referenced by datalayout_transfer_exec().

◆ BKE_object_data_transfer_mesh()

bool BKE_object_data_transfer_mesh ( struct Depsgraph depsgraph,
Scene scene,
Object ob_src,
Object ob_dst,
const int  data_types,
const bool  use_create,
const int  map_vert_mode,
const int  map_edge_mode,
const int  map_loop_mode,
const int  map_poly_mode,
SpaceTransform space_transform,
const bool  auto_transform,
const float  max_distance,
const float  ray_radius,
const float  islands_handling_precision,
const int  fromlayers_select[DT_MULTILAYER_INDEX_MAX],
const int  tolayers_select[DT_MULTILAYER_INDEX_MAX],
const int  mix_mode,
const float  mix_factor,
const char *  vgroup_name,
const bool  invert_vgroup,
ReportList reports 
)

Definition at line 1825 of file data_transfer.c.

References BKE_object_data_transfer_ex(), depsgraph, NULL, and scene.

Referenced by data_transfer_exec().

◆ data_transfer_dtdata_type_postprocess()

static void data_transfer_dtdata_type_postprocess ( Object UNUSEDob_src,
Object UNUSEDob_dst,
Mesh UNUSEDme_src,
Mesh me_dst,
const int  dtdata_type,
const bool  changed 
)
static

◆ data_transfer_dtdata_type_preprocess()

static void data_transfer_dtdata_type_preprocess ( Mesh me_src,
Mesh me_dst,
const int  dtdata_type,
const bool  dirty_nors_dst 
)
static

◆ data_transfer_get_loop_islands_generator()

static MeshRemapIslandsCalc data_transfer_get_loop_islands_generator ( const int  cddata_type)
static

◆ data_transfer_interp_char()

static void data_transfer_interp_char ( const CustomDataTransferLayerMap laymap,
void dest,
const void **  sources,
const float weights,
const int  count,
const float  mix_factor 
)
static

◆ data_transfer_interp_float_do()

float data_transfer_interp_float_do ( const int  mix_mode,
const float  val_dst,
const float  val_src,
const float  mix_factor 
)

◆ data_transfer_layersmapping_add_item()

void data_transfer_layersmapping_add_item ( ListBase r_map,
const int  cddata_type,
const int  mix_mode,
const float  mix_factor,
const float mix_weights,
const void data_src,
void data_dst,
const int  data_src_n,
const int  data_dst_n,
const size_t  elem_size,
const size_t  data_size,
const size_t  data_offset,
const uint64_t  data_flag,
cd_datatransfer_interp  interp,
void interp_data 
)

◆ data_transfer_layersmapping_add_item_cd()

static void data_transfer_layersmapping_add_item_cd ( ListBase r_map,
const int  cddata_type,
const int  mix_mode,
const float  mix_factor,
const float mix_weights,
const void data_src,
void data_dst,
cd_datatransfer_interp  interp,
void interp_data 
)
static

◆ data_transfer_layersmapping_cdlayers()

static bool data_transfer_layersmapping_cdlayers ( ListBase r_map,
const int  cddata_type,
const int  mix_mode,
const float  mix_factor,
const float mix_weights,
const int  num_elem_dst,
const bool  use_create,
const bool  use_delete,
CustomData cd_src,
CustomData cd_dst,
const bool  use_dupref_dst,
const int  fromlayers,
const int  tolayers,
cd_datatransfer_interp  interp,
void interp_data 
)
static

◆ data_transfer_layersmapping_cdlayers_multisrc_to_dst()

static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst ( ListBase r_map,
const int  cddata_type,
const int  mix_mode,
const float  mix_factor,
const float mix_weights,
const int  num_elem_dst,
const bool  use_create,
const bool  use_delete,
CustomData cd_src,
CustomData cd_dst,
const bool  use_dupref_dst,
const int  tolayers,
const bool use_layers_src,
const int  num_layers_src,
cd_datatransfer_interp  interp,
void interp_data 
)
static
Note
All those layer mapping handlers return false only if they were given invalid parameters. This means that even if they do nothing, they will return true if all given parameters were OK. Also, r_map may be NULL, in which case they will 'only' create/delete destination layers according to given parameters.

Definition at line 520 of file data_transfer.c.

References CD_CALLOC, CustomData_add_layer(), CustomData_add_layer_named(), CustomData_duplicate_referenced_layer_n(), CustomData_free_layer(), CustomData_get_layer_n(), CustomData_get_layer_name(), CustomData_get_named_layer(), CustomData_number_of_layers(), data_transfer_layersmapping_add_item_cd(), DT_LAYERS_INDEX_DST, DT_LAYERS_NAME_DST, interp(), MEM_freeN, MEM_mallocN, and NULL.

Referenced by data_transfer_layersmapping_cdlayers().

◆ data_transfer_layersmapping_generate()

static bool data_transfer_layersmapping_generate ( ListBase r_map,
Object ob_src,
Object ob_dst,
Mesh me_src,
Mesh me_dst,
const int  elem_type,
int  cddata_type,
int  mix_mode,
float  mix_factor,
const float mix_weights,
const int  num_elem_dst,
const bool  use_create,
const bool  use_delete,
const int  fromlayers,
const int  tolayers,
SpaceTransform space_transform 
)
static

Variable Documentation

◆ LOG

CLG_LogRef LOG = {"bke.data_transfer"}
static

Definition at line 38 of file data_transfer.c.

Referenced by BKE_object_data_transfer_ex().