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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorOmar Emara <mail@OmarEmara.dev>2022-08-23 10:24:25 +0300
committerOmar Emara <mail@OmarEmara.dev>2022-08-23 10:24:25 +0300
commit655e9eabc3fe7d6ce868325999847823c86303ca (patch)
tree7e1438fa57ea1ada7770bdd94f1412265a6d8a45 /source
parent78061e6c3e74e932218fec0bad2911cc550ad41c (diff)
Cleanup: Turn filter node methods into an Enum
This patch turns the filter node methods into an enum and renames the members from FILT into FILTER for easier writing.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_node.h10
-rw-r--r--source/blender/compositor/nodes/COM_FilterNode.cc16
-rw-r--r--source/blender/makesdna/DNA_node_types.h12
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_filter.cc36
4 files changed, 38 insertions, 36 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index b42b9df510d..509de0620c6 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1326,16 +1326,6 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, i
#define CMP_CHAN_RGB 1
#define CMP_CHAN_A 2
-/* filter types */
-#define CMP_FILT_SOFT 0
-#define CMP_FILT_SHARP_BOX 1
-#define CMP_FILT_LAPLACE 2
-#define CMP_FILT_SOBEL 3
-#define CMP_FILT_PREWITT 4
-#define CMP_FILT_KIRSCH 5
-#define CMP_FILT_SHADOW 6
-#define CMP_FILT_SHARP_DIAMOND 7
-
/* scale node type, in custom1 */
#define CMP_SCALE_RELATIVE 0
#define CMP_SCALE_ABSOLUTE 1
diff --git a/source/blender/compositor/nodes/COM_FilterNode.cc b/source/blender/compositor/nodes/COM_FilterNode.cc
index f2efa8caefd..dce08b4cf2c 100644
--- a/source/blender/compositor/nodes/COM_FilterNode.cc
+++ b/source/blender/compositor/nodes/COM_FilterNode.cc
@@ -21,7 +21,7 @@ void FilterNode::convert_to_operations(NodeConverter &converter,
ConvolutionFilterOperation *operation = nullptr;
switch (this->get_bnode()->custom1) {
- case CMP_FILT_SOFT:
+ case CMP_NODE_FILTER_SOFT:
operation = new ConvolutionFilterOperation();
operation->set3x3Filter(1 / 16.0f,
2 / 16.0f,
@@ -33,11 +33,11 @@ void FilterNode::convert_to_operations(NodeConverter &converter,
2 / 16.0f,
1 / 16.0f);
break;
- case CMP_FILT_SHARP_BOX:
+ case CMP_NODE_FILTER_SHARP_BOX:
operation = new ConvolutionFilterOperation();
operation->set3x3Filter(-1, -1, -1, -1, 9, -1, -1, -1, -1);
break;
- case CMP_FILT_LAPLACE:
+ case CMP_NODE_FILTER_LAPLACE:
operation = new ConvolutionEdgeFilterOperation();
operation->set3x3Filter(-1 / 8.0f,
-1 / 8.0f,
@@ -49,23 +49,23 @@ void FilterNode::convert_to_operations(NodeConverter &converter,
-1 / 8.0f,
-1 / 8.0f);
break;
- case CMP_FILT_SOBEL:
+ case CMP_NODE_FILTER_SOBEL:
operation = new ConvolutionEdgeFilterOperation();
operation->set3x3Filter(1, 2, 1, 0, 0, 0, -1, -2, -1);
break;
- case CMP_FILT_PREWITT:
+ case CMP_NODE_FILTER_PREWITT:
operation = new ConvolutionEdgeFilterOperation();
operation->set3x3Filter(1, 1, 1, 0, 0, 0, -1, -1, -1);
break;
- case CMP_FILT_KIRSCH:
+ case CMP_NODE_FILTER_KIRSCH:
operation = new ConvolutionEdgeFilterOperation();
operation->set3x3Filter(5, 5, 5, -3, -3, -3, -2, -2, -2);
break;
- case CMP_FILT_SHADOW:
+ case CMP_NODE_FILTER_SHADOW:
operation = new ConvolutionFilterOperation();
operation->set3x3Filter(1, 2, 1, 0, 1, 0, -1, -2, -1);
break;
- case CMP_FILT_SHARP_DIAMOND:
+ case CMP_NODE_FILTER_SHARP_DIAMOND:
operation = new ConvolutionFilterOperation();
operation->set3x3Filter(0, -1, 0, -1, 5, -1, 0, -1, 0);
break;
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index b9161e918c0..3477105f519 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1881,6 +1881,18 @@ typedef enum CMPNodeFlipMode {
CMP_NODE_FLIP_X_Y = 2,
} CMPNodeFlipMode;
+/* Filter Node. Stored in custom1. */
+typedef enum CMPNodeFilterMethod {
+ CMP_NODE_FILTER_SOFT = 0,
+ CMP_NODE_FILTER_SHARP_BOX = 1,
+ CMP_NODE_FILTER_LAPLACE = 2,
+ CMP_NODE_FILTER_SOBEL = 3,
+ CMP_NODE_FILTER_PREWITT = 4,
+ CMP_NODE_FILTER_KIRSCH = 5,
+ CMP_NODE_FILTER_SHADOW = 6,
+ CMP_NODE_FILTER_SHARP_DIAMOND = 7,
+} CMPNodeFilterMethod;
+
/* Plane track deform node. */
enum {
diff --git a/source/blender/nodes/composite/nodes/node_composite_filter.cc b/source/blender/nodes/composite/nodes/node_composite_filter.cc
index 6551114a60c..250b3b468c3 100644
--- a/source/blender/nodes/composite/nodes/node_composite_filter.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_filter.cc
@@ -64,9 +64,9 @@ class FilterOperation : public NodeOperation {
GPU_shader_unbind();
}
- int get_filter_method()
+ CMPNodeFilterMethod get_filter_method()
{
- return bnode().custom1;
+ return (CMPNodeFilterMethod)bnode().custom1;
}
float3x3 get_filter_kernel()
@@ -75,41 +75,41 @@ class FilterOperation : public NodeOperation {
* return the kernel in the X direction, while the kernel in the Y direction will be computed
* inside the shader by transposing the kernel in the X direction. */
switch (get_filter_method()) {
- case CMP_FILT_SOFT: {
+ case CMP_NODE_FILTER_SOFT: {
const float kernel[3][3] = {{1.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f},
{2.0f / 16.0f, 4.0f / 16.0f, 2.0f / 16.0f},
{1.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f}};
return float3x3(kernel);
}
- case CMP_FILT_SHARP_BOX: {
+ case CMP_NODE_FILTER_SHARP_BOX: {
const float kernel[3][3] = {
{-1.0f, -1.0f, -1.0f}, {-1.0f, 9.0f, -1.0f}, {-1.0f, -1.0f, -1.0f}};
return float3x3(kernel);
}
- case CMP_FILT_LAPLACE: {
+ case CMP_NODE_FILTER_LAPLACE: {
const float kernel[3][3] = {{-1.0f / 8.0f, -1.0f / 8.0f, -1.0f / 8.0f},
{-1.0f / 8.0f, 1.0f, -1.0f / 8.0f},
{-1.0f / 8.0f, -1.0f / 8.0f, -1.0f / 8.0f}};
return float3x3(kernel);
}
- case CMP_FILT_SOBEL: {
+ case CMP_NODE_FILTER_SOBEL: {
const float kernel[3][3] = {{1.0f, 0.0f, -1.0f}, {2.0f, 0.0f, -2.0f}, {1.0f, 0.0f, -1.0f}};
return float3x3(kernel);
}
- case CMP_FILT_PREWITT: {
+ case CMP_NODE_FILTER_PREWITT: {
const float kernel[3][3] = {{1.0f, 0.0f, -1.0f}, {1.0f, 0.0f, -1.0f}, {1.0f, 0.0f, -1.0f}};
return float3x3(kernel);
}
- case CMP_FILT_KIRSCH: {
+ case CMP_NODE_FILTER_KIRSCH: {
const float kernel[3][3] = {
{5.0f, -3.0f, -2.0f}, {5.0f, -3.0f, -2.0f}, {5.0f, -3.0f, -2.0f}};
return float3x3(kernel);
}
- case CMP_FILT_SHADOW: {
+ case CMP_NODE_FILTER_SHADOW: {
const float kernel[3][3] = {{1.0f, 2.0f, 1.0f}, {0.0f, 1.0f, 0.0f}, {-1.0f, -2.0f, -1.0f}};
return float3x3(kernel);
}
- case CMP_FILT_SHARP_DIAMOND: {
+ case CMP_NODE_FILTER_SHARP_DIAMOND: {
const float kernel[3][3] = {
{0.0f, -1.0f, 0.0f}, {-1.0f, 5.0f, -1.0f}, {0.0f, -1.0f, 0.0f}};
return float3x3(kernel);
@@ -124,15 +124,15 @@ class FilterOperation : public NodeOperation {
const char *get_shader_name()
{
switch (get_filter_method()) {
- case CMP_FILT_LAPLACE:
- case CMP_FILT_SOBEL:
- case CMP_FILT_PREWITT:
- case CMP_FILT_KIRSCH:
+ case CMP_NODE_FILTER_LAPLACE:
+ case CMP_NODE_FILTER_SOBEL:
+ case CMP_NODE_FILTER_PREWITT:
+ case CMP_NODE_FILTER_KIRSCH:
return "compositor_edge_filter";
- case CMP_FILT_SOFT:
- case CMP_FILT_SHARP_BOX:
- case CMP_FILT_SHADOW:
- case CMP_FILT_SHARP_DIAMOND:
+ case CMP_NODE_FILTER_SOFT:
+ case CMP_NODE_FILTER_SHARP_BOX:
+ case CMP_NODE_FILTER_SHADOW:
+ case CMP_NODE_FILTER_SHARP_DIAMOND:
default:
return "compositor_filter";
}