Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_layer.c
| Show All 19 Lines | |||||
| * ***** END GPL LICENSE BLOCK ***** | * ***** END GPL LICENSE BLOCK ***** | ||||
| */ | */ | ||||
| /** \file blender/makesrna/intern/rna_layer.c | /** \file blender/makesrna/intern/rna_layer.c | ||||
| * \ingroup RNA | * \ingroup RNA | ||||
| */ | */ | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_sequence_types.h" | |||||
| #include "DNA_layer_types.h" | #include "DNA_layer_types.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_string_utils.h" | #include "BLI_string_utils.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "BKE_sequencer.h" | |||||
| #include "ED_object.h" | #include "ED_object.h" | ||||
| #include "ED_render.h" | #include "ED_render.h" | ||||
| #include "RE_engine.h" | #include "RE_engine.h" | ||||
| #include "DRW_engine.h" | #include "DRW_engine.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| ▲ Show 20 Lines • Show All 930 Lines • ▼ Show 20 Lines | static int rna_ViewRenderSettings_engine_get(PointerRNA *ptr) | ||||
| for (type = R_engines.first; type; type = type->next, a++) | for (type = R_engines.first; type; type = type->next, a++) | ||||
| if (STREQ(type->idname, view_render->engine_id)) | if (STREQ(type->idname, view_render->engine_id)) | ||||
| return a; | return a; | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static void rna_ViewRenderSettings_engine_update(Main *bmain, Scene *UNUSED(unused), PointerRNA *UNUSED(ptr)) | typedef struct SequenceSearchData { | ||||
| Sequence *seq; | |||||
| void *data; | |||||
| } SequenceSearchData; | |||||
| static int seq_view_render_cmp__cb(Sequence *seq, void *arg_pt) | |||||
| { | |||||
| SequenceSearchData *data = arg_pt; | |||||
| if ((seq->flag & SEQ_USE_VIEW_RENDER_OVERRIDE) && (data->data == &(seq->view_render))) { | |||||
campbellbarton: The state of the flag doesn't matter - it could be enabled or disabled AFAICS.
Also, this… | |||||
| data->seq = seq; | |||||
| return -1; | |||||
| } | |||||
| return 1; | |||||
| } | |||||
| static Sequence *sequence_get_by_view_render(Editing *ed, ViewRender *view_render) | |||||
| { | { | ||||
| SequenceSearchData data; | |||||
| data.seq = NULL; | |||||
| data.data = view_render; | |||||
| BKE_sequencer_base_recursive_apply(&ed->seqbase, seq_view_render_cmp__cb, &data); | |||||
| return data.seq; | |||||
| } | |||||
| static void rna_ViewRenderSettings_engine_update(Main *bmain, Scene *scene, PointerRNA *ptr) | |||||
| { | |||||
| ViewRender *view_render = (ViewRender *)ptr->data; | |||||
| ID *id = (ID*)ptr->id.data; | |||||
| Editing *ed = BKE_sequencer_editing_get(scene, false); | |||||
| Sequence *sequence = sequence_get_by_view_render(ed, view_render); | |||||
| if (id == NULL) { | |||||
| return; | |||||
| } | |||||
| if (sequence) { | |||||
| BKE_sequence_invalidate_cache(scene, sequence); | |||||
| } | |||||
| else if (GS(id->name) == ID_SCE) { | |||||
| /* Must be a scene->view_render update b.c. we couldn't find a scene strip's view_render updated above */ | |||||
| ED_render_engine_changed(bmain); | ED_render_engine_changed(bmain); | ||||
| SeqIterator iter; | |||||
| for (BKE_sequence_iterator_begin(ed, &iter, true); iter.valid; BKE_sequence_iterator_next(&iter)) { | |||||
| sequence = iter.seq; | |||||
| if ((sequence->flag & SEQ_USE_VIEW_RENDER_OVERRIDE) == 0) { | |||||
| BKE_sequence_invalidate_cache(scene, sequence); | |||||
| } | |||||
| } | |||||
| BKE_sequence_iterator_end(&iter); | |||||
| } | |||||
| WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); | |||||
| } | } | ||||
| static int rna_ViewRenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr)) | static int rna_ViewRenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr)) | ||||
| { | { | ||||
| return (BLI_listbase_count(&R_engines) > 1); | return (BLI_listbase_count(&R_engines) > 1); | ||||
| } | } | ||||
| static int rna_ViewRenderSettings_use_shading_nodes_get(PointerRNA *ptr) | static int rna_ViewRenderSettings_use_shading_nodes_get(PointerRNA *ptr) | ||||
| ▲ Show 20 Lines • Show All 1,329 Lines • Show Last 20 Lines | |||||
The state of the flag doesn't matter - it could be enabled or disabled AFAICS.
Also, this function could be generalized so we don't need to write a new one for each struct member. SequenceSearchData can store an offset. then access the member with POINTER_OFFSET
See: source/blender/editors/armature/armature_select.c:933: for similar code.