- added ModifierTypeInfo.updateDepgraph function, responsible for building
authorDaniel Dunbar <daniel@zuster.org>
Tue, 19 Jul 2005 23:04:34 +0000 (23:04 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 19 Jul 2005 23:04:34 +0000 (23:04 +0000)
   appropriate relations in dep graph (modifiers respond to scene changes
   correctly now)
 - update modifier buttons to trigger depgraph rebuild if needed

source/blender/blenkernel/BKE_modifier.h
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/modifier.c
source/blender/src/buttons_object.c

index 651eb781fe77813c1755a21ddb8e8ac2dc7d4046..fab705a3a8cc56fda059722fae46f820b7a64d2e 100644 (file)
@@ -35,6 +35,8 @@
 
 struct DerivedMesh;
 struct ModifierData;
+struct DagForest;
+struct DagNode;
 struct Object;
 
 typedef enum {
@@ -79,6 +81,13 @@ typedef struct ModifierTypeInfo {
                 */
        int (*isDisabled)(struct ModifierData *md);
 
+               /* Add the appropriate relations to the DEP graph depending on the modifier
+                * data. 
+                *
+                * This function is optional.
+                */
+       void (*updateDepgraph)(struct ModifierData *md, struct DagForest *forest, struct Object *ob, struct DagNode *obNode);
+
                /* Only for deform types, should apply the deformation
                 * to the given vertex array. Object is guaranteed to be
                 * non-NULL.
index 9edaacecbb7884bf851a648d245afc26f1fa817d..018ceac2bc4f649b551324e9dd39e23a76e1bf7a 100644 (file)
@@ -48,6 +48,7 @@
 #include "DNA_effect_types.h"
 #include "DNA_lattice_types.h"
 #include "DNA_mesh_types.h"
+#include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
 #include "DNA_object_force.h"
 #include "DNA_oops_types.h"
@@ -59,6 +60,7 @@
 #include "BKE_action.h"
 #include "BKE_global.h"
 #include "BKE_mball.h"
+#include "BKE_modifier.h"
 #include "BKE_utildefines.h"
 
 #include "MEM_guardedalloc.h"
@@ -360,6 +362,15 @@ struct DagForest *build_dag(struct Scene *sce, short mask)
                                }
                        }
                }
+               if (ob->modifiers.first) {
+                       ModifierData *md;
+
+                       for(md=ob->modifiers.first; md; md=md->next) {
+                               ModifierTypeInfo *mti = modifierType_get_info(md->type);
+
+                               if (mti->updateDepgraph) mti->updateDepgraph(md, dag, ob, node);
+                       }
+               }
                if (ob->parent) {
                        node2 = dag_get_node(dag,ob->parent);
                        
index dd0f909f8abe9b2ca8e616546ae3fde25f1175f8..9bba515fbbf98482229cab57218911c5f027bc1f 100644 (file)
@@ -13,6 +13,7 @@
 #include "BKE_modifier.h"
 #include "BKE_lattice.h"
 #include "BKE_subsurf.h"
+#include "depsgraph_private.h"
 
 /***/
 
@@ -49,6 +50,17 @@ static int curveModifier_isDisabled(ModifierData *md)
        return !cmd->object;
 }
 
+static void curveModifier_updateDepgraph(ModifierData *md, DagForest *forest, Object *ob, DagNode *obNode)
+{
+       CurveModifierData *cmd = (CurveModifierData*) md;
+
+       if (cmd->object) {
+               DagNode *curNode = dag_get_node(forest, cmd->object);
+
+               dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA);
+       }
+}
+
 static void curveModifier_deformVerts(ModifierData *md, Object *ob, float (*vertexCos)[3], int numVerts)
 {
        CurveModifierData *cmd = (CurveModifierData*) md;
@@ -70,6 +82,17 @@ static int latticeModifier_isDisabled(ModifierData *md)
        return !lmd->object;
 }
 
+static void latticeModifier_updateDepgraph(ModifierData *md, DagForest *forest, Object *ob, DagNode *obNode)
+{
+       LatticeModifierData *lmd = (LatticeModifierData*) md;
+
+       if (lmd->object) {
+               DagNode *latNode = dag_get_node(forest, lmd->object);
+
+               dag_add_relation(forest, latNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA);
+       }
+}
+
 static void latticeModifier_deformVerts(ModifierData *md, Object *ob, float (*vertexCos)[3], int numVerts)
 {
        LatticeModifierData *lmd = (LatticeModifierData*) md;
@@ -149,6 +172,7 @@ ModifierTypeInfo *modifierType_get_info(ModifierType type)
                mti->flags = eModifierTypeFlag_AcceptsCVs;
                mti->allocData = curveModifier_allocData;
                mti->isDisabled = curveModifier_isDisabled;
+               mti->updateDepgraph = curveModifier_updateDepgraph;
                mti->deformVerts = curveModifier_deformVerts;
 
                mti = &typeArr[eModifierType_Lattice];
@@ -158,6 +182,7 @@ ModifierTypeInfo *modifierType_get_info(ModifierType type)
                mti->flags = eModifierTypeFlag_AcceptsCVs;
                mti->allocData = latticeModifier_allocData;
                mti->isDisabled = latticeModifier_isDisabled;
+               mti->updateDepgraph = latticeModifier_updateDepgraph;
                mti->deformVerts = latticeModifier_deformVerts;
 
                mti = &typeArr[eModifierType_Subsurf];
index f57728318f1c1b2b7a9eff18f1120f5b18627f2f..89e2d6fa9253f6ec1466627b1c17148d8e131fc2 100644 (file)
@@ -1823,10 +1823,10 @@ static void object_panel_modifiers(Object *ob)
                                uiDefButS(block, MENU, B_MAKEDISP, subsurfmenu,         550,280,150,19, &(smd->subdivType), 0, 0, 0, 0, "Selects type of subdivision algorithm.");
                        } else if (md->type==eModifierType_Lattice) {
                                LatticeModifierData *lmd = (LatticeModifierData*) md;
-                               uiDefIDPoinBut(block, modifier_testLatticeObj, B_MAKEDISP, "Ob:",               550, 320, 120,19, &lmd->object, "Lattice object to deform with");
+                               uiDefIDPoinBut(block, modifier_testLatticeObj, B_CHANGEDEP, "Ob:",              550, 320, 120,19, &lmd->object, "Lattice object to deform with");
                        } else if (md->type==eModifierType_Curve) {
                                CurveModifierData *cmd = (CurveModifierData*) md;
-                               uiDefIDPoinBut(block, modifier_testCurveObj, B_MAKEDISP, "Ob:",         550, 320, 120,19, &cmd->object, "Lattice object to deform with");
+                               uiDefIDPoinBut(block, modifier_testCurveObj, B_CHANGEDEP, "Ob:",                550, 320, 120,19, &cmd->object, "Lattice object to deform with");
                        }
                        uiBlockEndAlign(block);
                }