Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/object_dupli.cc
| Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | |||||
| struct DupliContext { | struct DupliContext { | ||||
| Depsgraph *depsgraph; | Depsgraph *depsgraph; | ||||
| /** XXX child objects are selected from this group if set, could be nicer. */ | /** XXX child objects are selected from this group if set, could be nicer. */ | ||||
| Collection *collection; | Collection *collection; | ||||
| /** Only to check if the object is in edit-mode. */ | /** Only to check if the object is in edit-mode. */ | ||||
| Object *obedit; | Object *obedit; | ||||
| Scene *scene; | Scene *scene; | ||||
| ViewLayer *view_layer; | |||||
| Object *object; | Object *object; | ||||
| float space_mat[4][4]; | float space_mat[4][4]; | ||||
| /** | /** | ||||
| * A stack that contains all the "parent" objects of a particular instance when recursive | * A stack that contains all the "parent" objects of a particular instance when recursive | ||||
| * instancing is used. This is used to prevent objects from instancing themselves accidentally. | * instancing is used. This is used to prevent objects from instancing themselves accidentally. | ||||
| * Use a vector instead of a stack because we want to use the #contains method. | * Use a vector instead of a stack because we want to use the #contains method. | ||||
| */ | */ | ||||
| Show All 22 Lines | static void init_context(DupliContext *r_ctx, | ||||
| Depsgraph *depsgraph, | Depsgraph *depsgraph, | ||||
| Scene *scene, | Scene *scene, | ||||
| Object *ob, | Object *ob, | ||||
| const float space_mat[4][4], | const float space_mat[4][4], | ||||
| Vector<Object *> &instance_stack) | Vector<Object *> &instance_stack) | ||||
| { | { | ||||
| r_ctx->depsgraph = depsgraph; | r_ctx->depsgraph = depsgraph; | ||||
| r_ctx->scene = scene; | r_ctx->scene = scene; | ||||
| r_ctx->view_layer = DEG_get_evaluated_view_layer(depsgraph); | |||||
| r_ctx->collection = nullptr; | r_ctx->collection = nullptr; | ||||
| r_ctx->object = ob; | r_ctx->object = ob; | ||||
| r_ctx->obedit = OBEDIT_FROM_OBACT(ob); | r_ctx->obedit = OBEDIT_FROM_OBACT(ob); | ||||
| r_ctx->instance_stack = &instance_stack; | r_ctx->instance_stack = &instance_stack; | ||||
| if (space_mat) { | if (space_mat) { | ||||
| copy_m4_m4(r_ctx->space_mat, space_mat); | copy_m4_m4(r_ctx->space_mat, space_mat); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 167 Lines • ▼ Show 20 Lines | FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (ctx->collection, ob, mode) { | ||||
| ob->flag |= OB_DONE; /* Doesn't render. */ | ob->flag |= OB_DONE; /* Doesn't render. */ | ||||
| } | } | ||||
| make_child_duplis_cb(&pctx, userdata, ob); | make_child_duplis_cb(&pctx, userdata, ob); | ||||
| } | } | ||||
| } | } | ||||
| FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; | FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; | ||||
| } | } | ||||
| else { | else { | ||||
| int baseid; | int persistent_dupli_id = 0; | ||||
| ViewLayer *view_layer = ctx->view_layer; | int deg_objects_visibility_flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | | ||||
| LISTBASE_FOREACH_INDEX (Base *, base, &view_layer->object_bases, baseid) { | DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY | | ||||
| Object *ob = base->object; | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET; | ||||
| DEG_OBJECT_ITER_BEGIN (ctx->depsgraph, ob, deg_objects_visibility_flags) { | |||||
sergey: Maybe add a clue that we want to investigate usage of `session_uuid`? | |||||
| if ((ob != ctx->obedit) && is_child(ob, parent)) { | if ((ob != ctx->obedit) && is_child(ob, parent)) { | ||||
| DupliContext pctx; | DupliContext pctx; | ||||
| copy_dupli_context(&pctx, ctx, ctx->object, nullptr, baseid); | copy_dupli_context(&pctx, ctx, ctx->object, nullptr, persistent_dupli_id); | ||||
| /* Meta-balls have a different dupli-handling. */ | /* Meta-balls have a different dupli-handling. */ | ||||
| if (ob->type != OB_MBALL) { | if (ob->type != OB_MBALL) { | ||||
| ob->flag |= OB_DONE; /* Doesn't render. */ | ob->flag |= OB_DONE; /* Doesn't render. */ | ||||
| } | } | ||||
| make_child_duplis_cb(&pctx, userdata, ob); | make_child_duplis_cb(&pctx, userdata, ob); | ||||
| } | } | ||||
| persistent_dupli_id++; | |||||
| } | } | ||||
| DEG_OBJECT_ITER_END; | |||||
| } | } | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Internal Data Access Utilities | /** \name Internal Data Access Utilities | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 1,359 Lines • Show Last 20 Lines | |||||
Maybe add a clue that we want to investigate usage of session_uuid?