From 17578408434fafd2463ed253eebb5cb1412a6c67 Mon Sep 17 00:00:00 2001 From: Johnny Matthews Date: Wed, 1 Dec 2021 09:36:25 -0600 Subject: Geometry Nodes: Generalized Compare Node Replace compare floats node with a generalized compare node. The node allows for the comparison of float, int, string, color, and vector. The datatypes support the following operators: Float, Int: <, >, <=, >=, ==, != String: ==, != Color: ==, !=, lighter, darker (using rgb_to_grayscale value as the brightness value) Vector Supports 5 comparison modes for: ==, !=, <, >, <=, >= Average: The average of the components of the vectors are compared. Dot Product: The dot product of the vectors are compared. Direction: The angle between the vectors is compared to an angle Element-wise: The individual components of the vectors are compared. Length: The lengths of the vectors are compared. Differential Revision: https://developer.blender.org/D13228 --- .../nodes/legacy/node_geo_legacy_attribute_compare.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/nodes/geometry') diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_compare.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_compare.cc index e64f41cca72..03ff5327628 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_compare.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_compare.cc @@ -52,7 +52,7 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) { NodeAttributeCompare *data = (NodeAttributeCompare *)MEM_callocN(sizeof(NodeAttributeCompare), __func__); - data->operation = NODE_FLOAT_COMPARE_GREATER_THAN; + data->operation = NODE_COMPARE_GREATER_THAN; data->input_type_a = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE; data->input_type_b = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE; node->storage = data; @@ -60,7 +60,7 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) static bool operation_tests_equality(const NodeAttributeCompare &node_storage) { - return ELEM(node_storage.operation, NODE_FLOAT_COMPARE_EQUAL, NODE_FLOAT_COMPARE_NOT_EQUAL); + return ELEM(node_storage.operation, NODE_COMPARE_EQUAL, NODE_COMPARE_NOT_EQUAL); } static void node_update(bNodeTree *ntree, bNode *node) @@ -77,7 +77,7 @@ static void node_update(bNodeTree *ntree, bNode *node) static void do_math_operation(const VArray &input_a, const VArray &input_b, - const FloatCompareOperation operation, + const NodeCompareOperation operation, MutableSpan span_result) { const int size = input_a.size(); @@ -241,7 +241,7 @@ static void attribute_compare_calc(GeometryComponent &component, const GeoNodeEx { const bNode &node = params.node(); NodeAttributeCompare *node_storage = (NodeAttributeCompare *)node.storage; - const FloatCompareOperation operation = static_cast( + const NodeCompareOperation operation = static_cast( node_storage->operation); const std::string result_name = params.get_input("Result"); @@ -271,7 +271,7 @@ static void attribute_compare_calc(GeometryComponent &component, const GeoNodeEx * conversions and float comparison. In other words, the comparison is not element-wise. */ if (operation_tests_equality(*node_storage)) { const float threshold = params.get_input("Threshold"); - if (operation == NODE_FLOAT_COMPARE_EQUAL) { + if (operation == NODE_COMPARE_EQUAL) { if (input_data_type == CD_PROP_FLOAT) { do_equal_operation_float( attribute_a.typed(), attribute_b.typed(), threshold, result_span); @@ -291,7 +291,7 @@ static void attribute_compare_calc(GeometryComponent &component, const GeoNodeEx attribute_a.typed(), attribute_b.typed(), threshold, result_span); } } - else if (operation == NODE_FLOAT_COMPARE_NOT_EQUAL) { + else if (operation == NODE_COMPARE_NOT_EQUAL) { if (input_data_type == CD_PROP_FLOAT) { do_not_equal_operation_float( attribute_a.typed(), attribute_b.typed(), threshold, result_span); -- cgit v1.2.3