SamplingTime GetOutputPlayTime(DebugMemory debugMemory, SamplingTime samplingTime, SamplingTime closestMatch, DebugIdentifier outputTimeIdentifier)
        {
            if (!closestMatch.IsValid)
            {
                return(samplingTime);
            }

            int playAtTimeTypeCode = BurstRuntime.GetHashCode32 <PlayAtTimeDebug>();

            for (DebugReference reference = debugMemory.FirstOrDefault; reference.IsValid; reference = debugMemory.Next(reference))
            {
                if (reference.identifier.typeHashCode != playAtTimeTypeCode)
                {
                    continue;
                }

                PlayAtTimeDebug playAtTime = debugMemory.ReadObject <PlayAtTimeDebug>(reference);
                if (playAtTime.playTime.Equals(outputTimeIdentifier))
                {
                    return(closestMatch);
                }
            }

            return(samplingTime);
        }
Esempio n. 2
0
        /// <summary>
        /// Switches the pose generation stream to read
        /// from the sampling time passed as argument.
        /// </summary>
        /// <remarks>
        /// Animation poses are always generated continuously
        /// based on a time index. This method allows to switch
        /// to a new starting time. The motion synthesizer automatically
        /// handles any discrepancies between the old and the new pose.
        /// </remarks>
        /// <param name="samplingTime">New sampling time for the pose generation.</param>
        public void PlayAtTime(SamplingTime samplingTime)
        {
            DebugWriteBlittableObject(ref samplingTime);
            PlayAtTimeDebug playAtTimeDebug = new PlayAtTimeDebug()
            {
                playTime = samplingTime.debugIdentifier
            };

            DebugWriteBlittableObject(ref playAtTimeDebug);

            samplingTime.debugIdentifier = DebugIdentifier.Invalid;

            if (updateInProgress)
            {
                delayedPushTime = samplingTime.timeIndex;
            }
            else
            {
                ref Binary binary = ref Binary;

                if (!binary.IsValid(samplingTime))
                {
                    throw new ArgumentException("Invalid sampling time passed as argument");
                }

                if (!Time.timeIndex.Equals(samplingTime.timeIndex))
                {
                    this.samplingTime = samplingTime;

                    poseGenerator.TriggerTransition();
                }

                Assert.IsTrue(binary.IsValid(Time));

                lastSamplingTime = TimeIndex.Invalid;
            }