| 245 | } |
| 246 | |
| 247 | void CRenderMap::RenderEvalEnvelope(const IEnvelopePointAccess *pPoints, std::chrono::nanoseconds TimeNanos, ColorRGBA &Result, size_t Channels) |
| 248 | { |
| 249 | const int NumPoints = pPoints->NumPoints(); |
| 250 | if(NumPoints == 0) |
| 251 | { |
| 252 | return; |
| 253 | } |
| 254 | |
| 255 | if(NumPoints == 1) |
| 256 | { |
| 257 | const CEnvPoint *pFirstPoint = pPoints->GetPoint(0); |
| 258 | for(size_t c = 0; c < Channels; c++) |
| 259 | { |
| 260 | Result[c] = fx2f(pFirstPoint->m_aValues[c]); |
| 261 | } |
| 262 | return; |
| 263 | } |
| 264 | |
| 265 | const CEnvPoint *pLastPoint = pPoints->GetPoint(NumPoints - 1); |
| 266 | const int64_t MaxPointTime = (int64_t)pLastPoint->m_Time.GetInternal() * std::chrono::nanoseconds(1ms).count(); |
| 267 | if(MaxPointTime > 0) // TODO: remove this check when implementing a IO check for maps(in this case broken envelopes) |
| 268 | TimeNanos = std::chrono::nanoseconds(TimeNanos.count() % MaxPointTime); |
| 269 | else |
| 270 | TimeNanos = decltype(TimeNanos)::zero(); |
| 271 | |
| 272 | const double TimeMillis = TimeNanos.count() / (double)std::chrono::nanoseconds(1ms).count(); |
| 273 | |
| 274 | int FoundIndex = pPoints->FindPointIndex(CFixedTime(TimeMillis)); |
| 275 | if(FoundIndex == -1) |
| 276 | { |
| 277 | for(size_t c = 0; c < Channels; c++) |
| 278 | { |
| 279 | Result[c] = fx2f(pLastPoint->m_aValues[c]); |
| 280 | } |
| 281 | return; |
| 282 | } |
| 283 | |
| 284 | const CEnvPoint *pCurrentPoint = pPoints->GetPoint(FoundIndex); |
| 285 | const CEnvPoint *pNextPoint = pPoints->GetPoint(FoundIndex + 1); |
| 286 | |
| 287 | const CFixedTime Delta = pNextPoint->m_Time - pCurrentPoint->m_Time; |
| 288 | if(Delta <= CFixedTime(0)) |
| 289 | { |
| 290 | for(size_t c = 0; c < Channels; c++) |
| 291 | { |
| 292 | Result[c] = fx2f(pCurrentPoint->m_aValues[c]); |
| 293 | } |
| 294 | return; |
| 295 | } |
| 296 | |
| 297 | float a = (float)(TimeMillis - pCurrentPoint->m_Time.GetInternal()) / Delta.GetInternal(); |
| 298 | |
| 299 | switch(pCurrentPoint->m_Curvetype) |
| 300 | { |
| 301 | case CURVETYPE_STEP: |
| 302 | a = 0.0f; |
| 303 | break; |
| 304 |
nothing calls this directly
no test coverage detected