[Bf-blender-cvs] [a6b53d6] fracture_modifier: fix: some performance optimization when rebuilding constraints on triggered objects (was calling unnecessary restoreKinematic() function in this case)
Martin Felke
noreply at git.blender.org
Fri Feb 20 12:57:23 CET 2015
Commit: a6b53d6892de071e4f2df95d17addb31db149f09
Author: Martin Felke
Date: Fri Feb 20 12:57:07 2015 +0100
Branches: fracture_modifier
https://developer.blender.org/rBa6b53d6892de071e4f2df95d17addb31db149f09
fix: some performance optimization when rebuilding constraints on triggered objects (was calling unnecessary restoreKinematic() function in this case)
===================================================================
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 06717b6..4fe3dfd 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -3292,7 +3292,7 @@ void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw)
{
if (rbw) {
rbw->pointcache->flag |= PTCACHE_OUTDATED;
- restoreKinematic(rbw);
+ //restoreKinematic(rbw);
}
}
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index 67fce9c..815ba10 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -1243,6 +1243,18 @@ static int BM_calc_center_centroid(BMesh *bm, float cent[3], int tagged)
return (bm->totface != 0);
}
+static int DM_mesh_minmax(DerivedMesh *dm, float r_min[3], float r_max[3])
+{
+ MVert *v;
+ int i = 0;
+ for (i = 0; i < dm->numVertData; i++) {
+ v = CDDM_get_vert(dm, i);
+ minmax_v3v3_v3(r_min, r_max, v->co);
+ }
+
+ return (dm->numVertData != 0);
+}
+
static int BM_mesh_minmax(BMesh *bm, float r_min[3], float r_max[3], int tagged)
{
@@ -1939,11 +1951,11 @@ static void create_constraints(FractureModifierData *rmd)
MeshIsland **mesh_islands = MEM_mallocN(sizeof(MeshIsland *), "mesh_islands");
int count, i = 0;
- if (rmd->visible_mesh && rmd->contact_dist == 0.0f) {
+ if (rmd->visible_mesh_cached && rmd->contact_dist == 0.0f) {
/* extend contact dist to bbox max dimension here, in case we enter 0 */
float min[3], max[3], dim[3];
BoundBox *bb = BKE_boundbox_alloc_unit();
- BM_mesh_minmax(rmd->visible_mesh, min, max, 0);
+ DM_mesh_minmax(rmd->visible_mesh_cached, min, max);
BKE_boundbox_init_from_minmax(bb, min, max);
bbox_dim(bb, dim);
rmd->contact_dist = MAX3(dim[0], dim[1], dim[2]);
@@ -2636,6 +2648,9 @@ static DerivedMesh *doSimulate(FractureModifierData *fmd, Object *ob, DerivedMes
start = PIL_check_seconds_timer();
+ create_constraints(fmd); /* check for actually creating the constraints inside*/
+
+#if 0
if ((fmd->visible_mesh != NULL || fmd->visible_mesh_cached != NULL) && (fmd->use_constraints)) {
if (fmd->visible_mesh == NULL) { /* ugh, needed to build constraints... */
fmd->visible_mesh = DM_to_bmesh(fmd->visible_mesh_cached, true);
@@ -2651,6 +2666,7 @@ static DerivedMesh *doSimulate(FractureModifierData *fmd, Object *ob, DerivedMes
fmd->visible_mesh = NULL;
}
}
+#endif
fmd->refresh_constraints = false;
More information about the Bf-blender-cvs
mailing list