From 9b6c4054857a93682e39c4db60c44d24ab3328d5 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 2 Aug 2019 19:43:08 +0200 Subject: [PATCH] Bin number shouldn't be floating point. --- server/TracyView.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 5ef142c3..5cf6beb8 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -6692,11 +6692,11 @@ void View::DrawFindZone() auto& io = ImGui::GetIO(); draw->AddLine( ImVec2( io.MousePos.x, wpos.y ), ImVec2( io.MousePos.x, wpos.y+Height-2 ), 0x33FFFFFF ); - const auto bin = double( io.MousePos.x - wpos.x - 2 ); + const auto bin = int64_t( io.MousePos.x - wpos.x - 2 ); int64_t t0, t1; if( m_findZone.logTime ) { - t0 = int64_t( pow( 10, ltmin + bin / numBins * ( ltmax - ltmin ) ) ); + t0 = int64_t( pow( 10, ltmin + double( bin ) / numBins * ( ltmax - ltmin ) ) ); // Hackfix for inability to select data in last bin. // A proper solution would be nice. @@ -6706,13 +6706,13 @@ void View::DrawFindZone() } else { - t1 = int64_t( pow( 10, ltmin + (bin+1) / numBins * ( ltmax - ltmin ) ) ); + t1 = int64_t( pow( 10, ltmin + double( bin+1 ) / numBins * ( ltmax - ltmin ) ) ); } } else { - t0 = int64_t( tmin + bin / numBins * ( tmax - tmin ) ); - t1 = int64_t( tmin + (bin+1) / numBins * ( tmax - tmin ) ); + t0 = int64_t( tmin + double( bin ) / numBins * ( tmax - tmin ) ); + t1 = int64_t( tmin + double( bin+1 ) / numBins * ( tmax - tmin ) ); } int64_t tBefore = 0; @@ -7978,17 +7978,17 @@ void View::DrawCompare() auto& io = ImGui::GetIO(); draw->AddLine( ImVec2( io.MousePos.x, wpos.y ), ImVec2( io.MousePos.x, wpos.y+Height-2 ), 0x33FFFFFF ); - const auto bin = double( io.MousePos.x - wpos.x - 2 ); + const auto bin = int64_t( io.MousePos.x - wpos.x - 2 ); int64_t t0, t1; if( m_compare.logTime ) { - t0 = int64_t( pow( 10, ltmin + bin / numBins * ( ltmax - ltmin ) ) ); - t1 = int64_t( pow( 10, ltmin + (bin+1) / numBins * ( ltmax - ltmin ) ) ); + t0 = int64_t( pow( 10, ltmin + double( bin ) / numBins * ( ltmax - ltmin ) ) ); + t1 = int64_t( pow( 10, ltmin + double( bin+1 ) / numBins * ( ltmax - ltmin ) ) ); } else { - t0 = int64_t( tmin + bin / numBins * ( tmax - tmin ) ); - t1 = int64_t( tmin + (bin+1) / numBins * ( tmax - tmin ) ); + t0 = int64_t( tmin + double( bin ) / numBins * ( tmax - tmin ) ); + t1 = int64_t( tmin + double( bin+1 ) / numBins * ( tmax - tmin ) ); } int64_t tBefore[2] = { 0, 0 }; @@ -8975,11 +8975,11 @@ void View::DrawInfo() auto& io = ImGui::GetIO(); draw->AddLine( ImVec2( io.MousePos.x, wpos.y ), ImVec2( io.MousePos.x, wpos.y+Height-2 ), 0x33FFFFFF ); - const auto bin = double( io.MousePos.x - wpos.x - 2 ); + const auto bin = int64_t( io.MousePos.x - wpos.x - 2 ); int64_t t0, t1; if( m_frameSortData.logTime ) { - t0 = int64_t( pow( 10, ltmin + bin / numBins * ( ltmax - ltmin ) ) ); + t0 = int64_t( pow( 10, ltmin + double( bin ) / numBins * ( ltmax - ltmin ) ) ); // Hackfix for inability to select data in last bin. // A proper solution would be nice. @@ -8989,13 +8989,13 @@ void View::DrawInfo() } else { - t1 = int64_t( pow( 10, ltmin + (bin+1) / numBins * ( ltmax - ltmin ) ) ); + t1 = int64_t( pow( 10, ltmin + double( bin+1 ) / numBins * ( ltmax - ltmin ) ) ); } } else { - t0 = int64_t( tmin + bin / numBins * ( tmax - tmin ) ); - t1 = int64_t( tmin + (bin+1) / numBins * ( tmax - tmin ) ); + t0 = int64_t( tmin + double( bin ) / numBins * ( tmax - tmin ) ); + t1 = int64_t( tmin + double( bin+1 ) / numBins * ( tmax - tmin ) ); } ImGui::BeginTooltip();