Bugfix #22685: Screen update slow, animation player ALT-A, files created with 2.4x

Modifiers were being mistakenly recalculated at every frame as long as the object had animation, slowing things down due to incorrect depsgraph recalc tags.

Renamed OB_RECALC -> OB_RECALC_ALL to reduce future confusion. During this process, I noticed a few dubious usages of OB_RECALC, so it's best to use this commit as a guide of places to check on. Apart from the place responsible for this bug, I haven't changed any OB_RECALC -> OB_RECALC_OB/DATA in case that introduces more unforseen bugs now, making it more difficult to track the problems later (rename + value change can be confusing to identify the genuine typos).
This commit is contained in:
Joshua Leung 2010-07-05 03:55:28 +00:00
parent 02b0188c16
commit faf1c9a4bb
Notes: blender-bot 2023-05-22 12:40:41 +02:00
Referenced by commit bb69e62710, Fix T68396: Unable to change any Collision input value after it has been keyframed
Referenced by issue #68396, Unable to change any Collision input value after it has been keyframed
21 changed files with 88 additions and 56 deletions

View File

@ -1754,7 +1754,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 +1797,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 +1810,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 +1864,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;
@ -1946,7 +1946,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 +1962,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 +2045,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;
}
@ -2276,7 +2295,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) {
@ -2331,7 +2350,7 @@ void DAG_id_flush_update(ID *id, short flag)
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);
}
}
@ -2344,7 +2363,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);
}
}
@ -2424,7 +2443,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 {

View File

@ -4071,7 +4071,7 @@ static void dxf_read(Scene *scene, char *filename)
ob->dupon= 1; ob->dupoff= 0;
ob->dupsta= 1; ob->dupend= 100;
ob->recalc= OB_RECALC; /* needed because of weird way of adding libdata directly */
ob->recalc= OB_RECALC_ALL; /* needed because of weird way of adding libdata directly */
ob->data= obdata;
((ID*)ob->data)->us++;

View File

@ -445,7 +445,7 @@ void recalc_all_library_objects(Main *main)
/* flag for full recalc */
for(ob=main->object.first; ob; ob=ob->id.next)
if(ob->id.lib)
ob->recalc |= OB_RECALC;
ob->recalc |= OB_RECALC_ALL;
}
/* note: MAX_LIBARRAY define should match this code */

View File

@ -317,7 +317,7 @@ static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Objec
if (*obpoin==unlinkOb) {
*obpoin = NULL;
ob->recalc |= OB_RECALC;
ob->recalc |= OB_RECALC_ALL; // XXX: should this just be OB_RECALC_DATA?
}
}
@ -357,7 +357,7 @@ void unlink_object(Scene *scene, Object *ob)
if(obt->parent==ob) {
obt->parent= NULL;
obt->recalc |= OB_RECALC;
obt->recalc |= OB_RECALC_ALL;
}
modifiers_foreachObjectLink(obt, unlink_object__unlinkModifierLinks, ob);
@ -367,15 +367,15 @@ void unlink_object(Scene *scene, Object *ob)
if(cu->bevobj==ob) {
cu->bevobj= NULL;
obt->recalc |= OB_RECALC;
obt->recalc |= OB_RECALC_ALL;
}
if(cu->taperobj==ob) {
cu->taperobj= NULL;
obt->recalc |= OB_RECALC;
obt->recalc |= OB_RECALC_ALL;
}
if(cu->textoncurve==ob) {
cu->textoncurve= NULL;
obt->recalc |= OB_RECALC;
obt->recalc |= OB_RECALC_ALL;
}
}
else if(obt->type==OB_ARMATURE && obt->pose) {
@ -1087,7 +1087,7 @@ Object *add_object(struct Scene *scene, int type)
base= scene_add_base(scene, ob);
scene_select_base(scene, base);
ob->recalc |= OB_RECALC;
ob->recalc |= OB_RECALC_ALL;
return ob;
}
@ -1533,7 +1533,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
ob->proxy_group= gob;
id_lib_extern(&target->id);
ob->recalc= target->recalc= OB_RECALC;
ob->recalc= target->recalc= OB_RECALC_ALL;
/* copy transform */
if(gob) {
@ -2474,14 +2474,15 @@ void object_tfm_restore(Object *ob, void *obtfm_pt)
/* requires flags to be set! */
void object_handle_update(Scene *scene, Object *ob)
{
if(ob->recalc & OB_RECALC) {
if(ob->recalc & OB_RECALC_ALL) {
/* speed optimization for animation lookups */
if(ob->pose)
make_pose_channels_hash(ob->pose);
/* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers,
which is only in where_is_object now */
if(ob->recalc & OB_RECALC) {
// XXX: should this case be OB_RECALC_OB instead?
if(ob->recalc & OB_RECALC_ALL) {
if (G.f & G_DEBUG)
printf("recalcob %s\n", ob->id.name+2);
@ -2623,7 +2624,7 @@ void object_handle_update(Scene *scene, Object *ob)
object_handle_update(scene, ob->proxy);
}
ob->recalc &= ~OB_RECALC;
ob->recalc &= ~OB_RECALC_ALL;
}
/* the case when this is a group proxy, object_update is called in group.c */

View File

@ -3943,7 +3943,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
BKE_animsys_evaluate_animdata(&part->id, part->adt, cfra, ADT_RECALC_DRIVERS);
/* TODO: only free child paths in case of PSYS_RECALC_CHILD */
if(psys->recalc & PSYS_RECALC || ob->recalc & OB_RECALC)
if(psys->recalc & PSYS_RECALC || ob->recalc & OB_RECALC_ALL)
psys_free_path_cache(psys, NULL);
if(psys->recalc & PSYS_RECALC_CHILD)

View File

@ -2244,7 +2244,7 @@ static void lib_link_pose(FileData *fd, Object *ob, bPose *pose)
}
if(rebuild) {
ob->recalc= OB_RECALC;
ob->recalc= OB_RECALC_ALL;
pose->flag |= POSE_RECALC;
}
}
@ -3458,7 +3458,7 @@ static void lib_link_object(FileData *fd, Main *main)
/* this triggers object_update to always use a copy */
ob->proxy->proxy_from= ob;
/* force proxy updates after load/undo, a bit weak */
ob->recalc= ob->proxy->recalc= OB_RECALC;
ob->recalc= ob->proxy->recalc= OB_RECALC_ALL;
}
}
ob->proxy_group= newlibadr(fd, ob->id.lib, ob->proxy_group);
@ -7892,7 +7892,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
if(ob->type==OB_ARMATURE) {
if(ob->pose)
ob->pose->flag |= POSE_RECALC;
ob->recalc |= OB_RECALC; // cannot call stuff now (pointers!), done in setup_app_data
ob->recalc |= OB_RECALC_ALL; // cannot call stuff now (pointers!), done in setup_app_data
/* new generic xray option */
arm= newlibadr(fd, lib, ob->data);
@ -12069,7 +12069,7 @@ static void give_base_to_groups(Main *mainvar, Scene *scene)
base= scene_add_base(scene, ob);
base->flag |= SELECT;
base->object->flag= base->flag;
ob->recalc |= OB_RECALC;
ob->recalc |= OB_RECALC_ALL;
scene->basact= base;
/* assign the group */

View File

@ -3206,6 +3206,7 @@ void ANIM_channel_draw_widgets (bAnimContext *ac, bAnimListElem *ale, uiBlock *b
*/
if ((draw_sliders) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_SHAPEKEY)) {
/* adjust offset */
// TODO: make slider width dynamic, so that they can be easier to use when the view is wide enough
offset += SLIDER_WIDTH;
/* need backdrop behind sliders... */

View File

@ -90,7 +90,7 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale)
else {
/* in other case we do standard depsgaph update, ideally
we'd be calling property update functions here too ... */
DAG_id_flush_update(id, OB_RECALC); // XXX or do we want something more restrictive?
DAG_id_flush_update(id, OB_RECALC_ALL); // XXX or do we want something more restrictive?
}
}
@ -106,7 +106,7 @@ void ANIM_id_update(Scene *scene, ID *id)
adt->recalc |= ADT_RECALC_ANIM;
/* set recalc flags */
DAG_id_flush_update(id, OB_RECALC); // XXX or do we want something more restrictive?
DAG_id_flush_update(id, OB_RECALC_ALL); // XXX or do we want something more restrictive?
}
}

View File

@ -946,6 +946,13 @@ static int animdata_filter_action (bAnimContext *ac, ListBase *anim_data, bDopeS
FCurve *lastchan=NULL;
int items = 0;
/* don't include anything from this action if it is linked in from another file,
* and we're getting stuff for editing...
*/
// TODO: need a way of tagging other channels that may also be affected...
if ((filter_mode & ANIMFILTER_FOREDIT) && (act->id.lib))
return 0;
/* loop over groups */
// TODO: in future, should we expect to need nested groups?
for (agrp= act->groups.first; agrp; agrp= agrp->next) {

View File

@ -918,7 +918,7 @@ int ANIM_apply_keyingset (bContext *C, ListBase *dsources, bAction *act, KeyingS
{
Object *ob= (Object *)ksp->id;
ob->recalc |= OB_RECALC;
ob->recalc |= OB_RECALC_ALL; // XXX: only object transforms only?
}
break;
}

View File

@ -102,8 +102,11 @@ typedef struct bAnimListElem {
int flag; /* copy of elem's flags for quick access */
int index; /* for un-named data, the index of the data in it's collection */
void *key_data; /* motion data - mostly F-Curves, but can be other types too */
short elemFlag; /* flags for the list elem instance (not the data it represents) */
short datatype; /* type of motion data to expect */
void *key_data; /* motion data - mostly F-Curves, but can be other types too */
struct ID *id; /* ID block that channel is attached to */
struct AnimData *adt; /* source of the animation data attached to ID block (for convenience) */

View File

@ -1067,7 +1067,7 @@ static Base *duplibase_for_convert(Scene *scene, Base *base, Object *ob)
}
obn= copy_object(ob);
obn->recalc |= OB_RECALC;
obn->recalc |= OB_RECALC_ALL;
basen= MEM_mallocN(sizeof(Base), "duplibase");
*basen= *base;
@ -1150,7 +1150,7 @@ static int convert_exec(bContext *C, wmOperator *op)
newob->data= copy_mesh(me);
} else {
newob = ob;
ob->recalc |= OB_RECALC;
ob->recalc |= OB_RECALC_ALL;
}
/* make new mesh data from the original copy */
@ -1211,7 +1211,7 @@ static int convert_exec(bContext *C, wmOperator *op)
for(ob1= G.main->object.first; ob1; ob1=ob1->id.next) {
if(ob1->data==ob->data) {
ob1->type= OB_CURVE;
ob1->recalc |= OB_RECALC;
ob1->recalc |= OB_RECALC_ALL;
}
}
}
@ -1402,7 +1402,7 @@ static Base *object_add_duplicate_internal(Scene *scene, Base *base, int dupflag
}
else {
obn= copy_object(ob);
obn->recalc |= OB_RECALC;
obn->recalc |= OB_RECALC_ALL;
basen= MEM_mallocN(sizeof(Base), "duplibase");
*basen= *base;

View File

@ -468,7 +468,7 @@ void ED_object_enter_editmode(bContext *C, int flag)
scene->obedit= ob;
ED_armature_to_edit(ob);
/* to ensure all goes in restposition and without striding */
DAG_id_flush_update(&ob->id, OB_RECALC);
DAG_id_flush_update(&ob->id, OB_RECALC_ALL); // XXX: should this be OB_RECALC_DATA?
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_ARMATURE, scene);
}

View File

@ -193,7 +193,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
if(ob != obedit) {
ob->recalc |= OB_RECALC;
ob->recalc |= OB_RECALC_ALL;
par= obedit->parent;
while(par) {
@ -339,7 +339,7 @@ static int make_proxy_exec (bContext *C, wmOperator *op)
/* depsgraph flushes are needed for the new data */
DAG_scene_sort(scene);
DAG_id_flush_update(&newob->id, OB_RECALC);
DAG_id_flush_update(&newob->id, OB_RECALC_ALL);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, newob);
}
else {
@ -427,7 +427,7 @@ static int parent_clear_exec(bContext *C, wmOperator *op)
else if(type == 2)
unit_m4(ob->parentinv);
ob->recalc |= OB_RECALC;
ob->recalc |= OB_RECALC_ALL;
}
CTX_DATA_END;
@ -869,7 +869,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op)
/* remove track-object for old track */
ob->track= NULL;
ob->recalc |= OB_RECALC;
ob->recalc |= OB_RECALC_ALL;
/* also remove all tracking constraints */
for (con= ob->constraints.last; con; con= pcon) {
@ -935,7 +935,7 @@ static int track_set_exec(bContext *C, wmOperator *op)
data = con->data;
data->tar = obact;
ob->recalc |= OB_RECALC;
ob->recalc |= OB_RECALC_ALL;
/* Lamp and Camera track differently by default */
if (ob->type == OB_LAMP || ob->type == OB_CAMERA)
@ -954,7 +954,7 @@ static int track_set_exec(bContext *C, wmOperator *op)
data = con->data;
data->tar = obact;
ob->recalc |= OB_RECALC;
ob->recalc |= OB_RECALC_ALL;
/* Lamp and Camera track differently by default */
if (ob->type == OB_LAMP || ob->type == OB_CAMERA) {
@ -975,7 +975,7 @@ static int track_set_exec(bContext *C, wmOperator *op)
data = con->data;
data->tar = obact;
ob->recalc |= OB_RECALC;
ob->recalc |= OB_RECALC_ALL;
/* Lamp and Camera track differently by default */
if (ob->type == OB_LAMP || ob->type == OB_CAMERA) {
@ -1259,7 +1259,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
break;
case MAKE_LINKS_MODIFIERS:
object_link_modifiers(obt, ob);
obt->recalc |= OB_RECALC;
obt->recalc |= OB_RECALC_ALL;
break;
}
}

View File

@ -4826,7 +4826,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
// fixme... some of this stuff is not good
if (ob) {
if (ob->pose || ob_get_key(ob))
DAG_id_flush_update(&ob->id, OB_RECALC);
DAG_id_flush_update(&ob->id, OB_RECALC_ALL);
else
DAG_id_flush_update(&ob->id, OB_RECALC_OB);
}

View File

@ -810,7 +810,7 @@ void recalcData(TransInfo *t)
/* sets recalc flags fully, instead of flushing existing ones
* otherwise proxies don't function correctly
*/
DAG_id_flush_update(&ob->id, OB_RECALC);
DAG_id_flush_update(&ob->id, OB_RECALC_ALL); // XXX: OB_RECALC_OB only?
}
}

View File

@ -436,7 +436,7 @@ extern Object workob;
#define OB_RECALC_DATA 2
/* time flag is set when time changes need recalc, so baked systems can ignore it */
#define OB_RECALC_TIME 4
#define OB_RECALC 7
#define OB_RECALC_ALL 7
/* controller state */
#define OB_MAX_STATES 30

View File

@ -1242,7 +1242,7 @@ static void rna_property_update(bContext *C, Main *bmain, Scene *scene, PointerR
else {
/* WARNING! This is so property drivers update the display!
* not especially nice */
DAG_id_flush_update(ptr->id.data, OB_RECALC);
DAG_id_flush_update(ptr->id.data, OB_RECALC_ALL);
WM_main_add_notifier(NC_WINDOW, NULL);
}

View File

@ -834,6 +834,7 @@ static void rna_def_textbox(BlenderRNA *brna)
srna= RNA_def_struct(brna, "TextBox", NULL);
RNA_def_struct_ui_text(srna, "Text Box", "Text bounding box for layout");
// XXX: still needs path function
/* number values */
prop= RNA_def_property(srna, "x", PROP_FLOAT, PROP_NONE);

View File

@ -459,7 +459,7 @@ static void rna_FieldSettings_update(Main *bmain, Scene *scene, PointerRNA *ptr)
part->pd2->tex= 0;
}
DAG_id_flush_update(&part->id, OB_RECALC|PSYS_RECALC_RESET);
DAG_id_flush_update(&part->id, OB_RECALC_ALL|PSYS_RECALC_RESET);
WM_main_add_notifier(NC_OBJECT|ND_DRAW, NULL);
}
@ -501,7 +501,7 @@ static void rna_FieldSettings_shape_update(Main *bmain, Scene *scene, PointerRNA
static void rna_FieldSettings_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
if(particle_id_check(ptr)) {
DAG_id_flush_update((ID*)ptr->id.data, OB_RECALC|PSYS_RECALC_RESET);
DAG_id_flush_update((ID*)ptr->id.data, OB_RECALC_ALL|PSYS_RECALC_RESET);
}
else {
Object *ob= (Object*)ptr->id.data;
@ -518,7 +518,7 @@ static void rna_FieldSettings_dependency_update(Main *bmain, Scene *scene, Point
DAG_scene_sort(scene);
if(ob->type == OB_CURVE && ob->pd->forcefield == PFIELD_GUIDE)
DAG_id_flush_update(&ob->id, OB_RECALC);
DAG_id_flush_update(&ob->id, OB_RECALC_ALL);
else
DAG_id_flush_update(&ob->id, OB_RECALC_OB);
@ -628,7 +628,7 @@ static void rna_CollisionSettings_update(Main *bmain, Scene *scene, PointerRNA *
{
Object *ob= (Object*)ptr->id.data;
DAG_id_flush_update(&ob->id, OB_RECALC);
DAG_id_flush_update(&ob->id, OB_RECALC_ALL);
WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob);
}

View File

@ -201,7 +201,7 @@ static Base *rna_Scene_object_link(Scene *scene, bContext *C, ReportList *report
if(scene == scene_act)
ob->lay= base->lay;
ob->recalc |= OB_RECALC;
ob->recalc |= OB_RECALC_ALL;
DAG_scene_sort(scene);