1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 * 16 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 17 * All rights reserved. 18 */ 19 #pragma once 20 21 /** \file 22 * \ingroup bke 23 */ 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 struct AviCodecData; 30 struct Collection; 31 struct Depsgraph; 32 struct GHash; 33 struct Main; 34 struct Object; 35 struct RenderData; 36 struct Scene; 37 struct TransformOrientation; 38 struct UnitSettings; 39 struct View3DCursor; 40 struct ViewLayer; 41 42 typedef enum eSceneCopyMethod { 43 SCE_COPY_NEW = 0, 44 SCE_COPY_EMPTY = 1, 45 SCE_COPY_LINK_COLLECTION = 2, 46 SCE_COPY_FULL = 3, 47 } eSceneCopyMethod; 48 49 /* Use as the contents of a 'for' loop: for (SETLOOPER(...)) { ... */ 50 #define SETLOOPER(_sce_basis, _sce_iter, _base) \ 51 _sce_iter = _sce_basis, \ 52 _base = _setlooper_base_step( \ 53 &_sce_iter, BKE_view_layer_context_active_PLACEHOLDER(_sce_basis), NULL); \ 54 _base; \ 55 _base = _setlooper_base_step(&_sce_iter, NULL, _base) 56 57 #define SETLOOPER_VIEW_LAYER(_sce_basis, _view_layer, _sce_iter, _base) \ 58 _sce_iter = _sce_basis, _base = _setlooper_base_step(&_sce_iter, _view_layer, NULL); \ 59 _base; \ 60 _base = _setlooper_base_step(&_sce_iter, NULL, _base) 61 62 #define SETLOOPER_SET_ONLY(_sce_basis, _sce_iter, _base) \ 63 _sce_iter = _sce_basis, _base = _setlooper_base_step(&_sce_iter, NULL, NULL); \ 64 _base; \ 65 _base = _setlooper_base_step(&_sce_iter, NULL, _base) 66 67 struct Base *_setlooper_base_step(struct Scene **sce_iter, 68 struct ViewLayer *view_layer, 69 struct Base *base); 70 71 void free_avicodecdata(struct AviCodecData *acd); 72 73 struct Scene *BKE_scene_add(struct Main *bmain, const char *name); 74 75 void BKE_scene_remove_rigidbody_object(struct Main *bmain, 76 struct Scene *scene, 77 struct Object *ob, 78 const bool free_us); 79 80 bool BKE_scene_object_find(struct Scene *scene, struct Object *ob); 81 struct Object *BKE_scene_object_find_by_name(const struct Scene *scene, const char *name); 82 83 /* Scene base iteration function. 84 * Define struct here, so no need to bother with alloc/free it. 85 */ 86 typedef struct SceneBaseIter { 87 struct ListBase *duplilist; 88 struct DupliObject *dupob; 89 float omat[4][4]; 90 struct Object *dupli_refob; 91 int phase; 92 } SceneBaseIter; 93 94 int BKE_scene_base_iter_next(struct Depsgraph *depsgraph, 95 struct SceneBaseIter *iter, 96 struct Scene **scene, 97 int val, 98 struct Base **base, 99 struct Object **ob); 100 101 void BKE_scene_base_flag_to_objects(struct ViewLayer *view_layer); 102 void BKE_scene_object_base_flag_sync_from_base(struct Base *base); 103 104 void BKE_scene_set_background(struct Main *bmain, struct Scene *sce); 105 struct Scene *BKE_scene_set_name(struct Main *bmain, const char *name); 106 107 struct ToolSettings *BKE_toolsettings_copy(struct ToolSettings *toolsettings, const int flag); 108 void BKE_toolsettings_free(struct ToolSettings *toolsettings); 109 110 struct Scene *BKE_scene_duplicate(struct Main *bmain, struct Scene *sce, eSceneCopyMethod type); 111 void BKE_scene_groups_relink(struct Scene *sce); 112 113 bool BKE_scene_has_view_layer(const struct Scene *scene, const struct ViewLayer *layer); 114 struct Scene *BKE_scene_find_from_collection(const struct Main *bmain, 115 const struct Collection *collection); 116 117 #ifdef DURIAN_CAMERA_SWITCH 118 struct Object *BKE_scene_camera_switch_find(struct Scene *scene); /* DURIAN_CAMERA_SWITCH */ 119 #endif 120 bool BKE_scene_camera_switch_update(struct Scene *scene); 121 122 const char *BKE_scene_find_marker_name(const struct Scene *scene, int frame); 123 const char *BKE_scene_find_last_marker_name(const struct Scene *scene, int frame); 124 125 int BKE_scene_frame_snap_by_seconds(struct Scene *scene, double interval_in_seconds, int cfra); 126 127 /* checks for cycle, returns 1 if it's all OK */ 128 bool BKE_scene_validate_setscene(struct Main *bmain, struct Scene *sce); 129 130 float BKE_scene_frame_get(const struct Scene *scene); 131 float BKE_scene_frame_to_ctime(const struct Scene *scene, const float frame); 132 void BKE_scene_frame_set(struct Scene *scene, double cfra); 133 134 struct TransformOrientationSlot *BKE_scene_orientation_slot_get_from_flag(struct Scene *scene, 135 int flag); 136 struct TransformOrientationSlot *BKE_scene_orientation_slot_get(struct Scene *scene, 137 int slot_index); 138 void BKE_scene_orientation_slot_set_index(struct TransformOrientationSlot *orient_slot, 139 int orientation); 140 int BKE_scene_orientation_slot_get_index(const struct TransformOrientationSlot *orient_slot); 141 142 /* ** Scene evaluation ** */ 143 144 void BKE_scene_update_sound(struct Depsgraph *depsgraph, struct Main *bmain); 145 void BKE_scene_update_tag_audio_volume(struct Depsgraph *, struct Scene *scene); 146 147 void BKE_scene_graph_update_tagged(struct Depsgraph *depsgraph, struct Main *bmain); 148 void BKE_scene_graph_evaluated_ensure(struct Depsgraph *depsgraph, struct Main *bmain); 149 150 void BKE_scene_graph_update_for_newframe(struct Depsgraph *depsgraph); 151 152 void BKE_scene_view_layer_graph_evaluated_ensure(struct Main *bmain, 153 struct Scene *scene, 154 struct ViewLayer *view_layer); 155 156 struct SceneRenderView *BKE_scene_add_render_view(struct Scene *sce, const char *name); 157 bool BKE_scene_remove_render_view(struct Scene *scene, struct SceneRenderView *srv); 158 159 /* render profile */ 160 int get_render_subsurf_level(const struct RenderData *r, int lvl, bool for_render); 161 int get_render_child_particle_number(const struct RenderData *r, int num, bool for_render); 162 163 bool BKE_scene_use_shading_nodes_custom(struct Scene *scene); 164 bool BKE_scene_use_spherical_stereo(struct Scene *scene); 165 166 bool BKE_scene_uses_blender_eevee(const struct Scene *scene); 167 bool BKE_scene_uses_blender_workbench(const struct Scene *scene); 168 bool BKE_scene_uses_cycles(const struct Scene *scene); 169 170 void BKE_scene_copy_data_eevee(struct Scene *sce_dst, const struct Scene *sce_src); 171 172 void BKE_scene_disable_color_management(struct Scene *scene); 173 bool BKE_scene_check_color_management_enabled(const struct Scene *scene); 174 bool BKE_scene_check_rigidbody_active(const struct Scene *scene); 175 176 int BKE_scene_num_threads(const struct Scene *scene); 177 int BKE_render_num_threads(const struct RenderData *r); 178 179 int BKE_render_preview_pixel_size(const struct RenderData *r); 180 181 /**********************************/ 182 183 double BKE_scene_unit_scale(const struct UnitSettings *unit, const int unit_type, double value); 184 185 /* multiview */ 186 bool BKE_scene_multiview_is_stereo3d(const struct RenderData *rd); 187 bool BKE_scene_multiview_is_render_view_active(const struct RenderData *rd, 188 const struct SceneRenderView *srv); 189 bool BKE_scene_multiview_is_render_view_first(const struct RenderData *rd, const char *viewname); 190 bool BKE_scene_multiview_is_render_view_last(const struct RenderData *rd, const char *viewname); 191 int BKE_scene_multiview_num_views_get(const struct RenderData *rd); 192 struct SceneRenderView *BKE_scene_multiview_render_view_findindex(const struct RenderData *rd, 193 const int view_id); 194 const char *BKE_scene_multiview_render_view_name_get(const struct RenderData *rd, 195 const int view_id); 196 int BKE_scene_multiview_view_id_get(const struct RenderData *rd, const char *viewname); 197 void BKE_scene_multiview_filepath_get(struct SceneRenderView *srv, 198 const char *filepath, 199 char *r_filepath); 200 void BKE_scene_multiview_view_filepath_get(const struct RenderData *rd, 201 const char *filepath, 202 const char *view, 203 char *r_filepath); 204 const char *BKE_scene_multiview_view_suffix_get(const struct RenderData *rd, const char *viewname); 205 const char *BKE_scene_multiview_view_id_suffix_get(const struct RenderData *rd, const int view_id); 206 void BKE_scene_multiview_view_prefix_get(struct Scene *scene, 207 const char *name, 208 char *r_prefix, 209 const char **r_ext); 210 void BKE_scene_multiview_videos_dimensions_get(const struct RenderData *rd, 211 const size_t width, 212 const size_t height, 213 size_t *r_width, 214 size_t *r_height); 215 int BKE_scene_multiview_num_videos_get(const struct RenderData *rd); 216 217 /* depsgraph */ 218 void BKE_scene_allocate_depsgraph_hash(struct Scene *scene); 219 void BKE_scene_ensure_depsgraph_hash(struct Scene *scene); 220 void BKE_scene_free_depsgraph_hash(struct Scene *scene); 221 void BKE_scene_free_view_layer_depsgraph(struct Scene *scene, struct ViewLayer *view_layer); 222 223 /* Do not allocate new depsgraph. */ 224 struct Depsgraph *BKE_scene_get_depsgraph(struct Scene *scene, struct ViewLayer *view_layer); 225 /* Allocate new depsgraph if necessary. */ 226 struct Depsgraph *BKE_scene_ensure_depsgraph(struct Main *bmain, 227 struct Scene *scene, 228 struct ViewLayer *view_layer); 229 230 struct GHash *BKE_scene_undo_depsgraphs_extract(struct Main *bmain); 231 void BKE_scene_undo_depsgraphs_restore(struct Main *bmain, struct GHash *depsgraph_extract); 232 233 void BKE_scene_transform_orientation_remove(struct Scene *scene, 234 struct TransformOrientation *orientation); 235 struct TransformOrientation *BKE_scene_transform_orientation_find(const struct Scene *scene, 236 const int index); 237 int BKE_scene_transform_orientation_get_index(const struct Scene *scene, 238 const struct TransformOrientation *orientation); 239 240 void BKE_scene_cursor_rot_to_mat3(const struct View3DCursor *cursor, float mat[3][3]); 241 void BKE_scene_cursor_mat3_to_rot(struct View3DCursor *cursor, 242 const float mat[3][3], 243 bool use_compat); 244 245 void BKE_scene_cursor_rot_to_quat(const struct View3DCursor *cursor, float quat[4]); 246 void BKE_scene_cursor_quat_to_rot(struct View3DCursor *cursor, 247 const float quat[4], 248 bool use_compat); 249 250 void BKE_scene_cursor_to_mat4(const struct View3DCursor *cursor, float mat[4][4]); 251 void BKE_scene_cursor_from_mat4(struct View3DCursor *cursor, 252 const float mat[4][4], 253 bool use_compat); 254 255 /* Dependency graph evaluation. */ 256 257 /* Evaluate parts of sequences which needs to be done as a part of a dependency graph evaluation. 258 * This does NOT include actual rendering of the strips, but rather makes them up-to-date for 259 * animation playback and makes them ready for the sequencer's rendering pipeline to render them. 260 */ 261 void BKE_scene_eval_sequencer_sequences(struct Depsgraph *depsgraph, struct Scene *scene); 262 263 #ifdef __cplusplus 264 } 265 #endif 266