Closed iassenev closed 11 months ago
The Intersection function is called from the RendererShaded::Render for parallel segments, which results in division by zero:
static inline ImVec2 Intersection(const ImVec2& a1, const ImVec2& a2, const ImVec2& b1, const ImVec2& b2) { float v1 = (a1.x * a2.y - a1.y * a2.x); float v2 = (b1.x * b2.y - b1.y * b2.x); float v3 = ((a1.x - a2.x) * (b1.y - b2.y) - (a1.y - a2.y) * (b1.x - b2.x)); return ImVec2((v1 * (b1.x - b2.x) - v2 * (a1.x - a2.x)) / v3, (v1 * (b1.y - b2.y) - v2 * (a1.y - a2.y)) / v3); }
v3 is zero for parallel segments.
Easy hotfix in RendererShaded::Render seems to fix the issue: ImVec2 intersection = intersect ? Intersection(P11,P21,P12,P22) : ImVec2{ 0, 0 };
ImVec2 intersection = intersect ? Intersection(P11,P21,P12,P22) : ImVec2{ 0, 0 };
https://github.com/epezent/implot/commit/433022038bdf498741147cba277fd283dc0ac68d
The Intersection function is called from the RendererShaded::Render for parallel segments, which results in division by zero:
v3 is zero for parallel segments.
Easy hotfix in RendererShaded::Render seems to fix the issue:
ImVec2 intersection = intersect ? Intersection(P11,P21,P12,P22) : ImVec2{ 0, 0 };