Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/object_dupli.c
| Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
| typedef struct DupliContext { | typedef struct DupliContext { | ||||
| const EvaluationContext *eval_ctx; | const EvaluationContext *eval_ctx; | ||||
| bool do_update; | bool do_update; | ||||
| bool animated; | bool animated; | ||||
| Group *group; /* XXX child objects are selected from this group if set, could be nicer */ | Group *group; /* XXX child objects are selected from this group if set, could be nicer */ | ||||
| Scene *scene; | Scene *scene; | ||||
| SceneLayer *scene_layer; | ViewLayer *view_layer; | ||||
| Object *object; | Object *object; | ||||
| float space_mat[4][4]; | float space_mat[4][4]; | ||||
| int persistent_id[MAX_DUPLI_RECUR]; | int persistent_id[MAX_DUPLI_RECUR]; | ||||
| int level; | int level; | ||||
| const struct DupliGenerator *gen; | const struct DupliGenerator *gen; | ||||
| /* result containers */ | /* result containers */ | ||||
| ListBase *duplilist; /* legacy doubly-linked list */ | ListBase *duplilist; /* legacy doubly-linked list */ | ||||
| } DupliContext; | } DupliContext; | ||||
| typedef struct DupliGenerator { | typedef struct DupliGenerator { | ||||
| short type; /* dupli type */ | short type; /* dupli type */ | ||||
| void (*make_duplis)(const DupliContext *ctx); | void (*make_duplis)(const DupliContext *ctx); | ||||
| } DupliGenerator; | } DupliGenerator; | ||||
| static const DupliGenerator *get_dupli_generator(const DupliContext *ctx); | static const DupliGenerator *get_dupli_generator(const DupliContext *ctx); | ||||
| /* create initial context for root object */ | /* create initial context for root object */ | ||||
| static void init_context(DupliContext *r_ctx, const EvaluationContext *eval_ctx, Scene *scene, Object *ob, float space_mat[4][4], bool update) | static void init_context(DupliContext *r_ctx, const EvaluationContext *eval_ctx, Scene *scene, Object *ob, float space_mat[4][4], bool update) | ||||
| { | { | ||||
| r_ctx->eval_ctx = eval_ctx; | r_ctx->eval_ctx = eval_ctx; | ||||
| r_ctx->scene = scene; | r_ctx->scene = scene; | ||||
| r_ctx->scene_layer = eval_ctx->scene_layer; | r_ctx->view_layer = eval_ctx->view_layer; | ||||
| /* don't allow BKE_object_handle_update for viewport during render, can crash */ | /* don't allow BKE_object_handle_update for viewport during render, can crash */ | ||||
| r_ctx->do_update = update && !(G.is_rendering && eval_ctx->mode != DAG_EVAL_RENDER); | r_ctx->do_update = update && !(G.is_rendering && eval_ctx->mode != DAG_EVAL_RENDER); | ||||
| r_ctx->animated = false; | r_ctx->animated = false; | ||||
| r_ctx->group = NULL; | r_ctx->group = NULL; | ||||
| r_ctx->object = ob; | r_ctx->object = ob; | ||||
| 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 141 Lines • ▼ Show 20 Lines | for (go = ctx->group->gobject.first; go; go = go->next, groupid++) { | ||||
| ob->flag |= OB_DONE; /* doesnt render */ | ob->flag |= OB_DONE; /* doesnt render */ | ||||
| make_child_duplis_cb(&pctx, userdata, ob); | make_child_duplis_cb(&pctx, userdata, ob); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| int baseid = 0; | int baseid = 0; | ||||
| SceneLayer *scene_layer = ctx->scene_layer; | ViewLayer *view_layer = ctx->view_layer; | ||||
| for (Base *base = scene_layer->object_bases.first; base; base = base->next, baseid++) { | for (Base *base = view_layer->object_bases.first; base; base = base->next, baseid++) { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| if ((base->flag & BASE_VISIBLED) && ob != obedit && is_child(ob, parent)) { | if ((base->flag & BASE_VISIBLED) && ob != obedit && is_child(ob, parent)) { | ||||
| DupliContext pctx; | DupliContext pctx; | ||||
| copy_dupli_context(&pctx, ctx, ctx->object, NULL, baseid, false); | copy_dupli_context(&pctx, ctx, ctx->object, NULL, baseid, false); | ||||
| /* mballs have a different dupli handling */ | /* mballs have a different dupli handling */ | ||||
| if (ob->type != OB_MBALL) | if (ob->type != OB_MBALL) | ||||
| ob->flag |= OB_DONE; /* doesnt render */ | ob->flag |= OB_DONE; /* doesnt render */ | ||||
| ▲ Show 20 Lines • Show All 1,059 Lines • Show Last 20 Lines | |||||