2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2014 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup edobj
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_modifier_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
|
Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).
However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.
This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.
Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).
Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.
Pull Request #110944
2023-08-09 11:39:20 +03:00
|
|
|
#include "BLI_math_matrix.h"
|
2020-11-06 15:29:25 +11:00
|
|
|
#include "BLI_string.h"
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2023-11-16 11:41:55 +01:00
|
|
|
#include "BKE_context.hh"
|
2023-12-26 23:21:19 -05:00
|
|
|
#include "BKE_customdata.hh"
|
2015-01-12 12:03:28 +01:00
|
|
|
#include "BKE_data_transfer.h"
|
2024-01-29 18:57:16 -05:00
|
|
|
#include "BKE_deform.hh"
|
2025-02-07 17:47:16 +01:00
|
|
|
#include "BKE_library.hh"
|
2023-08-02 22:14:18 +02:00
|
|
|
#include "BKE_mesh_remap.hh"
|
2023-10-09 23:41:53 +02:00
|
|
|
#include "BKE_object.hh"
|
2024-02-10 18:34:29 +01:00
|
|
|
#include "BKE_report.hh"
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
|
2023-09-22 03:18:17 +02:00
|
|
|
#include "DEG_depsgraph.hh"
|
|
|
|
|
#include "DEG_depsgraph_query.hh"
|
2017-06-08 10:14:53 +02:00
|
|
|
|
2024-02-09 18:59:42 +01:00
|
|
|
#include "BLT_translation.hh"
|
2022-02-04 07:31:53 -06:00
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_access.hh"
|
|
|
|
|
#include "RNA_define.hh"
|
|
|
|
|
#include "RNA_enum_types.hh"
|
2024-07-10 18:30:02 +02:00
|
|
|
#include "RNA_prototypes.hh"
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "WM_api.hh"
|
|
|
|
|
#include "WM_types.hh"
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_object.hh"
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
|
2024-03-26 20:34:48 -04:00
|
|
|
#include "object_intern.hh"
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
|
2024-03-28 01:30:38 +01:00
|
|
|
namespace blender::ed::object {
|
|
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
/* All possible data to transfer.
|
|
|
|
|
* Note some are 'fake' ones, i.e. they are not hold by real CDLayers. */
|
|
|
|
|
/* Not shared with modifier, since we use a usual enum here, not a multi-choice one. */
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem DT_layer_items[] = {
|
2023-07-05 20:03:41 +02:00
|
|
|
RNA_ENUM_ITEM_HEADING(N_("Vertex Data"), nullptr),
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{DT_TYPE_MDEFORMVERT,
|
|
|
|
|
"VGROUP_WEIGHTS",
|
|
|
|
|
0,
|
|
|
|
|
"Vertex Group(s)",
|
|
|
|
|
"Transfer active or all vertex groups"},
|
2021-02-05 16:23:34 +11:00
|
|
|
#if 0 /* XXX For now, would like to finish/merge work from 2014 GSOC first. */
|
2019-04-17 08:24:14 +02:00
|
|
|
{DT_TYPE_SHAPEKEY, "SHAPEKEYS", 0, "Shapekey(s)", "Transfer active or all shape keys"},
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
#endif
|
2019-04-18 07:21:26 +02:00
|
|
|
/* XXX When SkinModifier is enabled,
|
|
|
|
|
* it seems to erase its own CD_MVERT_SKIN layer from final DM :( */
|
|
|
|
|
#if 0
|
2019-04-17 08:24:14 +02:00
|
|
|
{DT_TYPE_SKIN, "SKIN", 0, "Skin Weight", "Transfer skin weights"},
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
#endif
|
|
|
|
|
{DT_TYPE_BWEIGHT_VERT, "BEVEL_WEIGHT_VERT", 0, "Bevel Weight", "Transfer bevel weights"},
|
2023-01-05 16:05:51 +01:00
|
|
|
{DT_TYPE_MPROPCOL_VERT | DT_TYPE_MLOOPCOL_VERT,
|
|
|
|
|
"COLOR_VERTEX",
|
|
|
|
|
0,
|
|
|
|
|
"Colors",
|
|
|
|
|
"Color Attributes"},
|
2022-05-31 14:07:15 +10:00
|
|
|
|
2023-07-05 20:03:41 +02:00
|
|
|
RNA_ENUM_ITEM_HEADING(N_("Edge Data"), nullptr),
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{DT_TYPE_SHARP_EDGE, "SHARP_EDGE", 0, "Sharp", "Transfer sharp mark"},
|
|
|
|
|
{DT_TYPE_SEAM, "SEAM", 0, "UV Seam", "Transfer UV seam mark"},
|
2020-06-14 19:06:37 -04:00
|
|
|
{DT_TYPE_CREASE, "CREASE", 0, "Subdivision Crease", "Transfer crease values"},
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{DT_TYPE_BWEIGHT_EDGE, "BEVEL_WEIGHT_EDGE", 0, "Bevel Weight", "Transfer bevel weights"},
|
|
|
|
|
{DT_TYPE_FREESTYLE_EDGE,
|
|
|
|
|
"FREESTYLE_EDGE",
|
|
|
|
|
0,
|
|
|
|
|
"Freestyle Mark",
|
|
|
|
|
"Transfer Freestyle edge mark"},
|
2022-05-31 14:07:15 +10:00
|
|
|
|
2023-07-05 20:03:41 +02:00
|
|
|
RNA_ENUM_ITEM_HEADING(N_("Face Corner Data"), nullptr),
|
2015-02-05 14:38:59 +01:00
|
|
|
{DT_TYPE_LNOR, "CUSTOM_NORMAL", 0, "Custom Normals", "Transfer custom normals"},
|
2023-01-05 16:05:51 +01:00
|
|
|
{DT_TYPE_MPROPCOL_LOOP | DT_TYPE_MLOOPCOL_LOOP,
|
|
|
|
|
"COLOR_CORNER",
|
|
|
|
|
0,
|
|
|
|
|
"Colors",
|
|
|
|
|
"Color Attributes"},
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{DT_TYPE_UV, "UV", 0, "UVs", "Transfer UV layers"},
|
2022-05-31 14:07:15 +10:00
|
|
|
|
2023-07-05 20:03:41 +02:00
|
|
|
RNA_ENUM_ITEM_HEADING(N_("Face Data"), nullptr),
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{DT_TYPE_SHARP_FACE, "SMOOTH", 0, "Smooth", "Transfer flat/smooth mark"},
|
|
|
|
|
{DT_TYPE_FREESTYLE_FACE,
|
|
|
|
|
"FREESTYLE_FACE",
|
|
|
|
|
0,
|
|
|
|
|
"Freestyle Mark",
|
|
|
|
|
"Transfer Freestyle face mark"},
|
2023-07-05 20:03:41 +02:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
};
|
|
|
|
|
|
2023-05-30 22:25:06 +02:00
|
|
|
static void dt_add_vcol_layers(const CustomData *cdata,
|
2022-06-01 14:38:06 +10:00
|
|
|
eCustomDataMask mask,
|
2022-04-05 11:42:55 -07:00
|
|
|
EnumPropertyItem **r_item,
|
|
|
|
|
int *r_totitem)
|
|
|
|
|
{
|
2025-03-28 00:59:11 +00:00
|
|
|
const int types[2] = {CD_PROP_COLOR, CD_PROP_BYTE_COLOR};
|
2023-01-05 16:05:51 +01:00
|
|
|
int idx = 0;
|
2022-04-05 11:42:55 -07:00
|
|
|
for (int i = 0; i < 2; i++) {
|
2023-07-05 20:03:41 +02:00
|
|
|
eCustomDataType type = eCustomDataType(types[i]);
|
2022-04-05 11:42:55 -07:00
|
|
|
|
|
|
|
|
if (!(mask & CD_TYPE_AS_MASK(type))) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-23 15:49:28 +10:00
|
|
|
int data_num = CustomData_number_of_layers(cdata, type);
|
2022-04-05 11:42:55 -07:00
|
|
|
|
|
|
|
|
RNA_enum_item_add_separator(r_item, r_totitem);
|
|
|
|
|
|
2024-07-23 15:49:28 +10:00
|
|
|
for (int j = 0; j < data_num; j++) {
|
2023-01-05 16:05:51 +01:00
|
|
|
EnumPropertyItem tmp_item = {0};
|
|
|
|
|
tmp_item.value = idx++;
|
2022-04-05 11:42:55 -07:00
|
|
|
tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(cdata, type, j);
|
|
|
|
|
RNA_enum_item_add(r_item, r_totitem, &tmp_item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-29 14:08:42 +02:00
|
|
|
/* NOTE: #rna_enum_dt_layers_select_src_items enum is from rna_modifier.cc. */
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C,
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
PointerRNA *ptr,
|
2023-07-05 20:03:41 +02:00
|
|
|
PropertyRNA * /*prop*/,
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
bool *r_free)
|
|
|
|
|
{
|
|
|
|
|
if (!C) { /* needed for docs and i18n tools */
|
2015-11-23 13:49:52 +11:00
|
|
|
return rna_enum_dt_layers_select_src_items;
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-05 20:03:41 +02:00
|
|
|
EnumPropertyItem *item = nullptr, tmp_item = {0};
|
2019-03-27 20:44:14 +01:00
|
|
|
int totitem = 0;
|
|
|
|
|
const int data_type = RNA_enum_get(ptr, "data_type");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-27 20:44:14 +01:00
|
|
|
PropertyRNA *prop = RNA_struct_find_property(ptr, "use_reverse_transfer");
|
2023-07-05 20:03:41 +02:00
|
|
|
const bool reverse_transfer = prop != nullptr && RNA_property_boolean_get(ptr, prop);
|
2019-03-27 20:44:14 +01:00
|
|
|
const int layers_select_dst = reverse_transfer ? RNA_enum_get(ptr, "layers_select_src") :
|
|
|
|
|
RNA_enum_get(ptr, "layers_select_dst");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-27 20:44:14 +01:00
|
|
|
if (!reverse_transfer || layers_select_dst == DT_LAYERS_ACTIVE_DST || layers_select_dst >= 0) {
|
|
|
|
|
RNA_enum_items_add_value(
|
|
|
|
|
&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ACTIVE_SRC);
|
|
|
|
|
}
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_enum_items_add_value(
|
|
|
|
|
&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ALL_SRC);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-03-28 01:30:38 +01:00
|
|
|
Object *ob_src = context_active_object(C);
|
2023-07-05 20:03:41 +02:00
|
|
|
if (ob_src == nullptr) {
|
2021-07-16 12:23:55 -04:00
|
|
|
RNA_enum_item_end(&item, &totitem);
|
|
|
|
|
*r_free = true;
|
|
|
|
|
return item;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-07-16 12:23:55 -04:00
|
|
|
if (data_type == DT_TYPE_MDEFORMVERT && BKE_object_supports_vertex_groups(ob_src)) {
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
if (BKE_object_pose_armature_get(ob_src)) {
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_enum_items_add_value(
|
|
|
|
|
&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_VGROUP_SRC_BONE_SELECT);
|
|
|
|
|
RNA_enum_items_add_value(
|
|
|
|
|
&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_VGROUP_SRC_BONE_DEFORM);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-07-16 12:23:55 -04:00
|
|
|
const bDeformGroup *dg;
|
|
|
|
|
int i;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-07-16 12:23:55 -04:00
|
|
|
RNA_enum_item_add_separator(&item, &totitem);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-07-16 12:23:55 -04:00
|
|
|
const ListBase *defbase = BKE_object_defgroup_list(ob_src);
|
2023-07-05 20:03:41 +02:00
|
|
|
for (i = 0, dg = static_cast<const bDeformGroup *>(defbase->first); dg; i++, dg = dg->next) {
|
2021-07-16 12:23:55 -04:00
|
|
|
tmp_item.value = i;
|
|
|
|
|
tmp_item.identifier = tmp_item.name = dg->name;
|
|
|
|
|
RNA_enum_item_add(&item, &totitem, &tmp_item);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (data_type == DT_TYPE_SHAPEKEY) {
|
|
|
|
|
/* TODO */
|
|
|
|
|
}
|
|
|
|
|
else if (data_type == DT_TYPE_UV) {
|
2023-05-30 22:25:06 +02:00
|
|
|
const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
2025-05-02 15:08:29 +02:00
|
|
|
const Object *ob_src_eval = DEG_get_evaluated(depsgraph, ob_src);
|
2024-03-11 11:21:12 -04:00
|
|
|
const Mesh *mesh_eval = BKE_object_get_evaluated_mesh_no_subsurf(ob_src_eval);
|
|
|
|
|
if (!mesh_eval) {
|
2023-05-30 22:25:06 +02:00
|
|
|
RNA_enum_item_end(&item, &totitem);
|
|
|
|
|
*r_free = true;
|
|
|
|
|
return item;
|
|
|
|
|
}
|
2024-07-23 15:49:28 +10:00
|
|
|
int data_num = CustomData_number_of_layers(&mesh_eval->corner_data, CD_PROP_FLOAT2);
|
2021-07-16 12:23:55 -04:00
|
|
|
|
|
|
|
|
RNA_enum_item_add_separator(&item, &totitem);
|
|
|
|
|
|
2024-07-23 15:49:28 +10:00
|
|
|
for (int i = 0; i < data_num; i++) {
|
2021-07-16 12:23:55 -04:00
|
|
|
tmp_item.value = i;
|
|
|
|
|
tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(
|
2024-03-11 11:21:12 -04:00
|
|
|
&mesh_eval->corner_data, CD_PROP_FLOAT2, i);
|
2021-07-16 12:23:55 -04:00
|
|
|
RNA_enum_item_add(&item, &totitem, &tmp_item);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
2022-04-05 11:42:55 -07:00
|
|
|
else if (data_type & DT_TYPE_VCOL_ALL) {
|
2023-05-30 22:25:06 +02:00
|
|
|
const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
2025-05-02 15:08:29 +02:00
|
|
|
const Object *ob_src_eval = DEG_get_evaluated(depsgraph, ob_src);
|
2024-03-11 11:21:12 -04:00
|
|
|
const Mesh *mesh_eval = BKE_object_get_evaluated_mesh_no_subsurf(ob_src_eval);
|
|
|
|
|
if (!mesh_eval) {
|
2023-05-30 22:25:06 +02:00
|
|
|
RNA_enum_item_end(&item, &totitem);
|
|
|
|
|
*r_free = true;
|
|
|
|
|
return item;
|
|
|
|
|
}
|
2021-07-16 12:23:55 -04:00
|
|
|
|
|
|
|
|
CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH;
|
2022-04-05 11:42:55 -07:00
|
|
|
if (data_type & (DT_TYPE_MPROPCOL_VERT)) {
|
|
|
|
|
cddata_masks.vmask |= CD_MASK_PROP_COLOR;
|
|
|
|
|
}
|
|
|
|
|
if (data_type & (DT_TYPE_MLOOPCOL_VERT)) {
|
2022-04-20 09:10:10 -05:00
|
|
|
cddata_masks.vmask |= CD_MASK_PROP_BYTE_COLOR;
|
2022-04-05 11:42:55 -07:00
|
|
|
}
|
2021-07-16 12:23:55 -04:00
|
|
|
|
2022-04-05 11:42:55 -07:00
|
|
|
if (data_type & (DT_TYPE_MPROPCOL_LOOP)) {
|
|
|
|
|
cddata_masks.lmask |= CD_MASK_PROP_COLOR;
|
|
|
|
|
}
|
|
|
|
|
if (data_type & (DT_TYPE_MLOOPCOL_LOOP)) {
|
2022-04-20 09:10:10 -05:00
|
|
|
cddata_masks.lmask |= CD_MASK_PROP_BYTE_COLOR;
|
2022-04-05 11:42:55 -07:00
|
|
|
}
|
2021-07-16 12:23:55 -04:00
|
|
|
|
2022-04-05 11:42:55 -07:00
|
|
|
if (data_type & (DT_TYPE_MLOOPCOL_VERT | DT_TYPE_MPROPCOL_VERT)) {
|
2024-03-11 11:21:12 -04:00
|
|
|
dt_add_vcol_layers(&mesh_eval->vert_data, cddata_masks.vmask, &item, &totitem);
|
2022-04-05 11:42:55 -07:00
|
|
|
}
|
|
|
|
|
if (data_type & (DT_TYPE_MLOOPCOL_LOOP | DT_TYPE_MPROPCOL_LOOP)) {
|
2024-03-11 11:21:12 -04:00
|
|
|
dt_add_vcol_layers(&mesh_eval->corner_data, cddata_masks.lmask, &item, &totitem);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
RNA_enum_item_end(&item, &totitem);
|
|
|
|
|
*r_free = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-29 14:08:42 +02:00
|
|
|
/* NOTE: #rna_enum_dt_layers_select_dst_items enum is from `rna_modifier.cc`. */
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem *dt_layers_select_dst_itemf(bContext *C,
|
2015-09-02 13:02:06 +02:00
|
|
|
PointerRNA *ptr,
|
2023-07-05 20:03:41 +02:00
|
|
|
PropertyRNA * /*prop*/,
|
2015-09-02 13:02:06 +02:00
|
|
|
bool *r_free)
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{
|
|
|
|
|
if (!C) { /* needed for docs and i18n tools */
|
2015-11-23 13:49:52 +11:00
|
|
|
return rna_enum_dt_layers_select_dst_items;
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
|
|
|
|
|
2023-07-05 20:03:41 +02:00
|
|
|
EnumPropertyItem *item = nullptr;
|
2019-03-27 20:44:14 +01:00
|
|
|
int totitem = 0;
|
|
|
|
|
|
|
|
|
|
PropertyRNA *prop = RNA_struct_find_property(ptr, "use_reverse_transfer");
|
2023-07-05 20:03:41 +02:00
|
|
|
const bool reverse_transfer = prop != nullptr && RNA_property_boolean_get(ptr, prop);
|
2019-03-27 20:44:14 +01:00
|
|
|
const int layers_select_src = reverse_transfer ? RNA_enum_get(ptr, "layers_select_dst") :
|
|
|
|
|
RNA_enum_get(ptr, "layers_select_src");
|
|
|
|
|
|
|
|
|
|
if (reverse_transfer || layers_select_src == DT_LAYERS_ACTIVE_SRC || layers_select_src >= 0) {
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_enum_items_add_value(
|
|
|
|
|
&item, &totitem, rna_enum_dt_layers_select_dst_items, DT_LAYERS_ACTIVE_DST);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_enum_items_add_value(
|
|
|
|
|
&item, &totitem, rna_enum_dt_layers_select_dst_items, DT_LAYERS_NAME_DST);
|
|
|
|
|
RNA_enum_items_add_value(
|
|
|
|
|
&item, &totitem, rna_enum_dt_layers_select_dst_items, DT_LAYERS_INDEX_DST);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
|
|
|
|
|
/* No 'specific' to-layers here, since we may transfer to several objects at once! */
|
|
|
|
|
|
|
|
|
|
RNA_enum_item_end(&item, &totitem);
|
|
|
|
|
*r_free = true;
|
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem *dt_layers_select_itemf(bContext *C,
|
|
|
|
|
PointerRNA *ptr,
|
|
|
|
|
PropertyRNA *prop,
|
|
|
|
|
bool *r_free)
|
2015-09-02 13:02:06 +02:00
|
|
|
{
|
|
|
|
|
const bool reverse_transfer = RNA_boolean_get(ptr, "use_reverse_transfer");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-09-02 13:02:06 +02:00
|
|
|
if (STREQ(RNA_property_identifier(prop), "layers_select_dst")) {
|
|
|
|
|
if (reverse_transfer) {
|
|
|
|
|
return dt_layers_select_src_itemf(C, ptr, prop, r_free);
|
|
|
|
|
}
|
|
|
|
|
return dt_layers_select_dst_itemf(C, ptr, prop, r_free);
|
|
|
|
|
}
|
2020-07-03 15:42:22 +02:00
|
|
|
if (reverse_transfer) {
|
|
|
|
|
return dt_layers_select_dst_itemf(C, ptr, prop, r_free);
|
2015-09-02 13:02:06 +02:00
|
|
|
}
|
2020-07-03 15:42:22 +02:00
|
|
|
return dt_layers_select_src_itemf(C, ptr, prop, r_free);
|
2015-09-02 13:02:06 +02:00
|
|
|
}
|
|
|
|
|
|
2023-06-29 14:08:42 +02:00
|
|
|
/* NOTE: rna_enum_dt_mix_mode_items enum is from `rna_modifier.cc`. */
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem *dt_mix_mode_itemf(bContext *C,
|
|
|
|
|
PointerRNA *ptr,
|
2023-07-05 20:03:41 +02:00
|
|
|
PropertyRNA * /*prop*/,
|
2017-10-18 15:07:26 +11:00
|
|
|
bool *r_free)
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{
|
2023-07-05 20:03:41 +02:00
|
|
|
EnumPropertyItem *item = nullptr;
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
int totitem = 0;
|
|
|
|
|
|
|
|
|
|
const int dtdata_type = RNA_enum_get(ptr, "data_type");
|
|
|
|
|
bool support_advanced_mixing, support_threshold;
|
|
|
|
|
|
|
|
|
|
if (!C) { /* needed for docs and i18n tools */
|
2015-11-23 13:49:52 +11:00
|
|
|
return rna_enum_dt_mix_mode_items;
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
|
|
|
|
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_mix_mode_items, CDT_MIX_TRANSFER);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
|
|
|
|
|
BKE_object_data_transfer_get_dttypes_capacity(
|
|
|
|
|
dtdata_type, &support_advanced_mixing, &support_threshold);
|
|
|
|
|
|
2015-01-14 10:51:41 +01:00
|
|
|
if (support_threshold) {
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_enum_items_add_value(
|
|
|
|
|
&item, &totitem, rna_enum_dt_mix_mode_items, CDT_MIX_REPLACE_ABOVE_THRESHOLD);
|
|
|
|
|
RNA_enum_items_add_value(
|
|
|
|
|
&item, &totitem, rna_enum_dt_mix_mode_items, CDT_MIX_REPLACE_BELOW_THRESHOLD);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (support_advanced_mixing) {
|
|
|
|
|
RNA_enum_item_add_separator(&item, &totitem);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_mix_mode_items, CDT_MIX_MIX);
|
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_mix_mode_items, CDT_MIX_ADD);
|
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_mix_mode_items, CDT_MIX_SUB);
|
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_mix_mode_items, CDT_MIX_MUL);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RNA_enum_item_end(&item, &totitem);
|
|
|
|
|
*r_free = true;
|
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-05 20:03:41 +02:00
|
|
|
static bool data_transfer_check(bContext * /*C*/, wmOperator *op)
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{
|
|
|
|
|
const int layers_select_src = RNA_enum_get(op->ptr, "layers_select_src");
|
|
|
|
|
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "layers_select_dst");
|
|
|
|
|
const int layers_select_dst = RNA_property_enum_get(op->ptr, prop);
|
|
|
|
|
|
|
|
|
|
/* TODO: check for invalid layers_src select modes too! */
|
|
|
|
|
|
|
|
|
|
if ((layers_select_src != DT_LAYERS_ACTIVE_SRC) && (layers_select_dst == DT_LAYERS_ACTIVE_DST)) {
|
|
|
|
|
RNA_property_enum_set(op->ptr, prop, DT_LAYERS_NAME_DST);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper, used by both data_transfer_exec and datalayout_transfer_exec. */
|
2015-01-11 18:29:14 +01:00
|
|
|
static void data_transfer_exec_preprocess_objects(bContext *C,
|
|
|
|
|
wmOperator *op,
|
|
|
|
|
Object *ob_src,
|
2024-03-28 01:30:38 +01:00
|
|
|
Vector<PointerRNA> *ctx_objects,
|
2015-01-11 18:29:14 +01:00
|
|
|
const bool reverse_transfer)
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{
|
|
|
|
|
CTX_data_selected_editable_objects(C, ctx_objects);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-11 18:29:14 +01:00
|
|
|
if (reverse_transfer) {
|
|
|
|
|
return; /* Nothing else to do in this case... */
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-03-27 00:47:39 +01:00
|
|
|
for (const PointerRNA &ptr : *ctx_objects) {
|
|
|
|
|
Object *ob = static_cast<Object *>(ptr.data);
|
2023-12-08 16:40:06 -05:00
|
|
|
Mesh *mesh;
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
if ((ob == ob_src) || (ob->type != OB_MESH)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-12-08 16:40:06 -05:00
|
|
|
mesh = static_cast<Mesh *>(ob->data);
|
2024-05-16 14:53:09 +02:00
|
|
|
if (!ID_IS_EDITABLE(mesh) || ID_IS_OVERRIDE_LIBRARY(mesh)) {
|
2022-03-28 17:34:36 +02:00
|
|
|
/* Do not transfer to linked/override data, not supported. */
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
BKE_reportf(op->reports,
|
|
|
|
|
RPT_WARNING,
|
2022-03-28 17:34:36 +02:00
|
|
|
"Skipping object '%s', linked or override data '%s' cannot be modified",
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
ob->id.name + 2,
|
2023-12-08 16:40:06 -05:00
|
|
|
mesh->id.name + 2);
|
2024-08-07 12:12:17 +02:00
|
|
|
mesh->id.tag &= ~ID_TAG_DOIT;
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-08-07 12:12:17 +02:00
|
|
|
mesh->id.tag |= ID_TAG_DOIT;
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper, used by both data_transfer_exec and datalayout_transfer_exec. */
|
2015-01-11 18:29:14 +01:00
|
|
|
static bool data_transfer_exec_is_object_valid(wmOperator *op,
|
|
|
|
|
Object *ob_src,
|
|
|
|
|
Object *ob_dst,
|
|
|
|
|
const bool reverse_transfer)
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{
|
2023-12-08 16:40:06 -05:00
|
|
|
Mesh *mesh;
|
2015-03-10 19:46:24 +11:00
|
|
|
if ((ob_dst == ob_src) || (ob_src->type != OB_MESH) || (ob_dst->type != OB_MESH)) {
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-11 18:29:14 +01:00
|
|
|
if (reverse_transfer) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-12-08 16:40:06 -05:00
|
|
|
mesh = static_cast<Mesh *>(ob_dst->data);
|
2024-08-07 12:12:17 +02:00
|
|
|
if (mesh->id.tag & ID_TAG_DOIT) {
|
|
|
|
|
mesh->id.tag &= ~ID_TAG_DOIT;
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2024-05-16 14:53:09 +02:00
|
|
|
if (ID_IS_EDITABLE(mesh) && !ID_IS_OVERRIDE_LIBRARY(mesh)) {
|
2019-03-27 09:45:59 +01:00
|
|
|
/* Do not apply transfer operation more than once. */
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
/* XXX This is not nice regarding vgroups, which are half-Object data... :/ */
|
|
|
|
|
BKE_reportf(
|
|
|
|
|
op->reports,
|
|
|
|
|
RPT_WARNING,
|
|
|
|
|
"Skipping object '%s', data '%s' has already been processed with a previous object",
|
|
|
|
|
ob_dst->id.name + 2,
|
2023-12-08 16:40:06 -05:00
|
|
|
mesh->id.name + 2);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-20 21:11:06 +00:00
|
|
|
static wmOperatorStatus data_transfer_exec(bContext *C, wmOperator *op)
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{
|
2024-03-28 01:30:38 +01:00
|
|
|
Object *ob_src = context_active_object(C);
|
2019-07-25 16:36:22 +02:00
|
|
|
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-03-28 01:30:38 +01:00
|
|
|
Vector<PointerRNA> ctx_objects;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
bool changed = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-08-07 16:33:48 +02:00
|
|
|
const bool is_frozen = RNA_boolean_get(op->ptr, "use_freeze");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-11 18:29:14 +01:00
|
|
|
const bool reverse_transfer = RNA_boolean_get(op->ptr, "use_reverse_transfer");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
const int data_type = RNA_enum_get(op->ptr, "data_type");
|
|
|
|
|
const bool use_create = RNA_boolean_get(op->ptr, "use_create");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
const int map_vert_mode = RNA_enum_get(op->ptr, "vert_mapping");
|
|
|
|
|
const int map_edge_mode = RNA_enum_get(op->ptr, "edge_mapping");
|
|
|
|
|
const int map_loop_mode = RNA_enum_get(op->ptr, "loop_mapping");
|
|
|
|
|
const int map_poly_mode = RNA_enum_get(op->ptr, "poly_mapping");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-13 18:00:08 +02:00
|
|
|
const bool use_auto_transform = RNA_boolean_get(op->ptr, "use_auto_transform");
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
const bool use_object_transform = RNA_boolean_get(op->ptr, "use_object_transform");
|
|
|
|
|
const bool use_max_distance = RNA_boolean_get(op->ptr, "use_max_distance");
|
|
|
|
|
const float max_distance = use_max_distance ? RNA_float_get(op->ptr, "max_distance") : FLT_MAX;
|
|
|
|
|
const float ray_radius = RNA_float_get(op->ptr, "ray_radius");
|
|
|
|
|
const float islands_precision = RNA_float_get(op->ptr, "islands_precision");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-27 18:12:40 +02:00
|
|
|
int layers_src = RNA_enum_get(op->ptr, "layers_select_src");
|
|
|
|
|
int layers_dst = RNA_enum_get(op->ptr, "layers_select_dst");
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
int layers_select_src[DT_MULTILAYER_INDEX_MAX] = {0};
|
|
|
|
|
int layers_select_dst[DT_MULTILAYER_INDEX_MAX] = {0};
|
|
|
|
|
const int fromto_idx = BKE_object_data_transfer_dttype_to_srcdst_index(data_type);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
const int mix_mode = RNA_enum_get(op->ptr, "mix_mode");
|
|
|
|
|
const float mix_factor = RNA_float_get(op->ptr, "mix_factor");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
SpaceTransform space_transform_data;
|
2015-07-13 18:00:08 +02:00
|
|
|
SpaceTransform *space_transform = (use_object_transform && !use_auto_transform) ?
|
|
|
|
|
&space_transform_data :
|
2023-07-05 20:03:41 +02:00
|
|
|
nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-08-07 16:33:48 +02:00
|
|
|
if (is_frozen) {
|
|
|
|
|
BKE_report(
|
|
|
|
|
op->reports,
|
|
|
|
|
RPT_INFO,
|
|
|
|
|
"Operator is frozen, changes to its settings won't take effect until you unfreeze it");
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-05-16 14:53:09 +02:00
|
|
|
if (reverse_transfer && (!ID_IS_EDITABLE(ob_src->data) || ID_IS_OVERRIDE_LIBRARY(ob_src->data)))
|
|
|
|
|
{
|
2020-06-30 17:51:41 +02:00
|
|
|
/* Do not transfer to linked or override data, not supported. */
|
2015-01-11 18:29:14 +01:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-27 18:12:40 +02:00
|
|
|
if (reverse_transfer) {
|
2024-01-31 21:12:16 -05:00
|
|
|
std::swap(layers_src, layers_dst);
|
2020-07-27 18:12:40 +02:00
|
|
|
}
|
|
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
if (fromto_idx != DT_MULTILAYER_INDEX_INVALID) {
|
|
|
|
|
layers_select_src[fromto_idx] = layers_src;
|
|
|
|
|
layers_select_dst[fromto_idx] = layers_dst;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-11 18:29:14 +01:00
|
|
|
data_transfer_exec_preprocess_objects(C, op, ob_src, &ctx_objects, reverse_transfer);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-03-27 00:47:39 +01:00
|
|
|
for (const PointerRNA &ptr : ctx_objects) {
|
|
|
|
|
Object *ob_dst = static_cast<Object *>(ptr.data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-11 18:29:14 +01:00
|
|
|
if (reverse_transfer) {
|
2024-01-31 21:12:16 -05:00
|
|
|
std::swap(ob_src, ob_dst);
|
2015-01-11 18:29:14 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-11 18:29:14 +01:00
|
|
|
if (data_transfer_exec_is_object_valid(op, ob_src, ob_dst, reverse_transfer)) {
|
2025-05-02 15:08:29 +02:00
|
|
|
Object *ob_src_eval = DEG_get_evaluated(depsgraph, ob_src);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
if (space_transform) {
|
2025-05-02 15:08:29 +02:00
|
|
|
Object *ob_dst_eval = DEG_get_evaluated(depsgraph, ob_dst);
|
2018-12-01 19:06:44 +03:00
|
|
|
BLI_SPACE_TRANSFORM_SETUP(space_transform, ob_dst_eval, ob_src_eval);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
if (BKE_object_data_transfer_mesh(depsgraph,
|
2018-12-01 19:06:44 +03:00
|
|
|
ob_src_eval,
|
|
|
|
|
ob_dst,
|
|
|
|
|
data_type,
|
|
|
|
|
use_create,
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
map_vert_mode,
|
|
|
|
|
map_edge_mode,
|
|
|
|
|
map_loop_mode,
|
|
|
|
|
map_poly_mode,
|
2015-07-13 18:00:08 +02:00
|
|
|
space_transform,
|
|
|
|
|
use_auto_transform,
|
|
|
|
|
max_distance,
|
|
|
|
|
ray_radius,
|
|
|
|
|
islands_precision,
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
layers_select_src,
|
|
|
|
|
layers_select_dst,
|
|
|
|
|
mix_mode,
|
|
|
|
|
mix_factor,
|
2023-07-05 20:03:41 +02:00
|
|
|
nullptr,
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
false,
|
|
|
|
|
op->reports))
|
|
|
|
|
{
|
2019-08-05 18:43:03 +02:00
|
|
|
DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
changed = true;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2015-01-11 18:29:14 +01:00
|
|
|
if (reverse_transfer) {
|
2024-01-31 21:12:16 -05:00
|
|
|
std::swap(ob_src, ob_dst);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-07-27 17:37:46 +02:00
|
|
|
if (changed) {
|
|
|
|
|
DEG_relations_tag_update(CTX_data_main(C));
|
2023-07-05 20:03:41 +02:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, nullptr);
|
2020-07-27 17:37:46 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
#if 0 /* TODO */
|
2021-07-03 23:08:40 +10:00
|
|
|
/* NOTE: issue with that is that if canceled, operator cannot be redone... Nasty in our case. */
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
return changed ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
|
|
|
|
|
#else
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-15 15:20:19 +10:00
|
|
|
/** Used by both #OBJECT_OT_data_transfer and #OBJECT_OT_datalayout_transfer. */
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool data_transfer_poll(bContext *C)
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{
|
2025-04-15 15:20:19 +10:00
|
|
|
/* Note this context poll is only really partial,
|
|
|
|
|
* it cannot check for all possible invalid cases. */
|
|
|
|
|
|
2024-03-28 01:30:38 +01:00
|
|
|
Object *ob = context_active_object(C);
|
2023-07-05 20:03:41 +02:00
|
|
|
ID *data = static_cast<ID *>((ob) ? ob->data : nullptr);
|
|
|
|
|
return (ob != nullptr && ob->type == OB_MESH && data != nullptr);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
|
|
|
|
|
2025-04-15 15:20:19 +10:00
|
|
|
/** Used by both #OBJECT_OT_data_transfer and #OBJECT_OT_datalayout_transfer. */
|
2023-07-05 20:03:41 +02:00
|
|
|
static bool data_transfer_poll_property(const bContext * /*C*/,
|
2018-07-26 17:35:33 +10:00
|
|
|
wmOperator *op,
|
|
|
|
|
const PropertyRNA *prop)
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{
|
2018-07-26 17:35:33 +10:00
|
|
|
PointerRNA *ptr = op->ptr;
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
PropertyRNA *prop_other;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
const char *prop_id = RNA_property_identifier(prop);
|
|
|
|
|
const int data_type = RNA_enum_get(ptr, "data_type");
|
2015-07-13 18:00:08 +02:00
|
|
|
bool use_auto_transform = false;
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
bool use_max_distance = false;
|
|
|
|
|
bool use_modifier = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-13 18:00:08 +02:00
|
|
|
if ((prop_other = RNA_struct_find_property(ptr, "use_auto_transform"))) {
|
|
|
|
|
use_auto_transform = RNA_property_boolean_get(ptr, prop_other);
|
|
|
|
|
}
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
if ((prop_other = RNA_struct_find_property(ptr, "use_max_distance"))) {
|
|
|
|
|
use_max_distance = RNA_property_boolean_get(ptr, prop_other);
|
|
|
|
|
}
|
|
|
|
|
if ((prop_other = RNA_struct_find_property(ptr, "modifier"))) {
|
|
|
|
|
use_modifier = RNA_property_is_set(ptr, prop_other);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
if (STREQ(prop_id, "modifier")) {
|
|
|
|
|
return use_modifier;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
if (use_modifier) {
|
|
|
|
|
/* Hide everything but 'modifier' property, if set. */
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-06 16:02:42 +11:00
|
|
|
if (STREQ(prop_id, "use_object_transform")) {
|
|
|
|
|
if (use_auto_transform) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-07-13 18:00:08 +02:00
|
|
|
}
|
2020-11-06 16:02:42 +11:00
|
|
|
else if (STREQ(prop_id, "max_distance")) {
|
|
|
|
|
if (!use_max_distance) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
2020-11-06 16:02:42 +11:00
|
|
|
else if (STREQ(prop_id, "islands_precision")) {
|
|
|
|
|
if (!DT_DATATYPE_IS_LOOP(data_type)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
2020-11-06 16:02:42 +11:00
|
|
|
else if (STREQ(prop_id, "vert_mapping")) {
|
|
|
|
|
if (!DT_DATATYPE_IS_VERT(data_type)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
2020-11-06 16:02:42 +11:00
|
|
|
else if (STREQ(prop_id, "edge_mapping")) {
|
|
|
|
|
if (!DT_DATATYPE_IS_EDGE(data_type)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
2020-11-06 16:02:42 +11:00
|
|
|
else if (STREQ(prop_id, "loop_mapping")) {
|
|
|
|
|
if (!DT_DATATYPE_IS_LOOP(data_type)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
2020-11-06 16:02:42 +11:00
|
|
|
else if (STREQ(prop_id, "poly_mapping")) {
|
2023-07-24 22:06:55 +02:00
|
|
|
if (!DT_DATATYPE_IS_FACE(data_type)) {
|
2020-11-06 16:02:42 +11:00
|
|
|
return false;
|
|
|
|
|
}
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
2020-11-06 16:02:42 +11:00
|
|
|
else if (STR_ELEM(prop_id, "layers_select_src", "layers_select_dst")) {
|
|
|
|
|
if (!DT_DATATYPE_IS_MULTILAYERS(data_type)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
/* Else, show it! */
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 19:11:27 +02:00
|
|
|
static std::string data_transfer_get_description(bContext * /*C*/,
|
|
|
|
|
wmOperatorType * /*ot*/,
|
|
|
|
|
PointerRNA *ptr)
|
2022-01-27 17:17:59 +01:00
|
|
|
{
|
|
|
|
|
const bool reverse_transfer = RNA_boolean_get(ptr, "use_reverse_transfer");
|
|
|
|
|
|
|
|
|
|
if (reverse_transfer) {
|
2023-08-11 19:11:27 +02:00
|
|
|
return TIP_(
|
|
|
|
|
"Transfer data layer(s) (weights, edge sharp, etc.) from selected meshes to active one");
|
2022-01-27 17:17:59 +01:00
|
|
|
}
|
|
|
|
|
|
2023-08-11 19:11:27 +02:00
|
|
|
return "";
|
2022-01-27 17:17:59 +01:00
|
|
|
}
|
|
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
void OBJECT_OT_data_transfer(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-26 21:35:18 +10:00
|
|
|
/* Identifiers. */
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
ot->name = "Transfer Mesh Data";
|
|
|
|
|
ot->idname = "OBJECT_OT_data_transfer";
|
|
|
|
|
ot->description =
|
2021-02-24 13:25:44 -06:00
|
|
|
"Transfer data layer(s) (weights, edge sharp, etc.) from active to selected meshes";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-26 21:35:18 +10:00
|
|
|
/* API callbacks. */
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
ot->poll = data_transfer_poll;
|
2018-07-26 17:35:33 +10:00
|
|
|
ot->poll_property = data_transfer_poll_property;
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
|
ot->exec = data_transfer_exec;
|
|
|
|
|
ot->check = data_transfer_check;
|
2022-01-27 17:17:59 +01:00
|
|
|
ot->get_description = data_transfer_get_description;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-26 21:35:18 +10:00
|
|
|
/* Flags. */
|
2019-07-25 16:36:22 +02:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-26 21:35:18 +10:00
|
|
|
/* Properties. */
|
2015-01-11 18:29:14 +01:00
|
|
|
prop = RNA_def_boolean(ot->srna,
|
|
|
|
|
"use_reverse_transfer",
|
|
|
|
|
false,
|
|
|
|
|
"Reverse Transfer",
|
|
|
|
|
"Transfer from selected objects to active one");
|
2015-09-02 13:02:06 +02:00
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-08-07 16:33:48 +02:00
|
|
|
RNA_def_boolean(ot->srna,
|
|
|
|
|
"use_freeze",
|
|
|
|
|
false,
|
|
|
|
|
"Freeze Operator",
|
|
|
|
|
"Prevent changes to settings to re-run the operator, "
|
|
|
|
|
"handy to change several things at once with heavy geometry");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
/* Data type to transfer. */
|
|
|
|
|
ot->prop = RNA_def_enum(
|
|
|
|
|
ot->srna, "data_type", DT_layer_items, 0, "Data Type", "Which data to transfer");
|
|
|
|
|
RNA_def_boolean(ot->srna,
|
|
|
|
|
"use_create",
|
|
|
|
|
true,
|
|
|
|
|
"Create Data",
|
|
|
|
|
"Add data layers on destination meshes if needed");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
/* Mapping methods. */
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
|
"vert_mapping",
|
|
|
|
|
rna_enum_dt_method_vertex_items,
|
|
|
|
|
MREMAP_MODE_VERT_NEAREST,
|
|
|
|
|
"Vertex Mapping",
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
"Method used to map source vertices to destination ones");
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
|
"edge_mapping",
|
|
|
|
|
rna_enum_dt_method_edge_items,
|
|
|
|
|
MREMAP_MODE_EDGE_NEAREST,
|
|
|
|
|
"Edge Mapping",
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
"Method used to map source edges to destination ones");
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
|
"loop_mapping",
|
|
|
|
|
rna_enum_dt_method_loop_items,
|
|
|
|
|
MREMAP_MODE_LOOP_NEAREST_POLYNOR,
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
"Face Corner Mapping",
|
|
|
|
|
"Method used to map source faces' corners to destination ones");
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
|
"poly_mapping",
|
|
|
|
|
rna_enum_dt_method_poly_items,
|
|
|
|
|
MREMAP_MODE_POLY_NEAREST,
|
|
|
|
|
"Face Mapping",
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
"Method used to map source faces to destination ones");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
/* Mapping options and filtering. */
|
2015-07-13 18:00:08 +02:00
|
|
|
RNA_def_boolean(
|
|
|
|
|
ot->srna,
|
|
|
|
|
"use_auto_transform",
|
|
|
|
|
false,
|
|
|
|
|
"Auto Transform",
|
|
|
|
|
"Automatically compute transformation to get the best possible match between source and "
|
2021-03-26 12:07:50 -04:00
|
|
|
"destination meshes.\n"
|
|
|
|
|
"Warning: Results will never be as good as manual matching of objects");
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
RNA_def_boolean(ot->srna,
|
|
|
|
|
"use_object_transform",
|
|
|
|
|
true,
|
|
|
|
|
"Object Transform",
|
2015-06-16 14:17:26 +02:00
|
|
|
"Evaluate source and destination meshes in global space");
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
RNA_def_boolean(ot->srna,
|
|
|
|
|
"use_max_distance",
|
|
|
|
|
false,
|
|
|
|
|
"Only Neighbor Geometry",
|
|
|
|
|
"Source elements must be closer than given distance from destination one");
|
|
|
|
|
prop = RNA_def_float(
|
|
|
|
|
ot->srna,
|
|
|
|
|
"max_distance",
|
|
|
|
|
1.0f,
|
|
|
|
|
0.0f,
|
|
|
|
|
FLT_MAX,
|
|
|
|
|
"Max Distance",
|
|
|
|
|
"Maximum allowed distance between source and destination element, for non-topology mappings",
|
|
|
|
|
0.0f,
|
|
|
|
|
100.0f);
|
|
|
|
|
RNA_def_property_subtype(prop, PROP_DISTANCE);
|
|
|
|
|
prop = RNA_def_float(
|
|
|
|
|
ot->srna,
|
|
|
|
|
"ray_radius",
|
|
|
|
|
0.0f,
|
|
|
|
|
0.0f,
|
|
|
|
|
FLT_MAX,
|
|
|
|
|
"Ray Radius",
|
|
|
|
|
"'Width' of rays (especially useful when raycasting against vertices or edges)",
|
|
|
|
|
0.0f,
|
|
|
|
|
10.0f);
|
|
|
|
|
RNA_def_property_subtype(prop, PROP_DISTANCE);
|
|
|
|
|
prop = RNA_def_float(
|
|
|
|
|
ot->srna,
|
|
|
|
|
"islands_precision",
|
|
|
|
|
0.1f,
|
|
|
|
|
0.0f,
|
|
|
|
|
10.0f,
|
|
|
|
|
"Islands Precision",
|
|
|
|
|
"Factor controlling precision of islands handling (the higher, the better the results)",
|
|
|
|
|
0.0f,
|
|
|
|
|
1.0f);
|
|
|
|
|
RNA_def_property_subtype(prop, PROP_FACTOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
/* How to handle multi-layers types of data. */
|
2015-11-23 13:49:52 +11:00
|
|
|
prop = RNA_def_enum(ot->srna,
|
|
|
|
|
"layers_select_src",
|
|
|
|
|
rna_enum_dt_layers_select_src_items,
|
|
|
|
|
DT_LAYERS_ACTIVE_SRC,
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
"Source Layers Selection",
|
|
|
|
|
"Which layers to transfer, in case of multi-layers types");
|
2023-07-05 20:03:41 +02:00
|
|
|
RNA_def_property_enum_funcs_runtime(prop, nullptr, nullptr, dt_layers_select_itemf);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-11-23 13:49:52 +11:00
|
|
|
prop = RNA_def_enum(ot->srna,
|
|
|
|
|
"layers_select_dst",
|
|
|
|
|
rna_enum_dt_layers_select_dst_items,
|
|
|
|
|
DT_LAYERS_ACTIVE_DST,
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
"Destination Layers Matching",
|
|
|
|
|
"How to match source and destination layers");
|
2023-07-05 20:03:41 +02:00
|
|
|
RNA_def_property_enum_funcs_runtime(prop, nullptr, nullptr, dt_layers_select_itemf);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-11-23 13:49:52 +11:00
|
|
|
prop = RNA_def_enum(ot->srna,
|
|
|
|
|
"mix_mode",
|
|
|
|
|
rna_enum_dt_mix_mode_items,
|
|
|
|
|
CDT_MIX_TRANSFER,
|
|
|
|
|
"Mix Mode",
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
"How to affect destination elements with source values");
|
2023-07-05 20:03:41 +02:00
|
|
|
RNA_def_property_enum_funcs_runtime(prop, nullptr, nullptr, dt_mix_mode_itemf);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
RNA_def_float(
|
|
|
|
|
ot->srna,
|
|
|
|
|
"mix_factor",
|
|
|
|
|
1.0f,
|
|
|
|
|
0.0f,
|
|
|
|
|
1.0f,
|
|
|
|
|
"Mix Factor",
|
|
|
|
|
"Factor to use when applying data to destination (exact behavior depends on mix mode)",
|
|
|
|
|
0.0f,
|
|
|
|
|
1.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
2021-07-03 23:08:40 +10:00
|
|
|
/* NOTE: This operator is hybrid, it can work as a usual standalone Object operator,
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
* or as a DataTransfer modifier tool.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool datalayout_transfer_poll(bContext *C)
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{
|
2020-08-12 14:21:40 +02:00
|
|
|
return (edit_modifier_poll_generic(C, &RNA_DataTransferModifier, (1 << OB_MESH), true, false) ||
|
2015-01-09 21:19:12 +01:00
|
|
|
data_transfer_poll(C));
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
|
|
|
|
|
2025-03-20 21:11:06 +00:00
|
|
|
static wmOperatorStatus datalayout_transfer_exec(bContext *C, wmOperator *op)
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{
|
2024-03-28 01:30:38 +01:00
|
|
|
Object *ob_act = context_active_object(C);
|
2019-07-25 16:36:22 +02:00
|
|
|
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
2015-01-09 21:19:12 +01:00
|
|
|
DataTransferModifierData *dtmd;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-09 21:19:12 +01:00
|
|
|
dtmd = (DataTransferModifierData *)edit_modifier_property_get(
|
|
|
|
|
op, ob_act, eModifierType_DataTransfer);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-29 19:29:41 +10:00
|
|
|
/* If we have a modifier, we transfer data layout from this modifier's source object to
|
|
|
|
|
* active one. Else, we transfer data layout from active object to all selected ones. */
|
2015-01-09 21:19:12 +01:00
|
|
|
if (dtmd) {
|
|
|
|
|
Object *ob_src = dtmd->ob_source;
|
|
|
|
|
Object *ob_dst = ob_act;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-09 21:19:12 +01:00
|
|
|
const bool use_delete = false; /* Never when used from modifier, for now. */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-05-16 14:53:09 +02:00
|
|
|
if (!ob_src || !ID_IS_EDITABLE(ob_dst) || ID_IS_OVERRIDE_LIBRARY(ob_dst)) {
|
2015-01-09 21:19:12 +01:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-05-02 15:08:29 +02:00
|
|
|
Object *ob_src_eval = DEG_get_evaluated(depsgraph, ob_src);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-01 19:06:44 +03:00
|
|
|
BKE_object_data_transfer_layout(depsgraph,
|
|
|
|
|
ob_src_eval,
|
|
|
|
|
ob_dst,
|
|
|
|
|
dtmd->data_types,
|
|
|
|
|
use_delete,
|
2015-01-09 21:19:12 +01:00
|
|
|
dtmd->layers_select_src,
|
|
|
|
|
dtmd->layers_select_dst);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY);
|
2015-01-09 21:19:12 +01:00
|
|
|
}
|
|
|
|
|
else {
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
Object *ob_src = ob_act;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-03-28 01:30:38 +01:00
|
|
|
Vector<PointerRNA> ctx_objects;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
const int data_type = RNA_enum_get(op->ptr, "data_type");
|
|
|
|
|
const bool use_delete = RNA_boolean_get(op->ptr, "use_delete");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
const int layers_src = RNA_enum_get(op->ptr, "layers_select_src");
|
|
|
|
|
const int layers_dst = RNA_enum_get(op->ptr, "layers_select_dst");
|
|
|
|
|
int layers_select_src[DT_MULTILAYER_INDEX_MAX] = {0};
|
|
|
|
|
int layers_select_dst[DT_MULTILAYER_INDEX_MAX] = {0};
|
|
|
|
|
const int fromto_idx = BKE_object_data_transfer_dttype_to_srcdst_index(data_type);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
if (fromto_idx != DT_MULTILAYER_INDEX_INVALID) {
|
|
|
|
|
layers_select_src[fromto_idx] = layers_src;
|
|
|
|
|
layers_select_dst[fromto_idx] = layers_dst;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-05-02 15:08:29 +02:00
|
|
|
Object *ob_src_eval = DEG_get_evaluated(depsgraph, ob_src);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-11 18:29:14 +01:00
|
|
|
data_transfer_exec_preprocess_objects(C, op, ob_src, &ctx_objects, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-03-27 00:47:39 +01:00
|
|
|
for (const PointerRNA &ptr : ctx_objects) {
|
|
|
|
|
Object *ob_dst = static_cast<Object *>(ptr.data);
|
2015-01-11 18:29:14 +01:00
|
|
|
if (data_transfer_exec_is_object_valid(op, ob_src, ob_dst, false)) {
|
2018-12-01 19:06:44 +03:00
|
|
|
BKE_object_data_transfer_layout(depsgraph,
|
|
|
|
|
ob_src_eval,
|
|
|
|
|
ob_dst,
|
|
|
|
|
data_type,
|
|
|
|
|
use_delete,
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
layers_select_src,
|
|
|
|
|
layers_select_dst);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-24 16:24:53 +03:00
|
|
|
DEG_relations_tag_update(CTX_data_main(C));
|
2023-07-05 20:03:41 +02:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-20 21:11:06 +00:00
|
|
|
static wmOperatorStatus datalayout_transfer_invoke(bContext *C,
|
|
|
|
|
wmOperator *op,
|
|
|
|
|
const wmEvent *event)
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
{
|
2020-12-02 13:35:07 +01:00
|
|
|
if (edit_modifier_invoke_properties(C, op)) {
|
2015-01-09 21:19:12 +01:00
|
|
|
return datalayout_transfer_exec(C, op);
|
|
|
|
|
}
|
2020-07-03 15:42:22 +02:00
|
|
|
return WM_menu_invoke(C, op, event);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_datalayout_transfer(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-13 21:03:15 +01:00
|
|
|
ot->name = "Transfer Mesh Data Layout";
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
ot->description = "Transfer layout of data layer(s) from active to selected meshes";
|
|
|
|
|
ot->idname = "OBJECT_OT_datalayout_transfer";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
ot->poll = datalayout_transfer_poll;
|
2018-07-26 17:35:33 +10:00
|
|
|
ot->poll_property = data_transfer_poll_property;
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
ot->invoke = datalayout_transfer_invoke;
|
|
|
|
|
ot->exec = datalayout_transfer_exec;
|
|
|
|
|
ot->check = data_transfer_check;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
/* flags */
|
2019-07-25 16:36:22 +02:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-26 21:35:18 +10:00
|
|
|
/* Properties. */
|
2015-01-09 21:19:12 +01:00
|
|
|
edit_modifier_properties(ot);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
/* Data type to transfer. */
|
|
|
|
|
ot->prop = RNA_def_enum(
|
|
|
|
|
ot->srna, "data_type", DT_layer_items, 0, "Data Type", "Which data to transfer");
|
|
|
|
|
RNA_def_boolean(ot->srna,
|
|
|
|
|
"use_delete",
|
|
|
|
|
false,
|
|
|
|
|
"Exact Match",
|
|
|
|
|
"Also delete some data layers from destination if necessary, so that it matches "
|
|
|
|
|
"exactly source");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
/* How to handle multi-layers types of data. */
|
2015-11-23 13:49:52 +11:00
|
|
|
prop = RNA_def_enum(ot->srna,
|
|
|
|
|
"layers_select_src",
|
|
|
|
|
rna_enum_dt_layers_select_src_items,
|
|
|
|
|
DT_LAYERS_ACTIVE_SRC,
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
"Source Layers Selection",
|
|
|
|
|
"Which layers to transfer, in case of multi-layers types");
|
2023-07-05 20:03:41 +02:00
|
|
|
RNA_def_property_enum_funcs_runtime(prop, nullptr, nullptr, dt_layers_select_src_itemf);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-11-23 13:49:52 +11:00
|
|
|
prop = RNA_def_enum(ot->srna,
|
|
|
|
|
"layers_select_dst",
|
|
|
|
|
rna_enum_dt_layers_select_dst_items,
|
|
|
|
|
DT_LAYERS_ACTIVE_DST,
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
"Destination Layers Matching",
|
|
|
|
|
"How to match source and destination layers");
|
2023-07-05 20:03:41 +02:00
|
|
|
RNA_def_property_enum_funcs_runtime(prop, nullptr, nullptr, dt_layers_select_dst_itemf);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
}
|
2024-03-28 01:30:38 +01:00
|
|
|
|
|
|
|
|
} // namespace blender::ed::object
|