[Bf-blender-cvs] [c5f52f87d0c] temp-fracture-modifier-2.8: added dynamic shard count setting, to decouple from prefractured

Martin Felke noreply at git.blender.org
Sat Nov 24 14:00:50 CET 2018


Commit: c5f52f87d0cfd0e3529cb1302c646d90a1eafb32
Author: Martin Felke
Date:   Sat Nov 24 14:00:36 2018 +0100
Branches: temp-fracture-modifier-2.8
https://developer.blender.org/rBc5f52f87d0cfd0e3529cb1302c646d90a1eafb32

added dynamic shard count setting, to decouple from prefractured

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

M	release/scripts/startup/bl_ui/properties_physics_fracture.py
M	source/blender/blenkernel/BKE_rigidbody.h
M	source/blender/blenkernel/intern/fracture.c
M	source/blender/blenkernel/intern/fracture_prefractured.c
M	source/blender/blenkernel/intern/fracture_rigidbody.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_fracture.c
M	source/blender/modifiers/intern/MOD_fracture.c

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_fracture.py b/release/scripts/startup/bl_ui/properties_physics_fracture.py
index 4ee94a798c2..db1f16ca2a1 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fracture.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py
@@ -123,6 +123,8 @@ class PHYSICS_PT_fracture_dynamic(PhysicButtonsPanel, Panel):
           layout = self.layout
           layout.active = md.use_dynamic
           row = layout.row(align=True)
+          row.prop(md, "dynamic_shard_count")
+          row = layout.row(align=True)
           row.prop(md, "dynamic_force")
           row.prop(md, "dynamic_percentage")
           col = layout.column(align=True)
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index 00521e1bd1b..9e47f71c203 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -146,7 +146,7 @@ struct MeshIsland* BKE_rigidbody_closest_meshisland_to_point(struct FractureModi
                                                              struct Object *ob2, struct Scene* scene);
 
 int BKE_rigidbody_filter_callback(void* scene, void* island1, void* island2, void *blenderOb1, void* blenderOb2, bool activate);
-void BKE_rigidbody_contact_callback(struct rbContactPoint* cp, void* world);
+void BKE_rigidbody_contact_callback(struct rbContactPoint* cp, void* sc);
 void BKE_rigidbody_id_callback(void* island, int* objectId, int* islandId);
 
 bool BKE_rigidbody_modifier_active(struct FractureModifierData *rmd);
diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index 42ea59e51ee..eb5d5d668a5 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -2202,7 +2202,7 @@ FracPointCloud BKE_fracture_points_get(Depsgraph *depsgraph, FractureModifierDat
 	if ((emd->point_source & MOD_FRACTURE_UNIFORM) || (emd->use_dynamic))
 	{
 		float cent[3] = {0, 0, 0}, bmin[3], bmax[3];
-		int count = emd->shard_count;
+		int count = emd->use_dynamic ? emd->dynamic_shard_count : emd->shard_count;
 
 		INIT_MINMAX(min, max);
 		//for limit impact we need entire container always, because we need to determine secondary impacts on the shards at their original pos
@@ -3218,24 +3218,6 @@ static void do_island_index_map(FractureModifierData *fmd, Object* obj)
 	}
 }
 
-#if 0
-Mesh *BKE_fracture_mesh_from_packdata(FractureModifierData *fmd, Mesh *derivedData)
-{
-	Mesh *dm = NULL;
-
-	/* keep old way of using dynamic external working as well, without interfering with packing */
-	if (fmd->shared->pack_storage.first && !fmd->is_dynamic_external)
-	{
-		dm = BKE_fracture_assemble_mesh_from_islands(fmd, );
-	}
-	else {
-		dm = derivedData;
-	}
-
-	return dm;
-}
-#endif
-
 Mesh* BKE_fracture_mesh_copy(Mesh* source, Object* ob)
 {
 	Mesh* me = BKE_mesh_new_nomain(source->totvert,
diff --git a/source/blender/blenkernel/intern/fracture_prefractured.c b/source/blender/blenkernel/intern/fracture_prefractured.c
index c8a2985d823..399ce6cad5b 100644
--- a/source/blender/blenkernel/intern/fracture_prefractured.c
+++ b/source/blender/blenkernel/intern/fracture_prefractured.c
@@ -212,6 +212,9 @@ Mesh* BKE_fracture_apply(FractureModifierData *fmd, Object *ob, Mesh *me_orig, D
 		/*free old stuff here */
 		BKE_fracture_constraints_free(fmd, scene);
 
+		int dynamic = fmd->use_dynamic;
+		fmd->use_dynamic = false;
+
 		/*keep shards at packing and at dynamic refresh */
 		if (fmd->dm_group)
 		{
@@ -227,6 +230,8 @@ Mesh* BKE_fracture_apply(FractureModifierData *fmd, Object *ob, Mesh *me_orig, D
 			}
 		}
 
+		fmd->use_dynamic = dynamic;
+
 		fmd->shared->refresh_constraints = true;
 		fmd->shared->refresh_autohide = true;
 		//fmd->shared->reset_shards = false;
diff --git a/source/blender/blenkernel/intern/fracture_rigidbody.c b/source/blender/blenkernel/intern/fracture_rigidbody.c
index 8e32ce8500b..6d86e3bb0f6 100644
--- a/source/blender/blenkernel/intern/fracture_rigidbody.c
+++ b/source/blender/blenkernel/intern/fracture_rigidbody.c
@@ -1509,10 +1509,14 @@ static void check_fracture(rbContactPoint* cp, Scene *scene)
 	cp = NULL;
 }
 
-void BKE_rigidbody_contact_callback(rbContactPoint* cp, void* world)
+static ThreadMutex dynamic_lock = BLI_MUTEX_INITIALIZER;
+void BKE_rigidbody_contact_callback(rbContactPoint* cp, void* sc)
 {
-	Scene* scene = (Scene*)DEG_get_original_id(world);
+	Scene* scene = (Scene*)DEG_get_original_id(sc);
+
+	BLI_mutex_lock(&dynamic_lock);
 	check_fracture(cp,scene);
+	BLI_mutex_unlock(&dynamic_lock);
 }
 
 void BKE_rigidbody_id_callback(void* island, int* objectId, int* islandId)
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 777a09a17a5..8ef685ba9a1 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1603,7 +1603,7 @@ typedef struct FractureModifierData {
 	int grease_decimate;
 	int cutter_axis;
 	int cluster_constraint_type;
-	//int fracture_mode;
+	int dynamic_shard_count;
 	int dynamic_percentage;
 	int constraint_type;
 	int grid_resolution[3];
@@ -1694,7 +1694,7 @@ typedef struct FractureModifierData {
 	short mat_ofs_intersect;
 	short mat_ofs_difference;
 
-	//char pad[4];
+	char pad[4];
 } FractureModifierData;
 
 typedef struct DataTransferModifierData {
diff --git a/source/blender/makesrna/intern/rna_fracture.c b/source/blender/makesrna/intern/rna_fracture.c
index 69f851ce199..60e476e80e6 100644
--- a/source/blender/makesrna/intern/rna_fracture.c
+++ b/source/blender/makesrna/intern/rna_fracture.c
@@ -1468,6 +1468,13 @@ void RNA_def_fracture(BlenderRNA *brna)
 	RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 0.1f, 2);
 	RNA_def_property_update(prop, noteflag, "rna_Modifier_update");
 
+	prop = RNA_def_property(srna, "dynamic_shard_count", PROP_INT, PROP_NONE);
+	RNA_def_property_range(prop, 1, 100000);
+	RNA_def_property_int_default(prop, 10);
+	RNA_def_property_ui_text(prop, "Dynamic Shard Count",
+	                         "How many sub-shards should be generated from the current shard dynamically");
+	//RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+	//RNA_def_property_update(prop, noteflag, "rna_Modifier_update");
 
 	RNA_api_fracture(brna, subrna);
 }
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index 0b3c0dc32b1..16c27d0d69f 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -165,6 +165,7 @@ static void initData(ModifierData *md)
 
 	fmd->dynamic_activation_size = 1.0f;
 	fmd->contact_size = 0.0f;
+	fmd->dynamic_shard_count = 10;
 
 	if (!fmd->shared) {
 		fmd->shared = MEM_callocN(sizeof(FractureModifierData_Shared), "FractureModifierData_Shared");



More information about the Bf-blender-cvs mailing list