Blender V5.3
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
11
12#include "node_util.hh"
13
14#include "RNA_access.hh"
15
17
19{
20 b.add_output<decl::Float>("Seconds"_ustr);
21 b.add_output<decl::Float>("Frame"_ustr);
22}
23
24static void node_exec(GeoNodeExecParams params)
25{
26 const Scene *scene = DEG_get_input_scene(params.depsgraph());
27 const float scene_ctime = BKE_scene_ctime_get(scene);
28 const double frame_rate = double(scene->r.frs_sec) / double(scene->r.frs_sec_base);
29 params.set_output("Seconds"_ustr, float(scene_ctime / frame_rate));
30 params.set_output("Frame"_ustr, scene_ctime);
31}
32
34 bNode *node,
35 bNodeExecData * /*execdata*/,
38{
40 GPU_stack_link(mat, node, "node_scene_time", in, out, GPU_kernel_globals());
41 return 1;
42}
43
45#ifdef WITH_MATERIALX
46{
47 return get_output_default(socket_out_->identifier, NodeItem::Type::Any);
48}
49#endif
51
52static void node_register()
53{
54 static bke::bNodeType ntype;
55 sh_geo_node_type_base(&ntype, "GeometryNodeInputSceneTime"_ustr, GEO_NODE_INPUT_SCENE_TIME);
56 ntype.ui_name = "Scene Time";
57 ntype.ui_description =
58 "Retrieve the current time in the scene's animation in units of seconds or frames";
59 ntype.enum_name_legacy = "INPUT_SCENE_TIME";
62 ntype.declare = node_declare;
63 ntype.gpu_fn = node_shader_gpu;
64 ntype.materialx_fn = node_shader_materialx;
66}
68
69} // namespace blender::nodes::node_geo_input_scene_time_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define GEO_NODE_INPUT_SCENE_TIME
#define NOD_REGISTER_NODE(REGISTER_FUNC)
const Depsgraph * depsgraph() const
void set_output(const UString identifier, T &&value)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_declare(NodeDeclarationBuilder &b)
static int node_shader_gpu(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_exec(GeoNodeExecParams params)
NODE_SHADER_MATERIALX_BEGIN static NODE_SHADER_MATERIALX_END void node_register()
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ GPU_MATFLAG_SCENE_TIME
void sh_geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
float BKE_scene_ctime_get(const Scene *scene)
Definition scene.cc:2581
Scene * DEG_get_input_scene(const Depsgraph *graph)
GPUNodeLink * GPU_kernel_globals()
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
struct RenderData r
Defines a node type.
Definition BKE_node.hh:265
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:375
std::string ui_description
Definition BKE_node.hh:271
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:373
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:385
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393