[Bf-blender-cvs] [ee936bc] fracture_modifier: added new setting for fracturing with particle sources, in most cases you want to use the particle birth coordinates as pointsource, but you can override this to get the coordinates of the current particle simulation state. But as the particle cache is kinda broken and shows wrong positions at beginning if simulation has been run before, this can lead to errors. Best practice is to keep this option enabled, only disable if you really need to !

Martin Felke noreply at git.blender.org
Wed Oct 8 13:02:43 CEST 2014


Commit: ee936bc922a00548227d4472926c4c37f11a1b9f
Author: Martin Felke
Date:   Wed Oct 8 13:02:08 2014 +0200
Branches: fracture_modifier
https://developer.blender.org/rBee936bc922a00548227d4472926c4c37f11a1b9f

added new setting for fracturing with particle sources, in most cases you want to use the particle
birth coordinates as pointsource, but you can override this to get the coordinates of the current particle simulation state. But as the particle cache is kinda broken and shows wrong positions at beginning if simulation has been run before, this can lead to errors. Best practice is to keep this option enabled, only disable if you really need to !

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

M	release/scripts/startup/bl_operators/presets.py
M	release/scripts/startup/bl_ui/properties_physics_fracture.py
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_fracture.c

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

diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py
index f87e0d4..9fcdf42 100644
--- a/release/scripts/startup/bl_operators/presets.py
+++ b/release/scripts/startup/bl_operators/presets.py
@@ -555,6 +555,7 @@ class AddPresetFracture(AddPresetBase, Operator):
         "fracture.point_source",
         "fracture.extra_group",
         "fracture.dm_group",
+        "fracture.use_particle_birth_coordinates",
         "fracture.percentage",
         "fracture.breaking_percentage",
         "fracture.breaking_percentage_weighted",
diff --git a/release/scripts/startup/bl_ui/properties_physics_fracture.py b/release/scripts/startup/bl_ui/properties_physics_fracture.py
index 414ebd9..9df9fc3 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fracture.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py
@@ -120,6 +120,7 @@ class PHYSICS_PT_fracture_simulation(PhysicButtonsPanel, Panel):
             box.prop(md, "point_source")
             box.prop(md, "extra_group")
             box.prop(md, "dm_group")
+            box.prop(md, "use_particle_birth_coordinates")
 
             box.prop(md, "percentage")
             box.label("Constraint Breaking Settings")
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index b94e80a..6130c1c 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1456,6 +1456,7 @@ typedef struct FractureModifierData {
 
 	int use_constraints;
 	int use_mass_dependent_thresholds;
+	int use_particle_birth_coordinates;
 
 	int shards_to_islands;
 	int execute_threaded;
@@ -1474,7 +1475,7 @@ typedef struct FractureModifierData {
 	/* internal values */
 	float max_vol;
 
-	char pad[4];
+	//char pad[4];
 } FractureModifierData;
 
 #endif  /* __DNA_MODIFIER_TYPES_H__ */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index f5a5597..a8060c8 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4212,6 +4212,11 @@ static void rna_def_modifier_fracture(BlenderRNA *brna)
 	RNA_def_property_boolean_sdna(prop, NULL, "breaking_distance_weighted", false);
 	RNA_def_property_ui_text(prop, "Weighted Distance", "Modify breaking distance by threshold weights");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	prop = RNA_def_property(srna, "use_particle_birth_coordinates", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "use_particle_birth_coordinates", false);
+	RNA_def_property_ui_text(prop, "Use Initial Particle Coordinates", "Use initial or simulated state particle coordinates");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 }
 
 void RNA_def_modifier(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index 15900e6..698ee0d 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -126,6 +126,10 @@ static void initData(ModifierData *md)
 		fmd->breaking_percentage_weighted = false;
 		fmd->breaking_angle_weighted = false;
 		fmd->breaking_distance_weighted = false;
+
+		/* XXX needed because of messy particle cache, shows incorrect positions when start/end on frame 1
+		 * default use case is with this flag being enabled, disable at own risk */
+		fmd->use_particle_birth_coordinates = true;
 }
 
 static void freeData(ModifierData *md)
@@ -723,7 +727,7 @@ static void points_from_verts(Object** ob, int totobj, FracPointCloud* points, f
 }
 
 static void points_from_particles(Object** ob, int totobj, Scene* scene, FracPointCloud* points, float mat[4][4],
-								 float thresh)
+								 float thresh, FractureModifierData *fmd)
 {
 	int o, p, pt = points->totpoints;
 	ParticleSystemModifierData* psmd;
@@ -752,11 +756,19 @@ static void points_from_particles(Object** ob, int totobj, Scene* scene, FracPoi
 
 					if ((BLI_frand() < thresh) && particle_mask) {
 						float co[3];
-						//psys_get_birth_coordinates(&sim, pa, &birth, 0, 0);
 
 						/* birth coordinates are not sufficient in case we did pre-simulate the particles, so they are not
-						 * aligned with the emitter any more */
-						psys_get_particle_state(&sim, p, &birth, 1);
+						 * aligned with the emitter any more BUT as the particle cache is messy and shows initially wrong
+						 * positions "sabotaging" fracture, default use case is using birth coordinates, let user decide... */
+						if (fmd->use_particle_birth_coordinates)
+						{
+							psys_get_birth_coordinates(&sim, pa, &birth, 0, 0);
+						}
+						else
+						{
+							psys_get_particle_state(&sim, p, &birth, 1);
+						}
+
 						points->points = MEM_reallocN(points->points, (pt+1) * sizeof(FracPoint));
 						copy_v3_v3(co, birth.co);
 
@@ -862,7 +874,7 @@ static FracPointCloud get_points_global(FractureModifierData *emd, Object *ob, D
 	}
 
 	if (emd->point_source & (MOD_FRACTURE_OWN_PARTICLES | MOD_FRACTURE_EXTRA_PARTICLES)) {
-		points_from_particles(go, totgroup, scene, &points, ob->obmat, thresh);
+		points_from_particles(go, totgroup, scene, &points, ob->obmat, thresh, emd);
 	}
 
 	if (emd->point_source & (MOD_FRACTURE_OWN_VERTS | MOD_FRACTURE_EXTRA_VERTS)) {
@@ -1017,6 +1029,8 @@ static void copyData(ModifierData *md, ModifierData *target)
 
 	/* sub object group  XXX Do we keep this ?*/
 	/* trmd->dm_group = rmd->dm_group;*/
+
+	trmd->use_particle_birth_coordinates = rmd->use_particle_birth_coordinates;
 }
 
 void freeMeshIsland(FractureModifierData* rmd, MeshIsland* mi, bool remove_rigidbody)




More information about the Bf-blender-cvs mailing list