Skip to content

I got a worng value because of the mismatch of current progress(float) and point(uint32) #46

@Wanxiaace

Description

@Wanxiaace
template<typename T> inline uint16_t tween<T>::pointAt(float progress) const {
    auto t = static_cast<uint32_t>(progress * total);// Cause uncertainty
    uint16_t point = 0;
    while (t > points.at(point).stacked) point++;
    if (point > 0 && t <= points.at(point - 1u).stacked) point--;
    return point;
}

and this one

template<typename T>
inline void tween<T>::interpolate(float prog, unsigned point, T & value) const {
    auto & p = points.at(point);
    //during fix
    auto pointDuration = /*uint32_t for origin*/lround(p.duration() - (p.stacked - (prog * static_cast<float>(total))));
    float pointTotal = static_cast<float>(pointDuration) / static_cast<float>(p.duration());
    if (pointTotal > 1.0f) pointTotal = 1.0f;
    auto easing = std::get<0>(p.easings);
    value = easing(pointTotal, std::get<0>(p.values), std::get<0>(points.at(point+1).values));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions