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

COM_CompositorNode.cc « nodes « compositor « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d9009e313dd91ea61f3d41be82e45e1e2f166113 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* SPDX-License-Identifier: GPL-2.0-or-later
 * Copyright 2011 Blender Foundation. */

#include "COM_CompositorNode.h"
#include "COM_CompositorOperation.h"

namespace blender::compositor {

CompositorNode::CompositorNode(bNode *editor_node) : Node(editor_node)
{
  /* pass */
}

void CompositorNode::convert_to_operations(NodeConverter &converter,
                                           const CompositorContext &context) const
{
  bNode *editor_node = this->get_bnode();
  bool is_active = (editor_node->flag & NODE_DO_OUTPUT_RECALC) || context.is_rendering();
  bool ignore_alpha = (editor_node->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0;

  NodeInput *image_socket = this->get_input_socket(0);
  NodeInput *alpha_socket = this->get_input_socket(1);
  NodeInput *depth_socket = this->get_input_socket(2);

  CompositorOperation *compositor_operation = new CompositorOperation();
  compositor_operation->set_scene(context.get_scene());
  compositor_operation->set_scene_name(context.get_scene()->id.name);
  compositor_operation->set_render_data(context.get_render_data());
  compositor_operation->set_view_name(context.get_view_name());
  compositor_operation->set_bnodetree(context.get_bnodetree());
  /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */
  compositor_operation->set_use_alpha_input(ignore_alpha || alpha_socket->is_linked());
  compositor_operation->set_active(is_active);

  converter.add_operation(compositor_operation);
  converter.map_input_socket(image_socket, compositor_operation->get_input_socket(0));
  /* only use alpha link if "use alpha" is enabled */
  if (ignore_alpha) {
    converter.add_input_value(compositor_operation->get_input_socket(1), 1.0f);
  }
  else {
    converter.map_input_socket(alpha_socket, compositor_operation->get_input_socket(1));
  }
  converter.map_input_socket(depth_socket, compositor_operation->get_input_socket(2));

  converter.add_node_input_preview(image_socket);
}

}  // namespace blender::compositor