diff options
-rw-r--r-- | release/scripts/startup/nodeitems_builtins.py | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_node.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.cc | 1 | ||||
-rw-r--r-- | source/blender/compositor/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/compositor/intern/COM_Converter.cc | 4 | ||||
-rw-r--r-- | source/blender/compositor/nodes/COM_SceneTimeNode.cc | 50 | ||||
-rw-r--r-- | source/blender/compositor/nodes/COM_SceneTimeNode.h | 36 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 1 | ||||
-rw-r--r-- | source/blender/nodes/NOD_composite.h | 1 | ||||
-rw-r--r-- | source/blender/nodes/NOD_static_types.h | 3 | ||||
-rw-r--r-- | source/blender/nodes/composite/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/nodes/composite/nodes/node_composite_curves.cc | 2 | ||||
-rw-r--r-- | source/blender/nodes/composite/nodes/node_composite_scene_time.cc | 39 |
13 files changed, 140 insertions, 2 deletions
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index cd67a41a701..f6ca200f570 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -501,6 +501,7 @@ compositor_node_categories = [ NodeItem("CompositorNodeTexture"), NodeItem("CompositorNodeBokehImage"), NodeItem("CompositorNodeTime"), + NodeItem("CompositorNodeSceneTime"), NodeItem("CompositorNodeTrackPos"), ]), CompositorNodeCategory("CMP_OUTPUT", "Output", items=[ diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 71d1728a870..5f8222e33d4 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -1313,6 +1313,7 @@ void ntreeGPUMaterialNodes(struct bNodeTree *localtree, #define CMP_NODE_CRYPTOMATTE 326 #define CMP_NODE_POSTERIZE 327 #define CMP_NODE_CONVERT_COLOR_SPACE 328 +#define CMP_NODE_SCENE_TIME 329 /* channel toggles */ #define CMP_CHAN_RGB 1 diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 1cb3fd6153c..8c6bdb13708 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -4447,6 +4447,7 @@ static void registerCompositNodes() register_node_type_cmp_value(); register_node_type_cmp_rgb(); register_node_type_cmp_curve_time(); + register_node_type_cmp_scene_time(); register_node_type_cmp_movieclip(); register_node_type_cmp_composite(); diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index f59fd885871..96dc17c2d1a 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -147,6 +147,8 @@ set(SRC nodes/COM_TimeNode.h nodes/COM_ValueNode.cc nodes/COM_ValueNode.h + nodes/COM_SceneTimeNode.cc + nodes/COM_SceneTimeNode.h # output nodes nodes/COM_CompositorNode.cc diff --git a/source/blender/compositor/intern/COM_Converter.cc b/source/blender/compositor/intern/COM_Converter.cc index 1b98a04cf96..6cf6c698a2f 100644 --- a/source/blender/compositor/intern/COM_Converter.cc +++ b/source/blender/compositor/intern/COM_Converter.cc @@ -94,6 +94,7 @@ #include "COM_RotateNode.h" #include "COM_ScaleNode.h" #include "COM_ScaleOperation.h" +#include "COM_SceneTimeNode.h" #include "COM_SeparateColorNode.h" #include "COM_SetAlphaNode.h" #include "COM_SetValueOperation.h" @@ -360,6 +361,9 @@ Node *COM_convert_bnode(bNode *b_node) case CMP_NODE_TRANSFORM: node = new TransformNode(b_node); break; + case CMP_NODE_SCENE_TIME: + node = new SceneTimeNode(b_node); + break; case CMP_NODE_STABILIZE2D: node = new Stabilize2dNode(b_node); break; diff --git a/source/blender/compositor/nodes/COM_SceneTimeNode.cc b/source/blender/compositor/nodes/COM_SceneTimeNode.cc new file mode 100644 index 00000000000..f495db5ed4c --- /dev/null +++ b/source/blender/compositor/nodes/COM_SceneTimeNode.cc @@ -0,0 +1,50 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2022, Blender Foundation. + */ + +#include "COM_SceneTimeNode.h" + +#include "COM_SetValueOperation.h" + +namespace blender::compositor { + +SceneTimeNode::SceneTimeNode(bNode *editor_node) : Node(editor_node) +{ + /* pass */ +} + +void SceneTimeNode::convert_to_operations(NodeConverter &converter, + const CompositorContext &context) const +{ + SetValueOperation *SecondOperation = new SetValueOperation(); + SetValueOperation *frameOperation = new SetValueOperation(); + + const int frameNumber = context.get_framenumber(); + const Scene* scene = context.get_scene(); + const double frameRate = (((double)scene->r.frs_sec) / (double)scene->r.frs_sec_base); + + SecondOperation->set_value(float(frameNumber / frameRate)); + converter.add_operation(SecondOperation); + + frameOperation->set_value(frameNumber); + converter.add_operation(frameOperation); + + converter.map_output_socket(get_output_socket(0), SecondOperation->get_output_socket()); + converter.map_output_socket(get_output_socket(1), frameOperation->get_output_socket()); +} + +} // namespace blender::compositor diff --git a/source/blender/compositor/nodes/COM_SceneTimeNode.h b/source/blender/compositor/nodes/COM_SceneTimeNode.h new file mode 100644 index 00000000000..62c502d26d2 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SceneTimeNode.h @@ -0,0 +1,36 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2022, Blender Foundation. + */ + +#pragma once + +#include "COM_Node.h" + +namespace blender::compositor { + +/** + * \brief SceneTimeNode + * \ingroup Node + */ +class SceneTimeNode : public Node { + public: + SceneTimeNode(bNode *editor_node); + void convert_to_operations(NodeConverter &converter, + const CompositorContext &context) const override; +}; + +} // namespace blender::compositor diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 20f77626e49..77c0db81b37 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -185,6 +185,7 @@ extern StructRNA RNA_CompositorNodeRGBToBW; extern StructRNA RNA_CompositorNodeRLayers; extern StructRNA RNA_CompositorNodeRotate; extern StructRNA RNA_CompositorNodeScale; +extern StructRNA RNA_CompositorNodeSceneTime; extern StructRNA RNA_CompositorNodeSepHSVA; extern StructRNA RNA_CompositorNodeSepRGBA; extern StructRNA RNA_CompositorNodeSepYCCA; diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h index 72539f6081e..c80d0bcdd1e 100644 --- a/source/blender/nodes/NOD_composite.h +++ b/source/blender/nodes/NOD_composite.h @@ -43,6 +43,7 @@ void register_node_type_cmp_texture(void); void register_node_type_cmp_value(void); void register_node_type_cmp_rgb(void); void register_node_type_cmp_curve_time(void); +void register_node_type_cmp_scene_time(void); void register_node_type_cmp_movieclip(void); void register_node_type_cmp_composite(void); diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index 07a29677b72..e3566f81e2d 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -148,7 +148,7 @@ DefNode(CompositorNode, CMP_NODE_BLUR, def_cmp_blur, "BLUR", DefNode(CompositorNode, CMP_NODE_FILTER, def_cmp_filter, "FILTER", Filter, "Filter", "" ) DefNode(CompositorNode, CMP_NODE_MAP_VALUE, def_cmp_map_value, "MAP_VALUE", MapValue, "Map Value", "" ) DefNode(CompositorNode, CMP_NODE_MAP_RANGE, def_cmp_map_range, "MAP_RANGE", MapRange, "Map Range", "" ) -DefNode(CompositorNode, CMP_NODE_TIME, def_time, "TIME", Time, "Time", "" ) +DefNode(CompositorNode, CMP_NODE_TIME, def_time, "TIME", Time, "Time Curve", "" ) DefNode(CompositorNode, CMP_NODE_VECBLUR, def_cmp_vector_blur, "VECBLUR", VecBlur, "Vector Blur", "" ) DefNode(CompositorNode, CMP_NODE_SEPRGBA, 0, "SEPRGBA", SepRGBA, "Separate RGBA", "" ) DefNode(CompositorNode, CMP_NODE_SEPHSVA, 0, "SEPHSVA", SepHSVA, "Separate HSVA", "" ) @@ -228,6 +228,7 @@ DefNode(CompositorNode, CMP_NODE_EXPOSURE, 0, "EXPOSU DefNode(CompositorNode, CMP_NODE_ANTIALIASING, def_cmp_antialiasing, "ANTIALIASING", AntiAliasing, "Anti-Aliasing", "" ) DefNode(CompositorNode, CMP_NODE_POSTERIZE, 0, "POSTERIZE", Posterize, "Posterize", "" ) DefNode(CompositorNode, CMP_NODE_CONVERT_COLOR_SPACE,def_cmp_convert_color_space, "CONVERT_COLORSPACE", ConvertColorSpace, "Color Space","" ) +DefNode(CompositorNode, CMP_NODE_SCENE_TIME, 0, "SCENE_TIME", SceneTime, "Scene Time", "" ) DefNode(TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" ) DefNode(TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" ) diff --git a/source/blender/nodes/composite/CMakeLists.txt b/source/blender/nodes/composite/CMakeLists.txt index 086c820ce1e..c2d9c8a71bb 100644 --- a/source/blender/nodes/composite/CMakeLists.txt +++ b/source/blender/nodes/composite/CMakeLists.txt @@ -122,6 +122,7 @@ set(SRC nodes/node_composite_vec_blur.cc nodes/node_composite_viewer.cc nodes/node_composite_zcombine.cc + nodes/node_composite_scene_time.cc node_composite_tree.cc node_composite_util.cc diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.cc b/source/blender/nodes/composite/nodes/node_composite_curves.cc index cb96fd0bb60..12390a8549d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_curves.cc +++ b/source/blender/nodes/composite/nodes/node_composite_curves.cc @@ -51,7 +51,7 @@ void register_node_type_cmp_curve_time() static bNodeType ntype; - cmp_node_type_base(&ntype, CMP_NODE_TIME, "Time", NODE_CLASS_INPUT); + cmp_node_type_base(&ntype, CMP_NODE_TIME, "Time Curve", NODE_CLASS_INPUT); ntype.declare = file_ns::cmp_node_time_declare; node_type_size(&ntype, 200, 140, 320); node_type_init(&ntype, file_ns::node_composit_init_curves_time); diff --git a/source/blender/nodes/composite/nodes/node_composite_scene_time.cc b/source/blender/nodes/composite/nodes/node_composite_scene_time.cc new file mode 100644 index 00000000000..845390665f2 --- /dev/null +++ b/source/blender/nodes/composite/nodes/node_composite_scene_time.cc @@ -0,0 +1,39 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +/** \file + * \ingroup cmpnodes + */ + +#include "node_composite_util.hh" + +namespace blender::nodes { + +static void cmp_node_scene_time_declare(NodeDeclarationBuilder &b) +{ + b.add_output<decl::Float>(N_("Seconds")); + b.add_output<decl::Float>(N_("Frame")); +} + +} // namespace blender::nodes + +void register_node_type_cmp_scene_time() +{ + static bNodeType ntype; + + cmp_node_type_base(&ntype, CMP_NODE_SCENE_TIME, "Scene Time", NODE_CLASS_INPUT); + ntype.declare = blender::nodes::cmp_node_scene_time_declare; + nodeRegisterType(&ntype); +}
\ No newline at end of file |