diff options
Diffstat (limited to 'source/blender/blenkernel/intern/scene.c')
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 113 |
1 files changed, 42 insertions, 71 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index a0bd3abbc1a..916a2786a98 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -71,6 +71,7 @@ #include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_armature.h" +#include "BKE_bpath.h" #include "BKE_cachefile.h" #include "BKE_collection.h" #include "BKE_colortools.h" @@ -891,6 +892,45 @@ static void scene_foreach_cache(ID *id, user_data); } +static bool seq_foreach_path_callback(Sequence *seq, void *user_data) +{ + if (SEQ_HAS_PATH(seq)) { + StripElem *se = seq->strip->stripdata; + BPathForeachPathData *bpath_data = (BPathForeachPathData *)user_data; + + if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM) && se) { + BKE_bpath_foreach_path_dirfile_fixed_process(bpath_data, seq->strip->dir, se->name); + } + else if ((seq->type == SEQ_TYPE_IMAGE) && se) { + /* NOTE: An option not to loop over all strips could be useful? */ + unsigned int len = (unsigned int)MEM_allocN_len(se) / (unsigned int)sizeof(*se); + unsigned int i; + + if (bpath_data->flag & BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE) { + /* only operate on one path */ + len = MIN2(1u, len); + } + + for (i = 0; i < len; i++, se++) { + BKE_bpath_foreach_path_dirfile_fixed_process(bpath_data, seq->strip->dir, se->name); + } + } + else { + /* simple case */ + BKE_bpath_foreach_path_fixed_process(bpath_data, seq->strip->dir); + } + } + return true; +} + +static void scene_foreach_path(ID *id, BPathForeachPathData *bpath_data) +{ + Scene *scene = (Scene *)id; + if (scene->ed != NULL) { + SEQ_for_each_callback(&scene->ed->seqbase, seq_foreach_path_callback, bpath_data); + } +} + static void scene_blend_write(BlendWriter *writer, ID *id, const void *id_address) { Scene *sce = (Scene *)id; @@ -1600,6 +1640,7 @@ IDTypeInfo IDType_ID_SCE = { .name_plural = "scenes", .translation_context = BLT_I18NCONTEXT_ID_SCENE, .flags = 0, + .asset_type_info = NULL, .init_data = scene_init_data, .copy_data = scene_copy_data, @@ -1609,6 +1650,7 @@ IDTypeInfo IDType_ID_SCE = { .make_local = NULL, .foreach_id = scene_foreach_id, .foreach_cache = scene_foreach_cache, + .foreach_path = scene_foreach_path, .owner_get = NULL, .blend_write = scene_blend_write, @@ -1659,7 +1701,6 @@ static void remove_sequencer_fcurves(Scene *sce) } } -/* flag -- copying options (see BKE_lib_id.h's LIB_ID_COPY_... flags for more). */ ToolSettings *BKE_toolsettings_copy(ToolSettings *toolsettings, const int flag) { if (toolsettings == NULL) { @@ -1986,9 +2027,6 @@ Scene *BKE_scene_add(Main *bmain, const char *name) return sce; } -/** - * Check if there is any instance of the object in the scene - */ bool BKE_scene_object_find(Scene *scene, Object *ob) { LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { @@ -2011,12 +2049,6 @@ Object *BKE_scene_object_find_by_name(const Scene *scene, const char *name) return NULL; } -/** - * Sets the active scene, mainly used when running in background mode - * (`--scene` command line argument). - * This is also called to set the scene directly, bypassing windowing code. - * Otherwise #WM_window_set_active_scene is used when changing scenes by the user. - */ void BKE_scene_set_background(Main *bmain, Scene *scene) { Object *ob; @@ -2041,7 +2073,6 @@ void BKE_scene_set_background(Main *bmain, Scene *scene) * (render code calls own animation updates). */ } -/* called from creator_args.c */ Scene *BKE_scene_set_name(Main *bmain, const char *name) { Scene *sce = (Scene *)BKE_libblock_find_name(bmain, ID_SCE, name); @@ -2055,8 +2086,6 @@ Scene *BKE_scene_set_name(Main *bmain, const char *name) return NULL; } -/* Used by meta-balls, return *all* objects (including duplis) - * existing in the scene (including scene's sets). */ int BKE_scene_base_iter_next( Depsgraph *depsgraph, SceneBaseIter *iter, Scene **scene, int val, Base **base, Object **ob) { @@ -2281,8 +2310,6 @@ const char *BKE_scene_find_marker_name(const Scene *scene, int frame) return NULL; } -/* return the current marker for this frame, - * we can have more than 1 marker per frame, this just returns the first :/ */ const char *BKE_scene_find_last_marker_name(const Scene *scene, int frame) { const TimeMarker *marker, *best_marker = NULL; @@ -2326,7 +2353,6 @@ void BKE_scene_remove_rigidbody_object(struct Main *bmain, } } -/* checks for cycle, returns 1 if it's all OK */ bool BKE_scene_validate_setscene(Main *bmain, Scene *sce) { Scene *sce_iter; @@ -2349,16 +2375,11 @@ bool BKE_scene_validate_setscene(Main *bmain, Scene *sce) return true; } -/* Return fractional frame number taking into account subframes and time - * remapping. This the time value used by animation, modifiers and physics - * evaluation. */ float BKE_scene_ctime_get(const Scene *scene) { return BKE_scene_frame_to_ctime(scene, scene->r.cfra); } -/* Convert integer frame number to fractional frame number taking into account - * subframes and time remapping. */ float BKE_scene_frame_to_ctime(const Scene *scene, const int frame) { float ctime = frame; @@ -2368,13 +2389,11 @@ float BKE_scene_frame_to_ctime(const Scene *scene, const int frame) return ctime; } -/* Get current fractional frame based on frame and subframe. */ float BKE_scene_frame_get(const Scene *scene) { return scene->r.cfra + scene->r.subframe; } -/* Set current frame and subframe based on a fractional frame. */ void BKE_scene_frame_set(Scene *scene, float frame) { double intpart; @@ -2411,12 +2430,6 @@ TransformOrientationSlot *BKE_scene_orientation_slot_get_from_flag(Scene *scene, return BKE_scene_orientation_slot_get(scene, slot_index); } -/** - * Activate a transform orientation in a 3D view based on an enum value. - * - * \param orientation: If this is #V3D_ORIENT_CUSTOM or greater, the custom transform orientation - * with index \a orientation - #V3D_ORIENT_CUSTOM gets activated. - */ void BKE_scene_orientation_slot_set_index(TransformOrientationSlot *orient_slot, int orientation) { const bool is_custom = orientation >= V3D_ORIENT_CUSTOM; @@ -2623,7 +2636,6 @@ void BKE_scene_graph_evaluated_ensure(Depsgraph *depsgraph, Main *bmain) scene_graph_update_tagged(depsgraph, bmain, true); } -/* applies changes right away, does all sets too */ void BKE_scene_graph_update_for_newframe_ex(Depsgraph *depsgraph, const bool clear_recalc) { Scene *scene = DEG_get_input_scene(depsgraph); @@ -2699,12 +2711,6 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph) BKE_scene_graph_update_for_newframe_ex(depsgraph, true); } -/** - * Ensures given scene/view_layer pair has a valid, up-to-date depsgraph. - * - * \warning Sets matching depsgraph as active, - * so should only be called from the active editing context (usually, from operators). - */ void BKE_scene_view_layer_graph_evaluated_ensure(Main *bmain, Scene *scene, ViewLayer *view_layer) { Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer); @@ -2712,7 +2718,6 @@ void BKE_scene_view_layer_graph_evaluated_ensure(Main *bmain, Scene *scene, View BKE_scene_graph_update_tagged(depsgraph, bmain); } -/* return default view */ SceneRenderView *BKE_scene_add_render_view(Scene *sce, const char *name) { SceneRenderView *srv; @@ -2782,12 +2787,6 @@ int get_render_child_particle_number(const RenderData *r, int num, bool for_rend return num; } -/** - * Helper function for the SETLOOPER and SETLOOPER_VIEW_LAYER macros - * - * It iterates over the bases of the active layer and then the bases - * of the active layer of the background (set) scenes recursively. - */ Base *_setlooper_base_step(Scene **sce_iter, ViewLayer *view_layer, Base *base) { if (base && base->next) { @@ -2852,7 +2851,6 @@ typedef enum eCyclesFeatureSet { CYCLES_FEATURES_EXPERIMENTAL = 1, } eCyclesFeatureSet; -/* We cannot use const as RNA_id_pointer_create is not using a const ID. */ bool BKE_scene_uses_cycles_experimental_features(Scene *scene) { BLI_assert(BKE_scene_uses_cycles(scene)); @@ -2878,16 +2876,6 @@ void BKE_scene_base_flag_to_objects(ViewLayer *view_layer) } } -/** - * Synchronize object base flags - * - * This is usually handled by the depsgraph. - * However, in rare occasions we need to use the latest object flags - * before depsgraph is fully updated. - * - * It should (ideally) only run for copy-on-written objects since this is - * runtime data generated per-viewlayer. - */ void BKE_scene_object_base_flag_sync_from_base(Base *base) { Object *ob = base->object; @@ -2960,10 +2948,6 @@ int BKE_render_preview_pixel_size(const RenderData *r) return r->preview_pixel_size; } -/** - * Apply the needed correction factor to value, based on unit_type - * (only length-related are affected currently) and unit->scale_length. - */ double BKE_scene_unit_scale(const UnitSettings *unit, const int unit_type, double value) { if (unit->system == USER_UNIT_NONE) { @@ -3038,7 +3022,6 @@ bool BKE_scene_multiview_is_stereo3d(const RenderData *rd) ((srv[1]->viewflag & SCE_VIEW_DISABLE) == 0)); } -/* return whether to render this SceneRenderView */ bool BKE_scene_multiview_is_render_view_active(const RenderData *rd, const SceneRenderView *srv) { if (srv == NULL) { @@ -3065,7 +3048,6 @@ bool BKE_scene_multiview_is_render_view_active(const RenderData *rd, const Scene return false; } -/* return true if viewname is the first or if the name is NULL or not found */ bool BKE_scene_multiview_is_render_view_first(const RenderData *rd, const char *viewname) { SceneRenderView *srv; @@ -3087,7 +3069,6 @@ bool BKE_scene_multiview_is_render_view_first(const RenderData *rd, const char * return true; } -/* return true if viewname is the last or if the name is NULL or not found */ bool BKE_scene_multiview_is_render_view_last(const RenderData *rd, const char *viewname) { SceneRenderView *srv; @@ -3171,12 +3152,6 @@ void BKE_scene_multiview_filepath_get(SceneRenderView *srv, const char *filepath BLI_path_suffix(r_filepath, FILE_MAX, srv->suffix, ""); } -/** - * When multiview is not used the filepath is as usual (e.g., `Image.jpg`). - * When multiview is on, even if only one view is enabled the view is incorporated - * into the file name (e.g., `Image_L.jpg`). That allows for the user to re-render - * individual views. - */ void BKE_scene_multiview_view_filepath_get(const RenderData *rd, const char *filepath, const char *viewname, @@ -3564,10 +3539,6 @@ TransformOrientation *BKE_scene_transform_orientation_find(const Scene *scene, c return BLI_findlink(&scene->transform_spaces, index); } -/** - * \return the index that \a orientation has within \a scene's transform-orientation list - * or -1 if not found. - */ int BKE_scene_transform_orientation_get_index(const Scene *scene, const TransformOrientation *orientation) { |