[Bf-blender-cvs] [1a8ea45] mesh-transfer-data: UI Hell work, think its good enough for review now.
Bastien Montagne
noreply at git.blender.org
Thu Nov 6 18:11:09 CET 2014
Commit: 1a8ea45b0fad387516bde6301cd3fea8c35cb933
Author: Bastien Montagne
Date: Thu Nov 6 18:07:45 2014 +0100
Branches: mesh-transfer-data
https://developer.blender.org/rB1a8ea45b0fad387516bde6301cd3fea8c35cb933
UI Hell work, think its good enough for review now.
Yet, UI code becomes really convoluted here. :/
Also, now each 'multilayer' type has its own from/to layers select
option, allows to transfer a specific layer. Only used in modifiers for now.
===================================================================
M release/scripts/startup/bl_ui/properties_data_modifier.py
M source/blender/blenkernel/BKE_data_transfer.h
M source/blender/blenkernel/intern/data_transfer.c
M source/blender/blenkernel/intern/data_transfer_intern.h
M source/blender/blenkernel/intern/deform.c
M source/blender/editors/object/object_data_transfer.c
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/makesrna/intern/rna_modifier.c
M source/blender/modifiers/intern/MOD_datatransfer.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 7a3641b..e78b5e6 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1234,45 +1234,59 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
layout.separator()
- col = layout.column()
- split = col.split(0.66)
- subcol = split.column()
- subcol.label("Vertex Mapping:")
- subcol.prop(md, "vert_mapping", text="")
- subcol = split.column()
- subcol.prop(md, "data_types_verts")
+ layout.prop(md, "vert_mapping")
+ col = layout.column(align=True)
+ split = col.split(0.333, align=True)
+ sub = split.column(align=True)
+ sub.prop(md, "data_types_verts_vgroup")
+ row = split.row(align=True)
+ row.prop(md, "fromlayers_vgroup_select", text="")
+ row.label(icon='RIGHTARROW')
+ row.prop(md, "tolayers_vgroup_select", text="")
+ split = col.split(0.333, align=True)
+ sub = split.column(align=True)
+ sub.prop(md, "data_types_verts")
layout.separator()
- col = layout.column()
- split = col.split(0.66)
- subcol = split.column()
- subcol.label("Edge Mapping:")
- subcol.prop(md, "edge_mapping", text="")
- subcol = split.column()
- subcol.prop(md, "data_types_edges")
+ layout.prop(md, "edge_mapping")
+ col = layout.column(align=True)
+ split = col.split(0.333, align=True)
+ sub = split.column(align=True)
+ sub.prop(md, "data_types_edges")
layout.separator()
- col = layout.column()
- split = col.split(0.66)
- subcol = split.column()
- subcol.label("Face Corner Mapping:")
- subcol.prop(md, "loop_mapping", text="")
- subcol = split.column()
- subcol.prop(md, "data_types_loops")
+
+ layout.prop(md, "loop_mapping")
+ col = layout.column(align=True)
+ split = col.split(0.333, align=True)
+ sub = split.column(align=True)
+ sub.prop(md, "data_types_loops")
+ split = col.split(0.333, align=True)
+ sub = split.column(align=True)
+ sub.prop(md, "data_types_loops_vcol")
+ row = split.row(align=True)
+ row.prop(md, "fromlayers_vcol_select", text="")
+ row.label(icon='RIGHTARROW')
+ row.prop(md, "tolayers_vcol_select", text="")
layout.separator()
- col = layout.column()
- split = col.split(0.66)
- subcol = split.column()
- subcol.label("Face Mapping:")
- subcol.prop(md, "poly_mapping", text="")
- subcol = split.column()
- subcol.prop(md, "data_types_polys")
+
+ layout.prop(md, "poly_mapping")
+ col = layout.column(align=True)
+ split = col.split(0.333, align=True)
+ sub = split.column(align=True)
+ sub.prop(md, "data_types_polys_uv")
+ row = split.row(align=True)
+ row.prop(md, "fromlayers_uv_select", text="")
+ row.label(icon='RIGHTARROW')
+ row.prop(md, "tolayers_uv_select", text="")
+ split = col.split(0.333, align=True)
+ sub = split.column(align=True)
+ sub.prop(md, "data_types_polys")
layout.separator()
- # First col.
split = layout.split()
col = split.column()
row = col.row(align=True)
@@ -1288,17 +1302,6 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
split = layout.split()
col = split.column()
- col.label("Source Layers Select Mode:")
- col.prop(md, "fromlayers_select", text="")
-
- col = split.column()
- col.label("Destination Layers Select Mode:")
- col.prop(md, "tolayers_select", text="")
-
- layout.separator()
-
- split = layout.split()
- col = split.column()
col.prop(md, "mix_mode")
col.prop(md, "mix_factor")
diff --git a/source/blender/blenkernel/BKE_data_transfer.h b/source/blender/blenkernel/BKE_data_transfer.h
index f7a28e1..fdc46a0 100644
--- a/source/blender/blenkernel/BKE_data_transfer.h
+++ b/source/blender/blenkernel/BKE_data_transfer.h
@@ -67,6 +67,7 @@ bool BKE_data_transfer_get_dttypes_capacity(
const int dtdata_types, bool *r_advanced_mixing, bool *r_threshold);
int BKE_data_transfer_dttype_to_cdtype(const int dtdata_type);
+int BKE_data_transfer_dttype_to_fromto_idx(const int dtdata_type);
#define DT_DATATYPE_IS_VERT(_dt) ELEM(_dt, DT_DATA_MDEFORMVERT, DT_DATA_SHAPEKEY, DT_DATA_SKIN, \
DT_DATA_BWEIGHT_VERT)
@@ -78,26 +79,36 @@ int BKE_data_transfer_dttype_to_cdtype(const int dtdata_type);
#define DT_DATATYPE_IS_MULTILAYERS(_dt) ELEM(_dt, DT_DATA_MDEFORMVERT, DT_DATA_SHAPEKEY, DT_DATA_UV, DT_DATA_VCOL)
+enum {
+ DT_MULTILAYER_IDX_INVALID = -1,
+ DT_MULTILAYER_IDX_MDEFORMVERT = 0,
+ DT_MULTILAYER_IDX_SHAPEKEY = 1,
+ DT_MULTILAYER_IDX_UV = 2,
+ DT_MULTILAYER_IDX_VCOL = 3,
+ DT_MULTILAYER_IDX_MAX = 4,
+};
+
+/* Below we keep positive values for real layers idx (generated dynamically). */
/* How to select data layers, for types supporting multi-layers.
* Here too, some options are highly dependent on type of transferred data! */
enum {
- DT_FROMLAYERS_ACTIVE = 0,
- DT_FROMLAYERS_ALL = 1,
+ DT_FROMLAYERS_ACTIVE = -1,
+ DT_FROMLAYERS_ALL = -2,
/* Datatype-specific. */
DT_FROMLAYERS_VGROUP = 1 << 8,
- DT_FROMLAYERS_VGROUP_BONE_SELECTED = DT_FROMLAYERS_VGROUP | 1,
- DT_FROMLAYERS_VGROUP_BONE_DEFORM = DT_FROMLAYERS_VGROUP | 2,
+ DT_FROMLAYERS_VGROUP_BONE_SELECTED = -(DT_FROMLAYERS_VGROUP | 1),
+ DT_FROMLAYERS_VGROUP_BONE_DEFORM = -(DT_FROMLAYERS_VGROUP | 2),
/* Other types-related modes... */
};
/* How to map a source layer to a destination layer, for types supporting multi-layers.
* Note: if no matching layer can be found, it will be created. */
enum {
- DT_TOLAYERS_ACTIVE = 0, /* Only for DT_LAYERS_FROMSEL_ACTIVE. */
- DT_TOLAYERS_NAME = 1,
- DT_TOLAYERS_INDEX = 2,
+ DT_TOLAYERS_ACTIVE = -1, /* Only for DT_LAYERS_FROMSEL_ACTIVE. */
+ DT_TOLAYERS_NAME = -2,
+ DT_TOLAYERS_INDEX = -3,
#if 0 /* TODO */
- DT_TOLAYERS_CREATE = 3, /* Never replace existing data in dst, always create new layers. */
+ DT_TOLAYERS_CREATE = -4, /* Never replace existing data in dst, always create new layers. */
#endif
};
@@ -105,14 +116,14 @@ bool BKE_data_transfer_mesh(
struct Scene *scene, struct Object *ob_src, struct Object *ob_dst, const int data_types, const bool use_create,
const int map_vert_mode, const int map_edge_mode, const int map_poly_mode, const int map_loop_mode,
struct SpaceTransform *space_transform, const float max_distance, const float precision,
- const int fromlayers_select, const int tolayers_select,
+ const int fromlayers_select[DT_MULTILAYER_IDX_MAX], const int tolayers_select[DT_MULTILAYER_IDX_MAX],
const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup);
bool BKE_data_transfer_dm(
struct Scene *scene, struct Object *ob_src, struct Object *ob_dst, struct DerivedMesh *dm_dst,
const int data_types, const bool use_create,
const int map_vert_mode, const int map_edge_mode, const int map_poly_mode, const int map_loop_mode,
struct SpaceTransform *space_transform, const float max_distance, const float ray_radius,
- const int fromlayers_select, const int tolayers_select,
+ const int fromlayers_select[DT_MULTILAYER_IDX_MAX], const int tolayers_select[DT_MULTILAYER_IDX_MAX],
const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup);
#ifdef __cplusplus
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index 9e98c2c..56e13ad 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -191,6 +191,22 @@ int BKE_data_transfer_dttype_to_cdtype(const int dtdata_type)
return 0; /* Should never be reached! */
}
+int BKE_data_transfer_dttype_to_fromto_idx(const int dtdata_type)
+{
+ switch (dtdata_type) {
+ case DT_DATA_MDEFORMVERT:
+ return DT_MULTILAYER_IDX_MDEFORMVERT;
+ case DT_DATA_SHAPEKEY:
+ return DT_MULTILAYER_IDX_SHAPEKEY;
+ case DT_DATA_UV:
+ return DT_MULTILAYER_IDX_UV;
+ case DT_DATA_VCOL:
+ return DT_MULTILAYER_IDX_VCOL;
+ default:
+ return DT_MULTILAYER_IDX_INVALID;
+ }
+}
+
/* ********** */
static loop_island_compute data_transfer_get_loop_islands_generator(const int cddata_type)
@@ -293,13 +309,13 @@ static void data_transfer_layersmapping_add_item_cd(
static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(
ListBase *r_map, const int cddata_type, const int mix_mode, const float mix_factor, const float *mix_weights,
const int num_create, CustomData *cd_src, CustomData *cd_dst, const bool dup_dst,
- const int tolayers_select, bool *use_layers_src, const int num_layers_src)
+ const int tolayers, bool *use_layers_src, const int num_layers_src)
{
void *data_src, *data_dst = NULL;
int idx_src = num_layers_src;
int idx_dst;
- switch (tolayers_select) {
+ switch (tolayers) {
case DT_TOLAYERS_INDEX:
{
idx_dst = CustomData_number_of_layers(data_dst, cddata_type);
@@ -363,7 +379,7 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(
static bool data_transfer_layersmapping_cdlayers(
ListBase *r_map, const int cddata_type, const int mix_mode, const float mix_factor, const float *mix_weights,
const int num_create, CustomData *cd_src, CustomData *cd_dst, const bool dup_dst,
- const int fromlayers_select, const int tolayers_select)
+ const int froml
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list