35 #include "RNA_prototypes.h"
53 "Transfer active or all vertex groups"},
55 {
DT_TYPE_SHAPEKEY,
"SHAPEKEYS", 0,
"Shapekey(s)",
"Transfer active or all shape keys"},
60 {
DT_TYPE_SKIN,
"SKIN", 0,
"Skin Weight",
"Transfer skin weights"},
71 {
DT_TYPE_SEAM,
"SEAM", 0,
"UV Seam",
"Transfer UV seam mark"},
72 {
DT_TYPE_CREASE,
"CREASE", 0,
"Subdivision Crease",
"Transfer crease values"},
78 "Transfer Freestyle edge mark"},
81 {
DT_TYPE_LNOR,
"CUSTOM_NORMAL", 0,
"Custom Normals",
"Transfer custom normals"},
87 {
DT_TYPE_UV,
"UV", 0,
"UVs",
"Transfer UV layers"},
95 "Transfer Freestyle face mark"},
106 for (
int i = 0; i < 2; i++) {
117 for (
int j = 0; j < num_data; j++) {
119 tmp_item.
value = idx++;
141 const int layers_select_dst = reverse_transfer ?
RNA_enum_get(
ptr,
"layers_select_src") :
152 if (ob_src ==
NULL) {
172 for (i = 0, dg = defbase->
first; dg; i++, dg = dg->
next) {
174 tmp_item.identifier = tmp_item.name = dg->
name;
193 for (
int i = 0; i < num_data; i++) {
251 const int layers_select_src = reverse_transfer ?
RNA_enum_get(
ptr,
"layers_select_dst") :
279 if (reverse_transfer) {
284 if (reverse_transfer) {
300 bool support_advanced_mixing, support_threshold;
309 dtdata_type, &support_advanced_mixing, &support_threshold);
311 if (support_threshold) {
318 if (support_advanced_mixing) {
334 const int layers_select_src =
RNA_enum_get(op->
ptr,
"layers_select_src");
353 const bool reverse_transfer)
358 if (reverse_transfer) {
362 for (ctx_ob = ctx_objects->
first; ctx_ob; ctx_ob = ctx_ob->
next) {
374 "Skipping object '%s', linked or override data '%s' cannot be modified",
389 const bool reverse_transfer)
396 if (reverse_transfer) {
411 "Skipping object '%s', data '%s' has already been processed with a previous object",
427 bool changed =
false;
444 const float max_distance = use_max_distance ?
RNA_float_get(op->
ptr,
"max_distance") : FLT_MAX;
446 const float islands_precision =
RNA_float_get(op->
ptr,
"islands_precision");
458 SpaceTransform *space_transform = (use_object_transform && !use_auto_transform) ?
459 &space_transform_data :
466 "Operator is frozen, changes to its settings won't take effect until you unfreeze it");
475 if (reverse_transfer) {
476 SWAP(
int, layers_src, layers_dst);
480 layers_select_src[fromto_idx] = layers_src;
481 layers_select_dst[fromto_idx] = layers_dst;
486 for (ctx_ob_dst = ctx_objects.
first; ctx_ob_dst; ctx_ob_dst = ctx_ob_dst->
next) {
489 if (reverse_transfer) {
496 if (space_transform) {
533 if (reverse_transfer) {
573 bool use_auto_transform =
false;
574 bool use_max_distance =
false;
575 bool use_modifier =
false;
587 if (
STREQ(prop_id,
"modifier")) {
596 if (
STREQ(prop_id,
"use_object_transform")) {
597 if (use_auto_transform) {
601 else if (
STREQ(prop_id,
"max_distance")) {
602 if (!use_max_distance) {
606 else if (
STREQ(prop_id,
"islands_precision")) {
611 else if (
STREQ(prop_id,
"vert_mapping")) {
616 else if (
STREQ(prop_id,
"edge_mapping")) {
621 else if (
STREQ(prop_id,
"loop_mapping")) {
626 else if (
STREQ(prop_id,
"poly_mapping")) {
631 else if (
STR_ELEM(prop_id,
"layers_select_src",
"layers_select_dst")) {
647 if (reverse_transfer) {
649 "Transfer data layer(s) (weights, edge sharp, etc.) from selected meshes to active one"));
660 ot->
name =
"Transfer Mesh Data";
661 ot->
idname =
"OBJECT_OT_data_transfer";
663 "Transfer data layer(s) (weights, edge sharp, etc.) from active to selected meshes";
678 "use_reverse_transfer",
681 "Transfer from selected objects to active one");
688 "Prevent changes to settings to re-run the operator, "
689 "handy to change several things at once with heavy geometry");
698 "Add data layers on destination meshes if needed");
706 "Method used to map source vertices to destination ones");
712 "Method used to map source edges to destination ones");
717 "Face Corner Mapping",
718 "Method used to map source faces' corners to destination ones");
724 "Method used to map source faces to destination ones");
729 "use_auto_transform",
732 "Automatically compute transformation to get the best possible match between source and "
733 "destination meshes.\n"
734 "Warning: Results will never be as good as manual matching of objects");
736 "use_object_transform",
739 "Evaluate source and destination meshes in global space");
743 "Only Neighbor Geometry",
744 "Source elements must be closer than given distance from destination one");
752 "Maximum allowed distance between source and destination element, for non-topology mappings",
763 "'Width' of rays (especially useful when raycasting against vertices or edges)",
774 "Factor controlling precision of islands handling (the higher, the better the results)",
784 "Source Layers Selection",
785 "Which layers to transfer, in case of multi-layers types");
792 "Destination Layers Matching",
793 "How to match source and destination layers");
801 "How to affect destination elements with source values");
810 "Factor to use when applying data to destination (exact behavior depends on mix mode)",
842 const bool use_delete =
false;
877 layers_select_src[fromto_idx] = layers_src;
878 layers_select_dst[fromto_idx] = layers_dst;
885 for (ctx_ob_dst = ctx_objects.
first; ctx_ob_dst; ctx_ob_dst = ctx_ob_dst->
next) {
922 ot->
name =
"Transfer Mesh Data Layout";
923 ot->
description =
"Transfer layout of data layer(s) from active to selected meshes";
924 ot->
idname =
"OBJECT_OT_datalayout_transfer";
945 "Also delete some data layers from destination if necessary, so that it matches "
953 "Source Layers Selection",
954 "Which layers to transfer, in case of multi-layers types");
961 "Destination Layers Matching",
962 "How to match source and destination layers");
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
int CTX_data_selected_editable_objects(const bContext *C, ListBase *list)
struct Main * CTX_data_main(const bContext *C)
const char * CustomData_get_layer_name(const struct CustomData *data, int type, int n)
int CustomData_number_of_layers(const struct CustomData *data, int type)
const CustomData_MeshMasks CD_MASK_BAREMESH
@ CDT_MIX_REPLACE_BELOW_THRESHOLD
@ CDT_MIX_REPLACE_ABOVE_THRESHOLD
#define CD_TYPE_AS_MASK(_type)
@ DT_MULTILAYER_INDEX_MAX
@ DT_MULTILAYER_INDEX_INVALID
@ DT_LAYERS_VGROUP_SRC_BONE_SELECT
@ DT_LAYERS_VGROUP_SRC_BONE_DEFORM
#define DT_DATATYPE_IS_POLY(_dt)
int BKE_object_data_transfer_dttype_to_srcdst_index(int dtdata_type)
#define DT_DATATYPE_IS_MULTILAYERS(_dt)
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])
#define DT_DATATYPE_IS_LOOP(_dt)
#define DT_DATATYPE_IS_EDGE(_dt)
bool BKE_object_data_transfer_get_dttypes_capacity(int dtdata_types, bool *r_advanced_mixing, bool *r_threshold)
bool BKE_object_data_transfer_mesh(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob_src, struct Object *ob_dst, int data_types, bool use_create, int map_vert_mode, int map_edge_mode, int map_loop_mode, int map_poly_mode, struct SpaceTransform *space_transform, bool auto_transform, float max_distance, float ray_radius, float islands_handling_precision, const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX], int mix_mode, float mix_factor, const char *vgroup_name, bool invert_vgroup, struct ReportList *reports)
#define DT_DATATYPE_IS_VERT(_dt)
@ MREMAP_MODE_VERT_NEAREST
@ MREMAP_MODE_LOOP_NEAREST_POLYNOR
@ MREMAP_MODE_EDGE_NEAREST
@ MREMAP_MODE_POLY_NEAREST
struct Mesh * mesh_get_eval_final(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
General operations, lookup, etc. for blender objects.
struct Object * BKE_object_pose_armature_get(struct Object *ob)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
#define BLI_SPACE_TRANSFORM_SETUP(data, local, target)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
struct Depsgraph Depsgraph
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
#define ID_IS_LINKED(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
#define CD_MASK_PROP_BYTE_COLOR
#define CD_MASK_PROP_COLOR
@ eModifierType_DataTransfer
Object is a sort of wrapper for general info.
struct Object * ED_object_active_context(const struct bContext *C)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
#define RNA_ENUM_ITEM_HEADING(name, description)
return(oflags[bm->toolflag_index].f &oflag) !=0
const Depsgraph * depsgraph
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
static const EnumPropertyItem DT_layer_items[]
static const EnumPropertyItem * dt_layers_select_src_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
static int datalayout_transfer_exec(bContext *C, wmOperator *op)
static int datalayout_transfer_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool data_transfer_poll_property(const bContext *UNUSED(C), wmOperator *op, const PropertyRNA *prop)
void OBJECT_OT_datalayout_transfer(wmOperatorType *ot)
static const EnumPropertyItem * dt_layers_select_dst_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
static char * data_transfer_get_description(bContext *UNUSED(C), wmOperatorType *UNUSED(ot), PointerRNA *ptr)
static bool data_transfer_check(bContext *UNUSED(C), wmOperator *op)
static bool data_transfer_exec_is_object_valid(wmOperator *op, Object *ob_src, Object *ob_dst, const bool reverse_transfer)
static const EnumPropertyItem * dt_layers_select_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free)
void OBJECT_OT_data_transfer(wmOperatorType *ot)
static void data_transfer_exec_preprocess_objects(bContext *C, wmOperator *op, Object *ob_src, ListBase *ctx_objects, const bool reverse_transfer)
static void dt_add_vcol_layers(CustomData *cdata, eCustomDataMask mask, EnumPropertyItem **r_item, int *r_totitem)
static bool datalayout_transfer_poll(bContext *C)
static int data_transfer_exec(bContext *C, wmOperator *op)
static bool data_transfer_poll(bContext *C)
static const EnumPropertyItem * dt_mix_mode_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
bool edit_modifier_invoke_properties(struct bContext *C, struct wmOperator *op)
bool edit_modifier_poll_generic(struct bContext *C, struct StructRNA *rna_type, int obtype_flag, bool is_editmode_allowed, bool is_liboverride_allowed)
struct ModifierData * edit_modifier_property_get(struct wmOperator *op, struct Object *ob, int type)
void edit_modifier_properties(struct wmOperatorType *ot)
const char * RNA_property_identifier(const PropertyRNA *prop)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
float RNA_float_get(PointerRNA *ptr, const char *name)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_enum_funcs_runtime(PropertyRNA *prop, EnumPropertyGetFunc getfunc, EnumPropertySetFunc setfunc, EnumPropertyItemFunc itemfunc)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_enum_item_add_separator(EnumPropertyItem **items, int *totitem)
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item, int value)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
const EnumPropertyItem rna_enum_dt_method_loop_items[]
const EnumPropertyItem rna_enum_dt_method_edge_items[]
const EnumPropertyItem rna_enum_dt_method_poly_items[]
const EnumPropertyItem rna_enum_dt_mix_mode_items[]
const EnumPropertyItem rna_enum_dt_layers_select_src_items[]
const EnumPropertyItem rna_enum_dt_method_vertex_items[]
const EnumPropertyItem rna_enum_dt_layers_select_dst_items[]
struct CollectionPointerLink * next
struct Object * ob_source
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
char *(* get_description)(struct bContext *C, struct wmOperatorType *, struct PointerRNA *)
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
bool(* poll_property)(const struct bContext *C, struct wmOperator *op, const PropertyRNA *prop) ATTR_WARN_UNUSED_RESULT
bool(* check)(struct bContext *, struct wmOperator *)
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))