1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 * 16 * The Original Code is Copyright (C) 2014 Blender Foundation. 17 * All rights reserved. 18 */ 19 20 /** \file 21 * \ingroup bke 22 */ 23 24 #pragma once 25 26 #include "BKE_customdata.h" 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 struct Depsgraph; 33 struct Object; 34 struct ReportList; 35 struct Scene; 36 struct SpaceTransform; 37 38 /* Warning, those def are stored in files (TransferData modifier), *DO NOT* modify those values. */ 39 enum { 40 DT_TYPE_MDEFORMVERT = 1 << 0, 41 DT_TYPE_SHAPEKEY = 1 << 1, 42 DT_TYPE_SKIN = 1 << 2, 43 DT_TYPE_BWEIGHT_VERT = 1 << 3, 44 45 DT_TYPE_SHARP_EDGE = 1 << 8, 46 DT_TYPE_SEAM = 1 << 9, 47 DT_TYPE_CREASE = 1 << 10, 48 DT_TYPE_BWEIGHT_EDGE = 1 << 11, 49 DT_TYPE_FREESTYLE_EDGE = 1 << 12, 50 51 DT_TYPE_VCOL = 1 << 16, 52 DT_TYPE_LNOR = 1 << 17, 53 54 DT_TYPE_UV = 1 << 24, 55 DT_TYPE_SHARP_FACE = 1 << 25, 56 DT_TYPE_FREESTYLE_FACE = 1 << 26, 57 #define DT_TYPE_MAX 27 58 59 DT_TYPE_VERT_ALL = DT_TYPE_MDEFORMVERT | DT_TYPE_SHAPEKEY | DT_TYPE_SKIN | DT_TYPE_BWEIGHT_VERT, 60 DT_TYPE_EDGE_ALL = DT_TYPE_SHARP_EDGE | DT_TYPE_SEAM | DT_TYPE_CREASE | DT_TYPE_BWEIGHT_EDGE | 61 DT_TYPE_FREESTYLE_EDGE, 62 DT_TYPE_LOOP_ALL = DT_TYPE_VCOL | DT_TYPE_LNOR | DT_TYPE_UV, 63 DT_TYPE_POLY_ALL = DT_TYPE_UV | DT_TYPE_SHARP_FACE | DT_TYPE_FREESTYLE_FACE, 64 }; 65 66 void BKE_object_data_transfer_dttypes_to_cdmask(const int dtdata_types, 67 struct CustomData_MeshMasks *r_data_masks); 68 bool BKE_object_data_transfer_get_dttypes_capacity(const int dtdata_types, 69 bool *r_advanced_mixing, 70 bool *r_threshold); 71 int BKE_object_data_transfer_get_dttypes_item_types(const int dtdata_types); 72 73 int BKE_object_data_transfer_dttype_to_cdtype(const int dtdata_type); 74 int BKE_object_data_transfer_dttype_to_srcdst_index(const int dtdata_type); 75 76 #define DT_DATATYPE_IS_VERT(_dt) \ 77 ELEM(_dt, DT_TYPE_MDEFORMVERT, DT_TYPE_SHAPEKEY, DT_TYPE_SKIN, DT_TYPE_BWEIGHT_VERT) 78 #define DT_DATATYPE_IS_EDGE(_dt) \ 79 ELEM(_dt, \ 80 DT_TYPE_CREASE, \ 81 DT_TYPE_SHARP_EDGE, \ 82 DT_TYPE_SEAM, \ 83 DT_TYPE_BWEIGHT_EDGE, \ 84 DT_TYPE_FREESTYLE_EDGE) 85 #define DT_DATATYPE_IS_LOOP(_dt) ELEM(_dt, DT_TYPE_UV, DT_TYPE_VCOL, DT_TYPE_LNOR) 86 #define DT_DATATYPE_IS_POLY(_dt) ELEM(_dt, DT_TYPE_UV, DT_TYPE_SHARP_FACE, DT_TYPE_FREESTYLE_FACE) 87 88 #define DT_DATATYPE_IS_MULTILAYERS(_dt) \ 89 ELEM(_dt, DT_TYPE_MDEFORMVERT, DT_TYPE_SHAPEKEY, DT_TYPE_VCOL, DT_TYPE_UV) 90 91 enum { 92 DT_MULTILAYER_INDEX_INVALID = -1, 93 DT_MULTILAYER_INDEX_MDEFORMVERT = 0, 94 DT_MULTILAYER_INDEX_SHAPEKEY = 1, 95 DT_MULTILAYER_INDEX_VCOL = 2, 96 DT_MULTILAYER_INDEX_UV = 3, 97 DT_MULTILAYER_INDEX_MAX = 4, 98 }; 99 100 /* Below we keep positive values for real layers idx (generated dynamically). */ 101 102 /* How to select data layers, for types supporting multi-layers. 103 * Here too, some options are highly dependent on type of transferred data! */ 104 enum { 105 DT_LAYERS_ACTIVE_SRC = -1, 106 DT_LAYERS_ALL_SRC = -2, 107 /* Datatype-specific. */ 108 DT_LAYERS_VGROUP_SRC = 1 << 8, 109 DT_LAYERS_VGROUP_SRC_BONE_SELECT = -(DT_LAYERS_VGROUP_SRC | 1), 110 DT_LAYERS_VGROUP_SRC_BONE_DEFORM = -(DT_LAYERS_VGROUP_SRC | 2), 111 /* Other types-related modes... */ 112 }; 113 114 /* How to map a source layer to a destination layer, for types supporting multi-layers. 115 * Note: if no matching layer can be found, it will be created. */ 116 enum { 117 DT_LAYERS_ACTIVE_DST = -1, /* Only for DT_LAYERS_FROMSEL_ACTIVE. */ 118 DT_LAYERS_NAME_DST = -2, 119 DT_LAYERS_INDEX_DST = -3, 120 #if 0 /* TODO */ 121 DT_LAYERS_CREATE_DST = -4, /* Never replace existing data in dst, always create new layers. */ 122 #endif 123 }; 124 125 void BKE_object_data_transfer_layout(struct Depsgraph *depsgraph, 126 struct Scene *scene, 127 struct Object *ob_src, 128 struct Object *ob_dst, 129 const int data_types, 130 const bool use_delete, 131 const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], 132 const int tolayers_select[DT_MULTILAYER_INDEX_MAX]); 133 134 bool BKE_object_data_transfer_mesh(struct Depsgraph *depsgraph, 135 struct Scene *scene, 136 struct Object *ob_src, 137 struct Object *ob_dst, 138 const int data_types, 139 const bool use_create, 140 const int map_vert_mode, 141 const int map_edge_mode, 142 const int map_loop_mode, 143 const int map_poly_mode, 144 struct SpaceTransform *space_transform, 145 const bool auto_transform, 146 const float max_distance, 147 const float ray_radius, 148 const float islands_handling_precision, 149 const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], 150 const int tolayers_select[DT_MULTILAYER_INDEX_MAX], 151 const int mix_mode, 152 const float mix_factor, 153 const char *vgroup_name, 154 const bool invert_vgroup, 155 struct ReportList *reports); 156 bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph, 157 struct Scene *scene, 158 struct Object *ob_src, 159 struct Object *ob_dst, 160 struct Mesh *me_dst, 161 const int data_types, 162 bool use_create, 163 const int map_vert_mode, 164 const int map_edge_mode, 165 const int map_loop_mode, 166 const int map_poly_mode, 167 struct SpaceTransform *space_transform, 168 const bool auto_transform, 169 const float max_distance, 170 const float ray_radius, 171 const float islands_handling_precision, 172 const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], 173 const int tolayers_select[DT_MULTILAYER_INDEX_MAX], 174 const int mix_mode, 175 const float mix_factor, 176 const char *vgroup_name, 177 const bool invert_vgroup, 178 struct ReportList *reports); 179 180 #ifdef __cplusplus 181 } 182 #endif 183