BKE_data_transfer.h 6.4 KB

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