parent
79fc55976a
commit
8fda30e5a2
4 changed files with 569 additions and 436 deletions
|
|
@ -236,6 +236,10 @@ static void OnEvent( const sapp_event* e )
|
|||
s_context.showMetrics = !s_context.showMetrics;
|
||||
break;
|
||||
|
||||
case SAPP_KEYCODE_I:
|
||||
s_context.showProfile = !s_context.showProfile;
|
||||
break;
|
||||
|
||||
case SAPP_KEYCODE_R:
|
||||
SelectSample( &s_context, s_context.sampleIndex, true );
|
||||
break;
|
||||
|
|
|
|||
1004
samples/sample.cpp
1004
samples/sample.cpp
File diff suppressed because it is too large
Load diff
|
|
@ -50,6 +50,10 @@ struct SampleContext
|
|||
char recordingFile[256] = "recording.b3rec";
|
||||
char replayFile[256] = "";
|
||||
|
||||
// Last recording saved this session, empty until a save succeeds. The default record path
|
||||
// may name a stale file from an earlier run, so Play only trusts this one.
|
||||
char savedRecordingFile[256] = "";
|
||||
|
||||
// Keyframe ring policy the Replay viewer applies on open, persisted across sessions.
|
||||
int replayKeyframeBudgetMB = 512;
|
||||
int replayKeyframeMinInterval = 16;
|
||||
|
|
@ -80,10 +84,13 @@ struct SampleContext
|
|||
// UI visibility (Tab / View > Hide UI). When hidden only the minimal HUD shows.
|
||||
bool showUI = true;
|
||||
|
||||
// Bottom diagnostics drawer (M), set by Ctrl+O for the fuzzy picker.
|
||||
// Bottom metrics drawer (M), set by Ctrl+O for the fuzzy picker.
|
||||
bool showMetrics = false;
|
||||
bool openSamplePicker = false;
|
||||
|
||||
// Left profile panel (I)
|
||||
bool showProfile = false;
|
||||
|
||||
// Controls help window (Help > Controls, toggled with ?). Promoted to the
|
||||
// context so the key handler can reach it. Seeded from newUser after Load.
|
||||
bool showControls = false;
|
||||
|
|
@ -145,6 +152,12 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
// Allow a sample without a world step to hide the profile panel.
|
||||
virtual bool HasProfile() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Width of the right info panel in em. The bottom drawer clears to the same width. A sample that
|
||||
// hosts heavier content there, such as the replay viewer's detail pane, can widen it.
|
||||
virtual float InfoPanelWidthEm() const;
|
||||
|
|
@ -169,10 +182,15 @@ public:
|
|||
void StartRecording();
|
||||
void FinishRecording();
|
||||
|
||||
// Bottom diagnostics drawer (Profile / Counters / Renderer / Frame Time).
|
||||
// Left profile panel, a table of the step sections readable at a glance.
|
||||
bool IsProfileVisible() const;
|
||||
float GetProfilePanelWidth() const;
|
||||
void DrawProfile();
|
||||
|
||||
// Bottom metrics drawer (Frame Time / Counters / Renderer).
|
||||
void DrawMetrics();
|
||||
|
||||
// Append extra tabs to the diagnostics drawer's tab bar (the Replay viewer adds Timeline).
|
||||
// Append extra tabs to the metrics drawer's tab bar (the Replay viewer adds Timeline).
|
||||
virtual void DrawMetricsTab()
|
||||
{
|
||||
}
|
||||
|
|
@ -221,6 +239,7 @@ public:
|
|||
float m_mouseForceScale;
|
||||
float m_launchSpeedScale;
|
||||
int m_stepCount;
|
||||
int m_textX;
|
||||
int m_textLine;
|
||||
int m_textIncrement;
|
||||
int m_triangleIndex;
|
||||
|
|
@ -288,8 +307,8 @@ void FrameSelection( SampleContext* context );
|
|||
// a blocking nested run loop), driven by SampleContext::openReplayPicker.
|
||||
void OpenReplayFileDialog( SampleContext* context );
|
||||
|
||||
// The single host UI callback: menu bar, sample picker, info panel, and the
|
||||
// bottom diagnostics drawer.
|
||||
// The single host UI callback: menu bar, sample picker, info panel, profile panel,
|
||||
// and the bottom metrics drawer.
|
||||
void DrawUI( SampleContext* context );
|
||||
|
||||
struct CastClosestContext
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ enum SelectionKind
|
|||
// - right info panel (DrawControls): Show Timeline button, view toggles, frame counter, and the
|
||||
// selection detail
|
||||
// - left Outline window (DrawSampleWindows): the recorded scene tree
|
||||
// - Timeline tab in the diagnostics drawer (DrawMetricsTab): transport, scrubber, keyframe readout
|
||||
// - Timeline tab in the metrics drawer (DrawMetricsTab): transport, scrubber, keyframe readout
|
||||
class ReplayViewer : public Sample
|
||||
{
|
||||
public:
|
||||
|
|
@ -695,6 +695,11 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
bool HasProfile() const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Wider than the default so the detail pane, hosted in the info panel, has room for ids and vectors.
|
||||
float InfoPanelWidthEm() const override
|
||||
{
|
||||
|
|
@ -1089,7 +1094,7 @@ public:
|
|||
float menuBarHeight = ImGui::GetFrameHeight();
|
||||
float top = menuBarHeight + 0.5f * fontSize;
|
||||
|
||||
// Stop above the diagnostics drawer when it is open so the panels do not overlap. The 16 em
|
||||
// Stop above the metrics drawer when it is open so the panels do not overlap. The 16 em
|
||||
// drawer height mirrors DrawMetrics.
|
||||
float bottom = m_context->showMetrics ? ( m_camera->m_height - 16.0f * fontSize - fontSize )
|
||||
: ( m_camera->m_height - 0.5f * fontSize );
|
||||
|
|
@ -1667,7 +1672,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
// Timeline tab in the diagnostics drawer: file, transport, keyframe readout, scrubber, divergence.
|
||||
// Timeline tab in the metrics drawer: file, transport, keyframe readout, scrubber, divergence.
|
||||
void DrawMetricsTab() override
|
||||
{
|
||||
ImGuiTabItemFlags flags = m_selectTimelineTab ? ImGuiTabItemFlags_SetSelected : 0;
|
||||
|
|
@ -1754,7 +1759,12 @@ public:
|
|||
b3Counters c = b3World_GetCounters( m_replayWorldId );
|
||||
ImGui::Text( "frames %d", m_info.frameCount );
|
||||
ImGui::SameLine();
|
||||
ImGui::Text( " %.0f hz, %d sub-steps", hz, m_info.subStepCount );
|
||||
ImGui::Text( " %.0f Hz, %d sub-steps", hz, m_info.subStepCount );
|
||||
if ( m_info.lengthScale > 0.0f )
|
||||
{
|
||||
ImGui::SameLine();
|
||||
ImGui::Text( " %g units/m", m_info.lengthScale );
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Text( " bodies %d shapes %d contacts %d joints %d", c.bodyCount, c.shapeCount, c.contactCount, c.jointCount );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue