Merge pull request #6994 from Marmare314/adding-env-bug

Disallow adding overlapping envelope points
This commit is contained in:
Dennis Felsing 2023-08-10 20:21:26 +00:00 committed by GitHub
commit 6d4f1a65c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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),
f2fx(Channels.r), f2fx(Channels.g),
f2fx(Channels.b), f2fx(Channels.a));
if(Time < 0)
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(FixedTime < 0)
RemoveTimeOffsetEnvelope(pEnvelope);
m_Map.OnModify();
}