[Bf-blender-cvs] [737a982] mesh-transfer-data: Minor changes, nothing really new here.

Bastien Montagne noreply at git.blender.org
Sun Oct 19 17:07:47 CEST 2014


Commit: 737a982f1fd37569d6aa82a9312f232b079eca34
Author: Bastien Montagne
Date:   Sun Oct 19 17:01:33 2014 +0200
Branches: mesh-transfer-data
https://developer.blender.org/rB737a982f1fd37569d6aa82a9312f232b079eca34

Minor changes, nothing really new here.

===================================================================

M	source/blender/blenkernel/BKE_mesh_mapping.h
M	source/blender/blenkernel/intern/mesh_mapping.c
M	source/blender/editors/object/object_transfer_data.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h
index bb783da..521dc4f 100644
--- a/source/blender/blenkernel/BKE_mesh_mapping.h
+++ b/source/blender/blenkernel/BKE_mesh_mapping.h
@@ -191,6 +191,8 @@ typedef struct Mesh2MeshMapping {
 void BKE_mesh2mesh_mapping_init(Mesh2MeshMapping *map, const int num_items);
 void BKE_mesh2mesh_mapping_free(Mesh2MeshMapping *map);
 
+void BKE_mesh2mesh_mapping_item_define_invalid(Mesh2MeshMapping *map, const int idx);
+
 /* TODO:
  * Add other 'from/to' mapping sources, like e.g. using an UVMap, etc.
  *     http://blenderartists.org/forum/showthread.php?346458-Move-Vertices-to-the-location-of-the-Reference-Mesh-based-on-the-UV-Position
diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c
index 322373b..ee4076f 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.c
+++ b/source/blender/blenkernel/intern/mesh_mapping.c
@@ -759,6 +759,11 @@ static void bke_mesh2mesh_mapping_item_define(
 	mapit->island = island;
 }
 
+void BKE_mesh2mesh_mapping_item_define_invalid(Mesh2MeshMapping *map, const int idx)
+{
+	bke_mesh2mesh_mapping_item_define(map, idx, FLT_MAX, 0, 0, NULL, NULL);
+}
+
 static int bke_mesh2mesh_mapping_get_interp_poly_data(
         const MPoly *mp, MLoop *mloops, const float (*vcos_src)[3], const float point[3],
         size_t *buff_size, float (**vcos)[3], const bool use_loops, int **indices, float **weights,
@@ -896,7 +901,7 @@ void BKE_dm2mesh_mapping_verts_compute(
 				}
 				else {
 					/* No source for this dest vertex! */
-					bke_mesh2mesh_mapping_item_define(r_map, i, FLT_MAX, 0, 0, NULL, NULL);
+					BKE_mesh2mesh_mapping_item_define_invalid(r_map, i);
 				}
 			}
 		}
@@ -944,7 +949,7 @@ void BKE_dm2mesh_mapping_verts_compute(
 				}
 				else {
 					/* No source for this dest vertex! */
-					bke_mesh2mesh_mapping_item_define(r_map, i, FLT_MAX, 0, 0, NULL, NULL);
+					BKE_mesh2mesh_mapping_item_define_invalid(r_map, i);
 				}
 			}
 
@@ -988,7 +993,7 @@ void BKE_dm2mesh_mapping_verts_compute(
 					}
 					else {
 						/* No source for this dest vertex! */
-						bke_mesh2mesh_mapping_item_define(r_map, i, FLT_MAX, 0, 0, NULL, NULL);
+						BKE_mesh2mesh_mapping_item_define_invalid(r_map, i);
 					}
 				}
 			}
@@ -1027,7 +1032,7 @@ void BKE_dm2mesh_mapping_verts_compute(
 					}
 					else {
 						/* No source for this dest vertex! */
-						bke_mesh2mesh_mapping_item_define(r_map, i, FLT_MAX, 0, 0, NULL, NULL);
+						BKE_mesh2mesh_mapping_item_define_invalid(r_map, i);
 					}
 				}
 			}
@@ -1179,7 +1184,7 @@ void BKE_dm2mesh_mapping_edges_compute(
 				}
 				else {
 					/* No source for this dest edge! */
-					bke_mesh2mesh_mapping_item_define(r_map, i, FLT_MAX, 0, 0, NULL, NULL);
+					BKE_mesh2mesh_mapping_item_define_invalid(r_map, i);
 				}
 			}
 
@@ -1205,7 +1210,7 @@ void BKE_dm2mesh_mapping_edges_compute(
 				}
 				else {
 					/* No source for this dest edge! */
-					bke_mesh2mesh_mapping_item_define(r_map, i, FLT_MAX, 0, 0, NULL, NULL);
+					BKE_mesh2mesh_mapping_item_define_invalid(r_map, i);
 				}
 			}
 		}
@@ -1256,7 +1261,7 @@ void BKE_dm2mesh_mapping_edges_compute(
 				}
 				else {
 					/* No source for this dest edge! */
-					bke_mesh2mesh_mapping_item_define(r_map, i, FLT_MAX, 0, 0, NULL, NULL);
+					BKE_mesh2mesh_mapping_item_define_invalid(r_map, i);
 				}
 			}
 
@@ -1348,7 +1353,7 @@ void BKE_dm2mesh_mapping_edges_compute(
 				}
 				else {
 					/* No source for this dest edge! */
-					bke_mesh2mesh_mapping_item_define(r_map, i, FLT_MAX, 0, 0, NULL, NULL);
+					BKE_mesh2mesh_mapping_item_define_invalid(r_map, i);
 				}
 			}
 
@@ -1426,7 +1431,7 @@ void BKE_dm2mesh_mapping_polys_compute(
 				}
 				else {
 					/* No source for this dest poly! */
-					bke_mesh2mesh_mapping_item_define(r_map, i, FLT_MAX, 0, 0, NULL, NULL);
+					BKE_mesh2mesh_mapping_item_define_invalid(r_map, i);
 				}
 			}
 		}
@@ -1449,7 +1454,7 @@ void BKE_dm2mesh_mapping_polys_compute(
 				}
 				else {
 					/* No source for this dest vertex! */
-					bke_mesh2mesh_mapping_item_define(r_map, i, FLT_MAX, 0, 0, NULL, NULL);
+					BKE_mesh2mesh_mapping_item_define_invalid(r_map, i);
 				}
 			}
 		}
@@ -1578,7 +1583,7 @@ void BKE_dm2mesh_mapping_polys_compute(
 				}
 				else {
 					/* No source for this dest poly! */
-					bke_mesh2mesh_mapping_item_define(r_map, i, FLT_MAX, 0, 0, NULL, NULL);
+					BKE_mesh2mesh_mapping_item_define_invalid(r_map, i);
 				}
 			}
 
@@ -1981,7 +1986,7 @@ void BKE_dm2mesh_mapping_loops_compute(
 
 					if (best_island_idx < 0) {
 						/* No source for any loops of our dest poly in any source islands. */
-						bke_mesh2mesh_mapping_item_define(r_map, lidx_dst, FLT_MAX, 0, 0, NULL, NULL);
+						BKE_mesh2mesh_mapping_item_define_invalid(r_map, lidx_dst);
 						continue;
 					}
 
diff --git a/source/blender/editors/object/object_transfer_data.c b/source/blender/editors/object/object_transfer_data.c
index eb944ce..0f27a33 100644
--- a/source/blender/editors/object/object_transfer_data.c
+++ b/source/blender/editors/object/object_transfer_data.c
@@ -300,6 +300,20 @@ static void data_transfer_interp_char(const DataTransferLayerMapping *UNUSED(lay
 	*data_dst = (char)(weight_dst * 255.0f);
 }
 
+static void data_transfer_mesh_mapping_filter(Object *ob_dst, Mesh2MeshMapping *geom_map, const int data_type,
+                                              const int replace_mode, const float replace_threshold)
+{
+	/* TODO!
+	 * geometry mapping filtering/post-process.
+	 * In addition to using threshold value (for things like vgroups, colors, creases, etc.) to exclude some
+	 * elements (by making them map to nothing), we may also want to:
+	 * * add more exclude ways (maybe a vgroup-based one?).
+	 * * add further postprocess on mapping in some cases (thinking about loop UVs here, especially in case of normal
+	 *   mapping and with islands, many dest loops may end with no source, while others of the same poly have some.
+	 *   this might be better tackled in mapping computation itself, though.
+	 */
+}
+
 /* Helpers to match sources and destinations data layers (also handles 'conversions' in CD_FAKE cases). */
 
 void data_transfer_layersmapping_add_item(
@@ -704,7 +718,7 @@ bool ED_data_transfer(
 		BKE_dm2mesh_mapping_verts_compute(map_vert_mode, space_transform, max_distance, ray_radius,
 		                                  me_dst->mvert, me_dst->totvert, dm_src, &geom_map);
 
-		/* TODO add further filtering of mapping data here! */
+		data_transfer_mesh_mapping_filter(me_dst, &geom_map, data_type, replace_mode, replace_threshold);
 
 		if (data_transfer_layersmapping_generate(&lay_map, ob_src, ob_dst, dm_src, me_dst, ME_VERT, data_type,
 		                                         num_create, fromlayers_select, tolayers_select))
@@ -727,7 +741,7 @@ bool ED_data_transfer(
 		                                  me_dst->mvert, me_dst->totvert, me_dst->medge, me_dst->totedge,
 		                                  dm_src, &geom_map);
 
-		/* TODO add further filtering of mapping data here! */
+		data_transfer_mesh_mapping_filter(me_dst, &geom_map, data_type, replace_mode, replace_threshold);
 
 		if (data_transfer_layersmapping_generate(&lay_map, ob_src, ob_dst, dm_src, me_dst, ME_EDGE, data_type,
 		                                         num_create, fromlayers_select, tolayers_select))
@@ -750,7 +764,7 @@ bool ED_data_transfer(
 		                                  me_dst->mvert, me_dst->totvert, me_dst->mpoly, me_dst->totpoly,
 		                                  me_dst->mloop, me_dst->totloop, &me_dst->pdata, dm_src, &geom_map);
 
-		/* TODO add further filtering of mapping data here! */
+		data_transfer_mesh_mapping_filter(me_dst, &geom_map, data_type, replace_mode, replace_threshold);
 
 		if (data_transfer_layersmapping_generate(&lay_map, ob_src, ob_dst, dm_src, me_dst, ME_POLY, data_type,
 		                                         num_create, fromlayers_select, tolayers_select))
@@ -777,7 +791,7 @@ bool ED_data_transfer(
 		                                  &me_dst->pdata, &me_dst->ldata, me_dst->smoothresh, dm_src,
 		                                  island_callback, &geom_map);
 
-		/* TODO add further filtering of mapping data here! */
+		data_transfer_mesh_mapping_filter(me_dst, &geom_map, data_type, replace_mode, replace_threshold);
 
 		if (data_transfer_layersmapping_generate(&lay_map, ob_src, ob_dst, dm_src, me_dst, ME_LOOP, data_type,
 		                                         num_create, fromlayers_select, tolayers_select))




More information about the Bf-blender-cvs mailing list