LineArt: Temporary fix for object loading iterator.

Use `DEG_OBJECT_ITER_BEGIN`for loading objects, this iterator is
technially unsafe to use *during* depsgraph evaluation,
see https://developer.blender.org/D14997 for detailed explainations.
This commit is contained in:
YimingWu 2022-06-01 14:34:10 +08:00
parent 1bf35f1b19
commit 71ce47a71d
Notes: blender-bot 2023-02-14 09:17:57 +01:00
Referenced by issue #102612, Regression: LineArt crash on file load
1 changed files with 18 additions and 14 deletions

View File

@ -2454,31 +2454,35 @@ static void lineart_main_load_geometries(
eEvaluationMode eval_mode = DEG_get_mode(depsgraph);
bool is_render = eval_mode == DAG_EVAL_RENDER;
FOREACH_SCENE_OBJECT_BEGIN (scene, ob) {
int flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
DEG_ITER_OBJECT_FLAG_VISIBLE;
/* Instance duplicated & particles. */
if (allow_duplicates) {
flags |= DEG_ITER_OBJECT_FLAG_DUPLI;
}
/* XXX(Yiming): Temporary solution, this iterator is technially unsafe to use *during* depsgraph
* evaluation, see https://developer.blender.org/D14997 for detailed explainations. */
DEG_OBJECT_ITER_BEGIN (depsgraph, ob, flags) {
Object *eval_ob = DEG_get_evaluated_object(depsgraph, ob);
if (!eval_ob) {
continue;
}
/* DEG_OBJECT_ITER_BEGIN will include the instanced mesh of these curve object types, so don't
* load them twice. */
if (allow_duplicates && ELEM(ob->type, OB_CURVES_LEGACY, OB_FONT, OB_SURF)) {
continue;
}
if (BKE_object_visibility(eval_ob, eval_mode) & OB_VISIBLE_SELF) {
lineart_object_load_single_instance(
rb, depsgraph, scene, eval_ob, eval_ob, eval_ob->obmat, is_render, olti, thread_count);
}
if (allow_duplicates) {
ListBase *dupli = object_duplilist(depsgraph, scene, eval_ob);
LISTBASE_FOREACH (DupliObject *, dob, dupli) {
if (BKE_object_visibility(eval_ob, eval_mode) &
(OB_VISIBLE_PARTICLES | OB_VISIBLE_INSTANCES)) {
Object *ob_ref = (dob->type & OB_DUPLIPARTS) ? eval_ob : dob->ob;
lineart_object_load_single_instance(
rb, depsgraph, scene, dob->ob, ob_ref, dob->mat, is_render, olti, thread_count);
}
}
free_object_duplilist(dupli);
}
}
FOREACH_SCENE_OBJECT_END;
DEG_OBJECT_ITER_END;
TaskPool *tp = BLI_task_pool_create(NULL, TASK_PRIORITY_HIGH);