Skip to content

3.8 -> 4.2 版本转换在 rotate 处理上的行为不符合预期 #23

@Hajimary

Description

@Hajimary

在处理 RotateTimeline 的逻辑中:

  • 3.8
    float lastTotal, lastDiff;
    if (firstFrame) {
    lastTotal = 0;
    lastDiff = diff;
    } else {
    lastTotal = timelinesRotation[i]; // Angle and direction of mix, including loops.
    lastDiff = timelinesRotation[i + 1]; // Difference between bones.
    }
    bool current = diff > 0, dir = lastTotal >= 0;
    // Detect cross at 0 (not 180).
    if (MathUtil::sign(lastDiff) != MathUtil::sign(diff) && MathUtil::abs(lastDiff) <= 90) {
    // A cross after a 360 rotation is a loop.
    if (MathUtil::abs(lastTotal) > 180) lastTotal += 360 * MathUtil::sign(lastTotal);
    dir = current;
    }
    total = diff + lastTotal - MathUtil::fmod(lastTotal, 360); // Store loops as part of lastTotal.
    if (dir != current) {
    total += 360 * MathUtil::sign(lastTotal);
    }
    timelinesRotation[i] = total;
  • 4.2
    float lastTotal, lastDiff;
    if (firstFrame) {
    lastTotal = 0;
    lastDiff = diff;
    } else {
    lastTotal = timelinesRotation[i];
    lastDiff = timelinesRotation[i + 1];
    }
    float loops = lastTotal - MathUtil::fmod(lastTotal, 360.f);
    total = diff + loops;
    bool current = diff >= 0, dir = lastTotal >= 0;
    if (MathUtil::abs(lastDiff) <= 90 && MathUtil::sign(lastDiff) != MathUtil::sign(diff)) {
    if (MathUtil::abs(lastTotal - loops) > 180) {
    total += 360.f * MathUtil::sign(lastTotal);
    dir = current;
    } else if (loops != 0)
    total -= 360.f * MathUtil::sign(lastTotal);
    else
    dir = current;
    }
    if (dir != current) {
    total += 360 * MathUtil::sign(lastTotal);
    }
    timelinesRotation[i] = total;

两者在 处理序列 [0, 180, 0] 或者 [180, 0, 180] 的场合会有差异。

  • 在 3.8 上视为 [0,180, 360]
  • 在 4.2 上视为 [0, 180, 0]

而在读取/写入过程中,对于 rotate 的 timeline 并未专门进行处理,这会导致最终转换行为产生的动画效果并不相同。

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