mirror of
https://github.com/wolfpld/tracy.git
synced 2026-06-08 08:33:48 +00:00
Extract UpdateZoomAnimation.
This will allow for it to be used in the flame graph.
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <mutex>
|
||||
|
||||
#include "imgui.h"
|
||||
@@ -29,10 +28,6 @@
|
||||
#include "imgui_internal.h"
|
||||
#include "IconsFontAwesome6.h"
|
||||
|
||||
#ifndef M_PI_2
|
||||
#define M_PI_2 1.57079632679489661923
|
||||
#endif
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
@@ -1251,19 +1246,7 @@ bool View::DrawImpl()
|
||||
m_zoomAnim.end1 += delta;
|
||||
}
|
||||
}
|
||||
m_zoomAnim.progress += io.DeltaTime * 3.33f;
|
||||
if( m_zoomAnim.progress >= 1.f )
|
||||
{
|
||||
m_zoomAnim.active = false;
|
||||
m_vd.zvStart = m_zoomAnim.start1;
|
||||
m_vd.zvEnd = m_zoomAnim.end1;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto v = sqrt( sin( M_PI_2 * m_zoomAnim.progress ) );
|
||||
m_vd.zvStart = int64_t( m_zoomAnim.start0 + ( m_zoomAnim.start1 - m_zoomAnim.start0 ) * v );
|
||||
m_vd.zvEnd = int64_t( m_zoomAnim.end0 + ( m_zoomAnim.end1 - m_zoomAnim.end0 ) * v );
|
||||
}
|
||||
UpdateZoomAnimation( m_zoomAnim, m_vd.zvStart, m_vd.zvEnd, io.DeltaTime );
|
||||
}
|
||||
|
||||
bool active = m_wasActive.load( std::memory_order_acquire );
|
||||
|
||||
@@ -372,6 +372,7 @@ private:
|
||||
void ZoomToPrevFrame();
|
||||
void ZoomToNextFrame();
|
||||
void CenterAtTime( int64_t t );
|
||||
void UpdateZoomAnimation( Animation& anim, int64_t& start, int64_t& end, float deltaTime );
|
||||
|
||||
void ShowZoneInfo( const ZoneEvent& ev );
|
||||
void ShowZoneInfo( const GpuEvent& ev, uint64_t thread );
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "TracyView.hpp"
|
||||
|
||||
#ifndef M_PI_2
|
||||
#define M_PI_2 1.57079632679489661923
|
||||
#endif
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
@@ -72,6 +78,25 @@ void View::ZoomToRange( int64_t start, int64_t end, bool pause )
|
||||
m_zoomAnim.progress = 0;
|
||||
}
|
||||
|
||||
void View::UpdateZoomAnimation( Animation& anim, int64_t& start, int64_t& end, float deltaTime )
|
||||
{
|
||||
if( !anim.active ) return;
|
||||
|
||||
anim.progress += deltaTime * 3.33f;
|
||||
if( anim.progress >= 1.f )
|
||||
{
|
||||
anim.active = false;
|
||||
start = anim.start1;
|
||||
end = anim.end1;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto v = sqrt( sin( M_PI_2 * anim.progress ) );
|
||||
start = int64_t( anim.start0 + ( anim.start1 - anim.start0 ) * v );
|
||||
end = int64_t( anim.end0 + ( anim.end1 - anim.end0 ) * v );
|
||||
}
|
||||
}
|
||||
|
||||
void View::ZoomToPrevFrame()
|
||||
{
|
||||
if( m_vd.zvStart >= m_worker.GetFrameBegin( *m_frames, 0 ) )
|
||||
|
||||
Reference in New Issue
Block a user