Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse timings in clips ignored when calling UsdStage.Flatten() #1116

Closed
benmalartre opened this issue Feb 13, 2020 · 2 comments
Closed

Reverse timings in clips ignored when calling UsdStage.Flatten() #1116

benmalartre opened this issue Feb 13, 2020 · 2 comments

Comments

@benmalartre
Copy link

Reverse Timings in clips are ignored when calling UsdStage.Flatten()

Steps to reproduce:

-reference an animated usd file (ex: Maneki USD Animated Model) and author a loop with forward and reverse timing in a anim_clips.usda:

#usda 1.0
(
    endTimeCode = 48
    startTimeCode = 1
    defaultPrim = "maneki"
)
over "maneki" (
  prepend references = @./maneki_anim.usd@
    clips = {
      dictionary default = {
        string primPath = "/manekineko"
        asset[] assetPaths = [@./maneki_anim.usd@]
        double2[] active = [(1, 0), (24, 0), (48, 0)]
        double2[] times = [(1, 1), (24, 24), (48, 1)]
      }
    }
)
{
}

-open in usdview : great it works!
-in usdview, File>Save Flattened As, create a new usd file : anim_clips_flat.usd
-open in usdview : reverse timings have disappeared !

What I have found
It seems that the problem come from here.

I can have it working by modifying this part to this:

    for (InternalTime t: timeSamplesInClip) {
        for (size_t i = 0; i < times.size() - 1; ++i) {
            const TimeMapping& m1 = times[i];
            const TimeMapping& m2 = times[i+1];

            // Ignore time mappings whose external time domain does not 
            // intersect the times at which this clip is active.
            InternalTime minTime = 
                (m1.internalTime <= m2.internalTime) ? 
                    m1.internalTime : m2.internalTime;
            InternalTime maxTime = 
                (m1.internalTime <= m2.internalTime) ? 
                    m2.internalTime : m1.internalTime;

            const GfInterval mappingInterval(minTime, maxTime);
            if (!mappingInterval.Intersects(clipTimeInterval)) {
                continue;
            }
            
            if (minTime <= t && t <= maxTime) {
                if (minTime == maxTime) {
                    timeSamples.insert(m1.externalTime);
                    timeSamples.insert(m2.externalTime);
                }
                else {
                    timeSamples.insert(_TranslateTimeToExternal(t, m1, m2));
                }
            }
        }
    }

I just send my Contributor License Agreement and will make a pull request when granted, if this make sense of course.

@jilliene
Copy link

Filed as internal issue #USD-5864

@sunyab
Copy link
Contributor

sunyab commented May 26, 2020

Hi @benmalartre, thank you for filing this issue! We had noticed this internally as well and just fixed it as part of a packet of work around value clips. The fix should be pushed up to the dev branch soon and will be included in the next USD release. I'm going to leave this issue open until then.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants