replay viewer fixes

This commit is contained in:
Erin Catto 2026-11-16 20:51:34 -08:00
commit 85387cfde6
4 changed files with 23 additions and 7 deletions

View file

@ -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 )
{

View file

@ -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;

View file

@ -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()
{

View file

@ -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
{