| 889 | } |
| 890 | |
| 891 | void VisjectExecutor::ProcessGroupTools(Box* box, Node* node, Value& value) |
| 892 | { |
| 893 | switch (node->TypeID) |
| 894 | { |
| 895 | // Color Gradient |
| 896 | case 10: |
| 897 | { |
| 898 | float time, prevTime, curTime; |
| 899 | Color prevColor, curColor; |
| 900 | const int32 count = (int32)node->Values[0]; |
| 901 | switch (count) |
| 902 | { |
| 903 | case 0: |
| 904 | // No sample |
| 905 | value = Value::Zero; |
| 906 | break; |
| 907 | case 1: |
| 908 | // Single sample |
| 909 | value = (Color)node->Values[2]; |
| 910 | break; |
| 911 | case 2: |
| 912 | // Linear blend between 2 samples |
| 913 | time = (float)tryGetValue(node->GetBox(0), Value::Zero); |
| 914 | prevTime = (float)node->Values[1]; |
| 915 | prevColor = (Color)node->Values[2]; |
| 916 | curTime = (float)node->Values[3]; |
| 917 | curColor = (Color)node->Values[4]; |
| 918 | value = Color::Lerp(prevColor, curColor, Math::Saturate((time - prevTime) / (curTime - prevTime))); |
| 919 | break; |
| 920 | default: |
| 921 | time = (float)tryGetValue(node->GetBox(0), Value::Zero); |
| 922 | if (time >= node->Values[1 + count * 2 - 2].AsFloat) |
| 923 | { |
| 924 | // Outside the range |
| 925 | value = (Color)node->Values[1 + count * 2 - 2 + 1]; |
| 926 | } |
| 927 | else |
| 928 | { |
| 929 | // Find 2 samples to blend between them |
| 930 | prevTime = (float)node->Values[1]; |
| 931 | prevColor = (Color)node->Values[2]; |
| 932 | for (int32 i = 1; i < count; i++) |
| 933 | { |
| 934 | curTime = (float)node->Values[i * 2 + 1]; |
| 935 | curColor = (Color)node->Values[i * 2 + 2]; |
| 936 | |
| 937 | if (time <= curTime) |
| 938 | { |
| 939 | value = Color::Lerp(prevColor, curColor, Math::Saturate((time - prevTime) / (curTime - prevTime))); |
| 940 | break; |
| 941 | } |
| 942 | |
| 943 | prevTime = curTime; |
| 944 | prevColor = curColor; |
| 945 | } |
| 946 | } |
| 947 | break; |
| 948 | } |
nothing calls this directly
no test coverage detected