Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/context.c
| Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "BKE_sound.h" | #include "BKE_sound.h" | ||||
| #include "BKE_workspace.h" | #include "BKE_workspace.h" | ||||
| #include "RE_engine.h" | |||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| # include "BPY_extern.h" | # include "BPY_extern.h" | ||||
| #endif | #endif | ||||
| /* struct */ | /* struct */ | ||||
| ▲ Show 20 Lines • Show All 854 Lines • ▼ Show 20 Lines | |||||
| SceneLayer *CTX_data_scene_layer(const bContext *C) | SceneLayer *CTX_data_scene_layer(const bContext *C) | ||||
| { | { | ||||
| SceneLayer *sl; | SceneLayer *sl; | ||||
| if (ctx_data_pointer_verify(C, "render_layer", (void *)&sl)) { | if (ctx_data_pointer_verify(C, "render_layer", (void *)&sl)) { | ||||
| return sl; | return sl; | ||||
| } | } | ||||
| else { | else { | ||||
| return BKE_scene_layer_from_workspace_get(CTX_wm_workspace(C)); | return BKE_scene_layer_from_workspace_get(CTX_data_scene(C), CTX_wm_workspace(C)); | ||||
| } | |||||
| } | |||||
| RenderEngineType *CTX_data_engine(const bContext *C) | |||||
| { | |||||
| const char *engine_name; | |||||
| if (!ctx_data_pointer_verify(C, "engine", (void *)&engine_name)) { | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| WorkSpace *workspace = CTX_wm_workspace(C); | |||||
| engine_name = BKE_render_engine_get(scene, workspace); | |||||
| } | } | ||||
| return RE_engines_find(engine_name); | |||||
| } | } | ||||
| /** | /** | ||||
| * This is tricky. Sometimes the user overrides the render_layer | * This is tricky. Sometimes the user overrides the render_layer | ||||
| * but not the scene_collection. In this case what to do? | * but not the scene_collection. In this case what to do? | ||||
| * | * | ||||
| * If the scene_collection is linked to the SceneLayer we use it. | * If the scene_collection is linked to the SceneLayer we use it. | ||||
| * Otherwise we fallback to the active one of the SceneLayer. | * Otherwise we fallback to the active one of the SceneLayer. | ||||
| ▲ Show 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| void CTX_data_eval_ctx(const bContext *C, EvaluationContext *eval_ctx) | void CTX_data_eval_ctx(const bContext *C, EvaluationContext *eval_ctx) | ||||
| { | { | ||||
| BLI_assert(C != NULL); | BLI_assert(C != NULL); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *scene_layer = CTX_data_scene_layer(C); | SceneLayer *scene_layer = CTX_data_scene_layer(C); | ||||
| RenderEngineType *engine = CTX_data_engine(C); | |||||
| DEG_evaluation_context_init_from_scene(eval_ctx, | DEG_evaluation_context_init_from_scene(eval_ctx, | ||||
| scene, scene_layer, | scene, scene_layer, engine, | ||||
| DAG_EVAL_VIEWPORT); | DAG_EVAL_VIEWPORT); | ||||
| } | } | ||||