Compare commits
1
Commits
c960decaea
...
03c41adbec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03c41adbec |
No files matched your search
@@ -9,12 +9,17 @@
|
||||
namespace plot::render {
|
||||
namespace {
|
||||
|
||||
#ifndef NDEBUG
|
||||
/// Two declared cells agree when neither size differs by more than the atlas'
|
||||
/// tolerance: the test `glyph_is_cell()` makes, for a cell against a cell.
|
||||
///
|
||||
/// Guarded because its one caller is an `assert` (see `TextBatch::set_cell`), so a
|
||||
/// release build has no use for it and would warn that it is unused.
|
||||
bool same_cell(Vec2 a, Vec2 b) noexcept {
|
||||
const auto near = [](f32 p, f32 q) { return std::fabs(p - q) <= kAtlasCellTolerance; };
|
||||
return near(a.x, b.x) && near(a.y, b.y);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// `axis` as a unit vector: the cell's local +x, which is what the instance and
|
||||
/// the shader both take (see `TextInstance`). A zero, infinite or NaN direction
|
||||
|
||||
@@ -1043,8 +1043,8 @@ void Renderer::draw_traces(const Plot& plot, const PlotLayout& layout) {
|
||||
const f64 x_abs = series.x0() + static_cast<f64>(gather_[k]);
|
||||
const f64 y_abs = static_cast<f64>(gather_[k + 1]);
|
||||
if (!std::isfinite(x_abs) || !std::isfinite(y_abs)) continue;
|
||||
const f32 sx = xt.to_screen_x(x_abs);
|
||||
const f32 sy = yt.to_screen_y(y_abs);
|
||||
const f32 sx = static_cast<f32>(xt.to_screen_x(x_abs));
|
||||
const f32 sy = static_cast<f32>(yt.to_screen_y(y_abs));
|
||||
if (!(sx >= layout.axes.x && sx <= layout.axes.right() && sy >= layout.axes.y &&
|
||||
sy <= layout.axes.bottom())) {
|
||||
continue;
|
||||
@@ -1085,12 +1085,12 @@ void Renderer::draw_traces(const Plot& plot, const PlotLayout& layout) {
|
||||
usize kept = 0;
|
||||
f64 next = std::numeric_limits<f64>::infinity();
|
||||
for (usize k = count; k > 0; --k) {
|
||||
const usize i = k - 1u;
|
||||
const f64 x = static_cast<f64>(gather_[2u * i]) + series.x0();
|
||||
const usize p = k - 1u; // the point index; `i` above is the trace's
|
||||
const f64 x = static_cast<f64>(gather_[2u * p]) + series.x0();
|
||||
if (!(x < next)) continue; // out of order with what follows: unreadable, and a NaN too
|
||||
next = x;
|
||||
gather_[2u * (count - 1u - kept)] = gather_[2u * i];
|
||||
gather_[2u * (count - 1u - kept) + 1u] = gather_[2u * i + 1u];
|
||||
gather_[2u * (count - 1u - kept)] = gather_[2u * p];
|
||||
gather_[2u * (count - 1u - kept) + 1u] = gather_[2u * p + 1u];
|
||||
++kept;
|
||||
}
|
||||
if (kept != count) {
|
||||
|
||||
Reference in new issue
Block a user