Add runtime field on the Scene

For C it is an opaque pointer, for the C++ it is a class which is
defined in BKE_scene_runtime.hh.

The runtime field ensured to exist after file load, and after new
scene is added. The field is not copied when scene is copied, and
instead the copy of the scene has its own runtime field. If any of
the fields in the runtime are desired to be copied it needs to be
done explicitly.

Currently unused, but is planned to be utilized for the upcoming
compositor timing functionality,

Pull Request: https://projects.blender.org/blender/blender/pulls/117978
This commit is contained in:
Sergey Sharybin
2024-02-08 14:30:14 +01:00
committed by Sergey Sharybin
parent da2d3be202
commit 8303bb167b
4 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
/* SPDX-FileCopyrightText: 2024 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "BLI_utility_mixins.hh"
namespace blender::bke {
class SceneRuntime : NonCopyable, NonMovable {
public:
};
} // namespace blender::bke

View File

@@ -487,6 +487,7 @@ set(SRC
BKE_report.h
BKE_rigidbody.h
BKE_scene.h
BKE_scene_runtime.hh
BKE_screen.hh
BKE_sequencer_offscreen.h
BKE_shader_fx.h

View File

@@ -89,6 +89,7 @@
#include "BKE_preview_image.hh"
#include "BKE_rigidbody.h"
#include "BKE_scene.h"
#include "BKE_scene_runtime.hh"
#include "BKE_screen.hh"
#include "BKE_sound.h"
#include "BKE_unit.hh"
@@ -120,6 +121,8 @@
#include "bmesh.hh"
using blender::bke::SceneRuntime;
CurveMapping *BKE_sculpt_default_cavity_curve()
{
@@ -249,6 +252,8 @@ static void scene_init_data(ID *id)
scene->master_collection = BKE_collection_master_add(scene);
BKE_view_layer_add(scene, DATA_("ViewLayer"), nullptr, VIEWLAYER_ADD_NEW);
scene->runtime = MEM_new<SceneRuntime>(__func__);
}
static void scene_copy_markers(Scene *scene_dst, const Scene *scene_src, const int flag)
@@ -369,6 +374,8 @@ static void scene_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int
}
BKE_scene_copy_data_eevee(scene_dst, scene_src);
scene_dst->runtime = MEM_new<SceneRuntime>(__func__);
}
static void scene_free_markers(Scene *scene, bool do_id_user)
@@ -464,6 +471,8 @@ static void scene_free_data(ID *id)
/* These are freed on `do_versions`. */
BLI_assert(scene->layer_properties == nullptr);
MEM_delete(scene->runtime);
}
static void scene_foreach_rigidbodyworldSceneLooper(RigidBodyWorld * /*rbw*/,
@@ -1259,6 +1268,8 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id)
/* set users to one by default, not in lib-link, this will increase it for compo nodes */
id_us_ensure_real(&sce->id);
sce->runtime = MEM_new<SceneRuntime>(__func__);
BLO_read_list(reader, &(sce->base));
BLO_read_list(reader, &sce->keyingsets);

View File

@@ -44,6 +44,16 @@ struct World;
struct bGPdata;
struct bNodeTree;
/** Workaround to forward-declare C++ type in C header. */
#ifdef __cplusplus
namespace blender::bke {
class SceneRuntime;
}
using SceneRuntimeHandle = blender::bke::SceneRuntime;
#else // __cplusplus
typedef struct SceneRuntimeHandle SceneRuntimeHandle;
#endif // __cplusplus
/* -------------------------------------------------------------------- */
/** \name FFMPEG
* \{ */
@@ -2081,6 +2091,9 @@ typedef struct Scene {
struct SceneEEVEE eevee;
struct SceneGpencil grease_pencil_settings;
struct SceneHydra hydra;
SceneRuntimeHandle *runtime;
void *_pad9;
} Scene;
/** \} */