[Bf-blender-cvs] [e732333] mesh-transfer-data: Mostly some refactor in preparation of advanced data mixing.
Bastien Montagne
noreply at git.blender.org
Sat Oct 25 08:42:00 CEST 2014
Commit: e73233377e737eb96b560abb3463f9aaf942a693
Author: Bastien Montagne
Date: Thu Oct 23 14:43:33 2014 +0200
Branches: mesh-transfer-data
https://developer.blender.org/rBe73233377e737eb96b560abb3463f9aaf942a693
Mostly some refactor in preparation of advanced data mixing.
===================================================================
M source/blender/blenkernel/BKE_customdata.h
M source/blender/blenkernel/intern/customdata.c
M source/blender/editors/include/ED_object.h
M source/blender/editors/object/object_intern.h
M source/blender/editors/object/object_transfer_data.c
M source/blender/editors/object/object_vgroup.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 5a3decf..fc5a741 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -371,10 +371,11 @@ void CustomData_external_reload(struct CustomData *data,
struct Mesh2MeshMapping;
typedef struct DataTransferLayerMapping DataTransferLayerMapping;
-typedef void (*cd_datatransfer_interp)(const DataTransferLayerMapping *laymap,
- void **sources, const float *weights, int count, void *dest);
+typedef void (*cd_datatransfer_interp)(const DataTransferLayerMapping *laymap, void *dest,
+ void **sources, const float *weights, const int count);
-/* Fake CD_LAYERS (those are actually 'real' data stored directly into elements' structs). */
+/* Fake CD_LAYERS (those are actually 'real' data stored directly into elements' structs, or otherwise not (directly)
+ * accessible to usual CDLayer system). */
enum {
CD_FAKE = 1 << 8,
@@ -404,6 +405,9 @@ typedef struct DataTransferLayerMapping {
DataTransferLayerMapping *next, *prev;
int data_type;
+ int mix_mode;
+ float mix_factor;
+ /* TODO: we may want to add more mixing features, eg based on vgroups? */
void *data_src; /* Data source array (can be regular CD data, vertices/edges/etc., keyblocks...). */
void *data_dst; /* Data dest array (same type as dat_src). */
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 0a89a48..280c3a9 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -3559,8 +3559,8 @@ static bool check_bit_flag(const size_t data_size, void *data, const uint64_t fl
}
}
-static void customdata_data_transfer_interp_generic(const DataTransferLayerMapping *laymap, void **sources,
- const float *weights, int count, void *data_dst)
+static void customdata_data_transfer_interp_generic(const DataTransferLayerMapping *laymap, void *data_dst,
+ void **sources, const float *weights, const int count)
{
/* Fake interpolation, we actually copy highest weighted source to dest.
* Note we also handle bitflags here, in which case we rather choose to transfer value of elements totalizing
@@ -3655,8 +3655,13 @@ void CustomData_data_transfer(const Mesh2MeshMapping *m2mmap, const DataTransfer
data_size = (size_t)type_info->size;
data_step = laymap->elem_size ? laymap->elem_size : data_size;
data_offset = laymap->data_offset;
- interp_cd = type_info->interp;
- copy_cd = type_info->copy;
+ if (laymap->interp) {
+ interp = laymap->interp;
+ }
+ else {
+ interp_cd = type_info->interp;
+ copy_cd = type_info->copy;
+ }
}
for (i = 0; i < totelem; i++, data_dst = (char *)data_dst + data_step, mapit++) {
@@ -3686,7 +3691,7 @@ void CustomData_data_transfer(const Mesh2MeshMapping *m2mmap, const DataTransfer
}
if (interp) {
- interp(laymap, tmp_data_src, mapit->weights_src, nbr_sources, (char *)data_dst + data_offset);
+ interp(laymap, (char *)data_dst + data_offset, tmp_data_src, mapit->weights_src, nbr_sources);
}
else if (nbr_sources > 1 && interp_cd) {
interp_cd(tmp_data_src, mapit->weights_src, NULL, nbr_sources, (char *)data_dst + data_offset);
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 3d23410..8b88a22 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -232,14 +232,15 @@ void ED_object_check_force_modifiers(struct Main *bmain, struct Scene *scene, st
* Note those options are highly dependent on type of transferred data! */
/* TODO: only MDT_REPLACE is implemented currently! */
enum {
- MDT_REPLACE = 0,
- MDT_REPLACE_THRESHOLD = 1,
+ MDT_MIX_REPLACE_ALL = 0,
+ MDT_MIX_REPLACE_ABOVE_THRESHOLD = 1,
+ MDT_MIX_REPLACE_BELOW_THRESHOLD = 2,
#if 0
- MDT_REPLACE_MIX = 2,
- MDT_REPLACE_ADD = 3,
- MDT_REPLACE_SUB = 4,
- MDT_REPLACE_MUL = 5,
- MDT_REPLACE_DIV = 6,
+ MDT_MIX_MIX = 16,
+ MDT_MIX_ADD = 17,
+ MDT_MIX_SUB = 18,
+ MDT_MIX_MUL = 19,
+ MDT_MIX_DIV = 20,
/* etc. etc. */
#endif
};
@@ -268,16 +269,15 @@ enum {
};
bool ED_data_transfer_layersmapping_cdlayers(
- struct ListBase *r_map, const int data_type, const int num_create,
- struct CustomData *data_src, struct CustomData *data_dst,
+ struct ListBase *r_map, const int data_type, const int mix_mode, const float mix_factor,
+ const int num_create, struct CustomData *data_src, struct CustomData *data_dst,
const int fromlayers_select, const int tolayers_select);
bool ED_data_transfer(
struct Scene *scene, struct Object *ob_src, struct Object *ob_dst, const int data_type, 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 replace_mode, const float replace_threshold,
- const int fromlayers_select, const int tolayers_select);
+ const int fromlayers_select, const int tolayers_select, const int mix_mode, const float mix_factor);
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 671e27d..b7ed71b 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -240,7 +240,8 @@ void OBJECT_OT_vertex_weight_normalize_active_vertex(struct wmOperatorType *ot);
void OBJECT_OT_vertex_weight_copy(struct wmOperatorType *ot);
bool data_transfer_layersmapping_vgroups(
- struct ListBase *r_map, const int num_create, struct Object *ob_src, struct Object *ob_dst,
+ struct ListBase *r_map, const int mix_mode, const float mix_factor, const int num_create,
+ struct Object *ob_src, struct Object *ob_dst,
struct CustomData *cd_src, struct CustomData *cd_dst, const int fromlayers_select, const int tolayers_select);
/* object_warp.c */
@@ -276,12 +277,12 @@ void OBJECT_OT_vertex_random(struct wmOperatorType *ot);
void OBJECT_OT_data_transfer(struct wmOperatorType *ot);
/* Copied from BKE_customdata.h :( */
-typedef void (*cd_datatransfer_interp)(const struct DataTransferLayerMapping *laymap,
- void **sources, const float *weights, int count, void *dest);
+typedef void (*cd_datatransfer_interp)(const struct DataTransferLayerMapping *laymap, void *dest,
+ void **sources, const float *weights, int count);
void data_transfer_layersmapping_add_item(
- struct ListBase *r_map, const int data_type, void *data_src, void *data_dst,
- const int data_n_src, const int data_n_dst,
+ struct ListBase *r_map, const int data_type, const int mix_mode, const float mix_factor,
+ void *data_src, void *data_dst, const int data_n_src, const int data_n_dst,
const size_t elem_size, const size_t data_size, const size_t data_offset, const uint64_t data_flag,
cd_datatransfer_interp interp);
diff --git a/source/blender/editors/object/object_transfer_data.c b/source/blender/editors/object/object_transfer_data.c
index 78a86f1..96aa055 100644
--- a/source/blender/editors/object/object_transfer_data.c
+++ b/source/blender/editors/object/object_transfer_data.c
@@ -172,10 +172,25 @@ static EnumPropertyItem MDT_method_loop_items[] = {
/* How to filter out some elements (to leave untouched).
* Note those options are highly dependent on type of transferred data! */
-static EnumPropertyItem MDT_replace_mode_items[] = {
- {MDT_REPLACE, "REPLACE", 0, "All", "Overwrite all elements' data"},
- {MDT_REPLACE_THRESHOLD, "REPLACE_THRESHOLD", 0, "Below Threshold",
- "Only affect dest elements where data is below given threshold (exact behavior depends on data type)"},
+static EnumPropertyItem MDT_mix_mode_items[] = {
+ {MDT_MIX_REPLACE_ALL, "REPLACE", 0, "All", "Overwrite all elements' data"},
+ {MDT_MIX_REPLACE_ABOVE_THRESHOLD, "ABOVE_THRESHOLD", 0, "Above Threshold",
+ "Only replace dest elements where data is above given threshold (exact behavior depends on data type)"},
+ {MDT_MIX_REPLACE_BELOW_THRESHOLD, "BELOW_THRESHOLD", 0, "Below Threshold",
+ "Only replace dest elements where data is below given threshold (exact behavior depends on data type)"},
+#if 0
+ {MDT_MIX_MIX, "MIX", 0, "Mix",
+ "Mix source value into destination one, using given threshold as factor"},
+ {MDT_MIX_ADD, "ADD", 0, "Add",
+ "Add source value to destination one, using given threshold as factor"},
+ {MDT_MIX_SUB, "SUB", 0, "Subtract",
+ "Subtract source value to destination one, using given threshold as factor"},
+ {MDT_MIX_MUL, "MUL", 0, "Multiply",
+ "Multiply source value to destination one, using given threshold as factor"},
+ {MDT_MIX_DIV, "DIV", 0, "Divide",
+ "Divide destination value by source one, using given threshold as factor"},
+ /* etc. etc. */
+#endif
{0, NULL, 0, NULL, NULL}
};
@@ -191,6 +206,43 @@ static EnumPropertyItem MDT_fromlayers_select_items[] = {
{0, NULL, 0, NULL, NULL}
};
+static bool mdt_get_layertype_capacity(const int type, bool *r_advanced_mixing)
+{
+ *r_advanced_mixing = false;
+ /* Note: for now we are cool and allow non-fake-like types as well. */
+ switch (type) {
+ /* Vertex data */
+ case CD_MDEFORMVERT:
+ case CD_FAKE_MDEFORMVERT:
+ *r_advanced_mixing = true;
+ return true;
+ case CD_MVERT_SKIN:
+ return true;
+ case CD_FAKE_BWEIGHT:
+ return true;
+ /* Edge data */
+ case CD_FAKE_SHARP:
+ return true;
+ case CD_FAKE_SEAM:
+ return true;
+ case CD_FAKE_CREASE:
+ return true;
+#if 0 /* Already handled with vertices data. */
+ case CD_FAKE_BWEIGHT:
+ return true;
+#endif
+ /* Loop/Poly data */
+ case CD_FAKE_UV:
+ return
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list