[Bf-blender-cvs] [84d8b15] fracture_modifier: set shards to passive if shard weight (average vertex weight) is > 0.0f instead of 0.5f, this allows to keep shards passive in case they dont get enough weightpaint (in case they are inside, and interpolation of weights is not enough)

Martin Felke noreply at git.blender.org
Wed Jan 6 18:28:11 CET 2016


Commit: 84d8b15a18ea457ea27b9aaf0494da6ce4c31cbb
Author: Martin Felke
Date:   Wed Jan 6 18:27:46 2016 +0100
Branches: fracture_modifier
https://developer.blender.org/rB84d8b15a18ea457ea27b9aaf0494da6ce4c31cbb

set shards to passive if shard weight (average vertex weight) is > 0.0f instead of 0.5f, this allows to keep shards passive in case they dont get enough weightpaint (in case they are inside, and interpolation of weights is not enough)

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

M	source/blender/blenkernel/intern/rigidbody.c
M	source/blender/modifiers/intern/MOD_fracture.c

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

diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 297f55e..43181f1 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -78,6 +78,7 @@
 static void resetDynamic(RigidBodyWorld *rbw);
 static void validateShard(RigidBodyWorld *rbw, MeshIsland *mi, Object *ob, int rebuild, int transfer_speed);
 
+
 static void activateRigidbody(RigidBodyOb* rbo, RigidBodyWorld *UNUSED(rbw), MeshIsland *UNUSED(mi), Object *UNUSED(ob))
 {
 	if (rbo->flag & RBO_FLAG_KINEMATIC && rbo->type == RBO_TYPE_ACTIVE)
@@ -2190,7 +2191,7 @@ RigidBodyOb *BKE_rigidbody_create_shard(Scene *scene, Object *ob, MeshIsland *mi
 	/* since we are always member of an object, dupe its settings,
 	 * create new settings data, and link it up */
 	rbo = BKE_rigidbody_copy_object(ob);
-	rbo->type = mi->ground_weight > 0.5f ? RBO_TYPE_PASSIVE : RBO_TYPE_ACTIVE;
+	rbo->type = mi->ground_weight > 0.0f ? RBO_TYPE_PASSIVE : RBO_TYPE_ACTIVE;
 
 	/* set initial transform */
 	mat4_to_loc_quat(rbo->pos, rbo->orn, ob->obmat);
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index ac4ab44..03e1bcc 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -1595,7 +1595,7 @@ static void do_rigidbody(FractureModifierData *fmd, MeshIsland* mi, Object* ob,
 
 static short do_vert_index_map(FractureModifierData *fmd, MeshIsland *mi)
 {
-	short rb_type = mi->ground_weight > 0.5f ? RBO_TYPE_PASSIVE : RBO_TYPE_ACTIVE;
+	short rb_type = mi->ground_weight > 0.0f ? RBO_TYPE_PASSIVE : RBO_TYPE_ACTIVE;
 
 	if (fmd->vert_index_map && fmd->dm_group && fmd->cluster_count == 0 && mi->vertex_indices)
 	{
@@ -1670,7 +1670,8 @@ static float do_setup_meshisland(FractureModifierData *fmd, Object *ob, int totv
 	}
 
 	mi->particle_index = -1;
-	mi->thresh_weight = 0;
+	mi->thresh_weight = 0.0f;
+	mi->ground_weight = 0.0f;
 	mi->id = id;
 	mi->vertices = verts; /*those are temporary only !!! */
 	mi->vertco = MEM_mallocN(sizeof(float) * 3 * totvert, "mi->vertco");
@@ -2540,7 +2541,7 @@ static DerivedMesh *createCache(FractureModifierData *fmd, Object *ob, DerivedMe
 
 		/*disable for dm_group, cannot paint onto this mesh at all */
 		if (mi->rigidbody != NULL && fmd->dm_group == NULL) {
-			mi->rigidbody->type = mi->ground_weight > 0.5f ? RBO_TYPE_PASSIVE : RBO_TYPE_ACTIVE;
+			mi->rigidbody->type = mi->ground_weight > 0.0f ? RBO_TYPE_PASSIVE : RBO_TYPE_ACTIVE;
 		}
 
 		/* use fallback over inner material*/
@@ -3041,8 +3042,8 @@ static void do_island_from_shard(FractureModifierData *fmd, Object *ob, Shard* s
 
 	mi->participating_constraints = NULL;
 	mi->participating_constraint_count = 0;
-	mi->thresh_weight = 0;
-	mi->ground_weight = 0;
+	mi->thresh_weight = 0.0f;
+	mi->ground_weight = 0.0f;
 	mi->vertex_count = s->totvert;
 
 	do_verts_weights(fmd, s, mi, vertstart, thresh_defgrp_index, ground_defgrp_index);




More information about the Bf-blender-cvs mailing list