[Bf-blender-cvs] [982f94f] fracture_modifier: rigidbody type on meshisland should be taken into account now properly and be settable, also adding new constraints should happen faster now (when called in a loop)
Martin Felke
noreply at git.blender.org
Tue Jan 19 21:20:37 CET 2016
Commit: 982f94f2697125c104a1d480e04bca7b93638eba
Author: Martin Felke
Date: Tue Jan 19 21:20:28 2016 +0100
Branches: fracture_modifier
https://developer.blender.org/rB982f94f2697125c104a1d480e04bca7b93638eba
rigidbody type on meshisland should be taken into account now properly and be settable, also adding new constraints should happen faster now (when called in a loop)
===================================================================
M source/blender/blenkernel/intern/fracture.c
M source/blender/blenkernel/intern/rigidbody.c
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/modifiers/intern/MOD_fracture.c
===================================================================
diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index cdec300..75b3194 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -2537,7 +2537,13 @@ RigidBodyShardCon *BKE_fracture_mesh_islands_connect(FractureModifierData *fmd,
copy_qt_qt(rbsc->orn, rbsc->mi1->rigidbody->orn);
+ if (BLI_listbase_is_empty(&fmd->meshConstraints))
+ {
+ fmd->constraint_count = 0;
+ }
+
BLI_addtail(&fmd->meshConstraints, rbsc);
+ fmd->constraint_count++;
if (index > -1)
{
@@ -2545,16 +2551,9 @@ RigidBodyShardCon *BKE_fracture_mesh_islands_connect(FractureModifierData *fmd,
}
else
{
- rbsc->id = BLI_listbase_count(&fmd->meshConstraints) - 1;
+ rbsc->id = fmd->constraint_count-1;
}
-#if 0
- first = fmd->meshConstraints.first;
- last = fmd->meshConstraints.last;
- index = (last-first) / sizeof(RigidBodyShardCon);
- rbsc->id = index;
-#endif
-
/* store constraints per meshisland too, to allow breaking percentage */
if (mi1->participating_constraints == NULL) {
mi1->participating_constraints = MEM_callocN(sizeof(RigidBodyShardCon *), "part_constraints_mi1");
@@ -2611,9 +2610,14 @@ void BKE_fracture_mesh_constraint_remove(FractureModifierData *fmd, RigidBodySha
BLI_remlink(&fmd->meshConstraints, con);
BKE_rigidbody_remove_shard_con(fmd->modifier.scene, con);
MEM_freeN(con);
+ if (fmd->constraint_count > 0)
+ {
+ fmd->constraint_count--;
+ }
}
void BKE_fracture_mesh_constraint_remove_all(FractureModifierData *fmd)
{
BKE_free_constraints(fmd);
+ fmd->constraint_count = 0;
}
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 309ef0d..e6d0ac2 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -2221,10 +2221,15 @@ RigidBodyOb *BKE_rigidbody_create_shard(Scene *scene, Object *ob, Object *target
/* since we are always member of an object, dupe its settings,
* create new settings data, and link it up */
if (target && target->rigidbody_object)
+ {
rbo = BKE_rigidbody_copy_object(target);
+ }
else
+ {
+ /* regular FM case */
rbo = BKE_rigidbody_copy_object(ob);
- rbo->type = mi->ground_weight > 0.0f ? 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/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index bf46fe9..9348edb 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1657,6 +1657,7 @@ typedef struct FractureModifierData {
int point_seed;
int percentage;
int cluster_count;
+ int constraint_count;
int constraint_limit;
int solver_iterations_override;
@@ -1732,7 +1733,7 @@ typedef struct FractureModifierData {
/*TODO XXX this is subject to change, a very experimental constraint breaking mode*/
int use_special_breaking;
- char pad[4];
+ //char pad[4];
} FractureModifierData;
typedef struct DataTransferModifierData {
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index d2fec60..26d7fef 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -214,6 +214,7 @@ static void initData(ModifierData *md)
fmd->autohide_filter_group = NULL;
fmd->use_special_breaking = false;
+ fmd->constraint_count = 0;
}
static void free_meshislands(FractureModifierData* fmd, ListBase* meshIslands)
More information about the Bf-blender-cvs
mailing list