From 36b4b285d3dbdab423511e7188c37bd1d0443edb Mon Sep 17 00:00:00 2001 From: David Gow Date: Thu, 11 Sep 2014 20:08:27 +0800 Subject: [PATCH] Because merging is going to be fun. --- src/bezier.h | 5 +++-- src/rect.h | 8 ++++---- src/view.cpp | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/bezier.h b/src/bezier.h index 2b0c1e1..206cbc8 100644 --- a/src/bezier.h +++ b/src/bezier.h @@ -15,7 +15,7 @@ namespace IPDF extern std::vector SolveQuadratic(const Real & a, const Real & b, const Real & c, const Real & min = 0, const Real & max = 1); - extern std::vector SolveCubic(const Real & a, const Real & b, const Real & c, const Real & d, const Real & min = 0, const Real & max = 1, const Real & delta = 1e-9); + extern std::vector SolveCubic(const Real & a, const Real & b, const Real & c, const Real & d, const Real & min = 0, const Real & max = 1, const Real & delta = 1e-4); /** A _cubic_ bezier. **/ struct Bezier @@ -293,11 +293,12 @@ namespace IPDF { Real t1 = *it; if (t1 == t0) continue; - Debug(" -- t0: %f to t1: %f", Double(t0), Double(t1)); + Debug(" -- t0: %f to t1: %f: %f", Double(t0), Double(t1), (t1 + t0)/Real(2)); Real ptx, pty; Evaluate(ptx, pty, ((t1 + t0) / Real(2))); if (r.PointIn(ptx, pty)) { + Debug("Adding segment: (point at %f, %f)", Double(ptx), Double(pty)); all_beziers.push_back(this->ReParametrise(t0, t1)); } else diff --git a/src/rect.h b/src/rect.h index 46aa5fb..3c4a105 100644 --- a/src/rect.h +++ b/src/rect.h @@ -20,10 +20,10 @@ namespace IPDF } inline bool PointIn(Real pt_x, Real pt_y) const { - if (pt_x < x) return false; - if (pt_y < y) return false; - if (pt_x > x + w) return false; - if (pt_y > y + h) return false; + if (pt_x <= x) return false; + if (pt_y <= y) return false; + if (pt_x >= x + w) return false; + if (pt_y >= y + h) return false; return true; } }; diff --git a/src/view.cpp b/src/view.cpp index 26e0591..554fb03 100644 --- a/src/view.cpp +++ b/src/view.cpp @@ -173,7 +173,7 @@ void View::Render(int width, int height) #ifndef QUADTREE_DISABLED if (m_bounds_dirty) { - if (false && (m_bounds.x > 1.0 || m_bounds.x < 0.0 || m_bounds.y > 1.0 || m_bounds.y < 0.0 || m_bounds.w > 1.0 || m_bounds.h > 1.0)) + if ( (m_bounds.x > 1.0 || m_bounds.x < 0.0 || m_bounds.y > 1.0 || m_bounds.y < 0.0 || m_bounds.w > 1.0 || m_bounds.h > 1.0)) { //TODO: Generate a new parent node. if (m_document.GetQuadTree().nodes[m_current_quadtree_node].parent != QUADTREE_EMPTY) -- 2.20.1