[Bf-blender-cvs] [908c6c49466] temp-fracture-modifier-2.8: removed separate pack operator, execute fracture handles this now

Martin Felke noreply at git.blender.org
Sun Nov 25 20:52:32 CET 2018


Commit: 908c6c49466b65629c6484d1ca61dcbdd641d8ea
Author: Martin Felke
Date:   Sun Nov 25 20:52:18 2018 +0100
Branches: temp-fracture-modifier-2.8
https://developer.blender.org/rB908c6c49466b65629c6484d1ca61dcbdd641d8ea

removed separate pack operator, execute fracture handles this now

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

M	release/scripts/startup/bl_ui/properties_physics_fracture.py
M	source/blender/blenkernel/BKE_rigidbody.h
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/editors/object/object_modifier.c
M	source/blender/editors/object/object_ops.c

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_fracture.py b/release/scripts/startup/bl_ui/properties_physics_fracture.py
index eae7895b2b7..cab15cb65b5 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fracture.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py
@@ -88,9 +88,6 @@ class PHYSICS_PT_fracture_advanced(PhysicButtonsPanel, Panel):
                 col.prop(md, "keep_cutter_shards")
                 col.prop(md, "material_offset_intersect", text="Intersect Material")
                 col.prop(md, "material_offset_difference", text="Difference Material")
-        col.prop(md, "pack_group", text="Pack Group")
-        col.prop(md, "use_constraint_group", text="Constraints Only")
-        col.operator("object.fracture_pack", text="Pack", icon="PACKAGE")
         col.prop(md, "use_particle_birth_coordinates")
         col.prop(md, "percentage")
 
@@ -266,6 +263,7 @@ class PHYSICS_PT_fracture_constraints_breaking(PhysicButtonsPanel, Panel):
         layout = self.layout
         md = context.fracture
 
+        layout.active = md.use_constraints
         layout.use_property_split = True
         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True);
         col = flow.column()
@@ -301,6 +299,7 @@ class PHYSICS_PT_fracture_constraints_deforming(PhysicButtonsPanel, Panel):
         layout = self.layout
         md = context.fracture
 
+        layout.active = md.use_constraints
         layout.use_property_split = True
         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True);
         col = flow.column()
@@ -315,11 +314,33 @@ class PHYSICS_PT_fracture_constraints_deforming(PhysicButtonsPanel, Panel):
         col.prop(md, "deform_angle_weighted")
         col.prop(md, "deform_distance_weighted")
 
+class PHYSICS_PT_fracture_basic_packing(PhysicButtonsPanel, Panel):
+    bl_label = "Packing"
+    bl_options = {'DEFAULT_CLOSED'}
+    bl_parent_id = 'PHYSICS_PT_fracture_basic'
+
+    @classmethod
+    def poll(cls, context):
+        md = context.fracture
+        return PhysicButtonsPanel.poll(context)
+
+    def draw(self, context):
+        layout = self.layout
+        md = context.fracture
+
+        layout.context_pointer_set("modifier", md)
+        layout.use_property_split = True
+        flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True);
+        col = flow.column()
+        col.prop(md, "pack_group", text="Pack Group")
+        col.prop(md, "use_constraint_group", text="Constraints Only")
+
 
 classes = (
     FRACTURE_PT_presets,
     PHYSICS_PT_fracture,
     PHYSICS_PT_fracture_basic,
+    PHYSICS_PT_fracture_basic_packing,
     PHYSICS_PT_fracture_advanced,
     PHYSICS_PT_fracture_utilities,
     PHYSICS_PT_fracture_dynamic,
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index 93d93a1b735..947aadd6fb9 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -73,7 +73,8 @@ void BKE_rigidbody_world_id_loop(struct RigidBodyWorld *rbw, RigidbodyWorldIDFun
 struct RigidBodyWorld *BKE_rigidbody_create_world(struct Scene *scene);
 struct RigidBodyOb *BKE_rigidbody_create_object(struct Scene *scene, struct Object *ob, short type, struct Shard *mi);
 struct RigidBodyCon *BKE_rigidbody_create_constraint(struct Scene *scene, struct Object *ob, short type, struct RigidBodyShardCon *con);
-struct RigidBodyOb *BKE_rigidbody_create_shard(struct Object *ob, struct Object *target, struct Shard *mi);
+struct RigidBodyOb *BKE_rigidbody_create_shard(struct Object *ob, struct Object *target, struct Shard *mi,
+                                               struct Scene *scene);
 struct RigidBodyShardCon *BKE_rigidbody_create_shard_constraint(struct Scene *scene, short type, bool reset);
 
 /* copy */
diff --git a/source/blender/blenkernel/intern/fracture_external.c b/source/blender/blenkernel/intern/fracture_external.c
index 1c283221681..6c3fba21945 100644
--- a/source/blender/blenkernel/intern/fracture_external.c
+++ b/source/blender/blenkernel/intern/fracture_external.c
@@ -136,7 +136,6 @@ Shard* BKE_fracture_mesh_island_add(Main* bmain, FractureModifierData *fmd, Obje
 
 	copy_v3_v3(mi->loc, loc);
 	copy_qt_qt(mi->rot, quat);
-	copy_v3_v3(mi->loc, loc);
 
 	//mi->rigidbody = BKE_rigidbody_create_shard(bmain, scene, own, target, mi);
 	BLI_strncpy(mi->name, target->id.name + 2, MAX_ID_NAME - 2);
diff --git a/source/blender/blenkernel/intern/fracture_prefractured.c b/source/blender/blenkernel/intern/fracture_prefractured.c
index 9a448390f9e..8595a6cd9b0 100644
--- a/source/blender/blenkernel/intern/fracture_prefractured.c
+++ b/source/blender/blenkernel/intern/fracture_prefractured.c
@@ -51,43 +51,17 @@
 
 #include "PIL_time.h"
 
-#if 0
-Mesh *BKE_fracture_prefractured_apply(FractureModifierData *fmd, Object *ob, Mesh *derivedData, Depsgraph* depsgraph)
-{
-    bool do_refresh = (fmd->auto_execute) || (fmd->dm_group && fmd->use_constraint_group && fmd->shared->refresh_constraints);
-    Scene *scene = fmd->scene;
-
-    Mesh *final_dm = derivedData;
-  //  Mesh *group_dm = BKE_fracture_group_dm(fmd, derivedData, ob, do_refresh || fmd->refresh);
-
-    if (do_refresh) {
-        fmd->shared->refresh = true;
-    }
-
-    if (fmd->shared->refresh)
-    {
-        BKE_fracture_refresh(fmd, ob, derivedData, depsgraph);
-    }
-
-    /* TODO_5, get rid of fmd->dm and perhaps of fmd->visible_mesh (BMESH!) too, the latter should be runtime data for creating islands ONLY */
-    /* we should ideally only have one cached derivedmesh */
-    if (fmd->shared->dm && fmd->shared->frac_mesh && (fmd->shared->dm->totpoly > 0)) {
-        final_dm = BKE_fracture_prefractured_do(fmd, ob, fmd->shared->dm, derivedData, NULL, 0, scene, depsgraph);
-    }
-    else {
-        final_dm = BKE_fracture_prefractured_do(fmd, ob, derivedData, derivedData, NULL, 0, scene, depsgraph);
-    }
-
-    return final_dm;
-}
-#endif
 
 Shard *BKE_fracture_mesh_island_create(Mesh* me, Scene *scene, Object *ob, int frame)
 {
-	int endframe = scene->rigidbody_world->shared->pointcache->endframe;
+	int endframe = 250;
 	Shard *mi = MEM_callocN(sizeof(Shard), "mesh_island");
 	mi->mesh = me;
 
+	if (scene->rigidbody_world) {
+		endframe = scene->rigidbody_world->shared->pointcache->endframe;
+	}
+
 	INIT_MINMAX(mi->min, mi->max);
 	BKE_mesh_minmax(mi->mesh, mi->min, mi->max);
 	BKE_fracture_mesh_center_centroid_area(mi->mesh, mi->loc);
@@ -104,7 +78,7 @@ Shard *BKE_fracture_mesh_island_create(Mesh* me, Scene *scene, Object *ob, int f
 		mi->aves = MEM_callocN(sizeof (float) * 3 *frame, "mi->aves");
 	}
 
-	mi->rigidbody = BKE_rigidbody_create_shard(ob, NULL, mi);
+	mi->rigidbody = BKE_rigidbody_create_shard(ob, NULL, mi, scene);
 	mi->rigidbody->type = RBO_TYPE_ACTIVE;
 	mi->rigidbody->flag |= (RBO_FLAG_NEEDS_VALIDATE | RBO_FLAG_NEEDS_RESHAPE);
 	BKE_rigidbody_calc_shard_mass(ob, mi);
@@ -121,7 +95,7 @@ static bool handle_initial_shards(FractureModifierData* fmd, Object* ob, Depsgra
 	int count = 0;
 	for (mi = fmd->shared->shards.first; mi; mi = mi->next)
 	{
-		if (!BKE_fracture_meshisland_check_frame(fmd, mi, frame) && mi->id > 0)
+		if (!BKE_fracture_meshisland_check_frame(fmd, mi, frame))
 		{
 			count++;
 		}
@@ -134,7 +108,7 @@ static bool handle_initial_shards(FractureModifierData* fmd, Object* ob, Depsgra
 	mi_tmp = MEM_callocN(sizeof(Shard*) * count, "mi_tmp");
 	for (mi = fmd->shared->shards.first; mi; mi = mi->next)
 	{
-		if (!BKE_fracture_meshisland_check_frame(fmd, mi, frame) && mi->id > 0)
+		if (!BKE_fracture_meshisland_check_frame(fmd, mi, frame))
 		{
 			mi_tmp[i] = mi;
 			i++;
@@ -142,8 +116,19 @@ static bool handle_initial_shards(FractureModifierData* fmd, Object* ob, Depsgra
 	}
 
 	/*decouple from listbase because it will continue growing ... */
-	for (mi = mi_tmp[0], i = 0; i < count; i++)
+	for (i = 0; i < count; i++)
 	{
+		/* make sure to get rid of initial islands after fracture, so "register" them as "Last islands/shards" */
+		if (fmd->shared->last_islands) {
+			MEM_freeN(fmd->shared->last_islands);
+			fmd->shared->last_islands = NULL;
+			fmd->shared->last_islands_count = 0;
+		}
+
+		fmd->shared->last_islands = MEM_callocN(sizeof(Shard*), "islands initial");
+		fmd->shared->last_islands[0] = mi_tmp[i];
+		fmd->shared->last_islands_count = 1;
+
 		BKE_fracture_do(fmd, mi_tmp[i], ob, depsgraph, bmain, scene, true);
 		mi_tmp[i]->endframe = frame;
 	}
@@ -182,7 +167,7 @@ static void do_initial_prefracture(FractureModifierData* fmd, Object* ob, Depsgr
 	//	mi->endframe = frame;
 }
 
-
+/* entry point of all FM operations / apply loop */
 Mesh* BKE_fracture_apply(FractureModifierData *fmd, Object *ob, Mesh *me_orig, Depsgraph* depsgraph)
 {
 	Scene *scene = DEG_get_input_scene(depsgraph);
@@ -218,6 +203,9 @@ Mesh* BKE_fracture_apply(FractureModifierData *fmd, Object *ob, Mesh *me_orig, D
 		/*keep shards at packing and at dynamic refresh */
 		if (fmd->pack_group)
 		{
+			/* keep re-packing, too */
+			BKE_fracture_meshislands_pack(fmd, ob, bmain, scene);
+
 			if (!handle_initial_shards(fmd, ob, depsgraph, bmain, scene, frame))
 			{
 				do_initial_prefracture(fmd, ob, depsgraph, bmain, scene, frame, me);
diff --git a/source/blender/blenkernel/intern/fracture_rigidbody.c b/source/blender/blenkernel/intern/fracture_rigidbody.c
index a99ae35ffc4..bc1bd034590 100644
--- a/source/blender/blenkernel/intern/fracture_rigidbody.c
+++ b/source/blender/blenkernel/intern/fracture_rigidbody.c
@@ -2414,7 +2414,7 @@ bool BKE_restoreKinematic(RigidBodyWorld *rbw, bool override_bind)
 }
 
 /* Add rigid body settings to the specified shard */
-RigidBodyOb *BKE_rigidbody_create_shard(Object *ob, Object *target, Shard *mi)
+RigidBodyOb *BKE_rigidbody_create_shard(Object *ob, Object *target, Shard *mi, Scene* scene)
 {
 	RigidBodyOb *rbo;
 	float centr[3], size[3];
@@ -2436,14 +2436,29 @@ RigidBodyOb *BKE_rigidbody_create_shard(Object *ob, Object *target, Shard *mi)
 	}
 
 	if (!ob->rigidbody_object) {
-		return NULL;
+		ob->rigidbody_object = BKE_rigidbody_create_object(scene, ob, RBO_T

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list