Disallow adding overlapping envelope points

Also now round is used to convert the mouse position to fixed
precision time which places the added point closer to the mouse position.
This commit is contained in:
marmare314 2023-08-10 08:38:10 +02:00
parent 2ea102ac9f
commit 93332af243

View file

@ -6299,11 +6299,21 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
pEnvelope->Eval(Time, Channels);
else
Channels = {0, 0, 0, 0};
pEnvelope->AddPoint(f2fxt(Time),
int FixedTime = std::round(Time * 1000.0f);
bool TimeFound = false;
for(CEnvPoint &Point : pEnvelope->m_vPoints)
{
if(Point.m_Time == FixedTime)
TimeFound = true;
}
if(!TimeFound)
pEnvelope->AddPoint(FixedTime,
f2fx(Channels.r), f2fx(Channels.g),
f2fx(Channels.b), f2fx(Channels.a));
if(Time < 0)
if(FixedTime < 0)
RemoveTimeOffsetEnvelope(pEnvelope);
m_Map.OnModify();
}