Commit: d16510425f1295ac275b39143162fe55ea1efbd6
Author: Martin Felke
Date:   Tue Feb 13 19:17:52 2018 +0100
Branches: fracture_modifier
https://developer.blender.org/rBd16510425f1295ac275b39143162fe55ea1efbd6

external constraints load / refresh fix

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

M       source/blender/blenloader/intern/readfile.c
M       source/blender/makesrna/intern/rna_fracture.c
M       source/blender/modifiers/intern/MOD_fracture.c

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

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 8a37e814ca1..f15fd82dfba 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5378,6 +5378,8 @@ static void load_fracture_modifier(FileData* fd, 
FractureModifierData *fmd)
                fmd->refresh_images = false;
                fmd->islandShards.first = NULL;
                fmd->islandShards.last = NULL;
+               fmd->anim_bind = NULL;
+               fmd->anim_bind_len = 0;
        }
        else {
                MeshIsland *mi;
@@ -9181,7 +9183,7 @@ static void fix_fracture_image_hack(Main* main)
 
        for (ob = main->object.first; ob; ob = ob->id.next) {
                FractureModifierData *fmd = 
(FractureModifierData*)modifiers_findByType(ob, eModifierType_Fracture);
-               if (fmd && fmd->dm_group && !fmd->use_constraint_group) {
+               if (fmd && fmd->dm_group) {
                        fmd->refresh_images = true;
                        fmd->refresh = true;
                }
diff --git a/source/blender/makesrna/intern/rna_fracture.c 
b/source/blender/makesrna/intern/rna_fracture.c
index f6d817f2b24..713939e673a 100644
--- a/source/blender/makesrna/intern/rna_fracture.c
+++ b/source/blender/makesrna/intern/rna_fracture.c
@@ -235,6 +235,11 @@ static void 
rna_FractureModifier_use_constraints_set(PointerRNA* ptr, int value)
        FractureModifierData *rmd = (FractureModifierData *)ptr->data;
        rmd->use_constraints = value;
        rmd->refresh_constraints = true;
+
+       /*if (rmd->dm_group)
+       {
+               rmd->refresh = true;
+       }*/
 }
 
 static void rna_FractureModifier_use_constraint_collision_set(PointerRNA* ptr, 
int value)
@@ -657,7 +662,12 @@ static void 
rna_FractureModifier_use_constraint_group_set(PointerRNA* ptr, int v
 {
        FractureModifierData *rmd = (FractureModifierData *)ptr->data;
        rmd->use_constraint_group = value;
-       //rmd->refresh_constraints = true;
+       rmd->refresh_constraints = true;
+
+       /*if (rmd->dm_group)
+       {
+               rmd->refresh = true;
+       }*/
 }
 
 
diff --git a/source/blender/modifiers/intern/MOD_fracture.c 
b/source/blender/modifiers/intern/MOD_fracture.c
index 042e6e3887b..a4c0481f56a 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -15,9 +15,6 @@
  * along with this program; if not, write to the Free Software  Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * The Original Code is Copyright (C) Blender Foundation
- * All rights reserved.
- *
  * The Original Code is: all of this file.
  *
  * Contributor(s): Martin Felke
@@ -97,6 +94,7 @@ static void free_shared_verts(ListBase *lb);
 static void reset_automerge(FractureModifierData *fmd);
 static void do_refresh_automerge(FractureModifierData *fmd);
 static void free_shards(FractureModifierData *fmd);
+static void do_island_index_map(FractureModifierData *fmd);
 
 //TODO XXX Make BKE
 static FracMesh* copy_fracmesh(FracMesh* fm)
@@ -2685,6 +2683,14 @@ static void connect_meshislands(FractureModifierData 
*fmd, MeshIsland *mi1, Mesh
 
                                        if (fmd1 && fmd2)
                                        {
+                                               if (!fmd1->vertex_island_map) {
+                                                       
do_island_index_map(fmd1);
+                                               }
+
+                                               if (!fmd2->vertex_island_map) {
+                                                       
do_island_index_map(fmd2);
+                                               }
+
                                                mi_1 = 
BLI_ghash_lookup(fmd1->vertex_island_map, 
SET_INT_IN_POINTER(mi1->vertex_indices[0] - v1));
                                                mi_2 = 
BLI_ghash_lookup(fmd2->vertex_island_map, 
SET_INT_IN_POINTER(mi2->vertex_indices[0] - v2));
 
@@ -4598,8 +4604,9 @@ static DerivedMesh *doSimulate(FractureModifierData *fmd, 
Object *ob, DerivedMes
 
                        /* 2 cases, we can have a visible mesh or a cached 
visible mesh, the latter primarily when loading blend from file or using 
halving */
                        /* free cached mesh in case of "normal refracture here 
if we have a visible mesh, does that mean REfracture ?*/
-                       if (fmd->visible_mesh != NULL && 
!fmd->shards_to_islands && fmd->frac_mesh->shard_count > 0 && fmd->refresh) {
-
+                       if (fmd->visible_mesh != NULL && 
!fmd->shards_to_islands && fmd->frac_mesh &&
+                           fmd->frac_mesh->shard_count > 0 && fmd->refresh)
+                       {
                                if (fmd->visible_mesh_cached) {
                                        fmd->visible_mesh_cached->needsFree = 1;
                                        
fmd->visible_mesh_cached->release(fmd->visible_mesh_cached);
@@ -5100,7 +5107,7 @@ static DerivedMesh *do_prefractured(FractureModifierData 
*fmd, Object *ob, Deriv
        /* hrm need to differentiate between on startframe and on startframe 
directly after loading */
        /* in latter case the rigidbodyworld is still empty, so if loaded do 
not execute (it damages FM data) */
        bool is_start = scene && rbw && cache && rbw->numbodies > 0 ? frame == 
cache->startframe : false;
-       bool do_refresh = fmd->auto_execute && is_start;
+       bool do_refresh = (fmd->auto_execute && is_start) || (fmd->dm_group && 
fmd->use_constraint_group && fmd->refresh_constraints);
 
        DerivedMesh *final_dm = derivedData;
        DerivedMesh *group_dm = get_group_dm(fmd, derivedData, ob, do_refresh 
|| fmd->refresh);

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to