public void Draw(Camera camera, ref MotionSynthesizer synthesizer, DebugMemory debugMemory, SamplingTime debugSamplingTime, ref DebugDrawOptions options)
        {
            if (!playTime.IsValid)
            {
                return;
            }

            SamplingTime samplingTime = debugMemory.ReadObjectFromIdentifier <SamplingTime>(playTime);
            string       text         = synthesizer.Binary.GetFragmentDebugText(samplingTime, "Play Clip", options.timeOffset);

            DebugDraw.SetMovableTextTitle(options.textWindowIdentifier, "Play At Time");
            DebugDraw.AddMovableTextLine(options.textWindowIdentifier, text, options.inputOutputFragTextColor);

            DebugDraw.DrawFragment(ref synthesizer, samplingTime, options.inputOutputFragmentColor, options.timeOffset, synthesizer.WorldRootTransform);
        }
        public void Draw(Camera camera, ref MotionSynthesizer synthesizer, DebugMemory debugMemory, SamplingTime debugSamplingTime, ref DebugDrawOptions options)
        {
            int fragmentSlot = 0;

            DebugDraw.SetMovableTextTitle(options.textWindowIdentifier, DebugWindowTitle);

            DeviationTable deviationTable = this.deviationTable.IsValid ? debugMemory.ReadObjectFromIdentifier <DeviationTable>(this.deviationTable) : DeviationTable.CreateInvalid();

            SamplingTime samplingTime = GetSamplingTime(debugMemory, this.samplingTime);

            if (samplingTime.IsValid)
            {
                if ((options.drawFlags & DebugDrawFlags.InputFragment) > 0)
                {
                    DebugDraw.DrawFragment(ref synthesizer, samplingTime, options.inputOutputFragmentColor, options.timeOffset, synthesizer.WorldRootTransform);
                    ++fragmentSlot;
                }
                DebugDraw.AddMovableTextLine(options.textWindowIdentifier, GetFragmentDebugText(ref synthesizer, "Input Clip", samplingTime, options.timeOffset, ref deviationTable), options.inputOutputFragTextColor);
            }

            SamplingTime    closestMatch         = GetSamplingTime(debugMemory, this.closestMatch);
            DebugIdentifier outputTimeIdentifier = this.closestMatch;

            if (closestMatch.IsValid)
            {
                if ((options.drawFlags & DebugDrawFlags.BestFragment) > 0)
                {
                    DebugDraw.DrawFragment(ref synthesizer, closestMatch, options.bestFragmentColor, options.timeOffset, GetAnchor(synthesizer.WorldRootTransform, fragmentSlot++ *options.distanceOffset, camera));

                    DebugDraw.AddMovableTextLine(options.textWindowIdentifier, GetFragmentDebugText(ref synthesizer, "Best Match Fragment", closestMatch, options.timeOffset, ref deviationTable), options.bestFragTextColor);
                    if (maxDeviation >= 0.0f)
                    {
                        string deviationMsg = GetDeviationText();
                        DebugDraw.AddMovableTextLine(options.textWindowIdentifier, deviationMsg, options.bestFragTextColor);
                    }

                    Nullable <TrajectoryHeuristicDebug> trajectoryHeuristic = FindTrajectoryHeuristic(debugMemory);
                    if (trajectoryHeuristic.HasValue)
                    {
                        trajectoryHeuristic.Value.DrawDebugText(ref options);

                        outputTimeIdentifier = trajectoryHeuristic.Value.outputTime;
                    }
                }
            }

            SamplingTime outputTime = GetOutputPlayTime(debugMemory, samplingTime, closestMatch, outputTimeIdentifier);

            if ((options.drawFlags & DebugDrawFlags.OutputFragment) > 0)
            {
                DebugDraw.DrawFragment(ref synthesizer, outputTime, options.inputOutputFragmentColor, options.timeOffset, GetAnchor(synthesizer.WorldRootTransform, fragmentSlot++ *options.distanceOffset, camera));
                DebugDraw.AddMovableTextLine(options.textWindowIdentifier, GetFragmentDebugText(ref synthesizer, "Output Clip", outputTime, options.timeOffset, ref deviationTable, false), options.inputOutputFragTextColor);
            }

            if (debugSamplingTime.IsValid)
            {
                if ((options.drawFlags & DebugDrawFlags.SelectedFragment) > 0)
                {
                    int slot = fragmentSlot > 0 ? -1 : 0;
                    DebugDraw.DrawFragment(ref synthesizer, debugSamplingTime, options.selectedFragmentColor, options.timeOffset, GetAnchor(synthesizer.WorldRootTransform, slot * options.distanceOffset, camera));
                    DebugDraw.AddMovableTextLine(options.textWindowIdentifier, GetFragmentDebugText(ref synthesizer, "Selected Clip", debugSamplingTime, options.timeOffset, ref deviationTable), options.selectedFragTextColor);
                }
            }

            deviationTable.Dispose();

            if ((options.drawFlags & DebugDrawFlags.Trajectory) > 0 && this.trajectory.IsValid)
            {
                using (Trajectory trajectory = debugMemory.ReadObjectFromIdentifier <Trajectory>(this.trajectory))
                {
                    Binary.TrajectoryFragmentDisplay.Options trajectoryOptions = Binary.TrajectoryFragmentDisplay.Options.Create();

                    DebugExtensions.DebugDrawTrajectory(synthesizer.WorldRootTransform,
                                                        trajectory,
                                                        synthesizer.Binary.SampleRate,
                                                        options.inputTrajectoryColor,
                                                        options.inputTrajectoryColor,
                                                        trajectoryOptions.showForward);
                }
            }
        }
 static internal SamplingTime GetSamplingTime(DebugMemory debugMemory, DebugIdentifier debugIdentifier)
 {
     return(debugIdentifier.IsValid ? debugMemory.ReadObjectFromIdentifier <SamplingTime>(debugIdentifier) : SamplingTime.Invalid);
 }