[Bf-blender-cvs] [8ebe58dc1d2] temp-fracture-modifier-2.8: put FM storage contents into cow-shared struct

Martin Felke noreply at git.blender.org
Fri Aug 10 14:00:43 CEST 2018


Commit: 8ebe58dc1d2c10f2a00b920b79dcc34f5fbc1992
Author: Martin Felke
Date:   Thu Aug 9 01:13:37 2018 +0200
Branches: temp-fracture-modifier-2.8
https://developer.blender.org/rB8ebe58dc1d2c10f2a00b920b79dcc34f5fbc1992

put FM storage contents into cow-shared struct

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

M	source/blender/blenkernel/BKE_fracture.h
M	source/blender/blenkernel/intern/fracture.c
M	source/blender/blenkernel/intern/fracture_automerge.c
M	source/blender/blenkernel/intern/fracture_constraints.c
M	source/blender/blenkernel/intern/fracture_dynamic.c
M	source/blender/blenkernel/intern/fracture_external.c
M	source/blender/blenkernel/intern/fracture_prefractured.c
M	source/blender/blenkernel/intern/fracture_rigidbody.c
M	source/blender/blenkernel/intern/fracture_util.c
M	source/blender/blenkernel/intern/rigidbody.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/depsgraph/DEG_depsgraph_query.h
M	source/blender/depsgraph/intern/depsgraph_query_iter.cc
M	source/blender/editors/object/object_modifier.c
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/makesdna/DNA_fracture_types.h
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesdna/intern/makesdna.c
M	source/blender/makesrna/intern/rna_fracture.c
M	source/blender/makesrna/intern/rna_fracture_api.c
M	source/blender/makesrna/intern/rna_rigidbody.c
M	source/blender/modifiers/intern/MOD_fracture.c

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

diff --git a/source/blender/blenkernel/BKE_fracture.h b/source/blender/blenkernel/BKE_fracture.h
index 47897b7d979..13ff5fda799 100644
--- a/source/blender/blenkernel/BKE_fracture.h
+++ b/source/blender/blenkernel/BKE_fracture.h
@@ -191,4 +191,9 @@ struct Mesh *BKE_fracture_prefractured_do(struct FractureModifierData *fmd, stru
                                           struct Mesh *orig_dm, char names [][66], int count, struct Scene* scene,
 										  struct Depsgraph *depsgraph);
 
+struct Mesh* BKE_fracture_mesh_copy(struct Mesh* source, struct Object* ob);
+struct BMesh* BKE_fracture_mesh_to_bmesh(struct Mesh* me);
+struct Mesh* BKE_fracture_bmesh_to_mesh(struct BMesh* bm);
+
+
 #endif /* BKE_FRACTURE_H */
diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index 44ad9115db0..a28110789e7 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -70,6 +70,7 @@
 #include "DNA_modifier_types.h"
 #include "DNA_rigidbody_types.h"
 
+#include "DNA_object_types.h"
 #include "DEG_depsgraph_query.h"
 
 #include "bmesh.h"
@@ -87,6 +88,60 @@
 #include "../../../../extern/voro++/src/c_interface.hh"
 #endif
 
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_callbacks.h"
+#include "BLI_edgehash.h"
+#include "BLI_ghash.h"
+#include "BLI_kdtree.h"
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_math_matrix.h"
+#include "BLI_math_vector.h"
+#include "BLI_rand.h"
+#include "BLI_utildefines.h"
+#include "BLI_string.h"
+#include "BLI_threads.h"
+
+
+#include "BKE_cdderivedmesh.h"
+#include "BKE_deform.h"
+#include "BKE_fracture.h"
+#include "BKE_global.h"
+#include "BKE_collection.h"
+#include "BKE_library.h"
+#include "BKE_library_query.h"
+#include "BKE_main.h"
+#include "BKE_material.h"
+#include "BKE_modifier.h"
+#include "BKE_object.h"
+#include "BKE_particle.h"
+#include "BKE_pointcache.h"
+#include "BKE_rigidbody.h"
+#include "BKE_scene.h"
+#include "BKE_mesh.h"
+#include "BKE_curve.h"
+#include "BKE_multires.h"
+
+#include "bmesh.h"
+
+#include "DNA_fracture_types.h"
+#include "DNA_gpencil_types.h"
+#include "DNA_group_types.h"
+#include "DNA_listBase.h"
+#include "DNA_material_types.h"
+#include "DNA_object_types.h"
+#include "DNA_particle_types.h"
+#include "DNA_rigidbody_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_curve_types.h"
+
+#include "../../rigidbody/RBI_api.h"
+#include "PIL_time.h"
+#include "../../bmesh/tools/bmesh_decimate.h" /* decimate_dissolve function */
+#include "limits.h"
+
 /* prototypes */
 static Shard *parse_cell(cell c);
 static void parse_cell_verts(cell c, MVert *mvert, int totvert);
@@ -120,12 +175,8 @@ static BMesh* fracture_shard_to_bmesh(Shard *s)
 	BMIter iter;
 	BMFace *f;
 
-	struct BMeshCreateParams bmc = {.use_toolflags = true};
-	struct BMeshFromMeshParams bme = { .calc_face_normal = true};
-
-	bm_parent = BM_mesh_create(&bm_mesh_allocsize_default, &bmc);
 	dm_parent = BKE_fracture_shard_to_mesh(s, true);
-	BM_mesh_bm_from_me(bm_parent, dm_parent, &bme);
+	bm_parent = BKE_fracture_mesh_to_bmesh(dm_parent);
 
 	BM_mesh_elem_table_ensure(bm_parent, BM_VERT | BM_FACE);
 
@@ -696,7 +747,7 @@ static void handle_boolean_fractal(Shard* t, int expected_shards, Mesh* dm_paren
 
 	/*continue with "halves", randomly*/
 	if ((*i) == 0) {
-		BKE_mesh_nomain_to_mesh(dm_parent, *dm_p, obj, CD_MASK_MESH, false);
+		*dm_p = BKE_fracture_mesh_copy(dm_parent, obj);
 	}
 
 	while (s == NULL || s2 == NULL) {
@@ -997,10 +1048,10 @@ static void do_prepare_cells(FracMesh *fm, cell *cells, int expected_shards, int
 
 	if (override_count > -1) {
 		printf("Deleting island shards!\n");
-		while (fmd->islandShards.first) {
-			Shard *sh = fmd->islandShards.first;
+		while (fmd->shared->islandShards.first) {
+			Shard *sh = fmd->shared->islandShards.first;
 			if (sh) {
-				BLI_remlink_safe(&fmd->islandShards, sh);
+				BLI_remlink_safe(&fmd->shared->islandShards, sh);
 				BKE_fracture_shard_free(sh, false);
 			}
 		}
@@ -1517,7 +1568,7 @@ static void do_intersect(FractureModifierData *fmd, Object* ob, Shard *t, short
 	int shards = 0, j = 0;
 
 	if (is_zero == false && *dm_parent == NULL) {
-		parent = BLI_findlink(&fmd->frac_mesh->shard_map, k);
+		parent = BLI_findlink(&fmd->shared->frac_mesh->shard_map, k);
 		*dm_parent = BKE_fracture_shard_to_mesh(parent, true);
 	}
 
@@ -1543,7 +1594,7 @@ static void do_intersect(FractureModifierData *fmd, Object* ob, Shard *t, short
 		if (s != NULL) {
 			fracture_shard_vgroup_add(s, ob, "Intersect");
 			fracture_shard_material_add(s, ob, fmd->mat_ofs_intersect);
-			fracture_shard_add(fmd->frac_mesh, s, mat);
+			fracture_shard_add(fmd->shared->frac_mesh, s, mat);
 			shards++;
 			s = NULL;
 		}
@@ -1553,7 +1604,7 @@ static void do_intersect(FractureModifierData *fmd, Object* ob, Shard *t, short
 		if (s2 != NULL) {
 			fracture_shard_vgroup_add(s2, ob, "Difference");
 			fracture_shard_material_add(s2, ob, fmd->mat_ofs_difference);
-			fracture_shard_add(fmd->frac_mesh, s2, mat);
+			fracture_shard_add(fmd->shared->frac_mesh, s2, mat);
 			shards++;
 			s2 = NULL;
 		}
@@ -1603,17 +1654,17 @@ static void intersect_shards_by_dm(FractureModifierData *fmd, Mesh *d, Object *o
 		mul_m4_v3(imat, mv->co);
 	}
 
-	count = fmd->frac_mesh->shard_count;
+	count = fmd->shared->frac_mesh->shard_count;
 
 	/*TODO, pass modifier mesh here !!! */
 	if (count == 0 && keep_other_shard) {
 
 		if (ob->runtime.mesh_eval != NULL) {
-			BKE_mesh_nomain_to_mesh(ob->runtime.mesh_eval, dm_parent, ob, CD_MASK_MESH, false);
+			dm_parent = BKE_fracture_mesh_copy(ob->runtime.mesh_eval, ob);
 		}
 
 		if (dm_parent == NULL) {
-			BKE_mesh_nomain_to_mesh(ob->data, dm_parent, ob, CD_MASK_MESH, false);
+			dm_parent = BKE_fracture_mesh_copy(ob->data, ob);
 		}
 
 		count = 1;
@@ -1635,14 +1686,14 @@ static void intersect_shards_by_dm(FractureModifierData *fmd, Mesh *d, Object *o
 			if (keep_other_shard)
 			{
 				/*clean up old entries here to avoid unnecessary shards*/
-				Shard *first = fmd->frac_mesh->shard_map.first;
-				BLI_remlink_safe(&fmd->frac_mesh->shard_map,first);
+				Shard *first = fmd->shared->frac_mesh->shard_map.first;
+				BLI_remlink_safe(&fmd->shared->frac_mesh->shard_map,first);
 				BKE_fracture_shard_free(first, true);
 				first = NULL;
 			}
 
 			/* keep asynchronous by intent, to keep track of original shard count */
-			fmd->frac_mesh->shard_count--;
+			fmd->shared->frac_mesh->shard_count--;
 		}
 	}
 
@@ -1656,7 +1707,7 @@ static void reset_shards(FractureModifierData *fmd)
 {
 	if (fmd->fracture_mode == MOD_FRACTURE_PREFRACTURED && fmd->reset_shards)
 	{
-		FracMesh *fm = fmd->frac_mesh;
+		FracMesh *fm = fmd->shared->frac_mesh;
 		while (fm && fm->shard_map.first)
 		{
 			Shard *t = fm->shard_map.first;
@@ -1688,12 +1739,11 @@ void BKE_fracture_shard_by_greasepencil(FractureModifierData *fmd, Object *obj,
 			for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
 				for (gps = gpf->strokes.first; gps; gps = gps->next) {
 					BMesh *bm = BM_mesh_create(&bm_mesh_allocsize_default, &((struct BMeshCreateParams){.use_toolflags = true,}));
-					Mesh *dm = NULL;
-					struct BMeshToMeshParams bmt = {.calc_object_remap = 0};
+					Mesh *dm;
 
 					/*create stroke mesh */
 					stroke_to_faces(fmd, &bm, gps, inner_material_index);
-					BM_mesh_bm_to_me(NULL, bm, dm, &bmt);
+					dm = BKE_fracture_bmesh_to_mesh(bm);
 #if 0
 					{
 						/*create debug mesh*/
@@ -1735,16 +1785,16 @@ void BKE_fracture_shard_by_planes(FractureModifierData *fmd, Object *obj, short
 			if (ob->type == OB_MESH) {
 
 				FractureModifierData *fmd2 = (FractureModifierData*)modifiers_findByType(ob, eModifierType_Fracture);
-				if (fmd2 && BLI_listbase_count(&fmd2->meshIslands) > 0)
+				if (fmd2 && BLI_listbase_count(&fmd2->shared->meshIslands) > 0)
 				{
 					MeshIsland* mi = NULL;
 					int j = 0;
-					for (mi = fmd2->meshIslands.first; mi; mi = mi->next)
+					for (mi = fmd2->shared->meshIslands.first; mi; mi = mi->next)
 					{
 						Mesh *dm;
 						MVert *mv, *v = NULL;
 
-						BKE_mesh_nomain_to_mesh(mi->physics_mesh, dm, ob, CD_MASK_MESH, false);
+						dm = BKE_fracture_mesh_copy(mi->physics_mesh, ob);
 						mv = dm->mvert;
 						int totvert = dm->totvert;
 						int i = 0;
@@ -1763,18 +1813,18 @@ void BKE_fracture_shard_by_planes(FractureModifierData *fmd, Object *obj, short
 					}
 
 					/*now delete first shards, those are the old ones */
-					while (fmd->frac_mesh->shard_count > 0)
+					while (fmd->shared->frac_mesh->shard_count > 0)
 					{
 						/*clean up old entries here to avoid unnecessary shards*/
-						Shard *first = fmd->frac_mesh->shard_map.first;
-						BLI_remlink_safe(&fmd->frac_mesh->shard_map,first);
+						Shard *first = fmd->shared->frac_mesh->shard_map.first;
+						BLI_remlink_safe(&fmd->shared->frac_mesh->shard_map,first);
 						BKE_fracture_shard_free(first, true);
 						first = NULL;
-						fmd->frac_mesh->shard_count--;
+						fmd->shared->frac_mesh->shard_count--;
 					}
 
 					/* re-synchronize counts, was possibly different before */
-					fmd->frac_mesh->shard_count = BLI_listbase_count(&fmd->frac_mesh->shard_map);
+					fmd->shared->frac_mesh->shard_count = BLI_listbase_count(&fmd->shared->frac_mesh->shard_map);
 				}
 				else
 				{
@@ -1884,13 +1934,13 @@ void BKE_fracture_shard_by_points(FractureModifierData *fmd, ShardID id, FracPoi
 	double time_start;
 #endif
 
-	shard = BKE_shard_by_id(fmd->frac_mesh, id, dm);
+	shard = BKE_shard_by_id(fmd->shared->frac_mesh, id, dm);
 	if (!shard || (shard->flag & SHARD_FRACTURED && (fmd->fracture_mode == MOD_FRACTURE_DYNAMIC))) {
 		int val = fmd->shards_to_islands ? -1 : 0;
 		if (id == val)
 		{
 			//fallback to entire mesh
-			shard = BKE_shard_by_id(fmd->frac_mesh, -1 , dm);
+			shard = BKE_shard_by_id(fmd->shared->frac_mesh, -1 , dm);
 		}
 		else
 		{
@@ -1999,7 +2049,8 @@ void BKE_fracture_shard_by_points(FractureModifierData *fmd, ShardID id, FracPoi
 		for (i = 0; i < num; i++) {
 			//give each task a segment of the shards...
 			int startcell = i * totcell;
-			FractureData fd = segment_cells(voro_cells, startcell, totcell, fmd->frac_mesh, id, fmd->frac_algorithm, obj, dm, 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list