Commit: 4f9941afcb8aa8764641043af405ccb004bb9e77
Author: Martin Felke
Date:   Tue Apr 7 17:10:48 2015 +0200
Branches: fracture_modifier
https://developer.blender.org/rB4f9941afcb8aa8764641043af405ccb004bb9e77

fix: modifier will respond now to manual changes in transformation (setting 
values numerically, clear transformations, apply transformations and origins) 
and ghost setting should be respected properly now with mesh collision shape

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

M       intern/rigidbody/rb_bullet_api.cpp
M       source/blender/blenkernel/intern/rigidbody.c
M       source/blender/editors/object/object_transform.c
M       source/blender/makesrna/intern/rna_object.c

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

diff --git a/intern/rigidbody/rb_bullet_api.cpp 
b/intern/rigidbody/rb_bullet_api.cpp
index 8921f88..cc2bdd6 100644
--- a/intern/rigidbody/rb_bullet_api.cpp
+++ b/intern/rigidbody/rb_bullet_api.cpp
@@ -206,7 +206,8 @@ struct rbFilterCallback : public btOverlapFilterCallback
                                }
                                else
                                {
-                                       result = 1;
+                                       //just check for ghost flags and 
collision groups there
+                                       result = this->callback(NULL, NULL, 
NULL, rb0->blenderOb, rb1->blenderOb);
                                }
                        }
                        else
diff --git a/source/blender/blenkernel/intern/rigidbody.c 
b/source/blender/blenkernel/intern/rigidbody.c
index ea5ee3b..796ffa0 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1714,6 +1714,13 @@ static void do_activate(Object* ob, Object *ob2, 
MeshIsland *mi_compare, RigidBo
        }
 }
 
+static int check_colgroup_ghost(Object* ob1, Object *ob2)
+{
+       int ret = 0;
+       ret = colgroup_check(ob1->rigidbody_object->col_groups, 
ob2->rigidbody_object->col_groups);
+       return ret && (!(ob1->rigidbody_object->flag & RBO_FLAG_IS_GHOST) && 
!(ob2->rigidbody_object->flag & RBO_FLAG_IS_GHOST));
+}
+
 /* this allows partial object activation, only some shards will be activated, 
called from bullet(!) */
 static int filterCallback(void* world, void* island1, void* island2, void 
*blenderOb1, void* blenderOb2) {
        MeshIsland* mi1, *mi2;
@@ -1721,14 +1728,16 @@ static int filterCallback(void* world, void* island1, 
void* island2, void *blend
        Object* ob1, *ob2;
        int ob_index1, ob_index2;
        bool validOb = true;
-       bool ret = false;
 
        mi1 = (MeshIsland*)island1;
        mi2 = (MeshIsland*)island2;
 
        if (rbw == NULL)
        {
-               return 1;
+               /* just check for ghost flags here, do not activate anything */
+               ob1 = blenderOb1;
+               ob2 = blenderOb2;
+               return check_colgroup_ghost(ob1, ob2);
        }
 
        /* cache offset map is a dull name for that... */
@@ -1787,8 +1796,7 @@ static int filterCallback(void* world, void* island1, 
void* island2, void *blend
                }
        }
 
-       ret = colgroup_check(ob1->rigidbody_object->col_groups, 
ob2->rigidbody_object->col_groups);
-       return ret && (!(ob1->rigidbody_object->flag & RBO_FLAG_IS_GHOST) && 
!(ob2->rigidbody_object->flag & RBO_FLAG_IS_GHOST));
+       return check_colgroup_ghost(ob1, ob2);
 }
 
 /* --------------------- */
diff --git a/source/blender/editors/object/object_transform.c 
b/source/blender/editors/object/object_transform.c
index 92fe5de..73283ec 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -39,6 +39,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_group_types.h"
 #include "DNA_lattice_types.h"
+#include "DNA_modifier_types.h"
 
 #include "BLI_math.h"
 #include "BLI_listbase.h"
@@ -54,6 +55,7 @@
 #include "BKE_object.h"
 #include "BKE_report.h"
 #include "BKE_editmesh.h"
+#include "BKE_modifier.h"
 #include "BKE_multires.h"
 #include "BKE_armature.h"
 #include "BKE_lattice.h"
@@ -73,6 +75,17 @@
 
 #include "object_intern.h"
 
+static void reset_fracturemodifier_matrix(Object* ob, bool do_refresh)
+{
+       /* reset modifier matrix here as well, else clear transforms wont have 
an effect with Fracture Modifier enabled */
+       FractureModifierData *fmd = (FractureModifierData*) 
modifiers_findByType(ob, eModifierType_Fracture);
+
+       if (fmd) {
+               zero_m4(fmd->origmat);
+               fmd->refresh = do_refresh;
+       }
+}
+
 /*************************** Clear Transformation ****************************/
 
 /* clear location of object */
@@ -230,6 +243,10 @@ static int object_clear_transform_generic_exec(bContext 
*C, wmOperator *op,
        CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
        {
                if (!(ob->mode & OB_MODE_WEIGHT_PAINT)) {
+
+                       /* reset modifier matrix here as well, else clear 
transforms wont have an effect with Fracture Modifier enabled */
+                       reset_fracturemodifier_matrix(ob, false);
+
                        /* run provided clearing function */
                        clear_func(ob);
 
@@ -319,6 +336,8 @@ static int object_origin_clear_exec(bContext *C, wmOperator 
*UNUSED(op))
 
        CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
        {
+               reset_fracturemodifier_matrix(ob, true);
+
                if (ob->parent) {
                        /* vectors pointed to by v1 and v3 will get modified */
                        v1 = ob->loc;
@@ -429,6 +448,8 @@ static int apply_objects_internal(bContext *C, ReportList 
*reports, bool apply_l
        /* now execute */
        CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
        {
+               /* reset modifier matrix here as well, else clear transforms 
wont have an effect with Fracture Modifier enabled */
+               reset_fracturemodifier_matrix(ob, true);
 
                /* calculate rotation/scale matrix */
                if (apply_scale && apply_rot)
@@ -572,6 +593,9 @@ static int visual_transform_apply_exec(bContext *C, 
wmOperator *UNUSED(op))
        
        CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
        {
+               /* reset modifier matrix here as well, else clear transforms 
wont have an effect with Fracture Modifier enabled */
+               reset_fracturemodifier_matrix(ob, true);
+
                BKE_object_where_is_calc(scene, ob);
                BKE_object_apply_mat4(ob, ob->obmat, true, true);
                BKE_object_where_is_calc(scene, ob);
@@ -731,6 +755,8 @@ static int object_origin_set_exec(bContext *C, wmOperator 
*op)
                Object *ob = ctx_ob->ptr.data;
                ob->flag &= ~OB_DONE;
 
+               reset_fracturemodifier_matrix(ob, true);
+
                /* move active first */
                if (ob == obact) {
                        ctx_ob_act = ctx_ob;
diff --git a/source/blender/makesrna/intern/rna_object.c 
b/source/blender/makesrna/intern/rna_object.c
index d8aa659..70ac46c 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -184,6 +184,7 @@ EnumPropertyItem object_axis_unsigned_items[] = {
 #include "DNA_key_types.h"
 #include "DNA_constraint_types.h"
 #include "DNA_lattice_types.h"
+#include "DNA_modifier_types.h"
 #include "DNA_node_types.h"
 
 #include "BKE_armature.h"
@@ -198,6 +199,7 @@ EnumPropertyItem object_axis_unsigned_items[] = {
 #include "BKE_object.h"
 #include "BKE_material.h"
 #include "BKE_mesh.h"
+#include "BKE_modifier.h"
 #include "BKE_particle.h"
 #include "BKE_scene.h"
 #include "BKE_deform.h"
@@ -210,6 +212,14 @@ EnumPropertyItem object_axis_unsigned_items[] = {
 
 static void rna_Object_internal_update(Main *UNUSED(bmain), Scene 
*UNUSED(scene), PointerRNA *ptr)
 {
+       /*keep object and modifier matrix in sync... but... what was the 
modifier matrix good for still ? XXX */
+
+       Object *ob = (Object*)ptr->id.data;
+       FractureModifierData *fmd = (FractureModifierData*) 
modifiers_findByType(ob, eModifierType_Fracture);
+       if (fmd) {
+               zero_m4(fmd->origmat);
+       }
+
        DAG_id_tag_update(ptr->id.data, OB_RECALC_OB);
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to