| 4532 | }; |
| 4533 | |
| 4534 | void CEditor::UpdateHotEnvelopePoint(const CUIRect &View, const CEnvelope *pEnvelope, int ActiveChannels) |
| 4535 | { |
| 4536 | if(!Ui()->MouseInside(&View)) |
| 4537 | return; |
| 4538 | |
| 4539 | const vec2 MousePos = Ui()->MousePos(); |
| 4540 | |
| 4541 | float MinDist = 200.0f; |
| 4542 | const void *pMinPointId = nullptr; |
| 4543 | |
| 4544 | const auto UpdateMinimum = [&](vec2 Position, const void *pId) { |
| 4545 | const float CurrDist = length_squared(Position - MousePos); |
| 4546 | if(CurrDist < MinDist) |
| 4547 | { |
| 4548 | MinDist = CurrDist; |
| 4549 | pMinPointId = pId; |
| 4550 | } |
| 4551 | }; |
| 4552 | |
| 4553 | for(size_t i = 0; i < pEnvelope->m_vPoints.size(); i++) |
| 4554 | { |
| 4555 | for(int c = pEnvelope->GetChannels() - 1; c >= 0; c--) |
| 4556 | { |
| 4557 | if(!(ActiveChannels & (1 << c))) |
| 4558 | continue; |
| 4559 | |
| 4560 | if(i > 0 && pEnvelope->m_vPoints[i - 1].m_Curvetype == CURVETYPE_BEZIER) |
| 4561 | { |
| 4562 | vec2 Position; |
| 4563 | Position.x = EnvelopeToScreenX(View, (pEnvelope->m_vPoints[i].m_Time + pEnvelope->m_vPoints[i].m_Bezier.m_aInTangentDeltaX[c]).AsSeconds()); |
| 4564 | Position.y = EnvelopeToScreenY(View, fx2f(pEnvelope->m_vPoints[i].m_aValues[c] + pEnvelope->m_vPoints[i].m_Bezier.m_aInTangentDeltaY[c])); |
| 4565 | UpdateMinimum(Position, &pEnvelope->m_vPoints[i].m_Bezier.m_aInTangentDeltaX[c]); |
| 4566 | } |
| 4567 | |
| 4568 | if(i < pEnvelope->m_vPoints.size() - 1 && pEnvelope->m_vPoints[i].m_Curvetype == CURVETYPE_BEZIER) |
| 4569 | { |
| 4570 | vec2 Position; |
| 4571 | Position.x = EnvelopeToScreenX(View, (pEnvelope->m_vPoints[i].m_Time + pEnvelope->m_vPoints[i].m_Bezier.m_aOutTangentDeltaX[c]).AsSeconds()); |
| 4572 | Position.y = EnvelopeToScreenY(View, fx2f(pEnvelope->m_vPoints[i].m_aValues[c] + pEnvelope->m_vPoints[i].m_Bezier.m_aOutTangentDeltaY[c])); |
| 4573 | UpdateMinimum(Position, &pEnvelope->m_vPoints[i].m_Bezier.m_aOutTangentDeltaX[c]); |
| 4574 | } |
| 4575 | |
| 4576 | vec2 Position; |
| 4577 | Position.x = EnvelopeToScreenX(View, pEnvelope->m_vPoints[i].m_Time.AsSeconds()); |
| 4578 | Position.y = EnvelopeToScreenY(View, fx2f(pEnvelope->m_vPoints[i].m_aValues[c])); |
| 4579 | UpdateMinimum(Position, &pEnvelope->m_vPoints[i].m_aValues[c]); |
| 4580 | } |
| 4581 | } |
| 4582 | |
| 4583 | if(pMinPointId != nullptr) |
| 4584 | { |
| 4585 | Ui()->SetHotItem(pMinPointId); |
| 4586 | } |
| 4587 | } |
| 4588 | |
| 4589 | void CEditor::RenderEnvelopeEditor(CUIRect View) |
| 4590 | { |
nothing calls this directly
no test coverage detected