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

COM_LensDistortionNode.cc « nodes « compositor « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3fe1125382eb7da6b784a8bb866eddb59c44d0be (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_LensDistortionNode.h"
#include "COM_ProjectorLensDistortionOperation.h"
#include "COM_ScreenLensDistortionOperation.h"

namespace blender::compositor {

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

void LensDistortionNode::convert_to_operations(NodeConverter &converter,
                                               const CompositorContext & /*context*/) const
{
  bNode *editor_node = this->get_bnode();
  NodeLensDist *data = (NodeLensDist *)editor_node->storage;
  if (data->proj) {
    ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation();
    converter.add_operation(operation);

    converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
    converter.map_input_socket(get_input_socket(2), operation->get_input_socket(1));
    converter.map_output_socket(get_output_socket(0), operation->get_output_socket(0));
  }
  else {
    ScreenLensDistortionOperation *operation = new ScreenLensDistortionOperation();
    operation->set_fit(data->fit);
    operation->set_jitter(data->jit);

    if (!get_input_socket(1)->is_linked()) {
      operation->set_distortion(get_input_socket(1)->get_editor_value_float());
    }
    if (!get_input_socket(2)->is_linked()) {
      operation->set_dispersion(get_input_socket(2)->get_editor_value_float());
    }

    converter.add_operation(operation);

    converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
    converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
    converter.map_input_socket(get_input_socket(2), operation->get_input_socket(2));
    converter.map_output_socket(get_output_socket(0), operation->get_output_socket(0));
  }
}

}  // namespace blender::compositor