Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/NOD_math_functions.hh
| Show First 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | inline bool try_dispatch_float_math_fl_fl_fl_to_fl(const int operation, Callback &&callback) | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /** | /** | ||||
| * This is similar to try_dispatch_float_math_fl_to_fl, just with a different callback signature. | * This is similar to try_dispatch_float_math_fl_to_fl, just with a different callback signature. | ||||
| */ | */ | ||||
| template<typename Callback> | template<typename Callback> | ||||
| inline bool try_dispatch_float_math_fl_fl_to_bool(const FloatCompareOperation operation, | inline bool try_dispatch_float_math_fl_fl_to_bool(const NodeCompareOperation operation, | ||||
| Callback &&callback) | Callback &&callback) | ||||
| { | { | ||||
| const FloatMathOperationInfo *info = get_float_compare_operation_info(operation); | const FloatMathOperationInfo *info = get_float_compare_operation_info(operation); | ||||
| if (info == nullptr) { | if (info == nullptr) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* This is just an utility function to keep the individual cases smaller. */ | /* This is just an utility function to keep the individual cases smaller. */ | ||||
| auto dispatch = [&](auto math_function) -> bool { | auto dispatch = [&](auto math_function) -> bool { | ||||
| callback(math_function, *info); | callback(math_function, *info); | ||||
| return true; | return true; | ||||
| }; | }; | ||||
| switch (operation) { | switch (operation) { | ||||
| case NODE_FLOAT_COMPARE_LESS_THAN: | case NODE_COMPARE_LESS_THAN: | ||||
| return dispatch([](float a, float b) { return a < b; }); | return dispatch([](float a, float b) { return a < b; }); | ||||
| case NODE_FLOAT_COMPARE_LESS_EQUAL: | case NODE_COMPARE_LESS_EQUAL: | ||||
| return dispatch([](float a, float b) { return a <= b; }); | return dispatch([](float a, float b) { return a <= b; }); | ||||
| case NODE_FLOAT_COMPARE_GREATER_THAN: | case NODE_COMPARE_GREATER_THAN: | ||||
| return dispatch([](float a, float b) { return a > b; }); | return dispatch([](float a, float b) { return a > b; }); | ||||
| case NODE_FLOAT_COMPARE_GREATER_EQUAL: | case NODE_COMPARE_GREATER_EQUAL: | ||||
| return dispatch([](float a, float b) { return a >= b; }); | return dispatch([](float a, float b) { return a >= b; }); | ||||
| default: | default: | ||||
| return false; | return false; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /** | /** | ||||
| ▲ Show 20 Lines • Show All 256 Lines • Show Last 20 Lines | |||||