Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/depsgraph.c')
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c196
1 files changed, 126 insertions, 70 deletions
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 86cafa733ff..382c0690ae3 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -41,6 +41,8 @@
#include "DNA_screen_types.h"
#include "DNA_windowmanager_types.h"
+#include "MEM_guardedalloc.h"
+
#include "BLI_ghash.h"
#include "BKE_animsys.h"
@@ -59,13 +61,7 @@
#include "BKE_scene.h"
#include "BKE_screen.h"
-#include "MEM_guardedalloc.h"
-
-#ifndef DISABLE_PYTHON
-#include "BPY_extern.h"
-#endif
-
- #include "depsgraph_private.h"
+#include "depsgraph_private.h"
/* Queue and stack operations for dag traversal
*
@@ -658,7 +654,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
dag_add_relation(dag,scenenode,node,DAG_RL_SCENE, "Scene Relation");
}
-struct DagForest *build_dag(struct Scene *sce, short mask)
+struct DagForest *build_dag(Main *bmain, Scene *sce, short mask)
{
Base *base;
Object *ob;
@@ -695,7 +691,7 @@ struct DagForest *build_dag(struct Scene *sce, short mask)
}
/* add groups used in current scene objects */
- for(group= G.main->group.first; group; group= group->id.next) {
+ for(group= bmain->group.first; group; group= group->id.next) {
if(group->id.flag & LIB_DOIT) {
for(go= group->gobject.first; go; go= go->next) {
build_dag_object(dag, scenenode, sce, go->ob, mask);
@@ -803,7 +799,7 @@ DagNode * dag_add_node (DagForest *forest, void * fob)
}
if(!forest->nodeHash)
- forest->nodeHash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
+ forest->nodeHash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dag_add_node gh");
BLI_ghash_insert(forest->nodeHash, fob, node);
}
@@ -1605,7 +1601,7 @@ static void dag_editors_update(Main *bmain, ID *id)
}
/* groups with objects in this scene need to be put in the right order as well */
-static void scene_sort_groups(Scene *sce)
+static void scene_sort_groups(Main *bmain, Scene *sce)
{
Base *base;
Group *group;
@@ -1613,14 +1609,14 @@ static void scene_sort_groups(Scene *sce)
Object *ob;
/* test; are group objects all in this scene? */
- for(ob= G.main->object.first; ob; ob= ob->id.next) {
+ for(ob= bmain->object.first; ob; ob= ob->id.next) {
ob->id.flag &= ~LIB_DOIT;
ob->id.newid= NULL; /* newid abuse for GroupObject */
}
for(base = sce->base.first; base; base= base->next)
base->object->id.flag |= LIB_DOIT;
- for(group= G.main->group.first; group; group= group->id.next) {
+ for(group= bmain->group.first; group; group= group->id.next) {
for(go= group->gobject.first; go; go= go->next) {
if((go->ob->id.flag & LIB_DOIT)==0)
break;
@@ -1649,7 +1645,7 @@ static void scene_sort_groups(Scene *sce)
}
/* sort the base list on dependency order */
-void DAG_scene_sort(struct Scene *sce)
+void DAG_scene_sort(Main *bmain, Scene *sce)
{
DagNode *node;
DagNodeQueue *nqueue;
@@ -1661,7 +1657,7 @@ void DAG_scene_sort(struct Scene *sce)
tempbase.first= tempbase.last= NULL;
- build_dag(sce, DAG_RL_ALL_BUT_DATA);
+ build_dag(bmain, sce, DAG_RL_ALL_BUT_DATA);
dag_check_cycle(sce->theDag);
@@ -1731,7 +1727,7 @@ void DAG_scene_sort(struct Scene *sce)
queue_delete(nqueue);
/* all groups with objects in this scene gets resorted too */
- scene_sort_groups(sce);
+ scene_sort_groups(bmain, sce);
if(G.f & G_DEBUG) {
printf("\nordered\n");
@@ -1754,7 +1750,7 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
node->lasttime= curtime;
ob= node->ob;
- if(ob && (ob->recalc & OB_RECALC)) {
+ if(ob && (ob->recalc & OB_RECALC_ALL)) {
all_layer= node->scelay;
/* got an object node that changes, now check relations */
@@ -1797,7 +1793,7 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
if(ob->recalc & OB_RECALC_DATA)
object_free_display(ob);
- ob->recalc &= ~OB_RECALC;
+ ob->recalc &= ~OB_RECALC_ALL;
}
}
@@ -1810,7 +1806,7 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
if(itA->node->type==ID_OB) {
obc= itA->node->ob;
/* child moves */
- if((obc->recalc & OB_RECALC)==OB_RECALC_OB) {
+ if((obc->recalc & OB_RECALC_ALL)==OB_RECALC_OB) {
/* parent has deforming info */
if(itA->type & (DAG_RL_OB_DATA|DAG_RL_DATA_DATA)) {
// printf("parent %s changes ob %s\n", ob->id.name, obc->id.name);
@@ -1864,7 +1860,7 @@ static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int
if(itA->node->lasttime!=curtime) {
ob= (Object*)(node->ob);
- if(reset || (ob->recalc & OB_RECALC)) {
+ if(reset || (ob->recalc & OB_RECALC_ALL)) {
if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH))
ob->recalc |= OB_RECALC_DATA;
@@ -1877,26 +1873,19 @@ static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int
}
}
-/* flushes all recalc flags in objects down the dependency tree */
-void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time)
+/* flush layer flags to dependencies */
+static void dag_scene_flush_layers(Scene *sce, int lay)
{
- DagNode *firstnode, *node;
+ DagNode *node, *firstnode;
DagAdjList *itA;
- Object *ob;
Base *base;
int lasttime;
-
- if(sce->theDag==NULL) {
- printf("DAG zero... not allowed to happen!\n");
- DAG_scene_sort(sce);
- }
-
+
firstnode= sce->theDag->DagNode.first; // always scene node
for(itA = firstnode->child; itA; itA= itA->next)
itA->lay= 0;
-
- /* first we flush the layer flags */
+
sce->theDag->time++; // so we know which nodes were accessed
lasttime= sce->theDag->time;
@@ -1930,7 +1919,26 @@ void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time)
for(itA = firstnode->child; itA; itA= itA->next)
if(itA->node->lasttime!=lasttime && itA->node->type==ID_OB)
flush_layer_node(sce, itA->node, lasttime);
+}
+
+/* flushes all recalc flags in objects down the dependency tree */
+void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, int time)
+{
+ DagNode *firstnode;
+ DagAdjList *itA;
+ Object *ob;
+ int lasttime;
+
+ if(sce->theDag==NULL) {
+ printf("DAG zero... not allowed to happen!\n");
+ DAG_scene_sort(bmain, sce);
+ }
+ firstnode= sce->theDag->DagNode.first; // always scene node
+
+ /* first we flush the layer flags */
+ dag_scene_flush_layers(sce, lay);
+
/* then we use the relationships + layer info to flush update events */
sce->theDag->time++; // so we know which nodes were accessed
lasttime= sce->theDag->time;
@@ -1946,7 +1954,7 @@ void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time)
if(itA->node->lasttime!=lasttime && itA->node->type==ID_OB) {
ob= (Object*)(itA->node->ob);
- if(ob->recalc & OB_RECALC) {
+ if(ob->recalc & OB_RECALC_ALL) {
if(BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH))
ob->recalc |= OB_RECALC_DATA;
@@ -1962,11 +1970,30 @@ void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time)
static int object_modifiers_use_time(Object *ob)
{
ModifierData *md;
-
+
+ /* check if a modifier in modifier stack needs time input */
for (md=ob->modifiers.first; md; md=md->next)
if (modifier_dependsOnTime(md))
return 1;
-
+
+ /* check whether any modifiers are animated */
+ if (ob->adt) {
+ AnimData *adt = ob->adt;
+
+ /* action - check for F-Curves with paths containing 'modifiers[' */
+ if (adt->action) {
+ FCurve *fcu;
+
+ for (fcu = adt->action->curves.first; fcu; fcu = fcu->next) {
+ if (fcu->rna_path && strstr(fcu->rna_path, "modifiers["))
+ return 1;
+ }
+ }
+
+ // XXX: also, should check NLA strips, though for now assume that nobody uses
+ // that and we can omit that for performance reasons...
+ }
+
return 0;
}
@@ -2026,14 +2053,14 @@ static void dag_object_time_update_flags(Object *ob)
/* this case is for groups with nla, whilst nla target has no action or nla */
for(strip= ob->nlastrips.first; strip; strip= strip->next) {
if(strip->object)
- strip->object->recalc |= OB_RECALC;
+ strip->object->recalc |= OB_RECALC_ALL;
}
}
}
#endif // XXX old animation system
if(animdata_use_time(ob->adt)) {
- ob->recalc |= OB_RECALC;
+ ob->recalc |= OB_RECALC_OB;
ob->adt->recalc |= ADT_RECALC_ANIM;
}
@@ -2104,7 +2131,7 @@ static void dag_object_time_update_flags(Object *ob)
}
}
/* flag all objects that need recalc, for changes in time for example */
-void DAG_scene_update_flags(Scene *scene, unsigned int lay)
+void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay)
{
Base *base;
Object *ob;
@@ -2126,7 +2153,7 @@ void DAG_scene_update_flags(Scene *scene, unsigned int lay)
}
/* we do groups each once */
- for(group= G.main->group.first; group; group= group->id.next) {
+ for(group= bmain->group.first; group; group= group->id.next) {
if(group->id.flag & LIB_DOIT) {
for(go= group->gobject.first; go; go= go->next) {
dag_object_time_update_flags(go->ob);
@@ -2135,7 +2162,7 @@ void DAG_scene_update_flags(Scene *scene, unsigned int lay)
}
for(sce= scene; sce; sce= sce->set)
- DAG_scene_flush_update(sce, lay, 1);
+ DAG_scene_flush_update(bmain, sce, lay, 1);
/* test: set time flag, to disable baked systems to update */
for(SETLOOPER(scene, base)) {
@@ -2149,7 +2176,7 @@ void DAG_scene_update_flags(Scene *scene, unsigned int lay)
dag_object_time_update_flags(scene->camera);
/* and store the info in groupobject */
- for(group= G.main->group.first; group; group= group->id.next) {
+ for(group= bmain->group.first; group; group= group->id.next) {
if(group->id.flag & LIB_DOIT) {
for(go= group->gobject.first; go; go= go->next) {
go->recalc= go->ob->recalc;
@@ -2186,45 +2213,48 @@ static void dag_current_scene_layers(Main *bmain, Scene **sce, unsigned int *lay
*sce= bmain->scene.first;
if(*sce) *lay= (*sce)->lay;
- /* XXX for background mode, we should get the scen
+ /* XXX for background mode, we should get the scene
from somewhere, for the -S option, but it's in
the context, how to get it here? */
}
}
-void DAG_ids_flush_update(int time)
+void DAG_ids_flush_update(Main *bmain, int time)
{
- Main *bmain= G.main;
Scene *sce;
unsigned int lay;
dag_current_scene_layers(bmain, &sce, &lay);
if(sce)
- DAG_scene_flush_update(sce, lay, time);
+ DAG_scene_flush_update(bmain, sce, lay, time);
}
-void DAG_on_load_update(void)
+void DAG_on_load_update(Main *bmain)
{
- Main *bmain= G.main;
Scene *scene, *sce;
Base *base;
Object *ob;
Group *group;
GroupObject *go;
- unsigned int lay;
+ DagNode *node;
+ unsigned int lay, oblay;
dag_current_scene_layers(bmain, &scene, &lay);
- if(scene) {
+ if(scene && scene->theDag) {
/* derivedmeshes and displists are not saved to file so need to be
remade, tag them so they get remade in the scene update loop,
note armature poses or object matrices are preserved and do not
require updates, so we skip those */
+ dag_scene_flush_layers(scene, lay);
+
for(SETLOOPER(scene, base)) {
ob= base->object;
+ node= (sce->theDag)? dag_get_node(sce->theDag, ob): NULL;
+ oblay= (node)? node->lay: ob->lay;
- if(base->lay & lay) {
+ if(oblay & lay) {
if(ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL))
ob->recalc |= OB_RECALC_DATA;
if(ob->dup_group)
@@ -2232,11 +2262,13 @@ void DAG_on_load_update(void)
}
}
- for(group= G.main->group.first; group; group= group->id.next) {
+ for(group= bmain->group.first; group; group= group->id.next) {
if(group->id.flag & LIB_DOIT) {
for(go= group->gobject.first; go; go= go->next) {
if(ELEM5(go->ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL))
go->ob->recalc |= OB_RECALC_DATA;
+ if(go->ob->proxy_from)
+ go->ob->recalc |= OB_RECALC_OB;
}
group->id.flag &= ~LIB_DOIT;
@@ -2244,7 +2276,17 @@ void DAG_on_load_update(void)
}
/* now tag update flags, to ensure deformers get calculated on redraw */
- DAG_scene_update_flags(scene, lay);
+ DAG_scene_update_flags(bmain, scene, lay);
+ }
+}
+
+static void dag_id_flush_update__isDependentTexture(void *userData, Object *ob, ID **idpoin)
+{
+ struct { ID *id; int is_dependent; } *data = userData;
+
+ if(*idpoin && GS((*idpoin)->name)==ID_TE) {
+ if (data->id == (*idpoin))
+ data->is_dependent = 1;
}
}
@@ -2264,7 +2306,7 @@ void DAG_id_flush_update(ID *id, short flag)
/* set flags & pointcache for object */
if(GS(id->name) == ID_OB) {
ob= (Object*)id;
- ob->recalc |= (flag & OB_RECALC);
+ ob->recalc |= (flag & OB_RECALC_ALL);
BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH);
if(flag & OB_RECALC_DATA) {
@@ -2272,15 +2314,10 @@ void DAG_id_flush_update(ID *id, short flag)
id= ob->data;
/* no point in trying in this cases */
- if(!id || id->us <= 1)
- id= NULL;
- /* curves and surfaces only need to mark one object, since
- otherwise cu->displist would be computed multiple times */
- else if(ob->type==OB_CURVE || ob->type==OB_SURF)
- id= NULL;
- /* also for locked shape keys we make an exception */
- else if(ob_get_key(ob) && (ob->shapeflag & OB_SHAPE_LOCK))
+ if(id && id->us <= 1) {
+ dag_editors_update(bmain, id);
id= NULL;
+ }
}
}
@@ -2289,25 +2326,44 @@ void DAG_id_flush_update(ID *id, short flag)
idtype= GS(id->name);
if(ELEM7(idtype, ID_ME, ID_CU, ID_MB, ID_LA, ID_LT, ID_CA, ID_AR)) {
+ int first_ob= 1;
for(obt=bmain->object.first; obt; obt= obt->id.next) {
if(!(ob && obt == ob) && obt->data == id) {
+
+ /* try to avoid displist recalculation for linked curves */
+ if (!first_ob && ELEM(obt->type, OB_CURVE, OB_SURF)) {
+ /* if curve object has got derivedFinal it means this
+ object has got constructive modifiers and object
+ should be recalculated anyhow */
+ if (!obt->derivedFinal)
+ continue;
+ }
+
obt->recalc |= OB_RECALC_DATA;
BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
- /* for these we only flag one object, otherwise cu->displist
- would be computed multiple times */
- if(obt->type==OB_CURVE || obt->type==OB_SURF)
- break;
+ first_ob= 0;
}
}
}
+ /* set flags based on textures - can influence depgraph via modifiers */
+ if(idtype == ID_TE) {
+ for(obt=bmain->object.first; obt; obt= obt->id.next) {
+ struct { ID *id; int is_dependent; } data = {id, 0};
+
+ modifiers_foreachIDLink(obt, dag_id_flush_update__isDependentTexture, &data);
+ if (data.is_dependent)
+ obt->recalc |= OB_RECALC_DATA;
+ }
+ }
+
/* set flags based on ShapeKey */
if(idtype == ID_KE) {
for(obt=bmain->object.first; obt; obt= obt->id.next) {
Key *key= ob_get_key(obt);
if(!(ob && obt == ob) && ((ID *)key == id)) {
- obt->flag |= (OB_RECALC|OB_RECALC_DATA);
+ obt->flag |= (OB_RECALC_OB|OB_RECALC_DATA);
BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
}
}
@@ -2320,7 +2376,7 @@ void DAG_id_flush_update(ID *id, short flag)
for(psys=obt->particlesystem.first; psys; psys=psys->next) {
if(&psys->part->id == id) {
BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
- obt->recalc |= (flag & OB_RECALC);
+ obt->recalc |= (flag & OB_RECALC_ALL);
psys->recalc |= (flag & PSYS_RECALC);
}
}
@@ -2332,7 +2388,7 @@ void DAG_id_flush_update(ID *id, short flag)
}
/* flush to other objects that depend on this one */
- DAG_scene_flush_update(sce, lay, 0);
+ DAG_scene_flush_update(bmain, sce, lay, 0);
}
/* recursively descends tree, each node only checked once */
@@ -2400,7 +2456,7 @@ void DAG_id_update_flags(ID *id)
GroupObject *go;
/* primitive; tag all... this call helps building groups for particles */
for(go= group->gobject.first; go; go= go->next)
- go->ob->recalc= OB_RECALC;
+ go->ob->recalc= OB_RECALC_ALL;
}
}
else {
@@ -2415,7 +2471,7 @@ void DAG_id_update_flags(ID *id)
}
/* set recalcs and flushes */
- DAG_scene_update_flags(sce, lay);
+ DAG_scene_update_flags(bmain, sce, lay);
/* now we clear recalcs, unless color is set */
for(node = sce->theDag->DagNode.first; node; node= node->next) {