Use ring offsets for spectrum history
This commit is contained in:
parent
07198f948d
commit
b44aaac7cc
6 changed files with 26 additions and 8 deletions
|
|
@ -678,6 +678,7 @@ static int RunMimirSpectrumUploadSmoke()
|
|||
const int expectedHistoryCount = 3;
|
||||
const int expectedHistoryCapacity = 40;
|
||||
const int expectedSubdivisions = 2;
|
||||
const int expectedRollingOffset = (expectedHistoryCapacity - (expectedHistoryCount - 1)) * expectedSourceLaneCapacity;
|
||||
var plannedTubePackets = plan.Packets
|
||||
.Where(packet =>
|
||||
packet.Backend == AquariumFieldBackendKind.TubeField &&
|
||||
|
|
@ -714,6 +715,7 @@ static int RunMimirSpectrumUploadSmoke()
|
|||
item.ColumnCount == expectedHistoryCount &&
|
||||
item.ColumnStride == expectedSourceLaneCapacity &&
|
||||
item.RollingModulo == resource.Height &&
|
||||
item.RollingOffset == expectedRollingOffset &&
|
||||
item.CatmullRomSubdivisions == expectedSubdivisions &&
|
||||
Math.Abs(item.ColumnStep.Z - 0.1f) < 0.0001f &&
|
||||
string.Equals(item.RampResourceKey, ramp.ResourceKey, StringComparison.Ordinal) &&
|
||||
|
|
|
|||
|
|
@ -278,9 +278,12 @@ public sealed class MimirRuntime : IAquariumRuntime
|
|||
var sourceCount = sourceIds.Length;
|
||||
var activeColumnCount = checked(sourceCount * historyCount);
|
||||
var resourceColumnCapacity = checked(spectrumSourceLaneCapacity * SpectrumHistoryWindowCount);
|
||||
var newestHistorySlot = PositiveModulo(-historyFrames[0].Sequence, SpectrumHistoryWindowCount);
|
||||
var rollingOffset = checked(newestHistorySlot * spectrumSourceLaneCapacity);
|
||||
var samples = new float[width * resourceColumnCapacity];
|
||||
for (var historyIndex = 0; historyIndex < historyFrames.Length; historyIndex++)
|
||||
{
|
||||
var historySlot = PositiveModulo(-historyFrames[historyIndex].Sequence, SpectrumHistoryWindowCount);
|
||||
foreach (var spectrum in historyFrames[historyIndex].Spectra)
|
||||
{
|
||||
if (!sourceIndexById.TryGetValue(spectrum.SourceId, out var sourceIndex))
|
||||
|
|
@ -288,7 +291,7 @@ public sealed class MimirRuntime : IAquariumRuntime
|
|||
continue;
|
||||
}
|
||||
|
||||
var physicalColumn = historyIndex * spectrumSourceLaneCapacity + sourceIndex;
|
||||
var physicalColumn = historySlot * spectrumSourceLaneCapacity + sourceIndex;
|
||||
WriteNormalizedSpectrum(spectrum, samples.AsSpan(physicalColumn * width, width));
|
||||
}
|
||||
}
|
||||
|
|
@ -378,7 +381,7 @@ public sealed class MimirRuntime : IAquariumRuntime
|
|||
ColumnCount: historyCount,
|
||||
ColumnStride: spectrumSourceLaneCapacity,
|
||||
RollingModulo: resourceColumnCapacity,
|
||||
RollingOffset: 0,
|
||||
RollingOffset: rollingOffset,
|
||||
Origin: new Vector3(-5.0f, sourceIndex * SpectrumChannelSeparation, 0.0f),
|
||||
AxisStep: new Vector3(axisStepX, 0.0f, 0.0f),
|
||||
ColumnStep: new Vector3(0.0f, 0.0f, SpectrumWindowDepthSeparation),
|
||||
|
|
@ -451,6 +454,12 @@ public sealed class MimirRuntime : IAquariumRuntime
|
|||
}
|
||||
}
|
||||
|
||||
private static int PositiveModulo(long value, int modulo)
|
||||
{
|
||||
var remainder = value % modulo;
|
||||
return (int)(remainder < 0 ? remainder + modulo : remainder);
|
||||
}
|
||||
|
||||
private static Vector3 SpectrumCameraPosition(
|
||||
int spectrumCount,
|
||||
int windowCount,
|
||||
|
|
|
|||
Loading…
Reference in a new issue