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); }
Nullable <TrajectoryHeuristicDebug> FindTrajectoryHeuristic(DebugMemory debugMemory) { if (!trajectory.IsValid) { return(null); } int heuristicTypeCode = BurstRuntime.GetHashCode32 <TrajectoryHeuristicDebug>(); for (DebugReference reference = debugMemory.FirstOrDefault; reference.IsValid; reference = debugMemory.Next(reference)) { if (reference.identifier.typeHashCode != heuristicTypeCode) { continue; } TrajectoryHeuristicDebug heuristicDebug = debugMemory.ReadObject <TrajectoryHeuristicDebug>(reference); if (heuristicDebug.closestMatch.Equals(closestMatch)) { return(heuristicDebug); } } return(null); }
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); }
MotionSynthesizer(BlobAssetReference <Binary> binary, AffineTransform worldRootTransform, float blendDuration, Allocator allocator) { m_binary = binary; arrayMemory = ArrayMemory.Create(); ReserveTraitTypes(ref arrayMemory); PoseGenerator.Reserve(ref arrayMemory, ref binary.Value); TrajectoryModel.Reserve(ref arrayMemory, ref binary.Value); arrayMemory.Allocate(allocator); // We basically copy statically available data into this instance // so that the burst compiler does not complain about accessing static data. traitTypes = ConstructTraitTypes(ref arrayMemory, ref binary.Value); poseGenerator = new PoseGenerator(ref arrayMemory, ref binary.Value, blendDuration); trajectory = new TrajectoryModel(ref arrayMemory, ref binary.Value); rootTransform = worldRootTransform; rootDeltaTransform = AffineTransform.identity; updateInProgress = false; _deltaTime = 0.0f; lastSamplingTime = TimeIndex.Invalid; samplingTime = SamplingTime.Invalid; delayedPushTime = TimeIndex.Invalid; frameCount = -1; lastProcessedFrameCount = -1; isValid = true; isDebugging = false; readDebugMemory = DebugMemory.Create(1024, allocator); writeDebugMemory = DebugMemory.Create(1024, allocator); }
public void Draw(Camera camera, ref MotionSynthesizer synthesizer, DebugMemory debugMemory, SamplingTime debugSamplingTime, ref DebugDrawOptions options) { DrawPath(); }
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); }
public void Draw(Camera camera, ref MotionSynthesizer synthesizer, DebugMemory debugMemory, SamplingTime debugSamplingTime, ref DebugDrawOptions options) { ref var binary = ref synthesizer.Binary;