| 5892 | } |
| 5893 | |
| 5894 | void CEditor::RenderEnvelopeEditorColorBar(CUIRect ColorBar, const std::shared_ptr<CEnvelope> &pEnvelope) |
| 5895 | { |
| 5896 | if(pEnvelope->m_vPoints.size() < 2) |
| 5897 | { |
| 5898 | return; |
| 5899 | } |
| 5900 | const float ViewStartTime = ScreenToEnvelopeX(ColorBar, ColorBar.x); |
| 5901 | const float ViewEndTime = ScreenToEnvelopeX(ColorBar, ColorBar.x + ColorBar.w); |
| 5902 | if(ViewEndTime < 0.0f || ViewStartTime > pEnvelope->EndTime()) |
| 5903 | { |
| 5904 | return; |
| 5905 | } |
| 5906 | const float StartX = maximum(EnvelopeToScreenX(ColorBar, 0.0f), ColorBar.x); |
| 5907 | const float TotalWidth = minimum(EnvelopeToScreenX(ColorBar, pEnvelope->EndTime()) - StartX, ColorBar.x + ColorBar.w - StartX); |
| 5908 | |
| 5909 | Ui()->ClipEnable(&ColorBar); |
| 5910 | CUIRect ColorBarBackground = CUIRect{StartX, ColorBar.y, TotalWidth, ColorBar.h}; |
| 5911 | RenderBackground(ColorBarBackground, m_CheckerTexture, ColorBarBackground.h, 1.0f); |
| 5912 | Graphics()->TextureClear(); |
| 5913 | Graphics()->QuadsBegin(); |
| 5914 | |
| 5915 | int PointBeginIndex = pEnvelope->FindPointIndex(CFixedTime::FromSeconds(ViewStartTime)); |
| 5916 | if(PointBeginIndex == -1) |
| 5917 | { |
| 5918 | PointBeginIndex = 0; |
| 5919 | } |
| 5920 | int PointEndIndex = pEnvelope->FindPointIndex(CFixedTime::FromSeconds(ViewEndTime)); |
| 5921 | if(PointEndIndex == -1) |
| 5922 | { |
| 5923 | PointEndIndex = (int)pEnvelope->m_vPoints.size() - 2; |
| 5924 | } |
| 5925 | for(int PointIndex = PointBeginIndex; PointIndex <= PointEndIndex; PointIndex++) |
| 5926 | { |
| 5927 | const auto &PointStart = pEnvelope->m_vPoints[PointIndex]; |
| 5928 | const auto &PointEnd = pEnvelope->m_vPoints[PointIndex + 1]; |
| 5929 | const float PointStartTime = PointStart.m_Time.AsSeconds(); |
| 5930 | const float PointEndTime = PointEnd.m_Time.AsSeconds(); |
| 5931 | |
| 5932 | int Steps; |
| 5933 | if(PointStart.m_Curvetype == CURVETYPE_LINEAR || PointStart.m_Curvetype == CURVETYPE_STEP) |
| 5934 | { |
| 5935 | Steps = 1; // let the GPU do the work |
| 5936 | } |
| 5937 | else |
| 5938 | { |
| 5939 | const float ClampedPointStartX = maximum(EnvelopeToScreenX(ColorBar, PointStartTime), ColorBar.x); |
| 5940 | const float ClampedPointEndX = minimum(EnvelopeToScreenX(ColorBar, PointEndTime), ColorBar.x + ColorBar.w); |
| 5941 | Steps = std::clamp((int)std::sqrt(5.0f * (ClampedPointEndX - ClampedPointStartX)), 1, 250); |
| 5942 | } |
| 5943 | const float OverallSectionStartTime = Steps == 1 ? PointStartTime : maximum(PointStartTime, ViewStartTime); |
| 5944 | const float OverallSectionEndTime = Steps == 1 ? PointEndTime : minimum(PointEndTime, ViewEndTime); |
| 5945 | float SectionStartTime = OverallSectionStartTime; |
| 5946 | float SectionStartX = EnvelopeToScreenX(ColorBar, SectionStartTime); |
| 5947 | for(int Step = 1; Step <= Steps; Step++) |
| 5948 | { |
| 5949 | const float SectionEndTime = OverallSectionStartTime + (OverallSectionEndTime - OverallSectionStartTime) * (Step / (float)Steps); |
| 5950 | const float SectionEndX = EnvelopeToScreenX(ColorBar, SectionEndTime); |
| 5951 |
nothing calls this directly
no test coverage detected