[Bf-blender-cvs] [08a343d] mesh-transfer-data: Make transfer data code accept DM too.
Bastien Montagne
noreply at git.blender.org
Tue Nov 4 10:38:03 CET 2014
Commit: 08a343d1c8a802014fed366fc6421aa03da3327c
Author: Bastien Montagne
Date: Tue Nov 4 10:36:49 2014 +0100
Branches: mesh-transfer-data
https://developer.blender.org/rB08a343d1c8a802014fed366fc6421aa03da3327c
Make transfer data code accept DM too.
First step towards transfer data modifier (DM part not yet tested).
===================================================================
M source/blender/blenkernel/intern/mesh_mapping.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/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c
index 1ef8535..86f61d2 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.c
+++ b/source/blender/blenkernel/intern/mesh_mapping.c
@@ -1975,7 +1975,6 @@ void BKE_dm2mesh_mapping_loops_compute(
w /= M2MMAP_RAYCAST_APPROXIMATE_FAC;
}
if (n == -1) {
- printf("foo\n");
/* No source for this dest loop! */
islands_res[tidx][plidx_dst].factor = 0.0f;
islands_res[tidx][plidx_dst].hit_distance = FLT_MAX;
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index ec05ca6..0d812ce 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -43,6 +43,7 @@ struct Base;
struct BezTriple;
struct Curve;
struct CustomData;
+struct DerivedMesh;
struct EditBone;
struct EnumPropertyItem;
struct ID;
@@ -251,16 +252,17 @@ enum {
#endif
};
-bool ED_data_transfer_layersmapping_cdlayers(
- 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 fromlayers_select, const int tolayers_select, const int mix_mode, const float mix_factor);
+bool ED_data_transfer_dm(
+ struct Scene *scene, struct Object *ob_src, struct Object *ob_dst, struct DerivedMesh *dm_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 ray_radius,
+ 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 b7ed71b..7b32020 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -241,7 +241,7 @@ void OBJECT_OT_vertex_weight_copy(struct wmOperatorType *ot);
bool data_transfer_layersmapping_vgroups(
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 Object *ob_src, struct Object *ob_dst, const bool dup_dst,
struct CustomData *cd_src, struct CustomData *cd_dst, const int fromlayers_select, const int tolayers_select);
/* object_warp.c */
diff --git a/source/blender/editors/object/object_transfer_data.c b/source/blender/editors/object/object_transfer_data.c
index b1b89d4..4fd93a0 100644
--- a/source/blender/editors/object/object_transfer_data.c
+++ b/source/blender/editors/object/object_transfer_data.c
@@ -414,7 +414,7 @@ static void data_transfer_layersmapping_add_item_cd(ListBase *r_map, const int d
static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(
ListBase *r_map, const int data_type, const int mix_mode, const float mix_factor,
- const int num_create, CustomData *cd_src, CustomData *cd_dst,
+ 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)
{
void *data_src, *data_dst = NULL;
@@ -444,7 +444,9 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(
continue;
}
data_src = CustomData_get_layer_n(cd_src, data_type, idx_src);
- data_dst = CustomData_get_layer_n(cd_dst, data_type, idx_src);
+ /* If dest is a derivedmesh, we do not want to overwrite cdlayers of org mesh! */
+ data_dst = dup_dst ? CustomData_duplicate_referenced_layer_n(cd_dst, data_type, num_create, idx_src) :
+ CustomData_get_layer_n(cd_dst, data_type, idx_src);
data_transfer_layersmapping_add_item_cd(r_map, data_type, mix_mode, mix_factor, data_src, data_dst);
}
}
@@ -467,7 +469,9 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(
idx_dst = CustomData_get_named_layer(cd_dst, data_type, name);
}
data_src = CustomData_get_layer_n(cd_src, data_type, idx_src);
- data_dst = CustomData_get_layer_n(cd_dst, data_type, idx_dst);
+ /* If dest is a derivedmesh, we do not want to overwrite cdlayers of org mesh! */
+ data_dst = dup_dst ? CustomData_duplicate_referenced_layer_n(cd_dst, data_type, num_create, idx_dst) :
+ CustomData_get_layer_n(cd_dst, data_type, idx_dst);
data_transfer_layersmapping_add_item_cd(r_map, data_type, mix_mode, mix_factor, data_src, data_dst);
}
break;
@@ -478,9 +482,9 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(
return true;
}
-bool ED_data_transfer_layersmapping_cdlayers(
+static bool data_transfer_layersmapping_cdlayers(
ListBase *r_map, const int data_type, const int mix_mode, const float mix_factor,
- const int num_create, CustomData *cd_src, CustomData *cd_dst,
+ const int num_create, CustomData *cd_src, CustomData *cd_dst, const bool dup_dst,
const int fromlayers_select, const int tolayers_select)
{
int idx_src, idx_dst;
@@ -490,7 +494,10 @@ bool ED_data_transfer_layersmapping_cdlayers(
if (!(data_src = CustomData_get_layer(cd_src, data_type))) {
return false;
}
- if (!(data_dst = CustomData_get_layer(cd_dst, data_type))) {
+ /* If dest is a derivedmesh, we do not want to overwrite cdlayers of org mesh! */
+ data_dst = dup_dst ? CustomData_duplicate_referenced_layer(cd_dst, data_type, num_create) :
+ CustomData_get_layer(cd_dst, data_type);
+ if (!data_dst) {
if (!num_create) {
return false;
}
@@ -513,7 +520,9 @@ bool ED_data_transfer_layersmapping_cdlayers(
data_dst = CustomData_add_layer(cd_dst, data_type, CD_CALLOC, NULL, num_create);
}
else {
- data_dst = CustomData_get_layer_n(cd_dst, data_type, idx_dst);
+ /* If dest is a derivedmesh, we do not want to overwrite cdlayers of org mesh! */
+ data_dst = dup_dst ? CustomData_duplicate_referenced_layer_n(cd_dst, data_type, num_create, idx_dst) :
+ CustomData_get_layer_n(cd_dst, data_type, idx_dst);
}
break;
case MDT_TOLAYERS_INDEX:
@@ -529,7 +538,9 @@ bool ED_data_transfer_layersmapping_cdlayers(
CustomData_add_layer(cd_dst, data_type, CD_CALLOC, NULL, num_create);
}
}
- data_dst = CustomData_get_layer_n(cd_dst, data_type, idx_dst);
+ /* If dest is a derivedmesh, we do not want to overwrite cdlayers of org mesh! */
+ data_dst = dup_dst ? CustomData_duplicate_referenced_layer_n(cd_dst, data_type, num_create, idx_dst) :
+ CustomData_get_layer_n(cd_dst, data_type, idx_dst);
}
break;
case MDT_TOLAYERS_NAME:
@@ -542,7 +553,9 @@ bool ED_data_transfer_layersmapping_cdlayers(
CustomData_add_layer_named(cd_dst, data_type, CD_CALLOC, NULL, num_create, name);
idx_dst = CustomData_get_named_layer(cd_dst, data_type, name);
}
- data_dst = CustomData_get_layer_n(cd_dst, data_type, idx_dst);
+ /* If dest is a derivedmesh, we do not want to overwrite cdlayers of org mesh! */
+ data_dst = dup_dst ? CustomData_duplicate_referenced_layer_n(cd_dst, data_type, num_create, idx_dst) :
+ CustomData_get_layer_n(cd_dst, data_type, idx_dst);
}
break;
default:
@@ -559,7 +572,7 @@ bool ED_data_transfer_layersmapping_cdlayers(
memset(use_layers_src, true, sizeof(*use_layers_src) * num_src);
ret = data_transfer_layersmapping_cdlayers_multisrc_to_dst(r_map, data_type, mix_mode, mix_factor,
- num_create, cd_src, cd_dst,
+ num_create, cd_src, cd_dst, dup_dst,
tolayers_select, use_layers_src, num_src);
MEM_freeN(use_layers_src);
@@ -573,8 +586,8 @@ bool ED_data_transfer_layersmapping_cdlayers(
}
static bool data_transfer_layersmapping_generate(
- ListBase *r_map, Object *ob_src, Object *ob_dst, DerivedMesh *dm_src, Mesh *me_dst, const int elem_type,
- int data_type, int mix_mode, float mix_factor,
+ ListBase *r_map, Object *ob_src, Object *ob_dst, DerivedMesh *dm_src, DerivedMesh *dm_dst, Mesh *me_dst,
+ const int elem_type, int data_type, int mix_mode, float mix_factor,
const int num_create, const int fromlayers_select, const int tolayers_select)
{
CustomData *cd_src, *cd_dst;
@@ -582,15 +595,14 @@ static bool data_transfer_layersmapping_generate(
if (elem_type == ME_VERT) {
if (!(data_type & CD_FAKE)) {
cd_src = dm_src->getVertDataLayout(dm_src);
- cd_dst = &me_dst->vdata;
+ cd_dst = dm_dst ? dm_dst->getVertDataLayout(dm_dst) : &me_dst->vdata;
if (!CustomData_has_layer(cd_src, data_type)) {
return false;
}
- if (!ED_data_transfer_layersmapping_cdlayers(r_map, data_type, mix_mode, mix_factor,
- num_create, cd_src, cd_dst,
- fromlayers_select, tolayers_select))
+ if (!data_transfer_layersmapping_cdlayers(r_map, data_type, mix_mode, mix_factor, num_create, cd_src,
+ cd_dst, dm_dst != NULL, fromlayers_select, tolayers_select))
{
/* We handle specific source selection cases here. */
return false;
@@ -606,20 +618,27 @@ static bool data_transfer_layersmapping_generate(
if (!(dm_src->cd_flag & ME_CDFLAG_VERT_BWEIGHT)) {
return false;
}
- me_dst->cd_flag |= ME_CD
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list