瀏覽代碼

Merge pull request #342 from nem0/master

PlotHistogram: Fixed rendering of histogram with a lot of values.
omar 10 年之前
父節點
當前提交
994c286f61
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      imgui.cpp

+ 1 - 1
imgui.cpp

@@ -6613,7 +6613,7 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
     for (int n = 0; n < res_w; n++)
     for (int n = 0; n < res_w; n++)
     {
     {
         const float t1 = t0 + t_step;
         const float t1 = t0 + t_step;
-        const int v_idx = (int)(t0 * values_count);
+        const int v_idx = (int)(t0 * values_count + 0.5f);
         IM_ASSERT(v_idx >= 0 && v_idx < values_count);
         IM_ASSERT(v_idx >= 0 && v_idx < values_count);
         const float v1 = values_getter(data, (v_idx + values_offset + 1) % values_count);
         const float v1 = values_getter(data, (v_idx + values_offset + 1) % values_count);
         const ImVec2 p1 = ImVec2( t1, 1.0f - ImSaturate((v1 - scale_min) / (scale_max - scale_min)) );
         const ImVec2 p1 = ImVec2( t1, 1.0f - ImSaturate((v1 - scale_min) / (scale_max - scale_min)) );