[Bf-blender-cvs] [fffff5a9931] blender2.8: Cleanup: nuke DM out of data transfer code.

Bastien Montagne noreply at git.blender.org
Thu Jun 21 15:33:35 CEST 2018


Commit: fffff5a9931931a5706fcd6de7743b3021bc09c2
Author: Bastien Montagne
Date:   Thu Jun 21 14:39:28 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBfffff5a9931931a5706fcd6de7743b3021bc09c2

Cleanup: nuke DM out of data transfer code.

This was actually rather hairy, this code is huge and complicated, easy
to make mistakes...

Good thing is, it will allow for significant simplification and more
(name) cleanup in following commits ;)

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

M	source/blender/blenkernel/BKE_data_transfer.h
M	source/blender/blenkernel/BKE_mesh_remap.h
M	source/blender/blenkernel/intern/data_transfer.c
M	source/blender/blenkernel/intern/mesh_remap.c
M	source/blender/modifiers/intern/MOD_datatransfer.c

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

diff --git a/source/blender/blenkernel/BKE_data_transfer.h b/source/blender/blenkernel/BKE_data_transfer.h
index 6559f9a954f..3186e4ffe06 100644
--- a/source/blender/blenkernel/BKE_data_transfer.h
+++ b/source/blender/blenkernel/BKE_data_transfer.h
@@ -145,7 +145,7 @@ bool BKE_object_data_transfer_mesh(
         struct ReportList *reports);
 bool BKE_object_data_transfer_dm(
         struct Depsgraph *depsgraph, struct Scene *scene,
-        struct Object *ob_src, struct Object *ob_dst, struct DerivedMesh *dm_dst,
+        struct Object *ob_src, struct Object *ob_dst, struct Mesh *dm_dst,
         const int data_types, bool use_create,
         const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode,
         struct SpaceTransform *space_transform, const bool auto_transform,
diff --git a/source/blender/blenkernel/BKE_mesh_remap.h b/source/blender/blenkernel/BKE_mesh_remap.h
index 5c77ab8a94e..3f520223d1b 100644
--- a/source/blender/blenkernel/BKE_mesh_remap.h
+++ b/source/blender/blenkernel/BKE_mesh_remap.h
@@ -26,7 +26,7 @@
  */
 
 struct CustomData;
-struct DerivedMesh;
+struct Mesh;
 struct MVert;
 struct MemArena;
 
@@ -142,10 +142,10 @@ enum {
 
 float BKE_mesh_remap_calc_difference_from_dm(
         const struct SpaceTransform *space_transform,
-        const struct MVert *verts_dst, const int numverts_dst, struct DerivedMesh *dm_src);
+        const struct MVert *verts_dst, const int numverts_dst, struct Mesh *dm_src);
 
 void BKE_mesh_remap_find_best_match_from_dm(
-        const struct MVert *verts_dst, const int numverts_dst, struct DerivedMesh *dm_src,
+        const struct MVert *verts_dst, const int numverts_dst, struct Mesh *dm_src,
         struct SpaceTransform *r_space_transform);
 
 /* TODO add mesh2mesh versions (we'll need mesh versions of bvhtree funcs too, though!). */
@@ -153,12 +153,12 @@ void BKE_mesh_remap_find_best_match_from_dm(
 void BKE_mesh_remap_calc_verts_from_dm(
         const int mode, const struct SpaceTransform *space_transform, const float max_dist, const float ray_radius,
         const struct MVert *verts_dst, const int numverts_dst, const bool dirty_nors_dst,
-        struct DerivedMesh *dm_src, MeshPairRemap *r_map);
+        struct Mesh *dm_src, MeshPairRemap *r_map);
 
 void BKE_mesh_remap_calc_edges_from_dm(
         const int mode, const struct SpaceTransform *space_transform, const float max_dist, const float ray_radius,
         const struct MVert *verts_dst, const int numverts_dst, const struct MEdge *edges_dst, const int numedges_dst,
-        const bool dirty_nors_dst, struct DerivedMesh *dm_src, MeshPairRemap *r_map);
+        const bool dirty_nors_dst, struct Mesh *dm_src, MeshPairRemap *r_map);
 
 void BKE_mesh_remap_calc_loops_from_dm(
         const int mode, const struct SpaceTransform *space_transform, const float max_dist, const float ray_radius,
@@ -166,13 +166,13 @@ void BKE_mesh_remap_calc_loops_from_dm(
         struct MLoop *loops_dst, const int numloops_dst, struct MPoly *polys_dst, const int numpolys_dst,
         struct CustomData *ldata_dst, struct CustomData *pdata_dst,
         const bool use_split_nors_dst, const float split_angle_dst, const bool dirty_nors_dst,
-        struct DerivedMesh *dm_src, const bool use_split_nors_src, const float split_angle_src,
+        struct Mesh *dm_src,
         MeshRemapIslandsCalc gen_islands_src, const float islands_precision_src, struct MeshPairRemap *r_map);
 
 void BKE_mesh_remap_calc_polys_from_dm(
         const int mode, const struct SpaceTransform *space_transform, const float max_dist, const float ray_radius,
         struct MVert *verts_dst, const int numverts_dst, struct MLoop *loops_dst, const int numloops_dst,
         struct MPoly *polys_dst, const int numpolys_dst, struct CustomData *pdata_dst, const bool dirty_nors_dst,
-        struct DerivedMesh *dm_src, struct MeshPairRemap *r_map);
+        struct Mesh *dm_src, struct MeshPairRemap *r_map);
 
 #endif  /* __BKE_MESH_REMAP_H__ */
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index 3639649eab5..208adf53bef 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -42,12 +42,10 @@
 #include "BLI_blenlib.h"
 #include "BLI_utildefines.h"
 
-#include "BKE_cdderivedmesh.h"
 #include "BKE_context.h"
 #include "BKE_customdata.h"
 #include "BKE_data_transfer.h"
 #include "BKE_deform.h"
-#include "BKE_DerivedMesh.h"
 #include "BKE_mesh.h"
 #include "BKE_mesh_mapping.h"
 #include "BKE_mesh_runtime.h"
@@ -257,77 +255,76 @@ int BKE_object_data_transfer_dttype_to_srcdst_index(const int dtdata_type)
 /* Generic pre/post processing, only used by custom loop normals currently. */
 
 static void data_transfer_dtdata_type_preprocess(
-        Object *UNUSED(ob_src), Object *UNUSED(ob_dst), DerivedMesh *dm_src, DerivedMesh *dm_dst, Mesh *me_dst,
-        const int dtdata_type, const bool dirty_nors_dst, const bool use_split_nors_src, const float split_angle_src)
+        Mesh *dm_src, Mesh *dm_dst,
+        const int dtdata_type, const bool dirty_nors_dst)
 {
 	if (dtdata_type == DT_TYPE_LNOR) {
 		/* Compute custom normals into regular loop normals, which will be used for the transfer. */
-		MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert;
-		const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert;
-		MEdge *edges_dst = dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge;
-		const int num_edges_dst = dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge;
-		MPoly *polys_dst = dm_dst ? dm_dst->getPolyArray(dm_dst) : me_dst->mpoly;
-		const int num_polys_dst = dm_dst ? dm_dst->getNumPolys(dm_dst) : me_dst->totpoly;
-		MLoop *loops_dst = dm_dst ? dm_dst->getLoopArray(dm_dst) : me_dst->mloop;
-		const int num_loops_dst = dm_dst ? dm_dst->getNumLoops(dm_dst) : me_dst->totloop;
-		CustomData *pdata_dst = dm_dst ? dm_dst->getPolyDataLayout(dm_dst) : &me_dst->pdata;
-		CustomData *ldata_dst = dm_dst ? dm_dst->getLoopDataLayout(dm_dst) : &me_dst->ldata;
-
-		const bool use_split_nors_dst = (me_dst->flag & ME_AUTOSMOOTH) != 0;
-		const float split_angle_dst = me_dst->smoothresh;
-
-		dm_src->calcLoopNormals(dm_src, use_split_nors_src, split_angle_src);
+		MVert *verts_dst = dm_dst->mvert;
+		const int num_verts_dst = dm_dst->totvert;
+		MEdge *edges_dst = dm_dst->medge;
+		const int num_edges_dst = dm_dst->totedge;
+		MPoly *polys_dst = dm_dst->mpoly;
+		const int num_polys_dst = dm_dst->totpoly;
+		MLoop *loops_dst = dm_dst->mloop;
+		const int num_loops_dst = dm_dst->totloop;
+		CustomData *pdata_dst = &dm_dst->pdata;
+		CustomData *ldata_dst = &dm_dst->ldata;
+
+		const bool use_split_nors_dst = (dm_dst->flag & ME_AUTOSMOOTH) != 0;
+		const float split_angle_dst = dm_dst->smoothresh;
+
+		BKE_mesh_calc_normals_split(dm_src);
+
+		float (*poly_nors_dst)[3];
+		float (*loop_nors_dst)[3];
+		short (*custom_nors_dst)[2] = CustomData_get_layer(ldata_dst, CD_CUSTOMLOOPNORMAL);
 
-		if (dm_dst) {
-			dm_dst->calcLoopNormals(dm_dst, use_split_nors_dst, split_angle_dst);
-		}
-		else {
-			float (*poly_nors_dst)[3];
-			float (*loop_nors_dst)[3];
-			short (*custom_nors_dst)[2] = CustomData_get_layer(ldata_dst, CD_CUSTOMLOOPNORMAL);
-
-			/* Cache poly nors into a temp CDLayer. */
-			poly_nors_dst = CustomData_get_layer(pdata_dst, CD_NORMAL);
-			if (dirty_nors_dst || !poly_nors_dst) {
-				if (!poly_nors_dst) {
-					poly_nors_dst = CustomData_add_layer(pdata_dst, CD_NORMAL, CD_CALLOC, NULL, num_polys_dst);
-					CustomData_set_layer_flag(pdata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
-				}
-				BKE_mesh_calc_normals_poly(verts_dst, NULL, num_verts_dst, loops_dst, polys_dst,
-				                           num_loops_dst, num_polys_dst, poly_nors_dst, true);
-			}
-			/* Cache loop nors into a temp CDLayer. */
-			loop_nors_dst = CustomData_get_layer(ldata_dst, CD_NORMAL);
-			if (dirty_nors_dst || loop_nors_dst) {
-				if (!loop_nors_dst) {
-					loop_nors_dst = CustomData_add_layer(ldata_dst, CD_NORMAL, CD_CALLOC, NULL, num_loops_dst);
-					CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
-				}
-				BKE_mesh_normals_loop_split(verts_dst, num_verts_dst, edges_dst, num_edges_dst,
-				                            loops_dst, loop_nors_dst, num_loops_dst,
-				                            polys_dst, (const float (*)[3])poly_nors_dst, num_polys_dst,
-				                            use_split_nors_dst, split_angle_dst, NULL, custom_nors_dst, NULL);
-			}
+		/* Cache poly nors into a temp CDLayer. */
+		poly_nors_dst = CustomData_get_layer(pdata_dst, CD_NORMAL);
+		const bool do_poly_nors_dst = (poly_nors_dst == NULL);
+		if (do_poly_nors_dst) {
+			poly_nors_dst = CustomData_add_layer(pdata_dst, CD_NORMAL, CD_CALLOC, NULL, num_polys_dst);
+			CustomData_set_layer_flag(pdata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
+		}
+		if (dirty_nors_dst || do_poly_nors_dst) {
+			BKE_mesh_calc_normals_poly(
+			            verts_dst, NULL, num_verts_dst, loops_dst, polys_dst,
+			            num_loops_dst, num_polys_dst, poly_nors_dst, true);
+		}
+		/* Cache loop nors into a temp CDLayer. */
+		loop_nors_dst = CustomData_get_layer(ldata_dst, CD_NORMAL);
+		const bool do_loop_nors_dst = (loop_nors_dst == NULL);
+		if (do_loop_nors_dst) {
+			loop_nors_dst = CustomData_add_layer(ldata_dst, CD_NORMAL, CD_CALLOC, NULL, num_loops_dst);
+			CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
+		}
+		if (dirty_nors_dst || do_loop_nors_dst) {
+			BKE_mesh_normals_loop_split(
+			            verts_dst, num_verts_dst, edges_dst, num_edges_dst,
+			            loops_dst, loop_nors_dst, num_loops_dst,
+			            polys_dst, (const float (*)[3])poly_nors_dst, num_polys_dst,
+			            use_split_nors_dst, split_angle_dst, NULL, custom_nors_dst, NULL);
 		}
 	}
 }
 
 static void data_transfer_dtdata_type_postprocess(
-        Object *UNUSED(ob_src), Object *UNUSED(ob_dst), DerivedMesh *UNUSED(dm_src), DerivedMesh *dm_dst, Mesh *me_dst,
+        Object *UNUSED(ob_src), Object *UNUSED(ob_dst), Mesh *UNUSED(dm_src), Mesh *dm_dst, Mesh *me_dst,
         const int dtdata_type, const b

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list