[Bf-blender-cvs] [b2ccd8546c7] master: Compositor: Add Scene Time Node, Rename Time node

Nathan Rozendaal noreply at git.blender.org
Wed Jan 12 12:29:46 CET 2022


Commit: b2ccd8546c7249a5ce279210d45ddbb5e90cd10d
Author: Nathan Rozendaal
Date:   Wed Jan 12 12:16:41 2022 +0100
Branches: master
https://developer.blender.org/rBb2ccd8546c7249a5ce279210d45ddbb5e90cd10d

Compositor: Add Scene Time Node, Rename Time node

Fixes issue T94603
It adds a new compositor node called Scene Time which is already present as a geo node, having the same basic nodes available in all node trees is a nice thing to have.
Renames "Time" node to "Time Curve", this is done to avoid confusion between the Time node and the Scene Time node.

Reviewed By: jbakker

Maniphest Tasks: T94603

Differential Revision: https://developer.blender.org/D13762

===================================================================

M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/intern/node.cc
M	source/blender/compositor/CMakeLists.txt
M	source/blender/compositor/intern/COM_Converter.cc
A	source/blender/compositor/nodes/COM_SceneTimeNode.cc
A	source/blender/compositor/nodes/COM_SceneTimeNode.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/nodes/NOD_composite.h
M	source/blender/nodes/NOD_static_types.h
M	source/blender/nodes/composite/CMakeLists.txt
M	source/blender/nodes/composite/nodes/node_composite_curves.cc
A	source/blender/nodes/composite/nodes/node_composite_scene_time.cc

===================================================================

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
--- 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list