diff --git a/samples/main.cpp b/samples/main.cpp index 9cc23f1..0fe8a6b 100644 --- a/samples/main.cpp +++ b/samples/main.cpp @@ -49,6 +49,7 @@ static SampleContext s_context; static int s_frame = 0; static int s_frameLimit = -1; static int s_sampleOverride = -1; +static bool s_openReplay = false; static int s_exitCode = 0; static int CompareSamples( const void* a, const void* b ) @@ -135,6 +136,12 @@ static void OnInit( void ) index = s_sampleOverride; } + // Resolved here rather than at parse time because sorting moves the slot. + if ( s_openReplay && g_replayIndex >= 0 ) + { + index = g_replayIndex; + } + SelectSample( &s_context, index, false ); } @@ -535,11 +542,8 @@ static sapp_desc BuildAppDesc( int argc, char** argv ) { const char* path = argv[++i]; - if ( g_replayIndex >= 0 ) - { - snprintf( s_context.replayFile, sizeof( s_context.replayFile ), "%s", path ); - s_sampleOverride = g_replayIndex; - } + snprintf( s_context.replayFile, sizeof( s_context.replayFile ), "%s", path ); + s_openReplay = true; } else if ( strcmp( argv[i], "--zup" ) == 0 ) { diff --git a/samples/sample.cpp b/samples/sample.cpp index 334b8ae..cff7428 100644 --- a/samples/sample.cpp +++ b/samples/sample.cpp @@ -1043,8 +1043,9 @@ void Sample::DrawMetrics() if ( ImGui::BeginTabItem( "Counters" ) ) { - b3Counters s = b3World_GetCounters( m_worldId ); - b3Capacity c = b3World_GetMaxCapacity( m_worldId ); + b3WorldId worldId = GetMetricsWorldId(); + b3Counters s = b3World_GetCounters( worldId ); + b3Capacity c = b3World_GetMaxCapacity( worldId ); constexpr int colorCount = sizeof( s.colorCounts ) / sizeof( s.colorCounts[0] ); constexpr int overflowIndex = colorCount - 1; diff --git a/samples/sample.h b/samples/sample.h index d6027ff..5e8ff18 100644 --- a/samples/sample.h +++ b/samples/sample.h @@ -206,6 +206,11 @@ public: // Bottom metrics drawer (Frame Time / Counters / Renderer). void DrawMetrics(); + virtual b3WorldId GetMetricsWorldId() const + { + return m_worldId; + } + // Append extra tabs to the metrics drawer's tab bar (the Replay viewer adds Timeline). virtual void DrawMetricsTab() { diff --git a/samples/sample_replay.cpp b/samples/sample_replay.cpp index 4879c1d..2d3b96f 100644 --- a/samples/sample_replay.cpp +++ b/samples/sample_replay.cpp @@ -704,6 +704,12 @@ public: return false; } + // The base world before a recording is open + b3WorldId GetMetricsWorldId() const override + { + return B3_IS_NON_NULL( m_replayWorldId ) ? m_replayWorldId : m_worldId; + } + // Wider than the default so the detail pane, hosted in the info panel, has room for ids and vectors. float InfoPanelWidthEm() const override {