2022-02-10 23:07:11 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
* Copyright 2022 Blender Foundation. */
|
2022-01-12 12:16:41 +01:00
|
|
|
|
|
|
|
#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,
|
2022-01-13 19:55:20 +01:00
|
|
|
const CompositorContext &context) const
|
2022-01-12 12:16:41 +01:00
|
|
|
{
|
|
|
|
SetValueOperation *SecondOperation = new SetValueOperation();
|
|
|
|
SetValueOperation *frameOperation = new SetValueOperation();
|
|
|
|
|
|
|
|
const int frameNumber = context.get_framenumber();
|
2022-01-13 19:55:20 +01:00
|
|
|
const Scene *scene = context.get_scene();
|
2022-09-25 10:33:28 +02:00
|
|
|
const double frameRate = (double(scene->r.frs_sec) / double(scene->r.frs_sec_base));
|
2022-01-12 12:16:41 +01:00
|
|
|
|
|
|
|
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
|