Welcome to mirror list, hosted at ThFree Co, Russian Federation.

COM_SceneTimeNode.cc « nodes « compositor « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dd5784f03ee6c8dbf3f4441c399e6be1a86f8903 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* SPDX-License-Identifier: GPL-2.0-or-later
 * 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