- added ModifierTypeInfo.updateDepgraph function, responsible for building
appropriate relations in dep graph (modifiers respond to scene changes correctly now) - update modifier buttons to trigger depgraph rebuild if needed
This commit is contained in:
parent
259a6fe8be
commit
d18600520e
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue