Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc
| Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | static void do_equal_operation_float3(const VArray<float3> &input_a, | ||||
| const int size = input_a.size(); | const int size = input_a.size(); | ||||
| for (const int i : IndexRange(size)) { | for (const int i : IndexRange(size)) { | ||||
| const float3 a = input_a[i]; | const float3 a = input_a[i]; | ||||
| const float3 b = input_b[i]; | const float3 b = input_b[i]; | ||||
| span_result[i] = len_squared_v3v3(a, b) < threshold_squared; | span_result[i] = len_squared_v3v3(a, b) < threshold_squared; | ||||
| } | } | ||||
| } | } | ||||
| static void do_equal_operation_color4f(const VArray<Color4f> &input_a, | static void do_equal_operation_color4f(const VArray<ColorGeometry4f> &input_a, | ||||
| const VArray<Color4f> &input_b, | const VArray<ColorGeometry4f> &input_b, | ||||
| const float threshold, | const float threshold, | ||||
| MutableSpan<bool> span_result) | MutableSpan<bool> span_result) | ||||
| { | { | ||||
| const float threshold_squared = pow2f(threshold); | const float threshold_squared = pow2f(threshold); | ||||
| const int size = input_a.size(); | const int size = input_a.size(); | ||||
| for (const int i : IndexRange(size)) { | for (const int i : IndexRange(size)) { | ||||
| const Color4f a = input_a[i]; | const ColorGeometry4f a = input_a[i]; | ||||
| const Color4f b = input_b[i]; | const ColorGeometry4f b = input_b[i]; | ||||
| span_result[i] = len_squared_v4v4(a, b) < threshold_squared; | span_result[i] = len_squared_v4v4(a, b) < threshold_squared; | ||||
| } | } | ||||
| } | } | ||||
| static void do_equal_operation_bool(const VArray<bool> &input_a, | static void do_equal_operation_bool(const VArray<bool> &input_a, | ||||
| const VArray<bool> &input_b, | const VArray<bool> &input_b, | ||||
| const float UNUSED(threshold), | const float UNUSED(threshold), | ||||
| MutableSpan<bool> span_result) | MutableSpan<bool> span_result) | ||||
| Show All 28 Lines | static void do_not_equal_operation_float3(const VArray<float3> &input_a, | ||||
| const int size = input_a.size(); | const int size = input_a.size(); | ||||
| for (const int i : IndexRange(size)) { | for (const int i : IndexRange(size)) { | ||||
| const float3 a = input_a[i]; | const float3 a = input_a[i]; | ||||
| const float3 b = input_b[i]; | const float3 b = input_b[i]; | ||||
| span_result[i] = len_squared_v3v3(a, b) >= threshold_squared; | span_result[i] = len_squared_v3v3(a, b) >= threshold_squared; | ||||
| } | } | ||||
| } | } | ||||
| static void do_not_equal_operation_color4f(const VArray<Color4f> &input_a, | static void do_not_equal_operation_color4f(const VArray<ColorGeometry4f> &input_a, | ||||
| const VArray<Color4f> &input_b, | const VArray<ColorGeometry4f> &input_b, | ||||
| const float threshold, | const float threshold, | ||||
| MutableSpan<bool> span_result) | MutableSpan<bool> span_result) | ||||
| { | { | ||||
| const float threshold_squared = pow2f(threshold); | const float threshold_squared = pow2f(threshold); | ||||
| const int size = input_a.size(); | const int size = input_a.size(); | ||||
| for (const int i : IndexRange(size)) { | for (const int i : IndexRange(size)) { | ||||
| const Color4f a = input_a[i]; | const ColorGeometry4f a = input_a[i]; | ||||
| const Color4f b = input_b[i]; | const ColorGeometry4f b = input_b[i]; | ||||
| span_result[i] = len_squared_v4v4(a, b) >= threshold_squared; | span_result[i] = len_squared_v4v4(a, b) >= threshold_squared; | ||||
| } | } | ||||
| } | } | ||||
| static void do_not_equal_operation_bool(const VArray<bool> &input_a, | static void do_not_equal_operation_bool(const VArray<bool> &input_a, | ||||
| const VArray<bool> &input_b, | const VArray<bool> &input_b, | ||||
| const float UNUSED(threshold), | const float UNUSED(threshold), | ||||
| MutableSpan<bool> span_result) | MutableSpan<bool> span_result) | ||||
| ▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | if (operation == NODE_FLOAT_COMPARE_EQUAL) { | ||||
| do_equal_operation_float( | do_equal_operation_float( | ||||
| attribute_a->typed<float>(), attribute_b->typed<float>(), threshold, result_span); | attribute_a->typed<float>(), attribute_b->typed<float>(), threshold, result_span); | ||||
| } | } | ||||
| else if (input_data_type == CD_PROP_FLOAT3) { | else if (input_data_type == CD_PROP_FLOAT3) { | ||||
| do_equal_operation_float3( | do_equal_operation_float3( | ||||
| attribute_a->typed<float3>(), attribute_b->typed<float3>(), threshold, result_span); | attribute_a->typed<float3>(), attribute_b->typed<float3>(), threshold, result_span); | ||||
| } | } | ||||
| else if (input_data_type == CD_PROP_COLOR) { | else if (input_data_type == CD_PROP_COLOR) { | ||||
| do_equal_operation_color4f( | do_equal_operation_color4f(attribute_a->typed<ColorGeometry4f>(), | ||||
| attribute_a->typed<Color4f>(), attribute_b->typed<Color4f>(), threshold, result_span); | attribute_b->typed<ColorGeometry4f>(), | ||||
| threshold, | |||||
| result_span); | |||||
| } | } | ||||
| else if (input_data_type == CD_PROP_BOOL) { | else if (input_data_type == CD_PROP_BOOL) { | ||||
| do_equal_operation_bool( | do_equal_operation_bool( | ||||
| attribute_a->typed<bool>(), attribute_b->typed<bool>(), threshold, result_span); | attribute_a->typed<bool>(), attribute_b->typed<bool>(), threshold, result_span); | ||||
| } | } | ||||
| } | } | ||||
| else if (operation == NODE_FLOAT_COMPARE_NOT_EQUAL) { | else if (operation == NODE_FLOAT_COMPARE_NOT_EQUAL) { | ||||
| if (input_data_type == CD_PROP_FLOAT) { | if (input_data_type == CD_PROP_FLOAT) { | ||||
| do_not_equal_operation_float( | do_not_equal_operation_float( | ||||
| attribute_a->typed<float>(), attribute_b->typed<float>(), threshold, result_span); | attribute_a->typed<float>(), attribute_b->typed<float>(), threshold, result_span); | ||||
| } | } | ||||
| else if (input_data_type == CD_PROP_FLOAT3) { | else if (input_data_type == CD_PROP_FLOAT3) { | ||||
| do_not_equal_operation_float3( | do_not_equal_operation_float3( | ||||
| attribute_a->typed<float3>(), attribute_b->typed<float3>(), threshold, result_span); | attribute_a->typed<float3>(), attribute_b->typed<float3>(), threshold, result_span); | ||||
| } | } | ||||
| else if (input_data_type == CD_PROP_COLOR) { | else if (input_data_type == CD_PROP_COLOR) { | ||||
| do_not_equal_operation_color4f( | do_not_equal_operation_color4f(attribute_a->typed<ColorGeometry4f>(), | ||||
| attribute_a->typed<Color4f>(), attribute_b->typed<Color4f>(), threshold, result_span); | attribute_b->typed<ColorGeometry4f>(), | ||||
| threshold, | |||||
| result_span); | |||||
| } | } | ||||
| else if (input_data_type == CD_PROP_BOOL) { | else if (input_data_type == CD_PROP_BOOL) { | ||||
| do_not_equal_operation_bool( | do_not_equal_operation_bool( | ||||
| attribute_a->typed<bool>(), attribute_b->typed<bool>(), threshold, result_span); | attribute_a->typed<bool>(), attribute_b->typed<bool>(), threshold, result_span); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines | |||||