diff options
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_context.c | 31 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 252 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene_api.c | 15 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 27 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_workspace.c | 22 |
7 files changed, 192 insertions, 158 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 114b0c32c15..501a1cccca6 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -708,6 +708,7 @@ extern StructRNA RNA_WaveModifier; extern StructRNA RNA_VertexWeightEditModifier; extern StructRNA RNA_VertexWeightMixModifier; extern StructRNA RNA_VertexWeightProximityModifier; +extern StructRNA RNA_ViewRenderSettings; extern StructRNA RNA_Window; extern StructRNA RNA_WindowManager; extern StructRNA RNA_WipeSequence; diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index 5701150b1bf..7be3dd60d52 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -39,6 +39,8 @@ #ifdef RNA_RUNTIME +#include "RE_engine.h" + static PointerRNA rna_Context_manager_get(PointerRNA *ptr) { bContext *C = (bContext *)ptr->data; @@ -133,6 +135,26 @@ static PointerRNA rna_Context_scene_layer_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_SceneLayer, CTX_data_scene_layer(C)); } +static PointerRNA rna_Context_view_render_get(PointerRNA *ptr) +{ + bContext *C = (bContext *)ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_ViewRenderSettings, CTX_data_view_render(C)); +} + +static void rna_Context_engine_get(PointerRNA *ptr, char *value) + { + bContext *C = (bContext *)ptr->data; + RenderEngineType *engine = CTX_data_engine(C); + strcpy(value, engine->idname); +} + +static int rna_Context_engine_length(PointerRNA *ptr) +{ + bContext *C = (bContext *)ptr->data; + RenderEngineType *engine = CTX_data_engine(C); + return strlen(engine->idname); +} + static PointerRNA rna_Context_scene_collection_get(PointerRNA *ptr) { bContext *C = (bContext *)ptr->data; @@ -263,6 +285,15 @@ void RNA_def_context(BlenderRNA *brna) RNA_def_property_struct_type(prop, "SceneLayer"); RNA_def_property_pointer_funcs(prop, "rna_Context_scene_layer_get", NULL, NULL, NULL); + prop = RNA_def_property(srna, "view_render", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "ViewRenderSettings"); + RNA_def_property_pointer_funcs(prop, "rna_Context_view_render_get", NULL, NULL, NULL); + + prop = RNA_def_property(srna, "engine", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_string_funcs(prop, "rna_Context_engine_get", "rna_Context_engine_length", NULL); + prop = RNA_def_property(srna, "scene_collection", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "SceneCollection"); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 29d68111bac..0f59451e17c 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -3027,7 +3027,7 @@ static void rna_ShaderNodeScript_update(Main *bmain, Scene *scene, PointerRNA *p { bNodeTree *ntree = (bNodeTree *)ptr->id.data; bNode *node = (bNode *)ptr->data; - RenderEngineType *engine_type = RE_engines_find(scene->r.engine); + RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id); if (engine_type && engine_type->update_script_node) { /* auto update node */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 685844149e1..3e1f8f06d92 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -454,6 +454,7 @@ EnumPropertyItem rna_enum_layer_collection_mode_settings_type_items[] = { #include "DNA_object_types.h" #include "DNA_mesh_types.h" #include "DNA_text_types.h" +#include "DNA_workspace_types.h" #include "RNA_access.h" @@ -1007,6 +1008,11 @@ static void rna_RenderSettings_stereoViews_begin(CollectionPropertyIterator *ite rna_iterator_listbase_begin(iter, &rd->views, rna_RenderSettings_stereoViews_skip); } +static char *rna_ViewRenderSettings_path(PointerRNA *UNUSED(ptr)) +{ + return BLI_sprintfN("viewport_render"); +} + static char *rna_RenderSettings_path(PointerRNA *UNUSED(ptr)) { return BLI_sprintfN("render"); @@ -1482,19 +1488,32 @@ static void rna_RenderView_remove( WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL); } -static void rna_RenderSettings_engine_set(PointerRNA *ptr, int value) +static void rna_RenderSettings_views_format_set(PointerRNA *ptr, int value) { RenderData *rd = (RenderData *)ptr->data; - RenderEngineType *type = BLI_findlink(&R_engines, value); - Scene *scene = (Scene *)ptr->id.data; - if (type) - BLI_strncpy_utf8(rd->engine, type->idname, sizeof(rd->engine)); + if (rd->views_format == SCE_VIEWS_FORMAT_MULTIVIEW && + value == SCE_VIEWS_FORMAT_STEREO_3D) + { + /* make sure the actview is visible */ + if (rd->actview > 1) rd->actview = 1; + } + + rd->views_format = value; +} + +static void rna_ViewRenderSettings_engine_set(PointerRNA *ptr, int value) +{ + ViewRender *view_render = (ViewRender *)ptr->data; + RenderEngineType *type = BLI_findlink(&R_engines, value); - DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); + if (type) { + BLI_strncpy_utf8(view_render->engine_id, type->idname, sizeof(view_render->engine_id)); + DEG_id_tag_update(ptr->id.data, DEG_TAG_COPY_ON_WRITE); + } } -static EnumPropertyItem *rna_RenderSettings_engine_itemf( +static EnumPropertyItem *rna_ViewRenderSettings_engine_itemf( bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { RenderEngineType *type; @@ -1515,20 +1534,20 @@ static EnumPropertyItem *rna_RenderSettings_engine_itemf( return item; } -static int rna_RenderSettings_engine_get(PointerRNA *ptr) +static int rna_ViewRenderSettings_engine_get(PointerRNA *ptr) { - RenderData *rd = (RenderData *)ptr->data; + ViewRender *view_render = (ViewRender *)ptr->data; RenderEngineType *type; int a = 0; for (type = R_engines.first; type; type = type->next, a++) - if (STREQ(type->idname, rd->engine)) + if (STREQ(type->idname, view_render->engine_id)) return a; return 0; } -static void rna_RenderSettings_engine_update(Main *bmain, Scene *UNUSED(unused), PointerRNA *UNUSED(ptr)) +static void rna_ViewRenderSettings_engine_update(Main *bmain, Scene *UNUSED(unused), PointerRNA *UNUSED(ptr)) { ED_render_engine_changed(bmain); } @@ -1624,44 +1643,30 @@ static char *rna_SceneRenderView_path(PointerRNA *ptr) return BLI_sprintfN("render.views[\"%s\"]", srv->name); } -static void rna_RenderSettings_views_format_set(PointerRNA *ptr, int value) -{ - RenderData *rd = (RenderData *)ptr->data; - - if (rd->views_format == SCE_VIEWS_FORMAT_MULTIVIEW && - value == SCE_VIEWS_FORMAT_STEREO_3D) - { - /* make sure the actview is visible */ - if (rd->actview > 1) rd->actview = 1; - } - - rd->views_format = value; -} - -static int rna_RenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr)) +static int rna_ViewRenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr)) { return (BLI_listbase_count(&R_engines) > 1); } -static int rna_RenderSettings_use_shading_nodes_get(PointerRNA *ptr) +static int rna_ViewRenderSettings_use_shading_nodes_get(PointerRNA *ptr) { - Scene *scene = (Scene *)ptr->id.data; - return BKE_scene_use_new_shading_nodes(scene); + ViewRender *view_render = (ViewRender *)ptr->data; + return BKE_viewrender_use_new_shading_nodes(view_render); } -static int rna_RenderSettings_use_spherical_stereo_get(PointerRNA *ptr) +static int rna_ViewRenderSettings_use_spherical_stereo_get(PointerRNA *ptr) { - Scene *scene = (Scene *)ptr->id.data; - return BKE_scene_use_spherical_stereo(scene); + ViewRender *view_render = (ViewRender *)ptr->data; + return BKE_viewrender_use_spherical_stereo(view_render); } -static int rna_RenderSettings_use_game_engine_get(PointerRNA *ptr) +static int rna_ViewRenderSettings_use_game_engine_get(PointerRNA *ptr) { - RenderData *rd = (RenderData *)ptr->data; + ViewRender *view_render = (ViewRender *)ptr->data; RenderEngineType *type; for (type = R_engines.first; type; type = type->next) - if (STREQ(type->idname, rd->engine)) + if (STREQ(type->idname, view_render->engine_id)) return (type->flag & RE_GAME) != 0; return 0; @@ -1771,26 +1776,32 @@ static void object_simplify_update(Object *ob) } } -static void rna_Scene_use_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Scene_use_simplify_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Scene *sce = ptr->id.data; Scene *sce_iter; Base *base; - BKE_main_id_tag_listbase(&bmain->object, LIB_TAG_DOIT, true); - for (SETLOOPER(sce, sce_iter, base)) + FOREACH_SCENE_OBJECT(sce, ob) + { + object_simplify_update(ob); + } + FOREACH_SCENE_OBJECT_END + + for (SETLOOPER_SET_ONLY(sce, sce_iter, base)) { object_simplify_update(base->object); + } WM_main_add_notifier(NC_GEOM | ND_DATA, NULL); - DEG_id_tag_update(&scene->id, 0); + DEG_id_tag_update(&sce->id, 0); } -static void rna_Scene_simplify_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Scene_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Scene *sce = ptr->id.data; if (sce->r.mode & R_SIMPLIFY) - rna_Scene_use_simplify_update(bmain, sce, ptr); + rna_Scene_use_simplify_update(bmain, scene, ptr); } static void rna_SceneRenderData_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -2977,59 +2988,6 @@ static void rna_LayerObjects_selected_begin(CollectionPropertyIterator *iter, Po rna_iterator_listbase_begin(iter, &sl->object_bases, rna_SceneLayer_objects_selected_skip); } -static void rna_SceneLayer_engine_set(PointerRNA *ptr, int value) -{ - SceneLayer *sl = (SceneLayer *)ptr->data; - RenderEngineType *type = BLI_findlink(&R_engines, value); - - if (type) - BKE_scene_layer_engine_set(sl, type->idname); -} - -static EnumPropertyItem *rna_SceneLayer_engine_itemf( - bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) -{ - RenderEngineType *type; - EnumPropertyItem *item = NULL; - EnumPropertyItem tmp = {0, "", 0, "", ""}; - int a = 0, totitem = 0; - - for (type = R_engines.first; type; type = type->next, a++) { - tmp.value = a; - tmp.identifier = type->idname; - tmp.name = type->name; - RNA_enum_item_add(&item, &totitem, &tmp); - } - - RNA_enum_item_end(&item, &totitem); - *r_free = true; - - return item; -} - -static int rna_SceneLayer_engine_get(PointerRNA *ptr) -{ - SceneLayer *sl = (SceneLayer *)ptr->data; - RenderEngineType *type; - int a = 0; - - for (type = R_engines.first; type; type = type->next, a++) - if (STREQ(type->idname, sl->engine)) - return a; - - return 0; -} - -static void rna_SceneLayer_engine_update(Main *bmain, Scene *UNUSED(unused), PointerRNA *UNUSED(ptr)) -{ - ED_render_engine_changed(bmain); -} - -static int rna_SceneLayer_multiple_engines_get(PointerRNA *UNUSED(ptr)) -{ - return (BLI_listbase_count(&R_engines) > 1); -} - static void rna_SceneLayer_update_tagged(SceneLayer *UNUSED(sl), bContext *C) { Depsgraph *graph = CTX_data_depsgraph(C); @@ -7067,11 +7025,6 @@ static void rna_def_scene_layer(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem engine_items[] = { - {0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"}, - {0, NULL, 0, NULL, NULL} - }; - srna = RNA_def_struct(brna, "SceneLayer", NULL); RNA_def_struct_ui_text(srna, "Render Layer", "Render layer"); RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS); @@ -7107,20 +7060,6 @@ static void rna_def_scene_layer(BlenderRNA *brna) RNA_def_property_struct_type(prop, "SceneLayerSettings"); RNA_def_property_ui_text(prop, "Layer Settings", "Override of engine specific render settings"); - /* engine */ - prop = RNA_def_property(srna, "engine", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, engine_items); - RNA_def_property_enum_funcs(prop, "rna_SceneLayer_engine_get", "rna_SceneLayer_engine_set", - "rna_SceneLayer_engine_itemf"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Engine", "Engine to use for rendering"); - RNA_def_property_update(prop, NC_WINDOW, "rna_SceneLayer_engine_update"); - - prop = RNA_def_property(srna, "has_multiple_engines", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_SceneLayer_multiple_engines_get", NULL); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Multiple Engines", "More than one rendering engine is available"); - /* debug update routine */ func = RNA_def_function(srna, "update", "rna_SceneLayer_update_tagged"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); @@ -7937,11 +7876,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem engine_items[] = { - {0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"}, - {0, NULL, 0, NULL, NULL} - }; - static EnumPropertyItem freestyle_thickness_items[] = { {R_LINE_THICKNESS_ABSOLUTE, "ABSOLUTE", 0, "Absolute", "Specify unit line thickness in pixels"}, {R_LINE_THICKNESS_RELATIVE, "RELATIVE", 0, "Relative", @@ -8678,35 +8612,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_enum_funcs(prop, NULL, "rna_RenderSettings_views_format_set", NULL); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - /* engine */ - prop = RNA_def_property(srna, "engine", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, engine_items); - RNA_def_property_enum_funcs(prop, "rna_RenderSettings_engine_get", "rna_RenderSettings_engine_set", - "rna_RenderSettings_engine_itemf"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Engine", "Engine to use for rendering"); - RNA_def_property_update(prop, NC_WINDOW, "rna_RenderSettings_engine_update"); - - prop = RNA_def_property(srna, "has_multiple_engines", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_multiple_engines_get", NULL); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Multiple Engines", "More than one rendering engine is available"); - - prop = RNA_def_property(srna, "use_shading_nodes", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_use_shading_nodes_get", NULL); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Use Shading Nodes", "Active render engine uses new shading nodes system"); - - prop = RNA_def_property(srna, "use_spherical_stereo", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_use_spherical_stereo_get", NULL); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Use Spherical Stereo", "Active render engine supports spherical stereo rendering"); - - prop = RNA_def_property(srna, "use_game_engine", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_use_game_engine_get", NULL); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Use Game Engine", "Current rendering engine is a game engine"); - /* simplify */ prop = RNA_def_property(srna, "use_simplify", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_SIMPLIFY); @@ -8788,6 +8693,52 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_api_scene_render(srna); } +static void rna_def_scene_view_render(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem engine_items[] = { + {0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"}, + {0, NULL, 0, NULL, NULL} + }; + + srna = RNA_def_struct(brna, "ViewRenderSettings", NULL); + RNA_def_struct_sdna(srna, "ViewRender"); + RNA_def_struct_nested(brna, srna, "Scene"); + RNA_def_struct_path_func(srna, "rna_ViewRenderSettings_path"); + RNA_def_struct_ui_text(srna, "View Render", "Rendering settings related to viewport drawing/rendering"); + + /* engine */ + prop = RNA_def_property(srna, "engine", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, engine_items); + RNA_def_property_enum_funcs(prop, "rna_ViewRenderSettings_engine_get", "rna_ViewRenderSettings_engine_set", + "rna_ViewRenderSettings_engine_itemf"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Engine", "Engine to use for rendering"); + RNA_def_property_update(prop, NC_WINDOW, "rna_ViewRenderSettings_engine_update"); + + prop = RNA_def_property(srna, "has_multiple_engines", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_multiple_engines_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Multiple Engines", "More than one rendering engine is available"); + + prop = RNA_def_property(srna, "use_shading_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_use_shading_nodes_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Use Shading Nodes", "Active render engine uses new shading nodes system"); + + prop = RNA_def_property(srna, "use_spherical_stereo", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_use_spherical_stereo_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Use Spherical Stereo", "Active render engine supports spherical stereo rendering"); + + prop = RNA_def_property(srna, "use_game_engine", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_use_game_engine_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Use Game Engine", "Current rendering engine is a game engine"); +} + /* scene.objects */ static void rna_def_scene_objects(BlenderRNA *brna, PropertyRNA *cprop) { @@ -9335,6 +9286,12 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_struct_type(prop, "RenderSettings"); RNA_def_property_ui_text(prop, "Render Data", ""); + /* View Render */ + prop = RNA_def_property(srna, "view_render", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "ViewRenderSettings"); + RNA_def_property_ui_text(prop, "View Render", ""); + /* Render Engine Data */ prop = RNA_def_property(srna, "layer_properties", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "layer_properties->data.group", NULL); @@ -9497,6 +9454,7 @@ void RNA_def_scene(BlenderRNA *brna) rna_def_scene_layer_settings(brna); rna_def_layer_collection_settings(brna); rna_def_scene_render_data(brna); + rna_def_scene_view_render(brna); rna_def_scene_render_layer(brna); rna_def_gpu_fx(brna); rna_def_scene_render_view(brna); diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index a1ef3f17bd6..baa29df3fc3 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -151,14 +151,24 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, int previe } static void rna_Scene_ray_cast( - Scene *scene, SceneLayer *sl, float origin[3], float direction[3], float ray_dist, + Scene *scene, SceneLayer *scene_layer, const char *engine_id, + float origin[3], float direction[3], float ray_dist, int *r_success, float r_location[3], float r_normal[3], int *r_index, Object **r_ob, float r_obmat[16]) { + RenderEngineType *engine; + + if (engine_id == NULL || engine_id[0] == '\0') { + engine = RE_engines_find(scene->view_render.engine_id); + } + else { + engine = RE_engines_find(engine_id); + } + normalize_v3(direction); SnapObjectContext *sctx = ED_transform_snap_object_context_create( - G.main, scene, sl, 0); + G.main, scene, scene_layer, engine, 0); bool ret = ED_transform_snap_object_project_ray_ex( sctx, @@ -354,6 +364,7 @@ void RNA_api_scene(StructRNA *srna) RNA_def_function_ui_description(func, "Cast a ray onto in object space"); parm = RNA_def_pointer(func, "scene_layer", "SceneLayer", "", "Scene Layer"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_string(func, "engine", NULL, MAX_NAME, "Engine", "Render engine, use scene one by default"); /* ray start and end */ parm = RNA_def_float_vector(func, "origin", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index bf583654fc6..016392754d1 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -210,6 +210,7 @@ static EnumPropertyItem buttons_context_items[] = { {BCONTEXT_PARTICLE, "PARTICLES", ICON_PARTICLES, "Particles", "Particle"}, {BCONTEXT_PHYSICS, "PHYSICS", ICON_PHYSICS, "Physics", "Physics"}, {BCONTEXT_COLLECTION, "COLLECTION", ICON_COLLAPSEMENU, "Collection", "Collection"}, + {BCONTEXT_WORKSPACE, "WORKSPACE", ICON_RENDER_RESULT, "Workspace", "Workspace"}, {0, NULL, 0, NULL, NULL} }; @@ -726,8 +727,14 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value static int rna_SpaceView3D_viewport_shade_get(PointerRNA *ptr) { - Scene *scene = WM_windows_scene_get_from_screen(G.main->wm.first, ptr->id.data); - RenderEngineType *type = RE_engines_find(scene->r.engine); + bScreen *screen = ptr->id.data; + + Scene *scene = WM_windows_scene_get_from_screen(G.main->wm.first, screen); + WorkSpace *workspace = WM_windows_workspace_get_from_screen(G.main->wm.first, screen); + + ViewRender *view_render = BKE_viewrender_get(scene, workspace); + RenderEngineType *type = RE_engines_find(view_render->engine_id); + View3D *v3d = (View3D *)ptr->data; int drawtype = v3d->drawtype; @@ -751,7 +758,9 @@ static EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *C, Point { wmWindow *win = CTX_wm_window(C); Scene *scene = WM_window_get_active_scene(win); - RenderEngineType *type = RE_engines_find(scene->r.engine); + WorkSpace *workspace = WM_window_get_active_workspace(win); + ViewRender *view_render = BKE_viewrender_get(scene, workspace); + RenderEngineType *type = RE_engines_find(view_render->engine_id); EnumPropertyItem *item = NULL; int totitem = 0; @@ -1117,14 +1126,18 @@ static EnumPropertyItem *rna_SpaceProperties_context_itemf(bContext *UNUSED(C), RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_SCENE); } - if (sbuts->pathflag & (1 << BCONTEXT_COLLECTION)) { - RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_COLLECTION); - } - if (sbuts->pathflag & (1 << BCONTEXT_WORLD)) { RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORLD); } + if (sbuts->pathflag & (1 << BCONTEXT_WORKSPACE)) { + RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORKSPACE); + } + + if (sbuts->pathflag & (1 << BCONTEXT_COLLECTION)) { + RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_COLLECTION); + } + if (sbuts->pathflag & (1 << BCONTEXT_OBJECT)) { RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_OBJECT); } diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c index c09cc204bbc..4e04581a0a8 100644 --- a/source/blender/makesrna/intern/rna_workspace.c +++ b/source/blender/makesrna/intern/rna_workspace.c @@ -28,11 +28,18 @@ #include "BKE_workspace.h" +#include "ED_render.h" + +#include "RE_engine.h" + #include "WM_api.h" #include "WM_types.h" #include "rna_internal.h" +/* Allow accessing private members of DNA_workspace_types.h */ +#define DNA_PRIVATE_WORKSPACE_ALLOW +#include "DNA_workspace_types.h" #ifdef RNA_RUNTIME @@ -42,7 +49,6 @@ #include "DNA_object_types.h" #include "DNA_screen_types.h" -#include "DNA_workspace_types.h" #include "RNA_access.h" @@ -154,6 +160,20 @@ static void rna_def_workspace(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Active Render Layer", "The active render layer used in this workspace"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, NULL); + + /* View Render */ + prop = RNA_def_property(srna, "view_render", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "ViewRenderSettings"); + RNA_def_property_ui_text(prop, "View Render", ""); + + /* Flags */ + prop = RNA_def_property(srna, "use_scene_settings", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", WORKSPACE_USE_SCENE_SETTINGS); + RNA_def_property_ui_text(prop, "Scene Settings", + "Use scene settings instead of workspace settings"); + RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, NULL); } static void rna_def_transform_orientation(BlenderRNA *brna) |