Blender  V3.3
scene.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 /* Allow using deprecated functionality for .blend file I/O. */
9 #define DNA_DEPRECATED_ALLOW
10 
11 #include <cstddef>
12 #include <cstdio>
13 #include <cstring>
14 
15 #include "MEM_guardedalloc.h"
16 
17 #include "DNA_anim_types.h"
18 #include "DNA_collection_types.h"
19 #include "DNA_curveprofile_types.h"
20 #include "DNA_defaults.h"
21 #include "DNA_gpencil_types.h"
22 #include "DNA_linestyle_types.h"
23 #include "DNA_mask_types.h"
24 #include "DNA_material_types.h"
25 #include "DNA_mesh_types.h"
26 #include "DNA_node_types.h"
27 #include "DNA_object_types.h"
28 #include "DNA_rigidbody_types.h"
29 #include "DNA_scene_types.h"
30 #include "DNA_screen_types.h"
31 #include "DNA_sequence_types.h"
32 #include "DNA_sound_types.h"
33 #include "DNA_space_types.h"
34 #include "DNA_text_types.h"
35 #include "DNA_vfont_types.h"
36 #include "DNA_view3d_types.h"
38 #include "DNA_workspace_types.h"
39 #include "DNA_world_types.h"
40 
41 #include "BKE_callbacks.h"
42 #include "BLI_blenlib.h"
43 #include "BLI_math.h"
44 #include "BLI_string.h"
45 #include "BLI_string_utils.h"
46 #include "BLI_task.h"
47 #include "BLI_threads.h"
48 #include "BLI_utildefines.h"
49 
50 #include "BLO_readfile.h"
51 
52 #include "BLT_translation.h"
53 
54 #include "BKE_action.h"
55 #include "BKE_anim_data.h"
56 #include "BKE_animsys.h"
57 #include "BKE_armature.h"
58 #include "BKE_bpath.h"
59 #include "BKE_cachefile.h"
60 #include "BKE_collection.h"
61 #include "BKE_colortools.h"
62 #include "BKE_curveprofile.h"
63 #include "BKE_duplilist.h"
64 #include "BKE_editmesh.h"
65 #include "BKE_effect.h"
66 #include "BKE_fcurve.h"
67 #include "BKE_freestyle.h"
68 #include "BKE_gpencil.h"
69 #include "BKE_icons.h"
70 #include "BKE_idprop.h"
71 #include "BKE_idtype.h"
72 #include "BKE_image.h"
73 #include "BKE_image_format.h"
74 #include "BKE_layer.h"
75 #include "BKE_lib_id.h"
76 #include "BKE_lib_query.h"
77 #include "BKE_lib_remap.h"
78 #include "BKE_linestyle.h"
79 #include "BKE_main.h"
80 #include "BKE_mask.h"
81 #include "BKE_node.h"
82 #include "BKE_object.h"
83 #include "BKE_paint.h"
84 #include "BKE_pointcache.h"
85 #include "BKE_rigidbody.h"
86 #include "BKE_scene.h"
87 #include "BKE_screen.h"
88 #include "BKE_sound.h"
89 #include "BKE_unit.h"
90 #include "BKE_workspace.h"
91 #include "BKE_world.h"
92 
93 #include "DEG_depsgraph.h"
94 #include "DEG_depsgraph_build.h"
95 #include "DEG_depsgraph_debug.h"
96 #include "DEG_depsgraph_query.h"
97 
98 #include "RE_engine.h"
99 
100 #include "RNA_access.h"
101 
102 #include "SEQ_edit.h"
103 #include "SEQ_iterator.h"
104 #include "SEQ_sequencer.h"
105 
106 #include "BLO_read_write.h"
107 
109 
110 #include "PIL_time.h"
111 
112 #include "IMB_colormanagement.h"
113 #include "IMB_imbuf.h"
114 
115 #include "bmesh.h"
116 
117 static void scene_init_data(ID *id)
118 {
119  Scene *scene = (Scene *)id;
120  const char *colorspace_name;
121  SceneRenderView *srv;
122  CurveMapping *mblur_shutter_curve;
123 
125 
127 
128  BLI_strncpy(scene->r.bake.filepath, U.renderdir, sizeof(scene->r.bake.filepath));
129 
130  mblur_shutter_curve = &scene->r.mblur_shutter_curve;
131  BKE_curvemapping_set_defaults(mblur_shutter_curve, 1, 0.0f, 0.0f, 1.0f, 1.0f);
132  BKE_curvemapping_init(mblur_shutter_curve);
133  BKE_curvemap_reset(mblur_shutter_curve->cm,
134  &mblur_shutter_curve->clipr,
137 
139 
140  scene->toolsettings->autokey_mode = (uchar)U.autokey_mode;
141 
142  /* Grease pencil multi-frame falloff curve. */
143  scene->toolsettings->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
144  CurveMapping *gp_falloff_curve = scene->toolsettings->gp_sculpt.cur_falloff;
145  BKE_curvemapping_init(gp_falloff_curve);
147  gp_falloff_curve->cm, &gp_falloff_curve->clipr, CURVE_PRESET_GAUSS, CURVEMAP_SLOPE_POSITIVE);
148 
149  scene->toolsettings->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
150  CurveMapping *gp_primitive_curve = scene->toolsettings->gp_sculpt.cur_primitive;
151  BKE_curvemapping_init(gp_primitive_curve);
152  BKE_curvemap_reset(gp_primitive_curve->cm,
153  &gp_primitive_curve->clipr,
156 
158  scene->unit.scale_length = 1.0f;
164 
165  /* Anti-Aliasing threshold. */
167 
168  {
169  ParticleEditSettings *pset;
170  pset = &scene->toolsettings->particle;
171  for (size_t i = 1; i < ARRAY_SIZE(pset->brush); i++) {
172  pset->brush[i] = pset->brush[0];
173  }
174  pset->brush[PE_BRUSH_CUT].strength = 1.0f;
175  }
176 
178 
179  BLI_strncpy(scene->r.pic, U.renderdir, sizeof(scene->r.pic));
180 
181  /* NOTE: in header_info.c the scene copy happens...,
182  * if you add more to renderdata it has to be checked there. */
183 
184  /* multiview - stereo */
186  srv = static_cast<SceneRenderView *>(scene->r.views.first);
187  BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix));
188 
190  srv = static_cast<SceneRenderView *>(scene->r.views.last);
191  BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix));
192 
194 
195  /* color management */
197 
200  &scene->view_settings, &scene->display_settings, "Filmic");
202  colorspace_name,
204 
207 
208  /* Curve Profile */
210 
211  /* Sequencer */
213 
214  for (size_t i = 0; i < ARRAY_SIZE(scene->orientation_slots); i++) {
216  }
217 
218  /* Master Collection */
220 
221  BKE_view_layer_add(scene, "ViewLayer", nullptr, VIEWLAYER_ADD_NEW);
222 }
223 
224 static void scene_copy_markers(Scene *scene_dst, const Scene *scene_src, const int flag)
225 {
226  BLI_duplicatelist(&scene_dst->markers, &scene_src->markers);
227  LISTBASE_FOREACH (TimeMarker *, marker, &scene_dst->markers) {
228  if (marker->prop != nullptr) {
229  marker->prop = IDP_CopyProperty_ex(marker->prop, flag);
230  }
231  }
232 }
233 
234 static void scene_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int flag)
235 {
236  Scene *scene_dst = (Scene *)id_dst;
237  const Scene *scene_src = (const Scene *)id_src;
238  /* We never handle usercount here for own data. */
239  const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
240  /* We always need allocation of our private ID data. */
241  const int flag_private_id_data = flag & ~LIB_ID_CREATE_NO_ALLOCATE;
242 
243  scene_dst->ed = nullptr;
244  scene_dst->depsgraph_hash = nullptr;
245  scene_dst->fps_info = nullptr;
246 
247  /* Master Collection */
248  if (scene_src->master_collection) {
249  BKE_id_copy_ex(bmain,
250  (ID *)scene_src->master_collection,
251  (ID **)&scene_dst->master_collection,
252  flag_private_id_data);
253  }
254 
255  /* View Layers */
256  BLI_duplicatelist(&scene_dst->view_layers, &scene_src->view_layers);
257  for (ViewLayer *view_layer_src = static_cast<ViewLayer *>(scene_src->view_layers.first),
258  *view_layer_dst = static_cast<ViewLayer *>(scene_dst->view_layers.first);
259  view_layer_src;
260  view_layer_src = view_layer_src->next, view_layer_dst = view_layer_dst->next) {
261  BKE_view_layer_copy_data(scene_dst, scene_src, view_layer_dst, view_layer_src, flag_subdata);
262  }
263 
264  scene_copy_markers(scene_dst, scene_src, flag);
265 
266  BLI_duplicatelist(&(scene_dst->transform_spaces), &(scene_src->transform_spaces));
267  BLI_duplicatelist(&(scene_dst->r.views), &(scene_src->r.views));
268  BKE_keyingsets_copy(&(scene_dst->keyingsets), &(scene_src->keyingsets));
269 
270  if (scene_src->nodetree) {
272  bmain, (ID *)scene_src->nodetree, (ID **)&scene_dst->nodetree, flag_private_id_data);
274  scene_dst->nodetree,
275  (void *)(&scene_src->id),
276  &scene_dst->id,
278  }
279 
280  if (scene_src->rigidbody_world) {
282  flag_subdata);
283  }
284 
285  /* copy color management settings */
287  &scene_src->display_settings);
290  &scene_src->sequencer_colorspace_settings);
291 
292  BKE_image_format_copy(&scene_dst->r.im_format, &scene_src->r.im_format);
293  BKE_image_format_copy(&scene_dst->r.bake.im_format, &scene_src->r.bake.im_format);
294 
296 
297  /* tool settings */
298  scene_dst->toolsettings = BKE_toolsettings_copy(scene_dst->toolsettings, flag_subdata);
299 
300  /* make a private copy of the avicodecdata */
301  if (scene_src->r.avicodecdata) {
302  scene_dst->r.avicodecdata = static_cast<AviCodecData *>(
303  MEM_dupallocN(scene_src->r.avicodecdata));
304  scene_dst->r.avicodecdata->lpFormat = MEM_dupallocN(scene_dst->r.avicodecdata->lpFormat);
305  scene_dst->r.avicodecdata->lpParms = MEM_dupallocN(scene_dst->r.avicodecdata->lpParms);
306  }
307 
308  if (scene_src->display.shading.prop) {
309  scene_dst->display.shading.prop = IDP_CopyProperty(scene_src->display.shading.prop);
310  }
311 
313 
314  /* Copy sequencer, this is local data! */
315  if (scene_src->ed) {
316  scene_dst->ed = MEM_cnew<Editing>(__func__);
317  scene_dst->ed->seqbasep = &scene_dst->ed->seqbase;
319  scene_dst,
320  &scene_dst->ed->seqbase,
321  &scene_src->ed->seqbase,
322  SEQ_DUPE_ALL,
323  flag_subdata);
324  BLI_duplicatelist(&scene_dst->ed->channels, &scene_src->ed->channels);
325  scene_dst->ed->displayed_channels = &scene_dst->ed->channels;
326  }
327 
328  if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
329  BKE_previewimg_id_copy(&scene_dst->id, &scene_src->id);
330  }
331  else {
332  scene_dst->preview = nullptr;
333  }
334 
335  BKE_scene_copy_data_eevee(scene_dst, scene_src);
336 }
337 
338 static void scene_free_markers(Scene *scene, bool do_id_user)
339 {
341  if (marker->prop != nullptr) {
342  IDP_FreePropertyContent_ex(marker->prop, do_id_user);
343  MEM_freeN(marker->prop);
344  }
345  MEM_freeN(marker);
346  }
347 }
348 
349 static void scene_free_data(ID *id)
350 {
351 
352  Scene *scene = (Scene *)id;
353  const bool do_id_user = false;
354 
355  SEQ_editing_free(scene, do_id_user);
356 
358 
359  /* is no lib link block, but scene extension */
360  if (scene->nodetree) {
363  scene->nodetree = nullptr;
364  }
365 
366  if (scene->rigidbody_world) {
367  /* Prevent rigidbody freeing code to follow other IDs pointers, this should never be allowed
368  * nor necessary from here, and with new undo code, those pointers may be fully invalid or
369  * worse, pointing to data actually belonging to new BMain! */
370  scene->rigidbody_world->constraints = nullptr;
371  scene->rigidbody_world->group = nullptr;
373  }
374 
375  if (scene->r.avicodecdata) {
378  scene->r.avicodecdata = nullptr;
379  }
380 
381  scene_free_markers(scene, do_id_user);
384 
386  scene->toolsettings = nullptr;
387 
389 
391 
393 
397 
400 
402  BLI_remlink(&scene->view_layers, view_layer);
403  BKE_view_layer_free_ex(view_layer, do_id_user);
404  }
405 
406  /* Master Collection */
407  /* TODO: what to do with do_id_user? it's also true when just
408  * closing the file which seems wrong? should decrement users
409  * for objects directly in the master collection? then other
410  * collections in the scene need to do it too? */
411  if (scene->master_collection) {
415  scene->master_collection = nullptr;
416  }
417 
420  scene->eevee.light_cache_data = nullptr;
421  }
422 
423  if (scene->display.shading.prop) {
425  scene->display.shading.prop = nullptr;
426  }
427 
428  /* These are freed on `do_versions`. */
429  BLI_assert(scene->layer_properties == nullptr);
430 }
431 
433  ID **id_pointer,
434  void *user_data,
435  int cb_flag)
436 {
439  data, BKE_lib_query_foreachid_process(data, id_pointer, cb_flag));
440 }
441 
447  /* Undo when preserving tool-settings from old scene, we also want to try to preserve that ID
448  * pointer from its old scene's value. */
450  /* Undo when preserving tool-settings from old scene, we want to keep the new value of that ID
451  * pointer. */
453 };
454 
456  ID **id_p,
458  BlendLibReader *reader,
459  ID **id_old_p,
460  const uint cb_flag)
461 {
462  switch (action) {
464  ID *id_old = *id_old_p;
465  /* Old data has not been remapped to new values of the pointers, if we want to keep the old
466  * pointer here we need its new address. */
467  ID *id_old_new = id_old != nullptr ?
468  BLO_read_get_new_id_address(reader, id_old->lib, id_old) :
469  nullptr;
470  if (id_old_new != nullptr) {
471  BLI_assert(ELEM(id_old, id_old_new, id_old_new->orig_id));
472  *id_old_p = id_old_new;
473  if (cb_flag & IDWALK_CB_USER) {
474  id_us_plus_no_lib(id_old_new);
475  id_us_min(id_old);
476  }
477  break;
478  }
479  /* We failed to find a new valid pointer for the previous ID, just keep the current one as
480  * if we had been under SCENE_FOREACH_UNDO_NO_RESTORE case. */
481  SWAP(ID *, *id_p, *id_old_p);
482  break;
483  }
485  /* Counteract the swap of the whole ToolSettings container struct. */
486  SWAP(ID *, *id_p, *id_old_p);
487  break;
488  }
489 }
490 
491 /* Special handling is needed here, as `scene_foreach_toolsettings` (and its dependency
492  * `scene_foreach_paint`) are also used by `scene_undo_preserve`, where `LibraryForeachIDData
493  * *data` is nullptr. */
494 #define BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS_IDSUPER( \
495  __data, __id, __do_undo_restore, __action, __reader, __id_old, __cb_flag) \
496  { \
497  if (__do_undo_restore) { \
498  scene_foreach_toolsettings_id_pointer_process( \
499  (ID **)&(__id), __action, __reader, (ID **)&(__id_old), __cb_flag); \
500  } \
501  else { \
502  BLI_assert((__data) != nullptr); \
503  BKE_LIB_FOREACHID_PROCESS_IDSUPER(__data, __id, __cb_flag); \
504  } \
505  } \
506  (void)0
507 
508 #define BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS_FUNCTION_CALL( \
509  __data, __do_undo_restore, __func_call) \
510  { \
511  if (__do_undo_restore) { \
512  __func_call; \
513  } \
514  else { \
515  BLI_assert((__data) != nullptr); \
516  BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(__data, __func_call); \
517  } \
518  } \
519  (void)0
520 
522  Paint *paint,
523  const bool do_undo_restore,
524  BlendLibReader *reader,
525  Paint *paint_old)
526 {
528  paint->brush,
529  do_undo_restore,
531  reader,
532  paint_old->brush,
534  for (int i = 0; i < paint_old->tool_slots_len; i++) {
535  /* This is a bit tricky.
536  * - In case we do not do `undo_restore`, `paint` and `paint_old` pointers are the same, so
537  * this is equivalent to simply looping over slots from `paint`.
538  * - In case we do `undo_restore`, we only want to consider the slots from the old one, since
539  * those are the one we keep in the end.
540  * + In case the new data has less valid slots, we feed in a dummy null pointer.
541  * + In case the new data has more valid slots, the extra ones are ignored.
542  */
543  Brush *brush_tmp = nullptr;
544  Brush **brush_p = i < paint->tool_slots_len ? &paint->tool_slots[i].brush : &brush_tmp;
546  *brush_p,
547  do_undo_restore,
549  reader,
550  paint_old->brush,
552  }
554  paint->palette,
555  do_undo_restore,
557  reader,
558  paint_old->palette,
560 }
561 
563  ToolSettings *toolsett,
564  const bool do_undo_restore,
565  BlendLibReader *reader,
566  ToolSettings *toolsett_old)
567 {
569  toolsett->particle.scene,
570  do_undo_restore,
572  reader,
573  toolsett_old->particle.scene,
574  IDWALK_CB_NOP);
576  toolsett->particle.object,
577  do_undo_restore,
579  reader,
580  toolsett_old->particle.object,
581  IDWALK_CB_NOP);
583  toolsett->particle.shape_object,
584  do_undo_restore,
586  reader,
587  toolsett_old->particle.shape_object,
588  IDWALK_CB_NOP);
589 
591  data, &toolsett->imapaint.paint, do_undo_restore, reader, &toolsett_old->imapaint.paint);
593  toolsett->imapaint.stencil,
594  do_undo_restore,
596  reader,
597  toolsett_old->imapaint.stencil,
600  toolsett->imapaint.clone,
601  do_undo_restore,
603  reader,
604  toolsett_old->imapaint.clone,
607  toolsett->imapaint.canvas,
608  do_undo_restore,
610  reader,
611  toolsett_old->imapaint.canvas,
613 
614  if (toolsett->vpaint) {
616  data,
617  do_undo_restore,
619  &toolsett->vpaint->paint,
620  do_undo_restore,
621  reader,
622  &toolsett_old->vpaint->paint));
623  }
624  if (toolsett->wpaint) {
626  data,
627  do_undo_restore,
629  &toolsett->wpaint->paint,
630  do_undo_restore,
631  reader,
632  &toolsett_old->wpaint->paint));
633  }
634  if (toolsett->sculpt) {
636  data,
637  do_undo_restore,
639  &toolsett->sculpt->paint,
640  do_undo_restore,
641  reader,
642  &toolsett_old->sculpt->paint));
644  toolsett->sculpt->gravity_object,
645  do_undo_restore,
647  reader,
648  toolsett_old->sculpt->gravity_object,
649  IDWALK_CB_NOP);
650  }
651  if (toolsett->uvsculpt) {
653  data,
654  do_undo_restore,
656  &toolsett->uvsculpt->paint,
657  do_undo_restore,
658  reader,
659  &toolsett_old->uvsculpt->paint));
660  }
661  if (toolsett->gp_paint) {
663  data,
664  do_undo_restore,
666  &toolsett->gp_paint->paint,
667  do_undo_restore,
668  reader,
669  &toolsett_old->gp_paint->paint));
670  }
671  if (toolsett->gp_vertexpaint) {
673  data,
674  do_undo_restore,
676  &toolsett->gp_vertexpaint->paint,
677  do_undo_restore,
678  reader,
679  &toolsett_old->gp_vertexpaint->paint));
680  }
681  if (toolsett->gp_sculptpaint) {
683  data,
684  do_undo_restore,
686  &toolsett->gp_sculptpaint->paint,
687  do_undo_restore,
688  reader,
689  &toolsett_old->gp_sculptpaint->paint));
690  }
691  if (toolsett->gp_weightpaint) {
693  data,
694  do_undo_restore,
696  &toolsett->gp_weightpaint->paint,
697  do_undo_restore,
698  reader,
699  &toolsett_old->gp_weightpaint->paint));
700  }
701  if (toolsett->curves_sculpt) {
703  data,
704  do_undo_restore,
706  &toolsett->curves_sculpt->paint,
707  do_undo_restore,
708  reader,
709  &toolsett_old->curves_sculpt->paint));
710  }
711 
713  toolsett->gp_sculpt.guide.reference_object,
714  do_undo_restore,
716  reader,
717  toolsett_old->gp_sculpt.guide.reference_object,
718  IDWALK_CB_NOP);
719 }
720 
721 #undef BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS_IDSUPER
722 #undef BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS_FUNCTION_CALL
723 
725 {
726  LISTBASE_FOREACH (LayerCollection *, lc, lb) {
727  /* XXX This is very weak. The whole idea of keeping pointers to private IDs is very bad
728  * anyway... */
729  const int cb_flag = (lc->collection != nullptr &&
730  (lc->collection->id.flag & LIB_EMBEDDED_DATA) != 0) ?
733  BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, lc->collection, cb_flag);
734  scene_foreach_layer_collection(data, &lc->layer_collections);
735  }
736 }
737 
739 {
741 
742 #define FOREACHID_PROCESS_IDSUPER(_data, _id_super, _cb_flag) \
743  { \
744  CHECK_TYPE(&((_id_super)->id), ID *); \
745  BKE_lib_query_foreachid_process((_data), (ID **)&(_id_super), (_cb_flag)); \
746  if (BKE_lib_query_foreachid_iter_stop((_data))) { \
747  return false; \
748  } \
749  } \
750  ((void)0)
751 
761  }
762 
763  if (seq->type == SEQ_TYPE_TEXT && seq->effectdata) {
764  TextVars *text_data = static_cast<TextVars *>(seq->effectdata);
766  }
767 
768 #undef FOREACHID_PROCESS_IDSUPER
769 
770  return true;
771 }
772 
774 {
775  Scene *scene = (Scene *)id;
776 
783  if (scene->nodetree) {
784  /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
787  }
788  if (scene->ed) {
791  }
792 
795 
796  /* This pointer can be nullptr during old files reading, better be safe than sorry. */
797  if (scene->master_collection != nullptr) {
800  }
801 
802  LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
803  BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, view_layer->mat_override, IDWALK_CB_USER);
805  data,
806  IDP_foreach_property(view_layer->id_properties,
809  data));
810  LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
813  }
814 
816  data, scene_foreach_layer_collection(data, &view_layer->layer_collections));
817 
818  LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) {
819  if (fmc->script) {
821  }
822  }
823 
824  LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) {
825  if (fls->group) {
827  }
828 
829  if (fls->linestyle) {
831  }
832  }
833  }
834 
835  LISTBASE_FOREACH (TimeMarker *, marker, &scene->markers) {
838  data,
839  IDP_foreach_property(marker->prop,
842  data));
843  }
844 
845  ToolSettings *toolsett = scene->toolsettings;
846  if (toolsett) {
848  data, scene_foreach_toolsettings(data, toolsett, false, nullptr, toolsett));
849  }
850 
851  if (scene->rigidbody_world) {
853  data,
856  }
857 }
858 
859 static void scene_foreach_cache(ID *id,
860  IDTypeForeachCacheFunctionCallback function_callback,
861  void *user_data)
862 {
863  Scene *scene = (Scene *)id;
864  IDCacheKey key{};
865  key.id_session_uuid = id->session_uuid;
866  key.offset_in_ID = offsetof(Scene, eevee.light_cache_data);
867 
868  function_callback(id,
869  &key,
870  (void **)&scene->eevee.light_cache_data,
872  user_data);
873 }
874 
876 {
877  if (SEQ_HAS_PATH(seq)) {
878  StripElem *se = seq->strip->stripdata;
880 
881  if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM) && se) {
883  }
884  else if ((seq->type == SEQ_TYPE_IMAGE) && se) {
885  /* NOTE: An option not to loop over all strips could be useful? */
886  unsigned int len = (unsigned int)MEM_allocN_len(se) / (unsigned int)sizeof(*se);
887  unsigned int i;
888 
889  if (bpath_data->flag & BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE) {
890  /* only operate on one path */
891  len = MIN2(1u, len);
892  }
893 
894  for (i = 0; i < len; i++, se++) {
896  }
897  }
898  else {
899  /* simple case */
901  }
902  }
903  return true;
904 }
905 
906 static void scene_foreach_path(ID *id, BPathForeachPathData *bpath_data)
907 {
908  Scene *scene = (Scene *)id;
909  if (scene->ed != nullptr) {
911  }
912 }
913 
914 static void scene_blend_write(BlendWriter *writer, ID *id, const void *id_address)
915 {
916  Scene *sce = (Scene *)id;
917 
918  if (BLO_write_is_undo(writer)) {
919  /* Clean up, important in undo case to reduce false detection of changed data-blocks. */
920  /* XXX This UI data should not be stored in Scene at all... */
921  memset(&sce->cursor, 0, sizeof(sce->cursor));
922  }
923 
924  /* write LibData */
925  BLO_write_id_struct(writer, Scene, id_address, &sce->id);
926  BKE_id_blend_write(writer, &sce->id);
927 
928  if (sce->adt) {
929  BKE_animdata_blend_write(writer, sce->adt);
930  }
931  BKE_keyingsets_blend_write(writer, &sce->keyingsets);
932 
933  /* direct data */
934  ToolSettings *tos = sce->toolsettings;
935  BLO_write_struct(writer, ToolSettings, tos);
936  if (tos->vpaint) {
937  BLO_write_struct(writer, VPaint, tos->vpaint);
938  BKE_paint_blend_write(writer, &tos->vpaint->paint);
939  }
940  if (tos->wpaint) {
941  BLO_write_struct(writer, VPaint, tos->wpaint);
942  BKE_paint_blend_write(writer, &tos->wpaint->paint);
943  }
944  if (tos->sculpt) {
945  BLO_write_struct(writer, Sculpt, tos->sculpt);
946  BKE_paint_blend_write(writer, &tos->sculpt->paint);
947  }
948  if (tos->uvsculpt) {
949  BLO_write_struct(writer, UvSculpt, tos->uvsculpt);
950  BKE_paint_blend_write(writer, &tos->uvsculpt->paint);
951  }
952  if (tos->gp_paint) {
953  BLO_write_struct(writer, GpPaint, tos->gp_paint);
954  BKE_paint_blend_write(writer, &tos->gp_paint->paint);
955  }
956  if (tos->gp_vertexpaint) {
959  }
960  if (tos->gp_sculptpaint) {
963  }
964  if (tos->gp_weightpaint) {
967  }
968  if (tos->curves_sculpt) {
970  BKE_paint_blend_write(writer, &tos->curves_sculpt->paint);
971  }
972  /* write grease-pencil custom ipo curve to file */
973  if (tos->gp_interpolate.custom_ipo) {
975  }
976  /* write grease-pencil multi-frame falloff curve to file */
977  if (tos->gp_sculpt.cur_falloff) {
979  }
980  /* write grease-pencil primitive curve to file */
981  if (tos->gp_sculpt.cur_primitive) {
983  }
984  /* Write the curve profile to the file. */
985  if (tos->custom_bevel_profile_preset) {
987  }
988  if (tos->sequencer_tool_settings) {
990  }
991 
992  BKE_paint_blend_write(writer, &tos->imapaint.paint);
993 
994  Editing *ed = sce->ed;
995  if (ed) {
996  BLO_write_struct(writer, Editing, ed);
997 
998  SEQ_blend_write(writer, &ed->seqbase);
999  LISTBASE_FOREACH (SeqTimelineChannel *, channel, &ed->channels) {
1000  BLO_write_struct(writer, SeqTimelineChannel, channel);
1001  }
1002  /* new; meta stack too, even when its nasty restore code */
1003  LISTBASE_FOREACH (MetaStack *, ms, &ed->metastack) {
1004  BLO_write_struct(writer, MetaStack, ms);
1005  }
1006  }
1007 
1008  if (sce->r.avicodecdata) {
1010  if (sce->r.avicodecdata->lpFormat) {
1011  BLO_write_raw(writer, (size_t)sce->r.avicodecdata->cbFormat, sce->r.avicodecdata->lpFormat);
1012  }
1013  if (sce->r.avicodecdata->lpParms) {
1014  BLO_write_raw(writer, (size_t)sce->r.avicodecdata->cbParms, sce->r.avicodecdata->lpParms);
1015  }
1016  }
1017 
1018  /* writing dynamic list of TimeMarkers to the blend file */
1019  LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
1020  BLO_write_struct(writer, TimeMarker, marker);
1021 
1022  if (marker->prop != nullptr) {
1023  IDP_BlendWrite(writer, marker->prop);
1024  }
1025  }
1026 
1027  /* writing dynamic list of TransformOrientations to the blend file */
1030  }
1031 
1032  /* writing MultiView to the blend file */
1033  LISTBASE_FOREACH (SceneRenderView *, srv, &sce->r.views) {
1034  BLO_write_struct(writer, SceneRenderView, srv);
1035  }
1036 
1037  if (sce->nodetree) {
1038  BLO_write_struct(writer, bNodeTree, sce->nodetree);
1039  ntreeBlendWrite(writer, sce->nodetree);
1040  }
1041 
1043  BKE_image_format_blend_write(writer, &sce->r.im_format);
1045 
1046  /* writing RigidBodyWorld data to the blend file */
1047  if (sce->rigidbody_world) {
1048  /* Set deprecated pointers to prevent crashes of older Blenders */
1049  sce->rigidbody_world->pointcache = sce->rigidbody_world->shared->pointcache;
1050  sce->rigidbody_world->ptcaches = sce->rigidbody_world->shared->ptcaches;
1052 
1056  }
1057 
1058  BKE_previewimg_blend_write(writer, sce->preview);
1060 
1061  LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
1062  BKE_view_layer_blend_write(writer, view_layer);
1063  }
1064 
1065  if (sce->master_collection) {
1068  }
1069 
1070  /* Eevee Light-cache */
1071  if (sce->eevee.light_cache_data && !BLO_write_is_undo(writer)) {
1074  }
1075 
1077 
1078  /* Freed on `do_versions()`. */
1079  BLI_assert(sce->layer_properties == nullptr);
1080 }
1081 
1082 static void direct_link_paint_helper(BlendDataReader *reader, const Scene *scene, Paint **paint)
1083 {
1084  /* TODO: is this needed. */
1085  BLO_read_data_address(reader, paint);
1086 
1087  if (*paint) {
1088  BKE_paint_blend_read_data(reader, scene, *paint);
1089  }
1090 }
1091 
1092 static void link_recurs_seq(BlendDataReader *reader, ListBase *lb)
1093 {
1094  BLO_read_list(reader, lb);
1095 
1096  LISTBASE_FOREACH_MUTABLE (Sequence *, seq, lb) {
1097  /* Sanity check. */
1098  if (!SEQ_valid_strip_channel(seq)) {
1099  BLI_freelinkN(lb, seq);
1101  }
1102  else if (seq->seqbase.first) {
1103  link_recurs_seq(reader, &seq->seqbase);
1104  }
1105  }
1106 }
1107 
1108 static void scene_blend_read_data(BlendDataReader *reader, ID *id)
1109 {
1110  Scene *sce = (Scene *)id;
1111 
1112  sce->depsgraph_hash = nullptr;
1113  sce->fps_info = nullptr;
1114 
1115  memset(&sce->customdata_mask, 0, sizeof(sce->customdata_mask));
1116  memset(&sce->customdata_mask_modal, 0, sizeof(sce->customdata_mask_modal));
1117 
1119 
1120  /* set users to one by default, not in lib-link, this will increase it for compo nodes */
1121  id_us_ensure_real(&sce->id);
1122 
1123  BLO_read_list(reader, &(sce->base));
1124 
1125  BLO_read_data_address(reader, &sce->adt);
1126  BKE_animdata_blend_read_data(reader, sce->adt);
1127 
1128  BLO_read_list(reader, &sce->keyingsets);
1130 
1131  BLO_read_data_address(reader, &sce->basact);
1132 
1133  BLO_read_data_address(reader, &sce->toolsettings);
1134  if (sce->toolsettings) {
1135 
1136  /* Reset last_location and last_hit, so they are not remembered across sessions. In some files
1137  * these are also NaN, which could lead to crashes in painting. */
1139  zero_v3(ups->last_location);
1140  ups->last_hit = 0;
1141 
1142  direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->sculpt);
1143  direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->vpaint);
1144  direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->wpaint);
1145  direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->uvsculpt);
1146  direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_paint);
1147  direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_vertexpaint);
1148  direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_sculptpaint);
1149  direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_weightpaint);
1150  direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->curves_sculpt);
1151 
1153 
1154  sce->toolsettings->particle.paintcursor = nullptr;
1155  sce->toolsettings->particle.scene = nullptr;
1156  sce->toolsettings->particle.object = nullptr;
1157  sce->toolsettings->gp_sculpt.paintcursor = nullptr;
1158 
1159  /* Relink grease pencil interpolation curves. */
1163  }
1164  /* Relink grease pencil multi-frame falloff curve. */
1166  if (sce->toolsettings->gp_sculpt.cur_falloff) {
1168  }
1169  /* Relink grease pencil primitive curve. */
1171  if (sce->toolsettings->gp_sculpt.cur_primitive) {
1173  }
1174 
1175  /* Relink toolsettings curve profile. */
1179  }
1180 
1183  }
1184 
1185  if (sce->ed) {
1186  ListBase *old_seqbasep = &sce->ed->seqbase;
1187  ListBase *old_displayed_channels = &sce->ed->channels;
1188 
1189  BLO_read_data_address(reader, &sce->ed);
1190  Editing *ed = sce->ed;
1191 
1192  BLO_read_data_address(reader, &ed->act_seq);
1193  ed->cache = nullptr;
1194  ed->prefetch_job = nullptr;
1195  ed->runtime.sequence_lookup = nullptr;
1196 
1197  /* recursive link sequences, lb will be correctly initialized */
1198  link_recurs_seq(reader, &ed->seqbase);
1199 
1200  /* Read in sequence member data. */
1201  SEQ_blend_read(reader, &ed->seqbase);
1202  BLO_read_list(reader, &ed->channels);
1203 
1204  /* link metastack, slight abuse of structs here,
1205  * have to restore pointer to internal part in struct */
1206  {
1207  Sequence temp;
1208  void *seqbase_poin;
1209  void *channels_poin;
1210  intptr_t seqbase_offset;
1211  intptr_t channels_offset;
1212 
1213  seqbase_offset = ((intptr_t) & (temp.seqbase)) - ((intptr_t)&temp);
1214  channels_offset = ((intptr_t) & (temp.channels)) - ((intptr_t)&temp);
1215 
1216  /* seqbase root pointer */
1217  if (ed->seqbasep == old_seqbasep) {
1218  ed->seqbasep = &ed->seqbase;
1219  }
1220  else {
1221  seqbase_poin = POINTER_OFFSET(ed->seqbasep, -seqbase_offset);
1222 
1223  seqbase_poin = BLO_read_get_new_data_address(reader, seqbase_poin);
1224 
1225  if (seqbase_poin) {
1226  ed->seqbasep = (ListBase *)POINTER_OFFSET(seqbase_poin, seqbase_offset);
1227  }
1228  else {
1229  ed->seqbasep = &ed->seqbase;
1230  }
1231  }
1232 
1233  /* Active channels root pointer. */
1234  if (ed->displayed_channels == old_displayed_channels || ed->displayed_channels == nullptr) {
1235  ed->displayed_channels = &ed->channels;
1236  }
1237  else {
1238  channels_poin = POINTER_OFFSET(ed->displayed_channels, -channels_offset);
1239  channels_poin = BLO_read_get_new_data_address(reader, channels_poin);
1240 
1241  if (channels_poin) {
1242  ed->displayed_channels = (ListBase *)POINTER_OFFSET(channels_poin, channels_offset);
1243  }
1244  else {
1245  ed->displayed_channels = &ed->channels;
1246  }
1247  }
1248 
1249  /* stack */
1250  BLO_read_list(reader, &(ed->metastack));
1251 
1252  LISTBASE_FOREACH (MetaStack *, ms, &ed->metastack) {
1253  BLO_read_data_address(reader, &ms->parseq);
1254 
1255  if (ms->oldbasep == old_seqbasep) {
1256  ms->oldbasep = &ed->seqbase;
1257  }
1258  else {
1259  seqbase_poin = POINTER_OFFSET(ms->oldbasep, -seqbase_offset);
1260  seqbase_poin = BLO_read_get_new_data_address(reader, seqbase_poin);
1261  if (seqbase_poin) {
1262  ms->oldbasep = (ListBase *)POINTER_OFFSET(seqbase_poin, seqbase_offset);
1263  }
1264  else {
1265  ms->oldbasep = &ed->seqbase;
1266  }
1267  }
1268 
1269  if (ms->old_channels == old_displayed_channels || ms->old_channels == nullptr) {
1270  ms->old_channels = &ed->channels;
1271  }
1272  else {
1273  channels_poin = POINTER_OFFSET(ms->old_channels, -channels_offset);
1274  channels_poin = BLO_read_get_new_data_address(reader, channels_poin);
1275 
1276  if (channels_poin) {
1277  ms->old_channels = (ListBase *)POINTER_OFFSET(channels_poin, channels_offset);
1278  }
1279  else {
1280  ms->old_channels = &ed->channels;
1281  }
1282  }
1283  }
1284  }
1285  }
1286 
1287 #ifdef DURIAN_CAMERA_SWITCH
1288  /* Runtime */
1289  sce->r.mode &= ~R_NO_CAMERA_SWITCH;
1290 #endif
1291 
1292  BLO_read_data_address(reader, &sce->r.avicodecdata);
1293  if (sce->r.avicodecdata) {
1294  BLO_read_data_address(reader, &sce->r.avicodecdata->lpFormat);
1295  BLO_read_data_address(reader, &sce->r.avicodecdata->lpParms);
1296  }
1297  BLO_read_list(reader, &(sce->markers));
1298  LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
1299  BLO_read_data_address(reader, &marker->prop);
1300  IDP_BlendDataRead(reader, &marker->prop);
1301  }
1302 
1303  BLO_read_list(reader, &(sce->transform_spaces));
1304  BLO_read_list(reader, &(sce->r.layers));
1305  BLO_read_list(reader, &(sce->r.views));
1306 
1307  LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) {
1308  BLO_read_data_address(reader, &srl->prop);
1309  IDP_BlendDataRead(reader, &srl->prop);
1310  BLO_read_list(reader, &(srl->freestyleConfig.modules));
1311  BLO_read_list(reader, &(srl->freestyleConfig.linesets));
1312  }
1313 
1317 
1318  BLO_read_data_address(reader, &sce->rigidbody_world);
1319  RigidBodyWorld *rbw = sce->rigidbody_world;
1320  if (rbw) {
1321  BLO_read_data_address(reader, &rbw->shared);
1322 
1323  if (rbw->shared == nullptr) {
1324  /* Link deprecated caches if they exist, so we can use them for versioning.
1325  * We should only do this when rbw->shared == nullptr, because those pointers
1326  * are always set (for compatibility with older Blenders). We mustn't link
1327  * the same pointcache twice. */
1328  BKE_ptcache_blend_read_data(reader, &rbw->ptcaches, &rbw->pointcache, false);
1329 
1330  /* make sure simulation starts from the beginning after loading file */
1331  if (rbw->pointcache) {
1332  rbw->ltime = (float)rbw->pointcache->startframe;
1333  }
1334  }
1335  else {
1336  /* must nullify the reference to physics sim object, since it no-longer exist
1337  * (and will need to be recalculated)
1338  */
1339  rbw->shared->physics_world = nullptr;
1340 
1341  /* link caches */
1342  BKE_ptcache_blend_read_data(reader, &rbw->shared->ptcaches, &rbw->shared->pointcache, false);
1343 
1344  /* make sure simulation starts from the beginning after loading file */
1345  if (rbw->shared->pointcache) {
1346  rbw->ltime = (float)rbw->shared->pointcache->startframe;
1347  }
1348  }
1349  rbw->objects = nullptr;
1350  rbw->numbodies = 0;
1351 
1352  /* set effector weights */
1353  BLO_read_data_address(reader, &rbw->effector_weights);
1354  if (!rbw->effector_weights) {
1356  }
1357  }
1358 
1359  BLO_read_data_address(reader, &sce->preview);
1360  BKE_previewimg_blend_read(reader, sce->preview);
1361 
1363 
1364 #ifdef USE_COLLECTION_COMPAT_28
1365  /* this runs before the very first doversion */
1366  if (sce->collection) {
1367  BLO_read_data_address(reader, &sce->collection);
1368  BKE_collection_compat_blend_read_data(reader, sce->collection);
1369  }
1370 #endif
1371 
1372  /* insert into global old-new map for reading without UI (link_global accesses it again) */
1373  BLO_read_glob_list(reader, &sce->view_layers);
1374  LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
1375  BKE_view_layer_blend_read_data(reader, view_layer);
1376  }
1377 
1378  if (BLO_read_data_is_undo(reader)) {
1379  /* If it's undo do nothing here, caches are handled by higher-level generic calling code. */
1380  }
1381  else {
1382  /* else try to read the cache from file. */
1384  if (sce->eevee.light_cache_data) {
1386  }
1387  }
1389 
1391 
1392  BLO_read_data_address(reader, &sce->layer_properties);
1393  IDP_BlendDataRead(reader, &sce->layer_properties);
1394 }
1395 
1396 /* patch for missing scene IDs, can't be in do-versions */
1398 {
1400  if (node->id == nullptr &&
1401  ((node->type == CMP_NODE_R_LAYERS) ||
1402  (node->type == CMP_NODE_CRYPTOMATTE && node->custom1 == CMP_CRYPTOMATTE_SRC_RENDER))) {
1403  node->id = &scene->id;
1404  }
1405  }
1406 }
1407 
1408 static void scene_blend_read_lib(BlendLibReader *reader, ID *id)
1409 {
1410  Scene *sce = (Scene *)id;
1411 
1412  BKE_keyingsets_blend_read_lib(reader, &sce->id, &sce->keyingsets);
1413 
1414  BLO_read_id_address(reader, sce->id.lib, &sce->camera);
1415  BLO_read_id_address(reader, sce->id.lib, &sce->world);
1416  BLO_read_id_address(reader, sce->id.lib, &sce->set);
1417  BLO_read_id_address(reader, sce->id.lib, &sce->gpd);
1418 
1419  BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->imapaint.paint);
1420  if (sce->toolsettings->sculpt) {
1421  BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->sculpt->paint);
1422  }
1423  if (sce->toolsettings->vpaint) {
1424  BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->vpaint->paint);
1425  }
1426  if (sce->toolsettings->wpaint) {
1427  BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->wpaint->paint);
1428  }
1429  if (sce->toolsettings->uvsculpt) {
1430  BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->uvsculpt->paint);
1431  }
1432  if (sce->toolsettings->gp_paint) {
1433  BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->gp_paint->paint);
1434  }
1435  if (sce->toolsettings->gp_vertexpaint) {
1437  }
1438  if (sce->toolsettings->gp_sculptpaint) {
1440  }
1441  if (sce->toolsettings->gp_weightpaint) {
1443  }
1444  if (sce->toolsettings->curves_sculpt) {
1446  }
1447 
1448  if (sce->toolsettings->sculpt) {
1450  }
1451 
1452  if (sce->toolsettings->imapaint.stencil) {
1453  BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->imapaint.stencil);
1454  }
1455 
1456  if (sce->toolsettings->imapaint.clone) {
1457  BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->imapaint.clone);
1458  }
1459 
1460  if (sce->toolsettings->imapaint.canvas) {
1461  BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->imapaint.canvas);
1462  }
1463 
1465 
1467 
1468  LISTBASE_FOREACH_MUTABLE (Base *, base_legacy, &sce->base) {
1469  BLO_read_id_address(reader, sce->id.lib, &base_legacy->object);
1470 
1471  if (base_legacy->object == nullptr) {
1473  RPT_WARNING,
1474  TIP_("LIB: object lost from scene: '%s'"),
1475  sce->id.name + 2);
1476  BLI_remlink(&sce->base, base_legacy);
1477  if (base_legacy == sce->basact) {
1478  sce->basact = nullptr;
1479  }
1480  MEM_freeN(base_legacy);
1481  }
1482  }
1483 
1484  if (sce->ed) {
1485  SEQ_blend_read_lib(reader, sce, &sce->ed->seqbase);
1486  }
1487 
1488  LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
1489  IDP_BlendReadLib(reader, sce->id.lib, marker->prop);
1490 
1491  if (marker->camera) {
1492  BLO_read_id_address(reader, sce->id.lib, &marker->camera);
1493  }
1494  }
1495 
1496  /* rigidbody world relies on its linked collections */
1497  if (sce->rigidbody_world) {
1498  RigidBodyWorld *rbw = sce->rigidbody_world;
1499  if (rbw->group) {
1500  BLO_read_id_address(reader, sce->id.lib, &rbw->group);
1501  }
1502  if (rbw->constraints) {
1503  BLO_read_id_address(reader, sce->id.lib, &rbw->constraints);
1504  }
1505  if (rbw->effector_weights) {
1506  BLO_read_id_address(reader, sce->id.lib, &rbw->effector_weights->group);
1507  }
1508  }
1509 
1510  if (sce->nodetree) {
1511  composite_patch(sce->nodetree, sce);
1512  }
1513 
1514  LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) {
1515  BLO_read_id_address(reader, sce->id.lib, &srl->mat_override);
1516  LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &srl->freestyleConfig.modules) {
1517  BLO_read_id_address(reader, sce->id.lib, &fmc->script);
1518  }
1519  LISTBASE_FOREACH (FreestyleLineSet *, fls, &srl->freestyleConfig.linesets) {
1520  BLO_read_id_address(reader, sce->id.lib, &fls->linestyle);
1521  BLO_read_id_address(reader, sce->id.lib, &fls->group);
1522  }
1523  }
1524  /* Motion Tracking */
1525  BLO_read_id_address(reader, sce->id.lib, &sce->clip);
1526 
1527 #ifdef USE_COLLECTION_COMPAT_28
1528  if (sce->collection) {
1529  BKE_collection_compat_blend_read_lib(reader, sce->id.lib, sce->collection);
1530  }
1531 #endif
1532 
1533  LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
1534  BKE_view_layer_blend_read_lib(reader, sce->id.lib, view_layer);
1535  }
1536 
1537  if (sce->r.bake.cage_object) {
1538  BLO_read_id_address(reader, sce->id.lib, &sce->r.bake.cage_object);
1539  }
1540 
1541 #ifdef USE_SETSCENE_CHECK
1542  if (sce->set != nullptr) {
1544  }
1545 #endif
1546 }
1547 
1548 static void scene_blend_read_expand(BlendExpander *expander, ID *id)
1549 {
1550  Scene *sce = (Scene *)id;
1551 
1552  LISTBASE_FOREACH (Base *, base_legacy, &sce->base) {
1553  BLO_expand(expander, base_legacy->object);
1554  }
1555  BLO_expand(expander, sce->camera);
1556  BLO_expand(expander, sce->world);
1557 
1559 
1560  if (sce->set) {
1561  BLO_expand(expander, sce->set);
1562  }
1563 
1564  LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) {
1565  BLO_expand(expander, srl->mat_override);
1566  LISTBASE_FOREACH (FreestyleModuleConfig *, module, &srl->freestyleConfig.modules) {
1567  if (module->script) {
1568  BLO_expand(expander, module->script);
1569  }
1570  }
1571  LISTBASE_FOREACH (FreestyleLineSet *, lineset, &srl->freestyleConfig.linesets) {
1572  if (lineset->group) {
1573  BLO_expand(expander, lineset->group);
1574  }
1575  BLO_expand(expander, lineset->linestyle);
1576  }
1577  }
1578 
1579  LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
1580  IDP_BlendReadExpand(expander, view_layer->id_properties);
1581 
1582  LISTBASE_FOREACH (FreestyleModuleConfig *, module, &view_layer->freestyle_config.modules) {
1583  if (module->script) {
1584  BLO_expand(expander, module->script);
1585  }
1586  }
1587 
1588  LISTBASE_FOREACH (FreestyleLineSet *, lineset, &view_layer->freestyle_config.linesets) {
1589  if (lineset->group) {
1590  BLO_expand(expander, lineset->group);
1591  }
1592  BLO_expand(expander, lineset->linestyle);
1593  }
1594  }
1595 
1596  if (sce->gpd) {
1597  BLO_expand(expander, sce->gpd);
1598  }
1599 
1600  if (sce->ed) {
1601  SEQ_blend_read_expand(expander, &sce->ed->seqbase);
1602  }
1603 
1604  if (sce->rigidbody_world) {
1605  BLO_expand(expander, sce->rigidbody_world->group);
1606  BLO_expand(expander, sce->rigidbody_world->constraints);
1607  }
1608 
1609  LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
1610  IDP_BlendReadExpand(expander, marker->prop);
1611 
1612  if (marker->camera) {
1613  BLO_expand(expander, marker->camera);
1614  }
1615  }
1616 
1617  BLO_expand(expander, sce->clip);
1618 
1619 #ifdef USE_COLLECTION_COMPAT_28
1620  if (sce->collection) {
1621  BKE_collection_compat_blend_read_expand(expander, sce->collection);
1622  }
1623 #endif
1624 
1625  if (sce->r.bake.cage_object) {
1626  BLO_expand(expander, sce->r.bake.cage_object);
1627  }
1628 }
1629 
1630 static void scene_undo_preserve(BlendLibReader *reader, ID *id_new, ID *id_old)
1631 {
1632  Scene *scene_new = (Scene *)id_new;
1633  Scene *scene_old = (Scene *)id_old;
1634 
1635  SWAP(View3DCursor, scene_old->cursor, scene_new->cursor);
1636  if (scene_new->toolsettings != nullptr && scene_old->toolsettings != nullptr) {
1637  /* First try to restore ID pointers that can be and should be preserved (like brushes or
1638  * palettes), and counteract the swap of the whole ToolSettings structs below for the others
1639  * (like object ones). */
1641  nullptr, scene_new->toolsettings, true, reader, scene_old->toolsettings);
1642  SWAP(ToolSettings, *scene_old->toolsettings, *scene_new->toolsettings);
1643  }
1644 }
1645 
1646 static void scene_lib_override_apply_post(ID *id_dst, ID *UNUSED(id_src))
1647 {
1648  Scene *scene = (Scene *)id_dst;
1649 
1650  if (scene->rigidbody_world != nullptr) {
1651  PTCacheID pid;
1653  LISTBASE_FOREACH (PointCache *, point_cache, pid.ptcaches) {
1654  point_cache->flag |= PTCACHE_FLAG_INFO_DIRTY;
1655  }
1656  }
1657 }
1658 
1660 {
1661  IDTypeInfo info{};
1662  info.id_code = ID_SCE;
1663  info.id_filter = FILTER_ID_SCE;
1664  info.main_listbase_index = INDEX_ID_SCE;
1665  info.struct_size = sizeof(Scene);
1666  info.name = "Scene";
1667  info.name_plural = "scenes";
1668  info.translation_context = BLT_I18NCONTEXT_ID_SCENE;
1669  info.flags = 0;
1670  info.asset_type_info = nullptr;
1671 
1672  info.init_data = scene_init_data;
1673  info.copy_data = scene_copy_data;
1674  info.free_data = scene_free_data;
1675  /* For now default `BKE_lib_id_make_local_generic()` should work, may need more work though to
1676  * support all possible corner cases. */
1677  info.make_local = nullptr;
1678  info.foreach_id = scene_foreach_id;
1679  info.foreach_cache = scene_foreach_cache;
1680  info.foreach_path = scene_foreach_path;
1681  info.owner_get = nullptr;
1682 
1683  info.blend_write = scene_blend_write;
1684  info.blend_read_data = scene_blend_read_data;
1685  info.blend_read_lib = scene_blend_read_lib;
1686  info.blend_read_expand = scene_blend_read_expand;
1687 
1688  info.blend_read_undo_preserve = scene_undo_preserve;
1689 
1690  info.lib_override_apply_post = scene_lib_override_apply_post;
1691  return info;
1692 }
1694 
1695 const char *RE_engine_id_BLENDER_EEVEE = "BLENDER_EEVEE";
1696 const char *RE_engine_id_BLENDER_WORKBENCH = "BLENDER_WORKBENCH";
1697 const char *RE_engine_id_CYCLES = "CYCLES";
1698 
1700 {
1701  if (acd) {
1702  if (acd->lpFormat) {
1703  MEM_freeN(acd->lpFormat);
1704  acd->lpFormat = nullptr;
1705  acd->cbFormat = 0;
1706  }
1707  if (acd->lpParms) {
1708  MEM_freeN(acd->lpParms);
1709  acd->lpParms = nullptr;
1710  acd->cbParms = 0;
1711  }
1712  }
1713 }
1714 
1716 {
1717  AnimData *adt = BKE_animdata_from_id(&sce->id);
1718 
1719  if (adt && adt->action) {
1720  LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, &adt->action->curves) {
1721  if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) {
1723  BKE_fcurve_free(fcu);
1724  }
1725  }
1726  }
1727 }
1728 
1730 {
1731  if (toolsettings == nullptr) {
1732  return nullptr;
1733  }
1734  ToolSettings *ts = static_cast<ToolSettings *>(MEM_dupallocN(toolsettings));
1735  if (ts->vpaint) {
1736  ts->vpaint = static_cast<VPaint *>(MEM_dupallocN(ts->vpaint));
1737  BKE_paint_copy(&ts->vpaint->paint, &ts->vpaint->paint, flag);
1738  }
1739  if (ts->wpaint) {
1740  ts->wpaint = static_cast<VPaint *>(MEM_dupallocN(ts->wpaint));
1741  BKE_paint_copy(&ts->wpaint->paint, &ts->wpaint->paint, flag);
1742  }
1743  if (ts->sculpt) {
1744  ts->sculpt = static_cast<Sculpt *>(MEM_dupallocN(ts->sculpt));
1745  BKE_paint_copy(&ts->sculpt->paint, &ts->sculpt->paint, flag);
1746  }
1747  if (ts->uvsculpt) {
1748  ts->uvsculpt = static_cast<UvSculpt *>(MEM_dupallocN(ts->uvsculpt));
1750  }
1751  if (ts->gp_paint) {
1752  ts->gp_paint = static_cast<GpPaint *>(MEM_dupallocN(ts->gp_paint));
1754  }
1755  if (ts->gp_vertexpaint) {
1756  ts->gp_vertexpaint = static_cast<GpVertexPaint *>(MEM_dupallocN(ts->gp_vertexpaint));
1758  }
1759  if (ts->gp_sculptpaint) {
1760  ts->gp_sculptpaint = static_cast<GpSculptPaint *>(MEM_dupallocN(ts->gp_sculptpaint));
1762  }
1763  if (ts->gp_weightpaint) {
1764  ts->gp_weightpaint = static_cast<GpWeightPaint *>(MEM_dupallocN(ts->gp_weightpaint));
1766  }
1767  if (ts->curves_sculpt) {
1768  ts->curves_sculpt = static_cast<CurvesSculpt *>(MEM_dupallocN(ts->curves_sculpt));
1770  }
1771 
1773  ts->particle.paintcursor = nullptr;
1774  ts->particle.scene = nullptr;
1775  ts->particle.object = nullptr;
1776 
1777  /* duplicate Grease Pencil interpolation curve */
1779  /* Duplicate Grease Pencil multi-frame falloff. */
1782 
1784 
1786  return ts;
1787 }
1788 
1790 {
1791  if (toolsettings == nullptr) {
1792  return;
1793  }
1794  if (toolsettings->vpaint) {
1795  BKE_paint_free(&toolsettings->vpaint->paint);
1796  MEM_freeN(toolsettings->vpaint);
1797  }
1798  if (toolsettings->wpaint) {
1799  BKE_paint_free(&toolsettings->wpaint->paint);
1800  MEM_freeN(toolsettings->wpaint);
1801  }
1802  if (toolsettings->sculpt) {
1803  BKE_paint_free(&toolsettings->sculpt->paint);
1804  MEM_freeN(toolsettings->sculpt);
1805  }
1806  if (toolsettings->uvsculpt) {
1807  BKE_paint_free(&toolsettings->uvsculpt->paint);
1808  MEM_freeN(toolsettings->uvsculpt);
1809  }
1810  if (toolsettings->gp_paint) {
1811  BKE_paint_free(&toolsettings->gp_paint->paint);
1812  MEM_freeN(toolsettings->gp_paint);
1813  }
1814  if (toolsettings->gp_vertexpaint) {
1815  BKE_paint_free(&toolsettings->gp_vertexpaint->paint);
1816  MEM_freeN(toolsettings->gp_vertexpaint);
1817  }
1818  if (toolsettings->gp_sculptpaint) {
1819  BKE_paint_free(&toolsettings->gp_sculptpaint->paint);
1820  MEM_freeN(toolsettings->gp_sculptpaint);
1821  }
1822  if (toolsettings->gp_weightpaint) {
1823  BKE_paint_free(&toolsettings->gp_weightpaint->paint);
1824  MEM_freeN(toolsettings->gp_weightpaint);
1825  }
1826  if (toolsettings->curves_sculpt) {
1827  BKE_paint_free(&toolsettings->curves_sculpt->paint);
1828  MEM_freeN(toolsettings->curves_sculpt);
1829  }
1830  BKE_paint_free(&toolsettings->imapaint.paint);
1831 
1832  /* free Grease Pencil interpolation curve */
1833  if (toolsettings->gp_interpolate.custom_ipo) {
1835  }
1836  /* free Grease Pencil multi-frame falloff curve */
1837  if (toolsettings->gp_sculpt.cur_falloff) {
1839  }
1840  if (toolsettings->gp_sculpt.cur_primitive) {
1842  }
1843 
1844  if (toolsettings->custom_bevel_profile_preset) {
1846  }
1847 
1848  if (toolsettings->sequencer_tool_settings) {
1850  }
1851 
1852  MEM_freeN(toolsettings);
1853 }
1854 
1855 void BKE_scene_copy_data_eevee(Scene *sce_dst, const Scene *sce_src)
1856 {
1857  /* Copy eevee data between scenes. */
1858  sce_dst->eevee = sce_src->eevee;
1859  sce_dst->eevee.light_cache_data = nullptr;
1860  sce_dst->eevee.light_cache_info[0] = '\0';
1861  /* TODO: Copy the cache. */
1862 }
1863 
1865 {
1866  Scene *sce_copy;
1867 
1868  /* TODO: this should/could most likely be replaced by call to more generic code at some point...
1869  * But for now, let's keep it well isolated here. */
1870  if (type == SCE_COPY_EMPTY) {
1871  ListBase rv;
1872 
1873  sce_copy = BKE_scene_add(bmain, sce->id.name + 2);
1874 
1875  rv = sce_copy->r.views;
1877  sce_copy->r = sce->r;
1878  sce_copy->r.views = rv;
1879  sce_copy->unit = sce->unit;
1880  sce_copy->physics_settings = sce->physics_settings;
1881  sce_copy->audio = sce->audio;
1882  BKE_scene_copy_data_eevee(sce_copy, sce);
1883 
1884  if (sce->id.properties) {
1885  sce_copy->id.properties = IDP_CopyProperty(sce->id.properties);
1886  }
1887 
1888  BKE_sound_destroy_scene(sce_copy);
1889 
1890  /* copy color management settings */
1895 
1896  BKE_image_format_copy(&sce_copy->r.im_format, &sce->r.im_format);
1897  BKE_image_format_copy(&sce_copy->r.bake.im_format, &sce->r.bake.im_format);
1898 
1900 
1901  /* viewport display settings */
1902  sce_copy->display = sce->display;
1903 
1904  /* tool settings */
1906  sce_copy->toolsettings = BKE_toolsettings_copy(sce->toolsettings, 0);
1907 
1908  /* make a private copy of the avicodecdata */
1909  if (sce->r.avicodecdata) {
1910  sce_copy->r.avicodecdata = static_cast<AviCodecData *>(MEM_dupallocN(sce->r.avicodecdata));
1911  sce_copy->r.avicodecdata->lpFormat = MEM_dupallocN(sce_copy->r.avicodecdata->lpFormat);
1912  sce_copy->r.avicodecdata->lpParms = MEM_dupallocN(sce_copy->r.avicodecdata->lpParms);
1913  }
1914 
1916 
1917  /* grease pencil */
1918  sce_copy->gpd = nullptr;
1919 
1920  sce_copy->preview = nullptr;
1921 
1922  return sce_copy;
1923  }
1924 
1925  eDupli_ID_Flags duplicate_flags = (eDupli_ID_Flags)(U.dupflag | USER_DUP_OBJECT);
1926 
1927  sce_copy = (Scene *)BKE_id_copy(bmain, (ID *)sce);
1928  id_us_min(&sce_copy->id);
1929  id_us_ensure_real(&sce_copy->id);
1930 
1931  BKE_animdata_duplicate_id_action(bmain, &sce_copy->id, duplicate_flags);
1932 
1933  /* Extra actions, most notably SCE_FULL_COPY also duplicates several 'children' datablocks. */
1934 
1935  if (type == SCE_COPY_FULL) {
1936  /* Scene duplication is always root of duplication currently. */
1937  const bool is_subprocess = false;
1938  const bool is_root_id = true;
1939  const int copy_flags = LIB_ID_COPY_DEFAULT;
1940 
1941  if (!is_subprocess) {
1943  }
1944  if (is_root_id) {
1945  /* In case root duplicated ID is linked, assume we want to get a local copy of it and
1946  * duplicate all expected linked data. */
1947  if (ID_IS_LINKED(sce)) {
1948  duplicate_flags = (eDupli_ID_Flags)(duplicate_flags | USER_DUP_LINKED_ID);
1949  }
1950  }
1951 
1952  /* Copy Freestyle LineStyle datablocks. */
1953  LISTBASE_FOREACH (ViewLayer *, view_layer_dst, &sce_copy->view_layers) {
1954  LISTBASE_FOREACH (FreestyleLineSet *, lineset, &view_layer_dst->freestyle_config.linesets) {
1955  BKE_id_copy_for_duplicate(bmain, (ID *)lineset->linestyle, duplicate_flags, copy_flags);
1956  }
1957  }
1958 
1959  /* Full copy of world (included animations) */
1960  BKE_id_copy_for_duplicate(bmain, (ID *)sce->world, duplicate_flags, copy_flags);
1961 
1962  /* Full copy of GreasePencil. */
1963  BKE_id_copy_for_duplicate(bmain, (ID *)sce->gpd, duplicate_flags, copy_flags);
1964 
1965  /* Deep-duplicate collections and objects (using preferences' settings for which sub-data to
1966  * duplicate along the object itself). */
1968  nullptr,
1969  sce_copy->master_collection,
1970  duplicate_flags,
1972 
1973  /* Rigid body world collections may not be instantiated as scene's collections, ensure they
1974  * also get properly duplicated. */
1975  if (sce_copy->rigidbody_world != nullptr) {
1976  if (sce_copy->rigidbody_world->group != nullptr) {
1978  nullptr,
1979  sce_copy->rigidbody_world->group,
1980  duplicate_flags,
1982  }
1983  if (sce_copy->rigidbody_world->constraints != nullptr) {
1985  nullptr,
1986  sce_copy->rigidbody_world->constraints,
1987  duplicate_flags,
1989  }
1990  }
1991 
1992  if (!is_subprocess) {
1993  /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW. */
1994  BKE_libblock_relink_to_newid(bmain, &sce_copy->id, 0);
1995 
1996 #ifndef NDEBUG
1997  /* Call to `BKE_libblock_relink_to_newid` above is supposed to have cleared all those
1998  * flags. */
1999  ID *id_iter;
2000  FOREACH_MAIN_ID_BEGIN (bmain, id_iter) {
2001  BLI_assert((id_iter->tag & LIB_TAG_NEW) == 0);
2002  }
2004 #endif
2005 
2006  /* Cleanup. */
2008 
2009  BKE_main_collection_sync(bmain);
2010  }
2011  }
2012  else {
2013  /* Remove sequencer if not full copy */
2014  /* XXX Why in Hell? :/ */
2015  remove_sequencer_fcurves(sce_copy);
2016  SEQ_editing_free(sce_copy, true);
2017  }
2018 
2019  return sce_copy;
2020 }
2021 
2023 {
2024  if (sce->rigidbody_world) {
2026  }
2027 }
2028 
2029 bool BKE_scene_can_be_removed(const Main *bmain, const Scene *scene)
2030 {
2031  /* Linked scenes can always be removed. */
2032  if (ID_IS_LINKED(scene)) {
2033  return true;
2034  }
2035  /* Local scenes can only be removed, when there is at least one local scene left. */
2036  LISTBASE_FOREACH (Scene *, other_scene, &bmain->scenes) {
2037  if (other_scene != scene && !ID_IS_LINKED(other_scene)) {
2038  return true;
2039  }
2040  }
2041  return false;
2042 }
2043 
2044 Scene *BKE_scene_add(Main *bmain, const char *name)
2045 {
2046  Scene *sce = static_cast<Scene *>(BKE_id_new(bmain, ID_SCE, name));
2047  id_us_min(&sce->id);
2048  id_us_ensure_real(&sce->id);
2049 
2050  return sce;
2051 }
2052 
2054 {
2055  LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
2056  if (BLI_findptr(&view_layer->object_bases, ob, offsetof(Base, object))) {
2057  return true;
2058  }
2059  }
2060  return false;
2061 }
2062 
2064 {
2065  LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
2066  LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
2067  if (STREQ(base->object->id.name + 2, name)) {
2068  return base->object;
2069  }
2070  }
2071  }
2072  return nullptr;
2073 }
2074 
2076 {
2077  /* check for cyclic sets, for reading old files but also for definite security (py?) */
2079 
2080  /* Deselect objects (for data select). */
2081  LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
2082  ob->flag &= ~SELECT;
2083  }
2084 
2085  /* copy layers and flags from bases to objects */
2086  LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
2087  LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
2088  /* collection patch... */
2090  }
2091  }
2092  /* No full animation update, this to enable render code to work
2093  * (render code calls own animation updates). */
2094 }
2095 
2096 Scene *BKE_scene_set_name(Main *bmain, const char *name)
2097 {
2098  Scene *sce = (Scene *)BKE_libblock_find_name(bmain, ID_SCE, name);
2099  if (sce) {
2100  BKE_scene_set_background(bmain, sce);
2101  printf("Scene switch for render: '%s' in file: '%s'\n", name, BKE_main_blendfile_path(bmain));
2102  return sce;
2103  }
2104 
2105  printf("Can't find scene: '%s' in file: '%s'\n", name, BKE_main_blendfile_path(bmain));
2106  return nullptr;
2107 }
2108 
2110  Depsgraph *depsgraph, SceneBaseIter *iter, Scene **scene, int val, Base **base, Object **ob)
2111 {
2112  bool run_again = true;
2113 
2114  /* init */
2115  if (val == 0) {
2116  iter->phase = F_START;
2117  iter->dupob = nullptr;
2118  iter->duplilist = nullptr;
2119  iter->dupli_refob = nullptr;
2120  }
2121  else {
2122  /* run_again is set when a duplilist has been ended */
2123  while (run_again) {
2124  run_again = false;
2125 
2126  /* the first base */
2127  if (iter->phase == F_START) {
2130  *base = static_cast<Base *>(view_layer->object_bases.first);
2131  if (*base) {
2132  *ob = (*base)->object;
2133  iter->phase = F_SCENE;
2134  }
2135  else {
2136  /* exception: empty scene layer */
2137  while ((*scene)->set) {
2138  (*scene) = (*scene)->set;
2139  ViewLayer *view_layer_set = BKE_view_layer_default_render(*scene);
2140  if (view_layer_set->object_bases.first) {
2141  *base = static_cast<Base *>(view_layer_set->object_bases.first);
2142  *ob = (*base)->object;
2143  iter->phase = F_SCENE;
2144  break;
2145  }
2146  }
2147  }
2148  }
2149  else {
2150  if (*base && iter->phase != F_DUPLI) {
2151  *base = (*base)->next;
2152  if (*base) {
2153  *ob = (*base)->object;
2154  }
2155  else {
2156  if (iter->phase == F_SCENE) {
2157  /* (*scene) is finished, now do the set */
2158  while ((*scene)->set) {
2159  (*scene) = (*scene)->set;
2160  ViewLayer *view_layer_set = BKE_view_layer_default_render(*scene);
2161  if (view_layer_set->object_bases.first) {
2162  *base = static_cast<Base *>(view_layer_set->object_bases.first);
2163  *ob = (*base)->object;
2164  break;
2165  }
2166  }
2167  }
2168  }
2169  }
2170  }
2171 
2172  if (*base == nullptr) {
2173  iter->phase = F_START;
2174  }
2175  else {
2176  if (iter->phase != F_DUPLI) {
2177  if (depsgraph && (*base)->object->transflag & OB_DUPLI) {
2178  /* Collections cannot be duplicated for meta-balls yet,
2179  * this enters eternal loop because of
2180  * makeDispListMBall getting called inside of collection_duplilist */
2181  if ((*base)->object->instance_collection == nullptr) {
2182  iter->duplilist = object_duplilist(depsgraph, (*scene), (*base)->object);
2183 
2184  iter->dupob = static_cast<DupliObject *>(iter->duplilist->first);
2185 
2186  if (!iter->dupob) {
2188  iter->duplilist = nullptr;
2189  }
2190  iter->dupli_refob = nullptr;
2191  }
2192  }
2193  }
2194  /* handle dupli's */
2195  if (iter->dupob) {
2196  (*base)->flag_legacy |= OB_FROMDUPLI;
2197  *ob = iter->dupob->ob;
2198  iter->phase = F_DUPLI;
2199 
2200  if (iter->dupli_refob != *ob) {
2201  if (iter->dupli_refob) {
2202  /* Restore previous object's real matrix. */
2203  copy_m4_m4(iter->dupli_refob->obmat, iter->omat);
2204  }
2205  /* Backup new object's real matrix. */
2206  iter->dupli_refob = *ob;
2207  copy_m4_m4(iter->omat, iter->dupli_refob->obmat);
2208  }
2209  copy_m4_m4((*ob)->obmat, iter->dupob->mat);
2210 
2211  iter->dupob = iter->dupob->next;
2212  }
2213  else if (iter->phase == F_DUPLI) {
2214  iter->phase = F_SCENE;
2215  (*base)->flag_legacy &= ~OB_FROMDUPLI;
2216 
2217  if (iter->dupli_refob) {
2218  /* Restore last object's real matrix. */
2219  copy_m4_m4(iter->dupli_refob->obmat, iter->omat);
2220  iter->dupli_refob = nullptr;
2221  }
2222 
2224  iter->duplilist = nullptr;
2225  run_again = true;
2226  }
2227  }
2228  }
2229  }
2230 
2231  return iter->phase;
2232 }
2233 
2234 bool BKE_scene_has_view_layer(const Scene *scene, const ViewLayer *layer)
2235 {
2236  return BLI_findindex(&scene->view_layers, layer) != -1;
2237 }
2238 
2239 Scene *BKE_scene_find_from_collection(const Main *bmain, const Collection *collection)
2240 {
2241  LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
2243  if (BKE_view_layer_has_collection(layer, collection)) {
2244  return scene;
2245  }
2246  }
2247  }
2248 
2249  return nullptr;
2250 }
2251 
2252 #ifdef DURIAN_CAMERA_SWITCH
2253 Object *BKE_scene_camera_switch_find(Scene *scene)
2254 {
2255  if (scene->r.mode & R_NO_CAMERA_SWITCH) {
2256  return nullptr;
2257  }
2258 
2259  const int ctime = (int)BKE_scene_ctime_get(scene);
2260  int frame = -(MAXFRAME + 1);
2261  int min_frame = MAXFRAME + 1;
2262  Object *camera = nullptr;
2263  Object *first_camera = nullptr;
2264 
2266  if (m->camera && (m->camera->visibility_flag & OB_HIDE_RENDER) == 0) {
2267  if ((m->frame <= ctime) && (m->frame > frame)) {
2268  camera = m->camera;
2269  frame = m->frame;
2270 
2271  if (frame == ctime) {
2272  break;
2273  }
2274  }
2275 
2276  if (m->frame < min_frame) {
2277  first_camera = m->camera;
2278  min_frame = m->frame;
2279  }
2280  }
2281  }
2282 
2283  if (camera == nullptr) {
2284  /* If there's no marker to the left of current frame,
2285  * use camera from left-most marker to solve all sort
2286  * of Schrodinger uncertainties.
2287  */
2288  return first_camera;
2289  }
2290 
2291  return camera;
2292 }
2293 #endif
2294 
2296 {
2297 #ifdef DURIAN_CAMERA_SWITCH
2298  Object *camera = BKE_scene_camera_switch_find(scene);
2299  if (camera && (camera != scene->camera)) {
2300  scene->camera = camera;
2302  return true;
2303  }
2304 #else
2305  (void)scene;
2306 #endif
2307  return false;
2308 }
2309 
2310 const char *BKE_scene_find_marker_name(const Scene *scene, int frame)
2311 {
2312  const ListBase *markers = &scene->markers;
2313  const TimeMarker *m1, *m2;
2314 
2315  /* search through markers for match */
2316  for (m1 = static_cast<const TimeMarker *>(markers->first),
2317  m2 = static_cast<const TimeMarker *>(markers->last);
2318  m1 && m2;
2319  m1 = m1->next, m2 = m2->prev) {
2320  if (m1->frame == frame) {
2321  return m1->name;
2322  }
2323 
2324  if (m1 == m2) {
2325  break;
2326  }
2327 
2328  if (m2->frame == frame) {
2329  return m2->name;
2330  }
2331  }
2332 
2333  return nullptr;
2334 }
2335 
2336 const char *BKE_scene_find_last_marker_name(const Scene *scene, int frame)
2337 {
2338  const TimeMarker *best_marker = nullptr;
2339  int best_frame = -MAXFRAME * 2;
2340  LISTBASE_FOREACH (const TimeMarker *, marker, &scene->markers) {
2341  if (marker->frame == frame) {
2342  return marker->name;
2343  }
2344 
2345  if (marker->frame > best_frame && marker->frame < frame) {
2346  best_marker = marker;
2347  best_frame = marker->frame;
2348  }
2349  }
2350 
2351  return best_marker ? best_marker->name : nullptr;
2352 }
2353 
2354 int BKE_scene_frame_snap_by_seconds(Scene *scene, double interval_in_seconds, int frame)
2355 {
2356  const int fps = round_db_to_int(FPS * interval_in_seconds);
2357  const int second_prev = frame - mod_i(frame, fps);
2358  const int second_next = second_prev + fps;
2359  const int delta_prev = frame - second_prev;
2360  const int delta_next = second_next - frame;
2361  return (delta_prev < delta_next) ? second_prev : second_next;
2362 }
2363 
2365  Scene *scene,
2366  Object *ob,
2367  const bool free_us)
2368 {
2369  /* remove rigid body constraint from world before removing object */
2370  if (ob->rigidbody_constraint) {
2371  BKE_rigidbody_remove_constraint(bmain, scene, ob, free_us);
2372  }
2373  /* remove rigid body object from world before removing object */
2374  if (ob->rigidbody_object) {
2375  BKE_rigidbody_remove_object(bmain, scene, ob, free_us);
2376  }
2377 }
2378 
2380 {
2381  Scene *sce_iter;
2382  int a, totscene;
2383 
2384  if (sce->set == nullptr) {
2385  return true;
2386  }
2387  totscene = BLI_listbase_count(&bmain->scenes);
2388 
2389  for (a = 0, sce_iter = sce; sce_iter->set; sce_iter = sce_iter->set, a++) {
2390  /* more iterations than scenes means we have a cycle */
2391  if (a > totscene) {
2392  /* the tested scene gets zero'ed, that's typically current scene */
2393  sce->set = nullptr;
2394  return false;
2395  }
2396  }
2397 
2398  return true;
2399 }
2400 
2402 {
2404 }
2405 
2406 float BKE_scene_frame_to_ctime(const Scene *scene, const int frame)
2407 {
2408  float ctime = frame;
2409  ctime += scene->r.subframe;
2410  ctime *= scene->r.framelen;
2411 
2412  return ctime;
2413 }
2414 
2416 {
2417  return scene->r.cfra + scene->r.subframe;
2418 }
2419 
2420 void BKE_scene_frame_set(Scene *scene, float frame)
2421 {
2422  double intpart;
2423  scene->r.subframe = modf((double)frame, &intpart);
2424  scene->r.cfra = (int)intpart;
2425 }
2426 
2427 /* -------------------------------------------------------------------- */
2432 {
2433  if ((scene->orientation_slots[slot_index].flag & SELECT) == 0) {
2434  slot_index = SCE_ORIENT_DEFAULT;
2435  }
2436  return &scene->orientation_slots[slot_index];
2437 }
2438 
2440 {
2443  int slot_index = SCE_ORIENT_DEFAULT;
2445  slot_index = SCE_ORIENT_TRANSLATE;
2446  }
2447  else if (flag & V3D_GIZMO_SHOW_OBJECT_ROTATE) {
2448  slot_index = SCE_ORIENT_ROTATE;
2449  }
2450  else if (flag & V3D_GIZMO_SHOW_OBJECT_SCALE) {
2451  slot_index = SCE_ORIENT_SCALE;
2452  }
2453  return BKE_scene_orientation_slot_get(scene, slot_index);
2454 }
2455 
2457 {
2458  const bool is_custom = orientation >= V3D_ORIENT_CUSTOM;
2459  orient_slot->type = is_custom ? V3D_ORIENT_CUSTOM : orientation;
2460  orient_slot->index_custom = is_custom ? (orientation - V3D_ORIENT_CUSTOM) : -1;
2461 }
2462 
2464 {
2465  return (orient_slot->type == V3D_ORIENT_CUSTOM) ?
2466  (orient_slot->type + orient_slot->index_custom) :
2467  orient_slot->type;
2468 }
2469 
2471 {
2473  return BKE_scene_orientation_slot_get_index(orient_slot);
2474 }
2475 
2477 {
2479  return BKE_scene_orientation_slot_get_index(orient_slot);
2480 }
2481 
2485 {
2486  wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
2487  LISTBASE_FOREACH (const wmWindow *, window, &wm->windows) {
2488  const bScreen *screen = BKE_workspace_active_screen_get(window->workspace_hook);
2489  Scene *scene = window->scene;
2491 
2492  if (type->draw_engine || !type->render) {
2493  continue;
2494  }
2495 
2496  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
2497  View3D *v3d = static_cast<View3D *>(area->spacedata.first);
2498  if (area->spacetype != SPACE_VIEW3D) {
2499  continue;
2500  }
2501  if (v3d->shading.type == OB_RENDER) {
2502  return true;
2503  }
2504  }
2505  }
2506  return false;
2507 }
2508 
2509 /* TODO(campbell): shouldn't we be able to use 'DEG_get_view_layer' here?
2510  * Currently this is nullptr on load, so don't. */
2511 static void prepare_mesh_for_viewport_render(Main *bmain, const ViewLayer *view_layer)
2512 {
2513  /* This is needed to prepare mesh to be used by the render
2514  * engine from the viewport rendering. We do loading here
2515  * so all the objects which shares the same mesh datablock
2516  * are nicely tagged for update and updated.
2517  *
2518  * This makes it so viewport render engine doesn't need to
2519  * call loading of the edit data for the mesh objects.
2520  */
2521 
2522  Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
2523  if (obedit) {
2524  Mesh *mesh = static_cast<Mesh *>(obedit->data);
2525  if ((obedit->type == OB_MESH) &&
2526  ((obedit->id.recalc & ID_RECALC_ALL) || (mesh->id.recalc & ID_RECALC_ALL))) {
2527  if (check_rendered_viewport_visible(bmain)) {
2528  BMesh *bm = mesh->edit_mesh->bm;
2530  params.calc_object_remap = true;
2531  params.update_shapekey_indices = true;
2532  BM_mesh_bm_to_me(bmain, bm, mesh, &params);
2533  DEG_id_tag_update(&mesh->id, 0);
2534  }
2535  }
2536  }
2537 }
2538 
2540 {
2542  const int recalc = scene->id.recalc;
2544  if (recalc & ID_RECALC_FRAME_CHANGE) {
2545  BKE_sound_seek_scene(bmain, scene);
2546  }
2547  if (recalc & ID_RECALC_AUDIO_FPS) {
2548  BKE_sound_update_fps(bmain, scene);
2549  }
2550  if (recalc & ID_RECALC_AUDIO_VOLUME) {
2552  }
2553  if (recalc & ID_RECALC_AUDIO_MUTE) {
2554  const bool is_mute = (scene->audio.flag & AUDIO_MUTE);
2555  BKE_sound_mute_scene(scene, is_mute);
2556  }
2557  if (recalc & ID_RECALC_AUDIO_LISTENER) {
2559  }
2561 }
2562 
2564 {
2566  /* The volume is actually updated in BKE_scene_update_sound(), from either
2567  * scene_graph_update_tagged() or from BKE_scene_graph_update_for_newframe(). */
2569 }
2570 
2571 /* TODO(sergey): This actually should become view_layer_graph or so.
2572  * Same applies to update_for_newframe.
2573  *
2574  * If only_if_tagged is truth then the function will do nothing if the dependency graph is up
2575  * to date already.
2576  */
2577 static void scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain, bool only_if_tagged)
2578 {
2579  if (only_if_tagged && DEG_is_fully_evaluated(depsgraph)) {
2580  return;
2581  }
2582 
2585  bool used_multiple_passes = false;
2586 
2587  bool run_callbacks = DEG_id_type_any_updated(depsgraph);
2588  if (run_callbacks) {
2590  }
2591 
2592  for (int pass = 0; pass < 2; pass++) {
2593  /* (Re-)build dependency graph if needed. */
2595  /* Uncomment this to check if graph was properly tagged for update. */
2596  // DEG_debug_graph_relations_validate(depsgraph, bmain, scene);
2597  /* Flush editing data if needed. */
2598  prepare_mesh_for_viewport_render(bmain, view_layer);
2599  /* Update all objects: drivers, matrices, #DispList, etc. flags set
2600  * by depsgraph or manual, no layer check here, gets correct flushed. */
2602  /* Update sound system. */
2604  /* Notify python about depsgraph update. */
2605  if (run_callbacks) {
2608 
2609  /* It is possible that the custom callback modified scene and removed some IDs from the main
2610  * database. In this case DEG_editors_update() will crash because it iterates over all IDs
2611  * which depsgraph was built for.
2612  *
2613  * The solution is to update relations prior to this call, avoiding access to freed IDs.
2614  * Should be safe because relations update is supposed to preserve flags of all IDs which are
2615  * still a part of the dependency graph. If an ID is kicked out of the dependency graph it
2616  * should also be fine because when/if it's added to another dependency graph it will need to
2617  * be tagged for an update anyway.
2618  *
2619  * If there are no relations changed by the callback this call will do nothing. */
2621  }
2622 
2623  /* If user callback did not tag anything for update we can skip second iteration.
2624  * Otherwise we update scene once again, but without running callbacks to bring
2625  * scene to a fully evaluated state with user modifications taken into account. */
2627  break;
2628  }
2629 
2630  /* Clear recalc flags for second pass, but back them up for editors update. */
2631  const bool backup = true;
2633  used_multiple_passes = true;
2634  run_callbacks = false;
2635  }
2636 
2637  /* Inform editors about changes, using recalc flags from both passes. */
2638  if (used_multiple_passes) {
2640  }
2641  const bool is_time_update = false;
2642  DEG_editors_update(depsgraph, is_time_update);
2643 
2644  const bool backup = false;
2646 }
2647 
2649 {
2650  scene_graph_update_tagged(depsgraph, bmain, false);
2651 }
2652 
2654 {
2655  scene_graph_update_tagged(depsgraph, bmain, true);
2656 }
2657 
2659 {
2661  Main *bmain = DEG_get_bmain(depsgraph);
2662  bool used_multiple_passes = false;
2663 
2664  /* Keep this first. */
2666 
2667  for (int pass = 0; pass < 2; pass++) {
2668  /* Update animated image textures for particles, modifiers, gpu, etc,
2669  * call this at the start so modifiers with textures don't lag 1 frame.
2670  */
2674  /* Update all objects: drivers, matrices, #DispList, etc. flags set
2675  * by depsgraph or manual, no layer check here, gets correct flushed.
2676  *
2677  * NOTE: Only update for new frame on first iteration. Second iteration is for ensuring user
2678  * edits from callback are properly taken into account. Doing a time update on those would
2679  * lose any possible unkeyed changes made by the handler. */
2680  if (pass == 0) {
2681  const float frame = BKE_scene_frame_get(scene);
2683  }
2684  else {
2686  }
2687  /* Update sound system animation. */
2689 
2690  /* Notify editors and python about recalc. */
2691  if (pass == 0) {
2693 
2694  /* NOTE: Similar to this case in scene_graph_update_tagged(). Need to ensure that
2695  * DEG_editors_update() doesn't access freed memory of possibly removed ID. */
2697  }
2698 
2699  /* If user callback did not tag anything for update we can skip second iteration.
2700  * Otherwise we update scene once again, but without running callbacks to bring
2701  * scene to a fully evaluated state with user modifications taken into account. */
2703  break;
2704  }
2705 
2706  /* Clear recalc flags for second pass, but back them up for editors update. */
2707  const bool backup = true;
2709  used_multiple_passes = true;
2710  }
2711 
2712  /* Inform editors about changes, using recalc flags from both passes. */
2713  if (used_multiple_passes) {
2715  }
2716 
2717  const bool is_time_update = true;
2718  DEG_editors_update(depsgraph, is_time_update);
2719 
2720  /* Clear recalc flags, can be skipped for e.g. renderers that will read these
2721  * and clear the flags later. */
2722  if (clear_recalc) {
2723  const bool backup = false;
2725  }
2726 }
2727 
2729 {
2731 }
2732 
2734 {
2735  Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer);
2738 }
2739 
2741 {
2742  if (!name) {
2743  name = DATA_("RenderView");
2744  }
2745 
2746  SceneRenderView *srv = MEM_cnew<SceneRenderView>(__func__);
2747  BLI_strncpy(srv->name, name, sizeof(srv->name));
2748  BLI_uniquename(&sce->r.views,
2749  srv,
2750  DATA_("RenderView"),
2751  '.',
2752  offsetof(SceneRenderView, name),
2753  sizeof(srv->name));
2754  BLI_addtail(&sce->r.views, srv);
2755 
2756  return srv;
2757 }
2758 
2760 {
2761  const int act = BLI_findindex(&scene->r.views, srv);
2762 
2763  if (act == -1) {
2764  return false;
2765  }
2766  if (scene->r.views.first == scene->r.views.last) {
2767  /* ensure 1 view is kept */
2768  return false;
2769  }
2770 
2771  BLI_remlink(&scene->r.views, srv);
2772  MEM_freeN(srv);
2773 
2774  scene->r.actview = 0;
2775 
2776  return true;
2777 }
2778 
2779 /* render simplification */
2780 
2781 int get_render_subsurf_level(const RenderData *r, int lvl, bool for_render)
2782 {
2783  if (r->mode & R_SIMPLIFY) {
2784  if (for_render) {
2785  return min_ii(r->simplify_subsurf_render, lvl);
2786  }
2787 
2788  return min_ii(r->simplify_subsurf, lvl);
2789  }
2790 
2791  return lvl;
2792 }
2793 
2794 int get_render_child_particle_number(const RenderData *r, int child_num, bool for_render)
2795 {
2796  if (r->mode & R_SIMPLIFY) {
2797  if (for_render) {
2798  return (int)(r->simplify_particles_render * child_num);
2799  }
2800 
2801  return (int)(r->simplify_particles * child_num);
2802  }
2803 
2804  return child_num;
2805 }
2806 
2807 Base *_setlooper_base_step(Scene **sce_iter, ViewLayer *view_layer, Base *base)
2808 {
2809  if (base && base->next) {
2810  /* Common case, step to the next. */
2811  return base->next;
2812  }
2813  if ((base == nullptr) && (view_layer != nullptr)) {
2814  /* First time looping, return the scenes first base. */
2815  /* For the first loop we should get the layer from workspace when available. */
2816  if (view_layer->object_bases.first) {
2817  return (Base *)view_layer->object_bases.first;
2818  }
2819  /* No base on this scene layer. */
2820  goto next_set;
2821  }
2822  else {
2823  next_set:
2824  /* Reached the end, get the next base in the set. */
2825  while ((*sce_iter = (*sce_iter)->set)) {
2826  ViewLayer *view_layer_set = BKE_view_layer_default_render(*sce_iter);
2827  base = (Base *)view_layer_set->object_bases.first;
2828 
2829  if (base) {
2830  return base;
2831  }
2832  }
2833  }
2834 
2835  return nullptr;
2836 }
2837 
2839 {
2841  return (type && type->flag & RE_USE_SHADING_NODES_CUSTOM);
2842 }
2843 
2845 {
2847  return (type && type->flag & RE_USE_SPHERICAL_STEREO);
2848 }
2849 
2851 {
2853 }
2854 
2856 {
2858 }
2859 
2861 {
2863 }
2864 
2865 /* This enumeration has to match the one defined in the Cycles addon. */
2869 };
2870 
2872 {
2874  PointerRNA scene_ptr;
2875  RNA_id_pointer_create(&scene->id, &scene_ptr);
2876  PointerRNA cycles_ptr = RNA_pointer_get(&scene_ptr, "cycles");
2877 
2878  if (RNA_pointer_is_null(&cycles_ptr)) {
2879  /* The pointer only exists if Cycles is enabled. */
2880  return false;
2881  }
2882 
2883  return RNA_enum_get(&cycles_ptr, "feature_set") == CYCLES_FEATURES_EXPERIMENTAL;
2884 }
2885 
2887 {
2888  Base *base = static_cast<Base *>(view_layer->object_bases.first);
2889 
2890  while (base) {
2892  base = base->next;
2893  }
2894 }
2895 
2897 {
2898  Object *ob = base->object;
2899  ob->base_flag = base->flag;
2900 }
2901 
2903 {
2904  ColorManagedDisplaySettings *display_settings = &scene->display_settings;
2905  ColorManagedViewSettings *view_settings = &scene->view_settings;
2906  const char *view;
2907  const char *none_display_name;
2908 
2909  none_display_name = IMB_colormanagement_display_get_none_name();
2910 
2911  BLI_strncpy(display_settings->display_device,
2912  none_display_name,
2913  sizeof(display_settings->display_device));
2914 
2916 
2917  if (view) {
2918  BLI_strncpy(view_settings->view_transform, view, sizeof(view_settings->view_transform));
2919  }
2920 }
2921 
2923 {
2924  return !STREQ(scene->display_settings.display_device, "None");
2925 }
2926 
2928 {
2931 }
2932 
2934 {
2935  int threads;
2936 
2937  /* override set from command line? */
2939 
2940  if (threads > 0) {
2941  return threads;
2942  }
2943 
2944  /* fixed number of threads specified in scene? */
2945  if (rd->mode & R_FIXED_THREADS) {
2946  threads = rd->threads;
2947  }
2948  else {
2950  }
2951 
2952  return max_ii(threads, 1);
2953 }
2954 
2956 {
2957  return BKE_render_num_threads(&scene->r);
2958 }
2959 
2961  const bool use_crop,
2962  int *r_width,
2963  int *r_height)
2964 {
2965  *r_width = (r->xsch * r->size) / 100;
2966  *r_height = (r->ysch * r->size) / 100;
2967 
2968  if (use_crop && (r->mode & R_BORDER) && (r->mode & R_CROP)) {
2969  *r_width *= BLI_rctf_size_x(&r->border);
2970  *r_height *= BLI_rctf_size_y(&r->border);
2971  }
2972 }
2973 
2975 {
2976  if (r->preview_pixel_size == 0) {
2977  return (U.pixelsize > 1.5f) ? 2 : 1;
2978  }
2979  return r->preview_pixel_size;
2980 }
2981 
2982 double BKE_scene_unit_scale(const UnitSettings *unit, const int unit_type, double value)
2983 {
2984  if (unit->system == USER_UNIT_NONE) {
2985  /* Never apply scale_length when not using a unit setting! */
2986  return value;
2987  }
2988 
2989  switch (unit_type) {
2990  case B_UNIT_LENGTH:
2991  case B_UNIT_VELOCITY:
2992  case B_UNIT_ACCELERATION:
2993  return value * (double)unit->scale_length;
2994  case B_UNIT_AREA:
2995  case B_UNIT_POWER:
2996  return value * pow(unit->scale_length, 2);
2997  case B_UNIT_VOLUME:
2998  return value * pow(unit->scale_length, 3);
2999  case B_UNIT_MASS:
3000  return value * pow(unit->scale_length, 3);
3001  case B_UNIT_CAMERA: /* *Do not* use scene's unit scale for camera focal lens! See T42026. */
3002  default:
3003  return value;
3004  }
3005 }
3006 
3007 /******************** multiview *************************/
3008 
3010 {
3011  int totviews = 0;
3012 
3013  if ((rd->scemode & R_MULTIVIEW) == 0) {
3014  return 1;
3015  }
3016 
3018  SceneRenderView *srv = static_cast<SceneRenderView *>(
3019  BLI_findstring(&rd->views, STEREO_LEFT_NAME, offsetof(SceneRenderView, name)));
3020  if ((srv && srv->viewflag & SCE_VIEW_DISABLE) == 0) {
3021  totviews++;
3022  }
3023 
3024  srv = static_cast<SceneRenderView *>(
3025  BLI_findstring(&rd->views, STEREO_RIGHT_NAME, offsetof(SceneRenderView, name)));
3026  if ((srv && srv->viewflag & SCE_VIEW_DISABLE) == 0) {
3027  totviews++;
3028  }
3029  }
3030  else {
3031  LISTBASE_FOREACH (SceneRenderView *, srv, &rd->views) {
3032  if ((srv->viewflag & SCE_VIEW_DISABLE) == 0) {
3033  totviews++;
3034  }
3035  }
3036  }
3037  return totviews;
3038 }
3039 
3041 {
3042  SceneRenderView *srv[2];
3043 
3044  if ((rd->scemode & R_MULTIVIEW) == 0) {
3045  return false;
3046  }
3047 
3048  srv[0] = (SceneRenderView *)BLI_findstring(
3049  &rd->views, STEREO_LEFT_NAME, offsetof(SceneRenderView, name));
3050  srv[1] = (SceneRenderView *)BLI_findstring(
3051  &rd->views, STEREO_RIGHT_NAME, offsetof(SceneRenderView, name));
3052 
3053  return (srv[0] && ((srv[0]->viewflag & SCE_VIEW_DISABLE) == 0) && srv[1] &&
3054  ((srv[1]->viewflag & SCE_VIEW_DISABLE) == 0));
3055 }
3056 
3058 {
3059  if (srv == nullptr) {
3060  return false;
3061  }
3062 
3063  if ((rd->scemode & R_MULTIVIEW) == 0) {
3064  return false;
3065  }
3066 
3067  if (srv->viewflag & SCE_VIEW_DISABLE) {
3068  return false;
3069  }
3070 
3072  return true;
3073  }
3074 
3075  /* SCE_VIEWS_SETUP_BASIC */
3077  return true;
3078  }
3079 
3080  return false;
3081 }
3082 
3083 bool BKE_scene_multiview_is_render_view_first(const RenderData *rd, const char *viewname)
3084 {
3085  if ((rd->scemode & R_MULTIVIEW) == 0) {
3086  return true;
3087  }
3088 
3089  if ((!viewname) || (!viewname[0])) {
3090  return true;
3091  }
3092 
3093  LISTBASE_FOREACH (const SceneRenderView *, srv, &rd->views) {
3095  return STREQ(viewname, srv->name);
3096  }
3097  }
3098 
3099  return true;
3100 }
3101 
3102 bool BKE_scene_multiview_is_render_view_last(const RenderData *rd, const char *viewname)
3103 {
3104  if ((rd->scemode & R_MULTIVIEW) == 0) {
3105  return true;
3106  }
3107 
3108  if ((!viewname) || (!viewname[0])) {
3109  return true;
3110  }
3111 
3112  LISTBASE_FOREACH_BACKWARD (const SceneRenderView *, srv, &rd->views) {
3114  return STREQ(viewname, srv->name);
3115  }
3116  }
3117 
3118  return true;
3119 }
3120 
3122 {
3123  SceneRenderView *srv;
3124  size_t nr;
3125 
3126  if ((rd->scemode & R_MULTIVIEW) == 0) {
3127  return nullptr;
3128  }
3129 
3130  for (srv = static_cast<SceneRenderView *>(rd->views.first), nr = 0; srv; srv = srv->next) {
3132  if (nr++ == view_id) {
3133  return srv;
3134  }
3135  }
3136  }
3137  return srv;
3138 }
3139 
3140 const char *BKE_scene_multiview_render_view_name_get(const RenderData *rd, const int view_id)
3141 {
3143 
3144  if (srv) {
3145  return srv->name;
3146  }
3147 
3148  return "";
3149 }
3150 
3151 int BKE_scene_multiview_view_id_get(const RenderData *rd, const char *viewname)
3152 {
3153  SceneRenderView *srv;
3154  size_t nr;
3155 
3156  if ((!rd) || ((rd->scemode & R_MULTIVIEW) == 0)) {
3157  return 0;
3158  }
3159 
3160  if ((!viewname) || (!viewname[0])) {
3161  return 0;
3162  }
3163 
3164  for (srv = static_cast<SceneRenderView *>(rd->views.first), nr = 0; srv; srv = srv->next) {
3166  if (STREQ(viewname, srv->name)) {
3167  return nr;
3168  }
3169 
3170  nr += 1;
3171  }
3172  }
3173 
3174  return 0;
3175 }
3176 
3178  const char *filepath,
3179  char *r_filepath)
3180 {
3181  BLI_strncpy(r_filepath, filepath, FILE_MAX);
3182  BLI_path_suffix(r_filepath, FILE_MAX, srv->suffix, "");
3183 }
3184 
3186  const char *filepath,
3187  const char *viewname,
3188  char *r_filepath)
3189 {
3190  SceneRenderView *srv;
3191  char suffix[FILE_MAX];
3192 
3193  srv = static_cast<SceneRenderView *>(
3194  BLI_findstring(&rd->views, viewname, offsetof(SceneRenderView, name)));
3195  if (srv) {
3196  BLI_strncpy(suffix, srv->suffix, sizeof(suffix));
3197  }
3198  else {
3199  BLI_strncpy(suffix, viewname, sizeof(suffix));
3200  }
3201 
3202  BLI_strncpy(r_filepath, filepath, FILE_MAX);
3203  BLI_path_suffix(r_filepath, FILE_MAX, suffix, "");
3204 }
3205 
3206 const char *BKE_scene_multiview_view_suffix_get(const RenderData *rd, const char *viewname)
3207 {
3208  SceneRenderView *srv;
3209 
3210  if ((viewname == nullptr) || (viewname[0] == '\0')) {
3211  return viewname;
3212  }
3213 
3214  srv = static_cast<SceneRenderView *>(
3215  BLI_findstring(&rd->views, viewname, offsetof(SceneRenderView, name)));
3216  if (srv) {
3217  return srv->suffix;
3218  }
3219 
3220  return viewname;
3221 }
3222 
3223 const char *BKE_scene_multiview_view_id_suffix_get(const RenderData *rd, const int view_id)
3224 {
3225  if ((rd->scemode & R_MULTIVIEW) == 0) {
3226  return "";
3227  }
3228 
3229  const char *viewname = BKE_scene_multiview_render_view_name_get(rd, view_id);
3230  return BKE_scene_multiview_view_suffix_get(rd, viewname);
3231 }
3232 
3234  const char *name,
3235  char *r_prefix,
3236  const char **r_ext)
3237 {
3238  const char *unused;
3239  const char delims[] = {'.', '\0'};
3240 
3241  r_prefix[0] = '\0';
3242 
3243  /* Split filename into base name and extension. */
3244  const size_t basename_len = BLI_str_rpartition(name, delims, r_ext, &unused);
3245  if (*r_ext == nullptr) {
3246  return;
3247  }
3248  BLI_assert(basename_len > 0);
3249 
3250  /* Split base name into prefix and known suffix. */
3253  const size_t suffix_len = strlen(srv->suffix);
3254  if (basename_len >= suffix_len &&
3255  STREQLEN(name + basename_len - suffix_len, srv->suffix, suffix_len)) {
3256  BLI_strncpy(r_prefix, name, basename_len - suffix_len + 1);
3257  break;
3258  }
3259  }
3260  }
3261 }
3262 
3264  const size_t width,
3265  const size_t height,
3266  size_t *r_width,
3267  size_t *r_height)
3268 {
3272  width,
3273  height,
3274  r_width,
3275  r_height);
3276  }
3277  else {
3278  *r_width = width;
3279  *r_height = height;
3280  }
3281 }
3282 
3284 {
3285  if (BKE_imtype_is_movie(rd->im_format.imtype) == false) {
3286  return 0;
3287  }
3288 
3289  if ((rd->scemode & R_MULTIVIEW) == 0) {
3290  return 1;
3291  }
3292 
3294  return 1;
3295  }
3296 
3297  /* R_IMF_VIEWS_INDIVIDUAL */
3299 }
3300 
3301 /* Manipulation of depsgraph storage. */
3302 
3303 /* This is a key which identifies depsgraph. */
3306  /* TODO(sergey): Need to include window somehow (same layer might be in a
3307  * different states in different windows).
3308  */
3309 };
3310 
3311 static unsigned int depsgraph_key_hash(const void *key_v)
3312 {
3313  const DepsgraphKey *key = static_cast<const DepsgraphKey *>(key_v);
3314  unsigned int hash = BLI_ghashutil_ptrhash(key->view_layer);
3315  /* TODO(sergey): Include hash from other fields in the key. */
3316  return hash;
3317 }
3318 
3319 static bool depsgraph_key_compare(const void *key_a_v, const void *key_b_v)
3320 {
3321  const DepsgraphKey *key_a = static_cast<const DepsgraphKey *>(key_a_v);
3322  const DepsgraphKey *key_b = static_cast<const DepsgraphKey *>(key_b_v);
3323  /* TODO(sergey): Compare rest of. */
3324  return !(key_a->view_layer == key_b->view_layer);
3325 }
3326 
3327 static void depsgraph_key_free(void *key_v)
3328 {
3329  DepsgraphKey *key = static_cast<DepsgraphKey *>(key_v);
3330  MEM_freeN(key);
3331 }
3332 
3333 static void depsgraph_key_value_free(void *value)
3334 {
3335  Depsgraph *depsgraph = static_cast<Depsgraph *>(value);
3337 }
3338 
3340 {
3342  depsgraph_key_hash, depsgraph_key_compare, "Scene Depsgraph Hash");
3343 }
3344 
3346 {
3347  if (scene->depsgraph_hash == nullptr) {
3349  }
3350 }
3351 
3353 {
3354  if (scene->depsgraph_hash == nullptr) {
3355  return;
3356  }
3358  scene->depsgraph_hash = nullptr;
3359 }
3360 
3362 {
3363  if (scene->depsgraph_hash != nullptr) {
3364  DepsgraphKey key = {view_layer};
3366  }
3367 }
3368 
3369 /* Query depsgraph for a specific contexts. */
3370 
3372  ViewLayer *view_layer,
3373  const bool allocate_ghash_entry)
3374 {
3375  /* bmain may be nullptr here! */
3376  BLI_assert(scene != nullptr);
3377  BLI_assert(view_layer != nullptr);
3379 
3380  /* Make sure hash itself exists. */
3381  if (allocate_ghash_entry) {
3383  }
3384  if (scene->depsgraph_hash == nullptr) {
3385  return nullptr;
3386  }
3387 
3388  DepsgraphKey key;
3389  key.view_layer = view_layer;
3390 
3391  Depsgraph **depsgraph_ptr;
3392  if (!allocate_ghash_entry) {
3393  depsgraph_ptr = (Depsgraph **)BLI_ghash_lookup_p(scene->depsgraph_hash, &key);
3394  return depsgraph_ptr;
3395  }
3396 
3397  DepsgraphKey **key_ptr;
3399  scene->depsgraph_hash, &key, (void ***)&key_ptr, (void ***)&depsgraph_ptr)) {
3400  return depsgraph_ptr;
3401  }
3402 
3403  /* Depsgraph was not found in the ghash, but the key still needs allocating. */
3404  *key_ptr = MEM_new<DepsgraphKey>(__func__);
3405  **key_ptr = key;
3406 
3407  *depsgraph_ptr = nullptr;
3408  return depsgraph_ptr;
3409 }
3410 
3412 {
3413  BLI_assert(bmain != nullptr);
3414 
3415  Depsgraph **depsgraph_ptr = scene_get_depsgraph_p(scene, view_layer, true);
3416  if (depsgraph_ptr == nullptr) {
3417  /* The scene has no depsgraph hash. */
3418  return nullptr;
3419  }
3420  if (*depsgraph_ptr != nullptr) {
3421  /* The depsgraph was found, no need to allocate. */
3422  return depsgraph_ptr;
3423  }
3424 
3425  /* Allocate a new depsgraph. scene_get_depsgraph_p() already ensured that the pointer is stored
3426  * in the scene's depsgraph hash. */
3427  *depsgraph_ptr = DEG_graph_new(bmain, scene, view_layer, DAG_EVAL_VIEWPORT);
3428 
3429  /* TODO(sergey): Would be cool to avoid string format print,
3430  * but is a bit tricky because we can't know in advance whether
3431  * we will ever enable debug messages for this depsgraph.
3432  */
3433  char name[1024];
3434  BLI_snprintf(name, sizeof(name), "%s :: %s", scene->id.name, view_layer->name);
3435  DEG_debug_name_set(*depsgraph_ptr, name);
3436 
3437  /* These viewport depsgraphs communicate changes to the editors. */
3438  DEG_enable_editors_update(*depsgraph_ptr);
3439 
3440  return depsgraph_ptr;
3441 }
3442 
3444 {
3446 
3447  if (scene->depsgraph_hash == nullptr) {
3448  return nullptr;
3449  }
3450 
3451  DepsgraphKey key;
3452  key.view_layer = view_layer;
3453  return static_cast<Depsgraph *>(BLI_ghash_lookup(scene->depsgraph_hash, &key));
3454 }
3455 
3457 {
3458  Depsgraph **depsgraph_ptr = scene_ensure_depsgraph_p(bmain, scene, view_layer);
3459  return (depsgraph_ptr != nullptr) ? *depsgraph_ptr : nullptr;
3460 }
3461 
3462 static char *scene_undo_depsgraph_gen_key(Scene *scene, ViewLayer *view_layer, char *key_full)
3463 {
3464  if (key_full == nullptr) {
3465  key_full = static_cast<char *>(MEM_callocN(MAX_ID_NAME + FILE_MAX + MAX_NAME, __func__));
3466  }
3467 
3468  size_t key_full_offset = BLI_strncpy_rlen(key_full, scene->id.name, MAX_ID_NAME);
3469  if (ID_IS_LINKED(scene)) {
3470  key_full_offset += BLI_strncpy_rlen(
3471  key_full + key_full_offset, scene->id.lib->filepath, FILE_MAX);
3472  }
3473  key_full_offset += BLI_strncpy_rlen(key_full + key_full_offset, view_layer->name, MAX_NAME);
3474  BLI_assert(key_full_offset < MAX_ID_NAME + FILE_MAX + MAX_NAME);
3475 
3476  return key_full;
3477 }
3478 
3480 {
3481  GHash *depsgraph_extract = BLI_ghash_new(
3483 
3484  LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
3485  if (scene->depsgraph_hash == nullptr) {
3486  /* In some cases, e.g. when undo has to perform multiple steps at once, no depsgraph will
3487  * be built so this pointer may be nullptr. */
3488  continue;
3489  }
3490  LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
3491  DepsgraphKey key;
3492  key.view_layer = view_layer;
3494 
3495  if (depsgraph != nullptr && *depsgraph != nullptr) {
3496  char *key_full = scene_undo_depsgraph_gen_key(scene, view_layer, nullptr);
3497 
3498  /* We steal the depsgraph from the scene. */
3499  BLI_ghash_insert(depsgraph_extract, key_full, *depsgraph);
3500  *depsgraph = nullptr;
3501  }
3502  }
3503  }
3504 
3505  return depsgraph_extract;
3506 }
3507 
3508 void BKE_scene_undo_depsgraphs_restore(Main *bmain, GHash *depsgraph_extract)
3509 {
3510  LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
3511  LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
3512  char key_full[MAX_ID_NAME + FILE_MAX + MAX_NAME] = {0};
3513  scene_undo_depsgraph_gen_key(scene, view_layer, key_full);
3514 
3515  Depsgraph **depsgraph_extract_ptr = (Depsgraph **)BLI_ghash_lookup_p(depsgraph_extract,
3516  key_full);
3517  if (depsgraph_extract_ptr == nullptr) {
3518  continue;
3519  }
3520  BLI_assert(*depsgraph_extract_ptr != nullptr);
3521 
3522  Depsgraph **depsgraph_scene_ptr = scene_get_depsgraph_p(scene, view_layer, true);
3523  BLI_assert(depsgraph_scene_ptr != nullptr);
3524  BLI_assert(*depsgraph_scene_ptr == nullptr);
3525 
3526  /* We steal the depsgraph back from our 'extract' storage to the scene. */
3527  Depsgraph *depsgraph = *depsgraph_extract_ptr;
3528 
3529  DEG_graph_replace_owners(depsgraph, bmain, scene, view_layer);
3530 
3532 
3533  *depsgraph_scene_ptr = depsgraph;
3534  *depsgraph_extract_ptr = nullptr;
3535  }
3536  }
3537 
3538  BLI_ghash_free(depsgraph_extract, MEM_freeN, depsgraph_key_value_free);
3539 }
3540 
3541 /* -------------------------------------------------------------------- */
3546 {
3547  const int orientation_index = BKE_scene_transform_orientation_get_index(scene, orientation);
3548 
3549  for (int i = 0; i < ARRAY_SIZE(scene->orientation_slots); i++) {
3550  TransformOrientationSlot *orient_slot = &scene->orientation_slots[i];
3551  if (orient_slot->index_custom == orientation_index) {
3552  /* could also use orientation_index-- */
3553  orient_slot->type = V3D_ORIENT_GLOBAL;
3554  orient_slot->index_custom = -1;
3555  }
3556  else if (orient_slot->index_custom > orientation_index) {
3557  BLI_assert(orient_slot->type == V3D_ORIENT_CUSTOM);
3558  orient_slot->index_custom--;
3559  }
3560  }
3561 
3562  BLI_freelinkN(&scene->transform_spaces, orientation);
3563 }
3564 
3566 {
3567  return static_cast<TransformOrientation *>(BLI_findlink(&scene->transform_spaces, index));
3568 }
3569 
3571  const TransformOrientation *orientation)
3572 {
3573  return BLI_findindex(&scene->transform_spaces, orientation);
3574 }
3575 
3578 /* -------------------------------------------------------------------- */
3584 void BKE_scene_cursor_rot_to_mat3(const View3DCursor *cursor, float mat[3][3])
3585 {
3586  if (cursor->rotation_mode > 0) {
3587  eulO_to_mat3(mat, cursor->rotation_euler, cursor->rotation_mode);
3588  }
3589  else if (cursor->rotation_mode == ROT_MODE_AXISANGLE) {
3590  axis_angle_to_mat3(mat, cursor->rotation_axis, cursor->rotation_angle);
3591  }
3592  else {
3593  float tquat[4];
3594  normalize_qt_qt(tquat, cursor->rotation_quaternion);
3595  quat_to_mat3(mat, tquat);
3596  }
3597 }
3598 
3599 void BKE_scene_cursor_rot_to_quat(const View3DCursor *cursor, float quat[4])
3600 {
3601  if (cursor->rotation_mode > 0) {
3602  eulO_to_quat(quat, cursor->rotation_euler, cursor->rotation_mode);
3603  }
3604  else if (cursor->rotation_mode == ROT_MODE_AXISANGLE) {
3605  axis_angle_to_quat(quat, cursor->rotation_axis, cursor->rotation_angle);
3606  }
3607  else {
3608  normalize_qt_qt(quat, cursor->rotation_quaternion);
3609  }
3610 }
3611 
3612 void BKE_scene_cursor_mat3_to_rot(View3DCursor *cursor, const float mat[3][3], bool use_compat)
3613 {
3614  BLI_ASSERT_UNIT_M3(mat);
3615 
3616  switch (cursor->rotation_mode) {
3617  case ROT_MODE_QUAT: {
3618  float quat[4];
3619  mat3_normalized_to_quat(quat, mat);
3620  if (use_compat) {
3621  float quat_orig[4];
3622  copy_v4_v4(quat_orig, cursor->rotation_quaternion);
3623  quat_to_compatible_quat(cursor->rotation_quaternion, quat, quat_orig);
3624  }
3625  else {
3626  copy_v4_v4(cursor->rotation_quaternion, quat);
3627  }
3628  break;
3629  }
3630  case ROT_MODE_AXISANGLE: {
3631  mat3_to_axis_angle(cursor->rotation_axis, &cursor->rotation_angle, mat);
3632  break;
3633  }
3634  default: {
3635  if (use_compat) {
3637  cursor->rotation_euler, cursor->rotation_euler, cursor->rotation_mode, mat);
3638  }
3639  else {
3640  mat3_to_eulO(cursor->rotation_euler, cursor->rotation_mode, mat);
3641  }
3642  break;
3643  }
3644  }
3645 }
3646 
3647 void BKE_scene_cursor_quat_to_rot(View3DCursor *cursor, const float quat[4], bool use_compat)
3648 {
3649  BLI_ASSERT_UNIT_QUAT(quat);
3650 
3651  switch (cursor->rotation_mode) {
3652  case ROT_MODE_QUAT: {
3653  if (use_compat) {
3654  float quat_orig[4];
3655  copy_v4_v4(quat_orig, cursor->rotation_quaternion);
3656  quat_to_compatible_quat(cursor->rotation_quaternion, quat, quat_orig);
3657  }
3658  else {
3659  copy_qt_qt(cursor->rotation_quaternion, quat);
3660  }
3661  break;
3662  }
3663  case ROT_MODE_AXISANGLE: {
3664  quat_to_axis_angle(cursor->rotation_axis, &cursor->rotation_angle, quat);
3665  break;
3666  }
3667  default: {
3668  if (use_compat) {
3670  cursor->rotation_euler, cursor->rotation_euler, cursor->rotation_mode, quat);
3671  }
3672  else {
3673  quat_to_eulO(cursor->rotation_euler, cursor->rotation_mode, quat);
3674  }
3675  break;
3676  }
3677  }
3678 }
3679 
3680 void BKE_scene_cursor_to_mat4(const View3DCursor *cursor, float mat[4][4])
3681 {
3682  float mat3[3][3];
3683  BKE_scene_cursor_rot_to_mat3(cursor, mat3);
3684  copy_m4_m3(mat, mat3);
3685  copy_v3_v3(mat[3], cursor->location);
3686 }
3687 
3688 void BKE_scene_cursor_from_mat4(View3DCursor *cursor, const float mat[4][4], bool use_compat)
3689 {
3690  float mat3[3][3];
3691  copy_m3_m4(mat3, mat);
3692  BKE_scene_cursor_mat3_to_rot(cursor, mat3, use_compat);
3693  copy_v3_v3(cursor->location, mat[3]);
3694 }
3695 
typedef float(TangentPoint)[2]
Blender kernel action and pose functionality.
void action_groups_remove_channel(struct bAction *act, struct FCurve *fcu)
Definition: action.c:542
void BKE_animdata_duplicate_id_action(struct Main *bmain, struct ID *id, uint duplicate_flags)
void BKE_animdata_blend_read_data(struct BlendDataReader *reader, struct AnimData *adt)
Definition: anim_data.c:1443
void BKE_animdata_blend_write(struct BlendWriter *writer, struct AnimData *adt)
Definition: anim_data.c:1421
struct AnimData * BKE_animdata_from_id(const struct ID *id)
void BKE_keyingsets_free(struct ListBase *list)
Definition: anim_sys.c:282
void BKE_keyingsets_copy(struct ListBase *newlist, const struct ListBase *list)
void BKE_keyingsets_blend_read_lib(struct BlendLibReader *reader, struct ID *id, struct ListBase *list)
Definition: anim_sys.c:332
void BKE_keyingsets_blend_read_data(struct BlendDataReader *reader, struct ListBase *list)
Definition: anim_sys.c:319
void BKE_keyingsets_blend_write(struct BlendWriter *writer, struct ListBase *list)
Definition: anim_sys.c:301
void BKE_keyingsets_foreach_id(struct LibraryForeachIDData *data, const struct ListBase *keyingsets)
void BKE_keyingsets_blend_read_expand(struct BlendExpander *expander, struct ListBase *list)
Definition: anim_sys.c:341
bool BKE_bpath_foreach_path_fixed_process(struct BPathForeachPathData *bpath_data, char *path)
Definition: bpath.c:121
@ BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE
Definition: BKE_bpath.h:55
bool BKE_bpath_foreach_path_dirfile_fixed_process(struct BPathForeachPathData *bpath_data, char *path_dir, char *path_file)
Definition: bpath.c:149
void BKE_callback_exec_id_depsgraph(struct Main *bmain, struct ID *id, struct Depsgraph *depsgraph, eCbEvent evt)
Definition: callbacks.c:56
@ BKE_CB_EVT_DEPSGRAPH_UPDATE_PRE
Definition: BKE_callbacks.h:92
@ BKE_CB_EVT_FRAME_CHANGE_PRE
Definition: BKE_callbacks.h:75
@ BKE_CB_EVT_FRAME_CHANGE_POST
Definition: BKE_callbacks.h:76
@ BKE_CB_EVT_DEPSGRAPH_UPDATE_POST
Definition: BKE_callbacks.h:93
void BKE_callback_exec_id(struct Main *bmain, struct ID *id, eCbEvent evt)
Definition: callbacks.c:46
struct Collection * BKE_collection_duplicate(struct Main *bmain, struct Collection *parent, struct Collection *collection, uint duplicate_flags, uint duplicate_options)
void BKE_collection_compat_blend_read_lib(struct BlendLibReader *reader, struct Library *lib, struct SceneCollection *sc)
void BKE_collection_compat_blend_read_expand(struct BlendExpander *expander, struct SceneCollection *sc)
void BKE_collection_free_data(struct Collection *collection)
Definition: collection.c:489
void BKE_collection_compat_blend_read_data(struct BlendDataReader *reader, struct SceneCollection *sc)
struct Collection * BKE_collection_master_add(void)
Definition: collection.c:852
void BKE_collection_blend_write_nolib(struct BlendWriter *writer, struct Collection *collection)
Definition: collection.c:190
void BKE_color_managed_display_settings_copy(struct ColorManagedDisplaySettings *new_settings, const struct ColorManagedDisplaySettings *settings)
void BKE_color_managed_colorspace_settings_copy(struct ColorManagedColorspaceSettings *colorspace_settings, const struct ColorManagedColorspaceSettings *settings)
void BKE_curvemapping_free_data(struct CurveMapping *cumap)
Definition: colortools.c:83
void BKE_curvemapping_init(struct CurveMapping *cumap)
Definition: colortools.c:1235
void BKE_curvemapping_set_defaults(struct CurveMapping *cumap, int tot, float minx, float miny, float maxx, float maxy)
Definition: colortools.c:37
struct CurveMapping * BKE_curvemapping_copy(const struct CurveMapping *cumap)
void BKE_color_managed_view_settings_blend_read_data(struct BlendDataReader *reader, struct ColorManagedViewSettings *settings)
Definition: colortools.c:1872
void BKE_curvemapping_blend_read(struct BlendDataReader *reader, struct CurveMapping *cumap)
Definition: colortools.c:1300
void BKE_curvemapping_curves_blend_write(struct BlendWriter *writer, const struct CurveMapping *cumap)
void BKE_color_managed_view_settings_free(struct ColorManagedViewSettings *settings)
Definition: colortools.c:1856
void BKE_curvemap_reset(struct CurveMap *cuma, const struct rctf *clipr, int preset, int slope)
void BKE_color_managed_view_settings_blend_write(struct BlendWriter *writer, struct ColorManagedViewSettings *settings)
Definition: colortools.c:1864
void BKE_color_managed_view_settings_copy(struct ColorManagedViewSettings *new_settings, const struct ColorManagedViewSettings *settings)
void BKE_curvemapping_blend_write(struct BlendWriter *writer, const struct CurveMapping *cumap)
void BKE_color_managed_view_settings_init_render(struct ColorManagedViewSettings *settings, const struct ColorManagedDisplaySettings *display_settings, const char *view_transform)
void BKE_color_managed_display_settings_init(struct ColorManagedDisplaySettings *settings)
Definition: colortools.c:1789
void BKE_curvemapping_free(struct CurveMapping *cumap)
Definition: colortools.c:103
@ CURVEMAP_SLOPE_POS_NEG
@ CURVEMAP_SLOPE_POSITIVE
void BKE_curvemapping_copy_data(struct CurveMapping *target, const struct CurveMapping *cumap)
struct CurveMapping * BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy)
Definition: colortools.c:72
void BKE_curveprofile_blend_read(struct BlendDataReader *reader, struct CurveProfile *profile)
Definition: curveprofile.cc:88
struct CurveProfile * BKE_curveprofile_copy(const struct CurveProfile *profile)
void BKE_curveprofile_blend_write(struct BlendWriter *writer, const struct CurveProfile *profile)
Definition: curveprofile.cc:82
struct CurveProfile * BKE_curveprofile_add(eCurveProfilePresets preset)
Definition: curveprofile.cc:31
void BKE_curveprofile_free(struct CurveProfile *profile)
Definition: curveprofile.cc:50
struct ListBase * object_duplilist(struct Depsgraph *depsgraph, struct Scene *sce, struct Object *ob)
void free_object_duplilist(struct ListBase *lb)
struct EffectorWeights * BKE_effector_add_weights(struct Collection *collection)
Definition: effect.c:58
void BKE_fcurve_free(struct FCurve *fcu)
Definition: fcurve.c:65
void BKE_previewimg_free(struct PreviewImage **prv)
Definition: icons.cc:283
void BKE_previewimg_id_copy(struct ID *new_id, const struct ID *old_id)
void BKE_previewimg_blend_read(struct BlendDataReader *reader, struct PreviewImage *prv)
Definition: icons.cc:615
void BKE_previewimg_blend_write(struct BlendWriter *writer, const struct PreviewImage *prv)
void IDP_BlendReadExpand(struct BlendExpander *expander, struct IDProperty *prop)
Definition: idprop.c:1471
struct IDProperty * IDP_CopyProperty_ex(const struct IDProperty *prop, int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void IDP_BlendWrite(struct BlendWriter *writer, const struct IDProperty *prop)
void IDP_foreach_property(struct IDProperty *id_property_root, int type_filter, IDPForeachPropertyCallback callback, void *user_data)
Definition: idprop.c:1117
#define IDP_BlendDataRead(reader, prop)
Definition: BKE_idprop.h:321
void IDP_FreeProperty(struct IDProperty *prop)
Definition: idprop.c:1093
void IDP_FreePropertyContent_ex(struct IDProperty *prop, bool do_id_user)
Definition: idprop.c:1055
void IDP_BlendReadLib(struct BlendLibReader *reader, struct Library *lib, struct IDProperty *prop)
Definition: idprop.c:1435
struct IDProperty * IDP_CopyProperty(const struct IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
@ IDTYPE_CACHE_CB_FLAGS_PERSISTENT
Definition: BKE_idtype.h:75
void(* IDTypeForeachCacheFunctionCallback)(struct ID *id, const struct IDCacheKey *cache_key, void **cache_p, uint flags, void *user_data)
Definition: BKE_idtype.h:77
void BKE_image_editors_update_frame(const struct Main *bmain, int cfra)
void BKE_image_format_free(struct ImageFormatData *imf)
Definition: image_format.cc:52
void BKE_image_format_blend_read_data(struct BlendDataReader *reader, struct ImageFormatData *imf)
Definition: image_format.cc:57
void BKE_image_format_copy(struct ImageFormatData *imf_dst, const struct ImageFormatData *imf_src)
void BKE_image_format_init(struct ImageFormatData *imf, const bool render)
Definition: image_format.cc:26
bool BKE_imtype_is_movie(char imtype)
void BKE_image_format_blend_write(struct BlendWriter *writer, struct ImageFormatData *imf)
Definition: image_format.cc:62
void BKE_main_collection_sync(const struct Main *bmain)
bool BKE_view_layer_has_collection(const struct ViewLayer *view_layer, const struct Collection *collection)
@ VIEWLAYER_ADD_NEW
Definition: BKE_layer.h:37
void BKE_view_layer_free_ex(struct ViewLayer *view_layer, bool do_id_user)
Definition: layer.c:244
void BKE_view_layer_blend_read_data(struct BlendDataReader *reader, struct ViewLayer *view_layer)
Definition: layer.c:2315
struct ViewLayer * BKE_view_layer_context_active_PLACEHOLDER(const struct Scene *scene)
struct ViewLayer * BKE_view_layer_default_render(const struct Scene *scene)
void BKE_view_layer_copy_data(struct Scene *scene_dst, const struct Scene *scene_src, struct ViewLayer *view_layer_dst, const struct ViewLayer *view_layer_src, int flag)
struct ViewLayer * BKE_view_layer_add(struct Scene *scene, const char *name, struct ViewLayer *view_layer_source, int type)
Definition: layer.c:185
void BKE_view_layer_blend_read_lib(struct BlendLibReader *reader, struct Library *lib, struct ViewLayer *view_layer)
Definition: layer.c:2357
void BKE_view_layer_blend_write(struct BlendWriter *writer, struct ViewLayer *view_layer)
Definition: layer.c:2273
struct ID * BKE_id_copy(struct Main *bmain, const struct ID *id)
@ LIB_ID_CREATE_NO_ALLOCATE
Definition: BKE_lib_id.h:130
@ LIB_ID_COPY_NO_PREVIEW
Definition: BKE_lib_id.h:150
@ LIB_ID_CREATE_NO_USER_REFCOUNT
Definition: BKE_lib_id.h:126
@ LIB_ID_COPY_DEFAULT
Definition: BKE_lib_id.h:181
void BKE_main_id_newptr_and_tag_clear(struct Main *bmain)
Definition: lib_id.c:1465
struct ID * BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, int flag)
void id_us_min(struct ID *id)
Definition: lib_id.c:313
void BKE_libblock_free_data_py(struct ID *id)
void id_us_ensure_real(struct ID *id)
Definition: lib_id.c:260
void BKE_id_blend_write(struct BlendWriter *writer, struct ID *id)
Definition: lib_id.c:2008
void id_us_plus_no_lib(struct ID *id)
Definition: lib_id.c:289
void * BKE_id_new(struct Main *bmain, short type, const char *name)
Definition: lib_id.c:1159
struct ID * BKE_id_copy_for_duplicate(struct Main *bmain, struct ID *id, uint duplicate_flags, int copy_flags)
@ LIB_ID_DUPLICATE_IS_SUBPROCESS
Definition: BKE_lib_id.h:225
struct ID * BKE_libblock_find_name(struct Main *bmain, short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: lib_id.c:1297
void BKE_lib_query_foreachid_process(struct LibraryForeachIDData *data, struct ID **id_pp, int cb_flag)
Definition: lib_query.c:68
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(_data, _id_super, _cb_flag)
#define BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(_data, _func_call)
void BKE_library_foreach_ID_embedded(struct LibraryForeachIDData *data, struct ID **id_pp)
Definition: lib_query.c:147
void BKE_lib_query_idpropertiesForeachIDLink_callback(struct IDProperty *id_prop, void *user_data)
Definition: lib_query.c:136
@ IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE
Definition: BKE_lib_query.h:60
@ IDWALK_CB_NEVER_SELF
Definition: BKE_lib_query.h:35
@ IDWALK_CB_USER
Definition: BKE_lib_query.h:73
@ IDWALK_CB_EMBEDDED
Definition: BKE_lib_query.h:48
@ IDWALK_CB_NOP
Definition: BKE_lib_query.h:33
@ ID_REMAP_SKIP_USER_CLEAR
Definition: BKE_lib_remap.h:63
@ ID_REMAP_SKIP_NEVER_NULL_USAGE
Definition: BKE_lib_remap.h:45
void BKE_libblock_relink_to_newid(struct Main *bmain, struct ID *id, int remap_flag) ATTR_NONNULL()
Definition: lib_remap.c:894
void BKE_libblock_relink_ex(struct Main *bmain, void *idv, void *old_idv, void *new_idv, short remap_flags) ATTR_NONNULL(1
Blender kernel freestyle line style functionality.
#define FOREACH_MAIN_ID_END
Definition: BKE_main.h:367
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
Definition: BKE_main.h:361
void ntreeBlendWrite(struct BlendWriter *writer, struct bNodeTree *ntree)
Definition: node.cc:519
#define CMP_NODE_CRYPTOMATTE
Definition: BKE_node.h:1292
void ntreeFreeEmbeddedTree(struct bNodeTree *ntree)
Definition: node.cc:3112
#define CMP_CRYPTOMATTE_SRC_RENDER
Definition: BKE_node.h:1331
#define CMP_NODE_R_LAYERS
Definition: BKE_node.h:1216
General operations, lookup, etc. for blender objects.
void BKE_paint_blend_write(struct BlendWriter *writer, struct Paint *paint)
Definition: paint.c:1196
void BKE_paint_copy(struct Paint *src, struct Paint *tar, int flag)
Definition: paint.c:1167
void BKE_paint_free(struct Paint *p)
Definition: paint.c:1161
void BKE_paint_blend_read_lib(struct BlendLibReader *reader, struct Scene *scene, struct Paint *paint)
Definition: paint.c:1230
void BKE_paint_blend_read_data(struct BlendDataReader *reader, const struct Scene *scene, struct Paint *paint)
void BKE_ptcache_id_from_rigidbody(PTCacheID *pid, struct Object *ob, struct RigidBodyWorld *rbw)
Definition: pointcache.c:1054
void BKE_ptcache_blend_read_data(struct BlendDataReader *reader, struct ListBase *ptcaches, struct PointCache **ocache, int force_disk)
Definition: pointcache.c:3896
void BKE_ptcache_blend_write(struct BlendWriter *writer, struct ListBase *ptcaches)
Definition: pointcache.c:3820
API for Blender-side Rigid Body stuff.
void BKE_rigidbody_remove_constraint(struct Main *bmain, struct Scene *scene, struct Object *ob, bool free_us)
Definition: rigidbody.c:2342
void BKE_rigidbody_remove_object(struct Main *bmain, struct Scene *scene, struct Object *ob, bool free_us)
Definition: rigidbody.c:2339
void BKE_rigidbody_free_world(struct Scene *scene)
Definition: rigidbody.c:90
void BKE_rigidbody_world_id_loop(struct RigidBodyWorld *rbw, RigidbodyWorldIDFunc func, void *userdata)
Definition: rigidbody.c:2311
void BKE_rigidbody_world_groups_relink(struct RigidBodyWorld *rbw)
Definition: rigidbody.c:2308
struct RigidBodyWorld * BKE_rigidbody_world_copy(struct RigidBodyWorld *rbw, int flag)
Definition: rigidbody.c:2304
eSceneCopyMethod
Definition: BKE_scene.h:28
@ SCE_COPY_EMPTY
Definition: BKE_scene.h:30
@ SCE_COPY_FULL
Definition: BKE_scene.h:32
void BKE_screen_view3d_shading_blend_read_data(struct BlendDataReader *reader, struct View3DShading *shading)
Definition: screen.c:1078
void BKE_screen_view3d_shading_blend_write(struct BlendWriter *writer, struct View3DShading *shading)
Definition: screen.c:1071
void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene)
void BKE_sound_set_scene_volume(struct Scene *scene, float volume)
void BKE_sound_mute_scene(struct Scene *scene, int muted)
void BKE_sound_ensure_scene(struct Scene *scene)
void BKE_sound_reset_scene_runtime(struct Scene *scene)
void BKE_sound_set_cfra(int cfra)
void BKE_sound_update_scene_listener(struct Scene *scene)
void BKE_sound_destroy_scene(struct Scene *scene)
void BKE_sound_update_scene(struct Depsgraph *depsgraph, struct Scene *scene)
void BKE_sound_update_fps(struct Main *bmain, struct Scene *scene)
int BKE_unit_base_of_type_get(int system, int type)
Definition: unit.c:1269
@ B_UNIT_AREA
Definition: BKE_unit.h:102
@ B_UNIT_VOLUME
Definition: BKE_unit.h:103
@ B_UNIT_LENGTH
Definition: BKE_unit.h:101
@ B_UNIT_TEMPERATURE
Definition: BKE_unit.h:112
@ B_UNIT_CAMERA
Definition: BKE_unit.h:110
@ B_UNIT_ACCELERATION
Definition: BKE_unit.h:109
@ B_UNIT_MASS
Definition: BKE_unit.h:104
@ B_UNIT_POWER
Definition: BKE_unit.h:111
@ B_UNIT_TIME
Definition: BKE_unit.h:106
@ B_UNIT_VELOCITY
Definition: BKE_unit.h:108
struct bScreen * BKE_workspace_active_screen_get(const struct WorkSpaceInstanceHook *hook) GETTER_ATTRS
#define BLI_assert(a)
Definition: BLI_assert.h:46
bool BLI_ghashutil_strcmp(const void *a, const void *b)
unsigned int BLI_ghashutil_ptrhash(const void *key)
unsigned int BLI_ghashutil_strhash_p(const void *ptr)
GHash * BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:689
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:734
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:790
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition: BLI_ghash.c:710
void ** BLI_ghash_lookup_p(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:748
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:863
bool BLI_ghash_ensure_p_ex(GHash *gh, const void *key, void ***r_key, void ***r_val) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:771
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:239
void void void void void BLI_duplicatelist(struct ListBase *dst, const struct ListBase *src) ATTR_NONNULL(1
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
Definition: BLI_listbase.h:354
#define LISTBASE_FOREACH_BACKWARD(type, var, list)
Definition: BLI_listbase.h:348
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:466
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:100
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findptr(const struct ListBase *listbase, const void *ptr, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
#define BLI_ASSERT_UNIT_M3(m)
MINLINE int mod_i(int i, int n)
#define BLI_ASSERT_UNIT_QUAT(q)
MINLINE int round_db_to_int(double a)
void copy_m3_m4(float m1[3][3], const float m2[4][4])
Definition: math_matrix.c:87
void copy_m4_m3(float m1[4][4], const float m2[3][3])
Definition: math_matrix.c:102
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:77
void eulO_to_mat3(float mat[3][3], const float eul[3], short order)
void axis_angle_to_quat(float r[4], const float axis[3], float angle)
void mat3_to_eulO(float eul[3], short order, const float mat[3][3])
void mat3_to_compatible_eulO(float eul[3], const float old[3], short order, const float mat[3][3])
float normalize_qt_qt(float r[4], const float q[4])
void quat_to_compatible_eulO(float eul[3], const float old[3], short order, const float quat[4])
void quat_to_eulO(float eul[3], short order, const float quat[4])
void mat3_to_axis_angle(float axis[3], float *angle, const float M[3][3])
void quat_to_axis_angle(float axis[3], float *angle, const float q[4])
void eulO_to_quat(float quat[4], const float eul[3], short order)
void copy_qt_qt(float q[4], const float a[4])
Definition: math_rotation.c:33
void quat_to_compatible_quat(float q[4], const float a[4], const float old[4])
void quat_to_mat3(float mat[3][3], const float q[4])
void axis_angle_to_mat3(float R[3][3], const float axis[3], float angle)
void mat3_normalized_to_quat(float q[4], const float mat[3][3])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v3(float r[3])
#define FILE_MAX
bool BLI_path_suffix(char *string, size_t maxlen, const char *suffix, const char *sep) ATTR_NONNULL()
Definition: path_util.c:588
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition: BLI_rect.h:194
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition: BLI_rect.h:198
#define STR_ELEM(...)
Definition: BLI_string.h:539
size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:120
size_t BLI_str_rpartition(const char *str, const char delim[], const char **sep, const char **suf) ATTR_NONNULL()
Definition: string.c:994
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
bool BLI_uniquename(struct ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t name_len)
Definition: string_utils.c:309
unsigned char uchar
Definition: BLI_sys_types.h:70
unsigned int uint
Definition: BLI_sys_types.h:67
int BLI_system_thread_count(void)
Definition: threads.cc:281
int BLI_system_num_threads_override_get(void)
Definition: threads.cc:322
#define ARRAY_SIZE(arr)
#define SWAP(type, a, b)
#define STREQLEN(a, b, n)
#define UNUSED(x)
#define ELEM(...)
#define MIN2(a, b)
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define POINTER_OFFSET(v, ofs)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define STREQ(a, b)
#define BLO_read_data_address(reader, ptr_p)
ID * BLO_read_get_new_id_address(BlendLibReader *reader, struct Library *lib, struct ID *id)
Definition: readfile.c:5138
struct BlendFileReadReport * BLO_read_lib_reports(BlendLibReader *reader)
Definition: readfile.c:5318
bool BLO_read_data_is_undo(BlendDataReader *reader)
Definition: readfile.c:5288
#define BLO_write_id_struct(writer, struct_name, id_address, id)
#define BLO_write_struct(writer, struct_name, data_ptr)
void BLO_read_list(BlendDataReader *reader, struct ListBase *list)
Definition: readfile.c:5172
void BLO_read_glob_list(BlendDataReader *reader, struct ListBase *list)
Definition: readfile.c:5298
void * BLO_read_get_new_data_address(BlendDataReader *reader, const void *old_address)
Definition: readfile.c:5123
#define BLO_read_id_address(reader, lib, id_ptr_p)
#define BLO_expand(expander, id)
void BLO_write_raw(BlendWriter *writer, size_t size_in_bytes, const void *data_ptr)
Definition: writefile.c:1489
struct BlendFileReadReport * BLO_read_data_reports(BlendDataReader *reader)
Definition: readfile.c:5303
void BLO_reportf_wrap(struct BlendFileReadReport *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
bool BLO_write_is_undo(BlendWriter *writer)
Definition: writefile.c:1608
external readfile function prototypes.
#define TIP_(msgid)
#define BLT_I18NCONTEXT_ID_SCENE
#define DATA_(msgid)
typedef double(DMatrix)[4][4]
void DEG_evaluate_on_refresh(Depsgraph *graph)
Depsgraph * DEG_graph_new(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, eEvaluationMode mode)
Definition: depsgraph.cc:267
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
void DEG_editors_update(struct Depsgraph *depsgraph, bool time)
void DEG_enable_editors_update(struct Depsgraph *depsgraph)
void DEG_ids_clear_recalc(Depsgraph *depsgraph, bool backup)
void DEG_make_active(struct Depsgraph *depsgraph)
Definition: depsgraph.cc:325
@ DAG_EVAL_VIEWPORT
Definition: DEG_depsgraph.h:45
void DEG_graph_replace_owners(struct Depsgraph *depsgraph, struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer)
Definition: depsgraph.cc:274
void DEG_graph_free(Depsgraph *graph)
Definition: depsgraph.cc:295
void DEG_evaluate_on_framechange(Depsgraph *graph, float frame)
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_ids_restore_recalc(Depsgraph *depsgraph)
void DEG_graph_tag_relations_update(struct Depsgraph *graph)
void DEG_graph_relations_update(struct Depsgraph *graph)
void DEG_debug_name_set(struct Depsgraph *depsgraph, const char *name)
struct Scene * DEG_get_input_scene(const Depsgraph *graph)
bool DEG_is_fully_evaluated(const struct Depsgraph *depsgraph)
bool DEG_id_type_any_updated(const struct Depsgraph *depsgraph)
struct ViewLayer * DEG_get_evaluated_view_layer(const struct Depsgraph *graph)
bool DEG_is_evaluated_id(const struct ID *id)
struct Main * DEG_get_bmain(const Depsgraph *graph)
struct ViewLayer * DEG_get_input_view_layer(const Depsgraph *graph)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
@ IDP_TYPE_FILTER_ID
Definition: DNA_ID.h:155
@ ID_RECALC_AUDIO_FPS
Definition: DNA_ID.h:843
@ ID_RECALC_AUDIO_LISTENER
Definition: DNA_ID.h:846
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:834
@ ID_RECALC_FRAME_CHANGE
Definition: DNA_ID.h:841
@ ID_RECALC_AUDIO_MUTE
Definition: DNA_ID.h:845
@ ID_RECALC_ALL
Definition: DNA_ID.h:891
@ ID_RECALC_AUDIO_VOLUME
Definition: DNA_ID.h:844
@ INDEX_ID_SCE
Definition: DNA_ID.h:1049
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:566
#define MAX_ID_NAME
Definition: DNA_ID.h:337
@ LIB_TAG_NEW
Definition: DNA_ID.h:704
@ LIB_EMBEDDED_DATA
Definition: DNA_ID.h:635
#define FILTER_ID_SCE
Definition: DNA_ID.h:919
@ ID_SCE
Definition: DNA_ID_enums.h:45
@ ROT_MODE_QUAT
@ ROT_MODE_AXISANGLE
Object groups, one object can be in many groups at once.
@ CURVE_PRESET_GAUSS
@ CURVE_PRESET_BELL
@ CURVE_PRESET_MAX
@ PROF_PRESET_LINE
#define DNA_struct_default_get(struct_name)
Definition: DNA_defaults.h:29
#define DNA_struct_default_alloc(struct_name)
Definition: DNA_defaults.h:32
#define MAX_NAME
Definition: DNA_defs.h:48
@ OB_RENDER
Object is a sort of wrapper for general info.
@ OB_HIDE_RENDER
@ OB_MESH
@ OB_DUPLI
#define OB_FROMDUPLI
@ PTCACHE_FLAG_INFO_DIRTY
Types and defines for representing Rigid Body entities.
@ RBW_FLAG_MUTED
#define OBEDIT_FROM_VIEW_LAYER(view_layer)
#define SCE_READFILE_LIBLINK_NEED_SETSCENE_CHECK
#define USER_UNIT_METRIC
#define STEREO_LEFT_NAME
#define R_BORDER
#define R_MULTIVIEW
#define R_NO_CAMERA_SWITCH
#define R_CROP
#define USER_UNIT_NONE
struct Scene Scene
#define F_START
#define PE_BRUSH_CUT
@ S3D_SQUEEZED_FRAME
@ SCE_ORIENT_DEFAULT
@ SCE_ORIENT_ROTATE
@ SCE_ORIENT_TRANSLATE
@ SCE_ORIENT_SCALE
#define R_FIXED_THREADS
#define F_SCENE
#define STEREO_LEFT_SUFFIX
#define STEREO_RIGHT_NAME
#define STEREO_RIGHT_SUFFIX
#define AUDIO_MUTE
#define FPS
@ R_IMF_VIEWS_STEREO_3D
#define R_SIMPLIFY
#define F_DUPLI
#define SCE_VIEW_DISABLE
@ SCE_VIEWS_FORMAT_STEREO_3D
@ SCE_VIEWS_FORMAT_MULTIVIEW
#define MAXFRAME
@ SEQ_TYPE_SOUND_RAM
@ SEQ_TYPE_TEXT
@ SEQ_TYPE_IMAGE
@ SEQ_TYPE_MOVIE
#define SEQ_HAS_PATH(_seq)
@ SPACE_VIEW3D
eDupli_ID_Flags
@ USER_DUP_LINKED_ID
@ USER_DUP_OBJECT
@ V3D_ORIENT_CUSTOM
@ V3D_ORIENT_GLOBAL
@ V3D_GIZMO_SHOW_OBJECT_ROTATE
@ V3D_GIZMO_SHOW_OBJECT_SCALE
@ V3D_GIZMO_SHOW_OBJECT_TRANSLATE
static AppView * view
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
const char * IMB_colormanagement_view_get_default_name(const char *display_name)
@ COLOR_ROLE_DEFAULT_SEQUENCER
const char * IMB_colormanagement_display_get_none_name(void)
const char * IMB_colormanagement_role_colorspace_name_get(int role)
void IMB_stereo3d_write_dimensions(char mode, bool is_squeezed, size_t width, size_t height, size_t *r_width, size_t *r_height)
Definition: stereoimbuf.c:507
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
Platform independent time functions.
#define RE_USE_SPHERICAL_STEREO
Definition: RE_engine.h:50
#define RE_USE_SHADING_NODES_CUSTOM
Definition: RE_engine.h:49
#define SEQ_DUPE_ALL
Definition: SEQ_sequencer.h:39
__forceinline const avxi srl(const avxi &a, const int32_t b)
Definition: avxi.h:335
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMeshParams *params)
unsigned int U
Definition: btGjkEpa3.h:78
#define SELECT
OperationNode * node
Scene scene
const Depsgraph * depsgraph
AnimationBackup * backup
void * user_data
SyclQueue void void size_t num_bytes void
int len
Definition: draw_manager.c:108
void EEVEE_lightcache_blend_read_data(BlendDataReader *reader, LightCache *cache)
void EEVEE_lightcache_blend_write(BlendWriter *writer, LightCache *cache)
void EEVEE_lightcache_free(LightCache *lcache)
void EEVEE_lightcache_info_update(SceneEEVEE *eevee)
bNodeTree * ntree
RenderEngineType * RE_engines_find(const char *idname)
Definition: engine.c:98
const vector< Marker > & markers
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void SEQ_for_each_callback(ListBase *seqbase, SeqForEachFunc callback, void *user_data)
Definition: iterator.c:76
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:28
size_t(* MEM_allocN_len)(const void *vmemh)
Definition: mallocn.c:26
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
ccl_device_inline float3 pow(float3 v, float e)
Definition: math_float3.h:533
static unsigned a[3]
Definition: RandGen.cpp:78
static void area(int d1, int d2, int e1, int e2, float weights[2])
ListBase threads
list of all thread for every CPUDevice in cpudevices a thread exists.
#define hash
Definition: noise.c:153
static struct PyModuleDef module
Definition: python.cpp:972
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5167
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
Definition: rna_access.c:112
bool RNA_pointer_is_null(const PointerRNA *ptr)
Definition: rna_access.c:164
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
void BKE_scene_base_flag_to_objects(ViewLayer *view_layer)
Definition: scene.cc:2886
void free_avicodecdata(AviCodecData *acd)
Definition: scene.cc:1699
int BKE_scene_transform_orientation_get_index(const Scene *scene, const TransformOrientation *orientation)
Definition: scene.cc:3570
void BKE_scene_graph_evaluated_ensure(Depsgraph *depsgraph, Main *bmain)
Definition: scene.cc:2653
#define BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS_FUNCTION_CALL(__data, __do_undo_restore, __func_call)
Definition: scene.cc:508
static bool seq_foreach_member_id_cb(Sequence *seq, void *user_data)
Definition: scene.cc:738
void BKE_scene_disable_color_management(Scene *scene)
Definition: scene.cc:2902
static void scene_blend_read_lib(BlendLibReader *reader, ID *id)
Definition: scene.cc:1408
const char * BKE_scene_multiview_render_view_name_get(const RenderData *rd, const int view_id)
Definition: scene.cc:3140
static void scene_undo_preserve(BlendLibReader *reader, ID *id_new, ID *id_old)
Definition: scene.cc:1630
bool BKE_scene_uses_cycles(const Scene *scene)
Definition: scene.cc:2860
static void scene_lib_override_apply_post(ID *id_dst, ID *UNUSED(id_src))
Definition: scene.cc:1646
IDTypeInfo IDType_ID_SCE
Definition: scene.cc:1693
void BKE_scene_copy_data_eevee(Scene *sce_dst, const Scene *sce_src)
Definition: scene.cc:1855
float BKE_scene_ctime_get(const Scene *scene)
Definition: scene.cc:2401
int get_render_subsurf_level(const RenderData *r, int lvl, bool for_render)
Definition: scene.cc:2781
static void scene_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int flag)
Definition: scene.cc:234
void BKE_scene_undo_depsgraphs_restore(Main *bmain, GHash *depsgraph_extract)
Definition: scene.cc:3508
const char * BKE_scene_multiview_view_id_suffix_get(const RenderData *rd, const int view_id)
Definition: scene.cc:3223
int BKE_scene_num_threads(const Scene *scene)
Definition: scene.cc:2955
int get_render_child_particle_number(const RenderData *r, int child_num, bool for_render)
Definition: scene.cc:2794
void BKE_scene_allocate_depsgraph_hash(Scene *scene)
Definition: scene.cc:3339
static void scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain, bool only_if_tagged)
Definition: scene.cc:2577
void BKE_scene_free_view_layer_depsgraph(Scene *scene, ViewLayer *view_layer)
Definition: scene.cc:3361
void BKE_scene_multiview_view_filepath_get(const RenderData *rd, const char *filepath, const char *viewname, char *r_filepath)
Definition: scene.cc:3185
static void depsgraph_key_free(void *key_v)
Definition: scene.cc:3327
const char * RE_engine_id_CYCLES
Definition: scene.cc:1697
static void scene_blend_read_data(BlendDataReader *reader, ID *id)
Definition: scene.cc:1108
static void direct_link_paint_helper(BlendDataReader *reader, const Scene *scene, Paint **paint)
Definition: scene.cc:1082
void BKE_toolsettings_free(ToolSettings *toolsettings)
Definition: scene.cc:1789
void BKE_scene_free_depsgraph_hash(Scene *scene)
Definition: scene.cc:3352
eSceneForeachUndoPreserveProcess
Definition: scene.cc:446
@ SCENE_FOREACH_UNDO_NO_RESTORE
Definition: scene.cc:452
@ SCENE_FOREACH_UNDO_RESTORE
Definition: scene.cc:449
static void link_recurs_seq(BlendDataReader *reader, ListBase *lb)
Definition: scene.cc:1092
int BKE_scene_multiview_num_views_get(const RenderData *rd)
Definition: scene.cc:3009
bool BKE_scene_multiview_is_render_view_active(const RenderData *rd, const SceneRenderView *srv)
Definition: scene.cc:3057
int BKE_scene_frame_snap_by_seconds(Scene *scene, double interval_in_seconds, int frame)
Definition: scene.cc:2354
#define FOREACHID_PROCESS_IDSUPER(_data, _id_super, _cb_flag)
void BKE_scene_transform_orientation_remove(Scene *scene, TransformOrientation *orientation)
Definition: scene.cc:3545
void BKE_scene_cursor_from_mat4(View3DCursor *cursor, const float mat[4][4], bool use_compat)
Definition: scene.cc:3688
bool BKE_scene_check_rigidbody_active(const Scene *scene)
Definition: scene.cc:2927
Scene * BKE_scene_find_from_collection(const Main *bmain, const Collection *collection)
Definition: scene.cc:2239
int BKE_render_preview_pixel_size(const RenderData *r)
Definition: scene.cc:2974
static bool depsgraph_key_compare(const void *key_a_v, const void *key_b_v)
Definition: scene.cc:3319
void BKE_scene_view_layer_graph_evaluated_ensure(Main *bmain, Scene *scene, ViewLayer *view_layer)
Definition: scene.cc:2733
bool BKE_scene_has_view_layer(const Scene *scene, const ViewLayer *layer)
Definition: scene.cc:2234
static void scene_free_markers(Scene *scene, bool do_id_user)
Definition: scene.cc:338
static void scene_copy_markers(Scene *scene_dst, const Scene *scene_src, const int flag)
Definition: scene.cc:224
void BKE_scene_frame_set(Scene *scene, float frame)
Definition: scene.cc:2420
static void scene_blend_read_expand(BlendExpander *expander, ID *id)
Definition: scene.cc:1548
static void remove_sequencer_fcurves(Scene *sce)
Definition: scene.cc:1715
static void composite_patch(bNodeTree *ntree, Scene *scene)
Definition: scene.cc:1397
static Depsgraph ** scene_get_depsgraph_p(Scene *scene, ViewLayer *view_layer, const bool allocate_ghash_entry)
Definition: scene.cc:3371
Depsgraph * BKE_scene_ensure_depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer)
Definition: scene.cc:3456
int BKE_scene_base_iter_next(Depsgraph *depsgraph, SceneBaseIter *iter, Scene **scene, int val, Base **base, Object **ob)
Definition: scene.cc:2109
bool BKE_scene_camera_switch_update(Scene *scene)
Definition: scene.cc:2295
static void scene_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition: scene.cc:914
static void scene_foreach_layer_collection(LibraryForeachIDData *data, ListBase *lb)
Definition: scene.cc:724
void BKE_render_resolution(const struct RenderData *r, const bool use_crop, int *r_width, int *r_height)
Definition: scene.cc:2960
SceneRenderView * BKE_scene_multiview_render_view_findindex(const RenderData *rd, const int view_id)
Definition: scene.cc:3121
bool BKE_scene_uses_cycles_experimental_features(Scene *scene)
Definition: scene.cc:2871
bool BKE_scene_multiview_is_stereo3d(const RenderData *rd)
Definition: scene.cc:3040
bool BKE_scene_multiview_is_render_view_first(const RenderData *rd, const char *viewname)
Definition: scene.cc:3083
static void scene_foreach_rigidbodyworldSceneLooper(struct RigidBodyWorld *UNUSED(rbw), ID **id_pointer, void *user_data, int cb_flag)
Definition: scene.cc:432
int BKE_scene_orientation_slot_get_index(const TransformOrientationSlot *orient_slot)
Definition: scene.cc:2463
void BKE_scene_cursor_rot_to_quat(const View3DCursor *cursor, float quat[4])
Definition: scene.cc:3599
float BKE_scene_frame_get(const Scene *scene)
Definition: scene.cc:2415
void BKE_scene_groups_relink(Scene *sce)
Definition: scene.cc:2022
bool BKE_scene_can_be_removed(const Main *bmain, const Scene *scene)
Definition: scene.cc:2029
void BKE_scene_set_background(Main *bmain, Scene *scene)
Definition: scene.cc:2075
void BKE_scene_cursor_mat3_to_rot(View3DCursor *cursor, const float mat[3][3], bool use_compat)
Definition: scene.cc:3612
eCyclesFeatureSet
Definition: scene.cc:2866
@ CYCLES_FEATURES_SUPPORTED
Definition: scene.cc:2867
@ CYCLES_FEATURES_EXPERIMENTAL
Definition: scene.cc:2868
Base * _setlooper_base_step(Scene **sce_iter, ViewLayer *view_layer, Base *base)
Definition: scene.cc:2807
const char * RE_engine_id_BLENDER_WORKBENCH
Definition: scene.cc:1696
bool BKE_scene_multiview_is_render_view_last(const RenderData *rd, const char *viewname)
Definition: scene.cc:3102
int BKE_render_num_threads(const RenderData *rd)
Definition: scene.cc:2933
bool BKE_scene_use_spherical_stereo(Scene *scene)
Definition: scene.cc:2844
void BKE_scene_multiview_videos_dimensions_get(const RenderData *rd, const size_t width, const size_t height, size_t *r_width, size_t *r_height)
Definition: scene.cc:3263
void BKE_scene_ensure_depsgraph_hash(Scene *scene)
Definition: scene.cc:3345
TransformOrientation * BKE_scene_transform_orientation_find(const Scene *scene, const int index)
Definition: scene.cc:3565
void BKE_scene_update_sound(Depsgraph *depsgraph, Main *bmain)
Definition: scene.cc:2539
Scene * BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type)
Definition: scene.cc:1864
#define BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS_IDSUPER(__data, __id, __do_undo_restore, __action, __reader, __id_old, __cb_flag)
Definition: scene.cc:494
SceneRenderView * BKE_scene_add_render_view(Scene *sce, const char *name)
Definition: scene.cc:2740
int BKE_scene_orientation_get_index_from_flag(Scene *scene, int flag)
Definition: scene.cc:2476
bool BKE_scene_validate_setscene(Main *bmain, Scene *sce)
Definition: scene.cc:2379
int BKE_scene_multiview_num_videos_get(const RenderData *rd)
Definition: scene.cc:3283
Depsgraph * BKE_scene_get_depsgraph(const Scene *scene, const ViewLayer *view_layer)
Definition: scene.cc:3443
static void scene_init_data(ID *id)
Definition: scene.cc:117
const char * BKE_scene_find_last_marker_name(const Scene *scene, int frame)
Definition: scene.cc:2336
static void scene_foreach_toolsettings_id_pointer_process(ID **id_p, const eSceneForeachUndoPreserveProcess action, BlendLibReader *reader, ID **id_old_p, const uint cb_flag)
Definition: scene.cc:455
int BKE_scene_orientation_get_index(Scene *scene, int slot_index)
Definition: scene.cc:2470
const char * BKE_scene_find_marker_name(const Scene *scene, int frame)
Definition: scene.cc:2310
void BKE_scene_cursor_quat_to_rot(View3DCursor *cursor, const float quat[4], bool use_compat)
Definition: scene.cc:3647
GHash * BKE_scene_undo_depsgraphs_extract(Main *bmain)
Definition: scene.cc:3479
bool BKE_scene_object_find(Scene *scene, Object *ob)
Definition: scene.cc:2053
void BKE_scene_orientation_slot_set_index(TransformOrientationSlot *orient_slot, int orientation)
Definition: scene.cc:2456
float BKE_scene_frame_to_ctime(const Scene *scene, const int frame)
Definition: scene.cc:2406
void BKE_scene_cursor_rot_to_mat3(const View3DCursor *cursor, float mat[3][3])
Definition: scene.cc:3584
const char * RE_engine_id_BLENDER_EEVEE
Definition: scene.cc:1695
void BKE_scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain)
Definition: scene.cc:2648
Scene * BKE_scene_add(Main *bmain, const char *name)
Definition: scene.cc:2044
const char * BKE_scene_multiview_view_suffix_get(const RenderData *rd, const char *viewname)
Definition: scene.cc:3206
static Depsgraph ** scene_ensure_depsgraph_p(Main *bmain, Scene *scene, ViewLayer *view_layer)
Definition: scene.cc:3411
static void scene_foreach_id(ID *id, LibraryForeachIDData *data)
Definition: scene.cc:773
bool BKE_scene_use_shading_nodes_custom(Scene *scene)
Definition: scene.cc:2838
void BKE_scene_multiview_filepath_get(const SceneRenderView *srv, const char *filepath, char *r_filepath)
Definition: scene.cc:3177
int BKE_scene_multiview_view_id_get(const RenderData *rd, const char *viewname)
Definition: scene.cc:3151
static void scene_free_data(ID *id)
Definition: scene.cc:349
static void prepare_mesh_for_viewport_render(Main *bmain, const ViewLayer *view_layer)
Definition: scene.cc:2511
static bool seq_foreach_path_callback(Sequence *seq, void *user_data)
Definition: scene.cc:875
void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph)
Definition: scene.cc:2728
TransformOrientationSlot * BKE_scene_orientation_slot_get_from_flag(Scene *scene, int flag)
Definition: scene.cc:2439
double BKE_scene_unit_scale(const UnitSettings *unit, const int unit_type, double value)
Definition: scene.cc:2982
static unsigned int depsgraph_key_hash(const void *key_v)
Definition: scene.cc:3311
static void scene_foreach_cache(ID *id, IDTypeForeachCacheFunctionCallback function_callback, void *user_data)
Definition: scene.cc:859
static void scene_foreach_toolsettings(LibraryForeachIDData *data, ToolSettings *toolsett, const bool do_undo_restore, BlendLibReader *reader, ToolSettings *toolsett_old)
Definition: scene.cc:562
constexpr IDTypeInfo get_type_info()
Definition: scene.cc:1659
static void scene_foreach_path(ID *id, BPathForeachPathData *bpath_data)
Definition: scene.cc:906
Object * BKE_scene_object_find_by_name(const Scene *scene, const char *name)
Definition: scene.cc:2063
ToolSettings * BKE_toolsettings_copy(ToolSettings *toolsettings, const int flag)
Definition: scene.cc:1729
void BKE_scene_cursor_to_mat4(const View3DCursor *cursor, float mat[4][4])
Definition: scene.cc:3680
static bool check_rendered_viewport_visible(Main *bmain)
Definition: scene.cc:2484
void BKE_scene_graph_update_for_newframe_ex(Depsgraph *depsgraph, const bool clear_recalc)
Definition: scene.cc:2658
static void depsgraph_key_value_free(void *value)
Definition: scene.cc:3333
bool BKE_scene_remove_render_view(Scene *scene, SceneRenderView *srv)
Definition: scene.cc:2759
void BKE_scene_update_tag_audio_volume(Depsgraph *UNUSED(depsgraph), Scene *scene)
Definition: scene.cc:2563
bool BKE_scene_check_color_management_enabled(const Scene *scene)
Definition: scene.cc:2922
static char * scene_undo_depsgraph_gen_key(Scene *scene, ViewLayer *view_layer, char *key_full)
Definition: scene.cc:3462
void BKE_scene_remove_rigidbody_object(struct Main *bmain, Scene *scene, Object *ob, const bool free_us)
Definition: scene.cc:2364
static void scene_foreach_paint(LibraryForeachIDData *data, Paint *paint, const bool do_undo_restore, BlendLibReader *reader, Paint *paint_old)
Definition: scene.cc:521
void BKE_scene_object_base_flag_sync_from_base(Base *base)
Definition: scene.cc:2896
Scene * BKE_scene_set_name(Main *bmain, const char *name)
Definition: scene.cc:2096
bool BKE_scene_uses_blender_workbench(const Scene *scene)
Definition: scene.cc:2855
void BKE_scene_multiview_view_prefix_get(Scene *scene, const char *name, char *r_prefix, const char **r_ext)
Definition: scene.cc:3233
bool BKE_scene_uses_blender_eevee(const Scene *scene)
Definition: scene.cc:2850
TransformOrientationSlot * BKE_scene_orientation_slot_get(Scene *scene, int slot_index)
Definition: scene.cc:2431
void SEQ_tool_settings_free(SequencerToolSettings *tool_settings)
Definition: sequencer.c:341
void SEQ_sequence_base_dupli_recursive(const Scene *scene_src, Scene *scene_dst, ListBase *nseqbase, const ListBase *seqbase, int dupe_flag, const int flag)
Definition: sequencer.c:613
void SEQ_blend_read_expand(BlendExpander *expander, ListBase *seqbase)
Definition: sequencer.c:919
SequencerToolSettings * SEQ_tool_settings_init(void)
Definition: sequencer.c:316
void SEQ_blend_read_lib(BlendLibReader *reader, Scene *scene, ListBase *seqbase)
Definition: sequencer.c:884
void SEQ_editing_free(Scene *scene, const bool do_id_user)
Definition: sequencer.c:263
SequencerToolSettings * SEQ_tool_settings_copy(SequencerToolSettings *tool_settings)
Definition: sequencer.c:664
void SEQ_blend_read(BlendDataReader *reader, ListBase *seqbase)
Definition: sequencer.c:823
bool SEQ_valid_strip_channel(Sequence *seq)
Definition: sequencer.c:653
void SEQ_blend_write(BlendWriter *writer, ListBase *seqbase)
Definition: sequencer.c:755
_W64 int intptr_t
Definition: stdint.h:118
bAction * action
unsigned int cbFormat
unsigned int cbParms
struct BMesh * bm
Definition: BKE_editmesh.h:40
eBPathForeachFlag flag
Definition: BKE_bpath.h:78
struct Object * cage_object
char filepath[1024]
struct ImageFormatData im_format
struct Base * next
short flag
struct Object * object
struct BlendFileReadReport::@134 count
CurveMap cm[4]
const ViewLayer * view_layer
Definition: scene.cc:3305
float mat[4][4]
Definition: BKE_duplilist.h:37
struct Object * ob
Definition: BKE_duplilist.h:34
struct DupliObject * next
Definition: BKE_duplilist.h:32
struct SequenceLookup * sequence_lookup
ListBase seqbase
struct PrefetchJob * prefetch_job
ListBase * seqbasep
Sequence * act_seq
ListBase channels
ListBase * displayed_channels
ListBase metastack
struct SeqCache * cache
EditingRuntime runtime
struct Collection * group
struct CurveMapping * custom_ipo
struct Object * reference_object
struct GP_Sculpt_Guide guide
struct CurveMapping * cur_primitive
struct CurveMapping * cur_falloff
unsigned int id_session_uuid
Definition: BKE_idtype.h:46
short id_code
Definition: BKE_idtype.h:114
Definition: DNA_ID.h:368
int tag
Definition: DNA_ID.h:387
struct Library * lib
Definition: DNA_ID.h:372
int recalc
Definition: DNA_ID.h:390
IDProperty * properties
Definition: DNA_ID.h:409
struct ID * orig_id
Definition: DNA_ID.h:419
char name[66]
Definition: DNA_ID.h:378
Stereo3dFormat stereo3d_format
struct Image * stencil
struct Image * canvas
struct Image * clone
char filepath[1024]
Definition: DNA_ID.h:461
void * last
Definition: DNA_listBase.h:31
void * first
Definition: DNA_listBase.h:31
Definition: BKE_main.h:121
ListBase scenes
Definition: BKE_main.h:168
ListBase wm
Definition: BKE_main.h:197
ListBase objects
Definition: BKE_main.h:170
struct BMEditMesh * edit_mesh
void set(const SocketType &input, bool value)
Definition: graph/node.cpp:57
short base_flag
struct RigidBodyOb * rigidbody_object
float obmat[4][4]
struct RigidBodyCon * rigidbody_constraint
void * data
struct ListBase * ptcaches
struct Brush * brush
int tool_slots_len
struct PaintToolSlot * tool_slots
struct Palette * palette
struct Brush * brush
ParticleBrushData brush[7]
struct Object * shape_object
struct Object * object
struct Scene * scene
struct CurveMapping mblur_shutter_curve
struct BakeData bake
char engine[32]
struct ImageFormatData im_format
struct AviCodecData * avicodecdata
char pic[1024]
ListBase views
short views_format
struct PointCache * pointcache
struct Collection * constraints
struct Collection * group
struct RigidBodyWorld_Shared * shared
struct Object ** objects
struct EffectorWeights * effector_weights
float omat[4][4]
Definition: BKE_scene.h:84
struct DupliObject * dupob
Definition: BKE_scene.h:83
struct Object * dupli_refob
Definition: BKE_scene.h:85
struct ListBase * duplilist
Definition: BKE_scene.h:82
View3DShading shading
struct LightCache * light_cache_data
char light_cache_info[64]
struct SceneRenderView * next
struct bNodeTree * nodetree
struct Collection * master_collection
struct GHash * depsgraph_hash
struct PhysicsSettings physics_settings
struct RigidBodyWorld * rigidbody_world
IDProperty * layer_properties
struct SceneDisplay display
struct CustomData_MeshMasks customdata_mask
struct SceneGpencil grease_pencil_settings
struct MovieClip * clip
short flag
ListBase keyingsets
void * fps_info
struct ToolSettings * toolsettings
ColorManagedViewSettings view_settings
struct PreviewImage * preview
struct Editing * ed
struct bGPdata * gpd
struct RenderData r
View3DCursor cursor
ListBase view_layers
struct CustomData_MeshMasks customdata_mask_modal
TransformOrientationSlot orientation_slots[4]
struct AnimData * adt
struct UnitSettings unit
struct Object * camera
ListBase markers
ListBase transform_spaces
struct World * world
ColorManagedColorspaceSettings sequencer_colorspace_settings
struct Scene * set
struct AudioData audio
struct SceneEEVEE eevee
ColorManagedDisplaySettings display_settings
struct Object * gravity_object
Paint paint
struct MovieClip * clip
struct Scene * scene
struct Object * scene_camera
struct Mask * mask
ListBase channels
ListBase modifiers
ListBase seqbase
struct bSound * sound
struct IDProperty * prop
char name[256]
StripElem * stripdata
char dir[768]
struct VFont * text_font
char name[64]
struct TimeMarker * prev
struct TimeMarker * next
GpWeightPaint * gp_weightpaint
struct ImagePaintSettings imapaint
struct CurveProfile * custom_bevel_profile_preset
GpPaint * gp_paint
struct SequencerToolSettings * sequencer_tool_settings
GpSculptPaint * gp_sculptpaint
struct PaintModeSettings paint_mode
struct UnifiedPaintSettings unified_paint_settings
struct GP_Interpolate_Settings gp_interpolate
struct ParticleEditSettings particle
CurvesSculpt * curves_sculpt
UvSculpt * uvsculpt
struct GP_Sculpt_Settings gp_sculpt
GpVertexPaint * gp_vertexpaint
float rotation_axis[3]
float rotation_quaternion[4]
float rotation_euler[3]
struct IDProperty * prop
View3DShading shading
struct ViewLayer * next
ListBase object_bases
char name[64]
ListBase curves
ListBase nodes
ListBase areabase