Blender  V3.3
COM_MaskNode.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2012 Blender Foundation. */
3 
4 #include "COM_MaskNode.h"
5 #include "COM_MaskOperation.h"
6 
7 namespace blender::compositor {
8 
9 MaskNode::MaskNode(bNode *editor_node) : Node(editor_node)
10 {
11  /* pass */
12 }
13 
15  const CompositorContext &context) const
16 {
17  const RenderData *rd = context.get_render_data();
18  const float render_size_factor = context.get_render_percentage_as_factor();
19 
20  NodeOutput *output_mask = this->get_output_socket(0);
21 
22  bNode *editor_node = this->get_bnode();
23  NodeMask *data = (NodeMask *)editor_node->storage;
24  Mask *mask = (Mask *)editor_node->id;
25 
26  /* Always connect the output image. */
27  MaskOperation *operation = new MaskOperation();
28 
29  if (editor_node->custom1 & CMP_NODEFLAG_MASK_FIXED) {
30  operation->set_mask_width(data->size_x);
31  operation->set_mask_height(data->size_y);
32  }
33  else if (editor_node->custom1 & CMP_NODEFLAG_MASK_FIXED_SCENE) {
34  operation->set_mask_width(data->size_x * render_size_factor);
35  operation->set_mask_height(data->size_y * render_size_factor);
36  }
37  else {
38  operation->set_mask_width(rd->xsch * render_size_factor);
39  operation->set_mask_height(rd->ysch * render_size_factor);
40  }
41 
42  operation->set_mask(mask);
43  operation->set_framenumber(context.get_framenumber());
44  operation->set_feather((bool)(editor_node->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0);
45 
46  if ((editor_node->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) && (editor_node->custom2 > 1) &&
47  (editor_node->custom3 > FLT_EPSILON)) {
48  operation->set_motion_blur_samples(editor_node->custom2);
49  operation->set_motion_blur_shutter(editor_node->custom3);
50  }
51 
52  converter.add_operation(operation);
53  converter.map_output_socket(output_mask, operation->get_output_socket());
54 }
55 
56 } // namespace blender::compositor
@ CMP_NODEFLAG_MASK_FIXED_SCENE
@ CMP_NODEFLAG_MASK_NO_FEATHER
@ CMP_NODEFLAG_MASK_FIXED
@ CMP_NODEFLAG_MASK_MOTION_BLUR
Overall context of the compositor.
MaskNode(bNode *editor_node)
Definition: COM_MaskNode.cc:9
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
Definition: COM_MaskNode.cc:14
void set_motion_blur_shutter(float shutter)
void set_framenumber(int frame_number)
void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
void add_operation(NodeOperation *operation)
NodeOperationOutput * get_output_socket(unsigned int index=0)
NodeOutput are sockets that can send data/input.
Definition: COM_Node.h:238
NodeOutput * get_output_socket(unsigned int index=0) const
Definition: COM_Node.cc:84
bNode * get_bnode() const
get the reference to the SDNA bNode struct
Definition: COM_Node.h:64
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
short custom1
struct ID * id
void * storage
short custom2
float custom3