Blender V5.0
node_geo_input_scene_time.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BKE_scene.hh"
6
8
10
12
14{
15 b.add_output<decl::Float>("Seconds");
16 b.add_output<decl::Float>("Frame");
17}
18
20{
21 const Scene *scene = DEG_get_input_scene(params.depsgraph());
22 const float scene_ctime = BKE_scene_ctime_get(scene);
23 const double frame_rate = double(scene->r.frs_sec) / double(scene->r.frs_sec_base);
24 params.set_output("Seconds", float(scene_ctime / frame_rate));
25 params.set_output("Frame", scene_ctime);
26}
27
28static void node_register()
29{
30 static blender::bke::bNodeType ntype;
31 geo_node_type_base(&ntype, "GeometryNodeInputSceneTime", GEO_NODE_INPUT_SCENE_TIME);
32 ntype.ui_name = "Scene Time";
33 ntype.ui_description =
34 "Retrieve the current time in the scene's animation in units of seconds or frames";
35 ntype.enum_name_legacy = "INPUT_SCENE_TIME";
38 ntype.declare = node_declare;
40}
42
43} // namespace blender::nodes::node_geo_input_scene_time_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define GEO_NODE_INPUT_SCENE_TIME
float BKE_scene_ctime_get(const Scene *scene)
Definition scene.cc:2370
Scene * DEG_get_input_scene(const Depsgraph *graph)
#define NOD_REGISTER_NODE(REGISTER_FUNC)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static void node_declare(NodeDeclarationBuilder &b)
static void node_exec(GeoNodeExecParams params)
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
struct RenderData r
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:354
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362