Depsgraph fix for editing linked Objects with the other instances being

in other layers (or hidden with local view).

In my search for the absolute minimum of recalculations, changes are only
flushed when they're visible. On changing layers, the tags then are just
set again (for everything that potentially moves) to ensure proper state.

However, it didn't work proper for linked Mesh objects that changed in
editmode, the Derivedmesh callback then accessed memory out of bounds.

The current dependency code was more designed for animation systems...
updating display data should work too, but might need some more tests!

(Thanks Andrea for clear error sample!)
This commit is contained in:
2005-11-27 20:49:25 +00:00
parent ebb00c1ce5
commit acd06aebc1
4 changed files with 33 additions and 8 deletions

View File

@@ -50,8 +50,11 @@ void copy_baseflags(void);
void copy_objectflags(void);
struct SoftBody *copy_softbody(struct SoftBody *sb);
void update_base_layer(struct Object *ob);
void free_object(struct Object *ob);
void object_free_display(struct Object *ob);
void object_free_modifiers(struct Object *ob);
void unlink_object(struct Object *ob);
int exist_object(struct Object *obtest);
void *add_camera(void);

View File

@@ -67,6 +67,7 @@
#include "BKE_key.h"
#include "BKE_mball.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_utildefines.h"
#include "MEM_guardedalloc.h"
@@ -1390,9 +1391,13 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
}
}
/* even nicer, we can clear recalc flags... */
if((all_layer & layer)==0)
if((all_layer & layer)==0) {
/* but existing displaylists or derivedmesh should be freed */
if(ob->recalc & OB_RECALC_DATA)
object_free_display(ob);
ob->recalc &= ~OB_RECALC;
}
}
/* check case where child changes and parent forcing obdata to change */

View File

@@ -161,14 +161,29 @@ void object_free_modifiers(Object *ob)
}
}
/* here we will collect all local displist stuff */
/* also (ab)used in depsgraph */
void object_free_display(Object *ob)
{
if(ob->derivedDeform) {
ob->derivedDeform->release(ob->derivedDeform);
ob->derivedDeform= NULL;
}
if(ob->derivedFinal) {
ob->derivedFinal->release(ob->derivedFinal);
ob->derivedFinal= NULL;
}
freedisplist(&ob->disp);
}
/* do not free object itself */
void free_object(Object *ob)
{
int a;
if(ob->derivedDeform) ob->derivedDeform->release(ob->derivedDeform);
if(ob->derivedFinal) ob->derivedFinal->release(ob->derivedFinal);
object_free_display(ob);
/* disconnect specific data */
if(ob->data) {
ID *id= ob->data;
@@ -211,8 +226,6 @@ void free_object(Object *ob)
free_constraint_channels(&ob->constraintChannels);
free_nlastrips(&ob->nlastrips);
freedisplist(&ob->disp);
BPY_free_scriptlink(&ob->scriptlink);
if(ob->pd) MEM_freeN(ob->pd);

View File

@@ -3881,7 +3881,11 @@ void do_view3d_buttons(short event)
case B_LOCALVIEW:
if(G.vd->localview) initlocalview();
else endlocalview(curarea);
else {
endlocalview(curarea);
/* new layers might need unflushed events events */
DAG_scene_update_flags(G.scene, G.vd->lay); // tags all that moves and flushes
}
scrarea_queue_headredraw(curarea);
break;