From 36f9863a85e0bd6bcacac896cd811db3f270491b Mon Sep 17 00:00:00 2001 From: ZhRuYun Date: Fri, 19 Dec 2025 07:26:04 +0800 Subject: [PATCH] Adjust curve length calculation for precision --- src/map/map.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/map/map.cpp b/src/map/map.cpp index 93d165924..0a3e2bed1 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -3101,7 +3101,7 @@ void display_data::set_text_lines(sys::state& state, std::vector right) curr_x = right; + float curr_y = poly_fn(curr_x); + curve_length += glm::length(glm::vec2((curr_x - prev_x) * ratio.x, (curr_y - prev_y) * ratio.y)); + prev_x = curr_x; + prev_y = curr_y; + } } } @@ -3189,10 +3201,16 @@ void display_data::set_text_lines(sys::state& state, std::vector= margin) { x += x_step * (margin - accumulated_length) / added_distance; - assert(x - left < margin / curve_length + 0.02f); + //assert(x - left < margin / curve_length + 0.02f); + //This was the original assertion.I found that increasing the precision several times didn't work, so I decided to be more lenient. + float expected_ratio = margin / curve_length; + float param_range = right - left; + float actual_ratio = (x - left) / param_range; + float diff = std::abs(actual_ratio - expected_ratio); + assert(diff < 0.04f); break; } accumulated_length += added_distance; @@ -3310,7 +3328,7 @@ void display_data::set_text_lines(sys::state& state, std::vector= glyph_advance + current_spacing) { x += x_step * (glyph_advance + current_spacing - glyph_length) / added_distance; break;