[Bf-blender-cvs] [cdba2bc0fce] master: BKE mesh remap: add utils to add needed cddata mask for source mesh.

Bastien Montagne noreply at git.blender.org
Fri Mar 8 17:53:47 CET 2019


Commit: cdba2bc0fce86e814aaa5a969a018b5c1c9f8b3b
Author: Bastien Montagne
Date:   Fri Mar 8 11:45:00 2019 +0100
Branches: master
https://developer.blender.org/rBcdba2bc0fce86e814aaa5a969a018b5c1c9f8b3b

BKE mesh remap: add utils to add needed cddata mask for source mesh.

In some cases (currently, only when using avanced mapping of loops),
code needs access to some cddata of the source mesh (CD_NORMAL...).

We need a way to inform calling code about that (actual issue requiring
this change is fixed in next commit).

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

M	source/blender/blenkernel/BKE_mesh_remap.h
M	source/blender/blenkernel/intern/mesh_remap.c

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

diff --git a/source/blender/blenkernel/BKE_mesh_remap.h b/source/blender/blenkernel/BKE_mesh_remap.h
index 170ee9f0ccb..754e5b2cd05 100644
--- a/source/blender/blenkernel/BKE_mesh_remap.h
+++ b/source/blender/blenkernel/BKE_mesh_remap.h
@@ -22,6 +22,7 @@
  */
 
 struct CustomData;
+struct CustomData_MeshMasks;
 struct MVert;
 struct MemArena;
 struct Mesh;
@@ -136,6 +137,10 @@ enum {
 	MREMAP_MODE_TOPOLOGY                 = MREMAP_MODE_VERT | MREMAP_MODE_EDGE | MREMAP_MODE_LOOP | MREMAP_MODE_POLY,
 };
 
+void BKE_mesh_remap_calc_source_cddata_masks_from_map_modes(
+        const int vert_mode, const int edge_mode, const int loop_mode, const int poly_mode,
+        struct CustomData_MeshMasks *cddata_mask);
+
 float BKE_mesh_remap_calc_difference_from_mesh(
         const struct SpaceTransform *space_transform,
         const struct MVert *verts_dst, const int numverts_dst, struct Mesh *me_src);
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index ccb6265b17a..55e8a96fa16 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -303,6 +303,22 @@ void BKE_mesh_remap_find_best_match_from_mesh(
 /** \name Mesh to mesh mapping
  * \{ */
 
+void BKE_mesh_remap_calc_source_cddata_masks_from_map_modes(
+        const int UNUSED(vert_mode), const int UNUSED(edge_mode), const int loop_mode, const int UNUSED(poly_mode),
+        CustomData_MeshMasks *cddata_mask)
+{
+	/* vert, edge and poly mapping modes never need extra cddata from source object. */
+	const bool need_lnors_src = (loop_mode & MREMAP_USE_LOOP) && (loop_mode & MREMAP_USE_NORMAL);
+	const bool need_pnors_src = need_lnors_src || ((loop_mode & MREMAP_USE_POLY) && (loop_mode & MREMAP_USE_NORMAL));
+
+	if (need_lnors_src) {
+		cddata_mask->lmask |= CD_MASK_NORMAL;
+	}
+	if (need_pnors_src) {
+		cddata_mask->pmask |= CD_MASK_NORMAL;
+	}
+}
+
 void BKE_mesh_remap_init(MeshPairRemap *map, const int items_num)
 {
 	MemArena *mem = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);



More information about the Bf-blender-cvs mailing list