rlottie/trim: Fix trim segment calculation.

In AE start and end value can naver be -ve. but the final
start and end value after applting interpolator curve could be -ve.

So refactor to always take the -ve value into account.
This commit is contained in:
subhransu mohanty 2019-05-23 09:54:16 +09:00 committed by Subhransu
parent 0fa16936d1
commit 281d3f3a00

View File

@ -768,10 +768,6 @@ public:
if (vCompare(diff, 0.0f)) return Segment(0, 0); if (vCompare(diff, 0.0f)) return Segment(0, 0);
if (vCompare(diff, 1.0f)) return Segment(0, 1); if (vCompare(diff, 1.0f)) return Segment(0, 1);
// no offset case
if (vCompare(fabs(offset), 0.0f)) {
return noloop(start, end);
} else {
if (offset > 0) { if (offset > 0) {
start += offset; start += offset;
end += offset; end += offset;
@ -789,23 +785,26 @@ public:
if (start >= 0 && end >= 0) { if (start >= 0 && end >= 0) {
return noloop(start, end); return noloop(start, end);
} else if (start < 0 && end < 0) { } else if (start < 0 && end < 0) {
return noloop(-start, -end); return noloop(1 + start, 1 + end);
} else { } else {
if (start < 0) return loop(1 + start, end); if (start < 0) return loop(1 + start, end);
else return loop(start , 1 + end); else return loop(start , 1 + end);
} }
} }
} }
}
LOTTrimData::TrimType type() const {return mTrimType;} LOTTrimData::TrimType type() const {return mTrimType;}
private: private:
Segment noloop(float start, float end) const{ Segment noloop(float start, float end) const{
assert(start >= 0);
assert(end >= 0);
Segment s; Segment s;
s.start = std::min(start, end); s.start = std::min(start, end);
s.end = std::max(start, end); s.end = std::max(start, end);
return s; return s;
} }
Segment loop(float start, float end) const{ Segment loop(float start, float end) const{
assert(start >= 0);
assert(end >= 0);
Segment s; Segment s;
s.start = std::max(start, end); s.start = std::max(start, end);
s.end = std::min(start, end); s.end = std::min(start, end);