MCPcopy Create free account
hub / github.com/brenocq/implot3d / IsPointInEdgeHoverRegion

Function IsPointInEdgeHoverRegion

implot3d.cpp:603–617  ·  view source on GitHub ↗

Check if a point is inside an edge's hover region (a rectangle extending outward from the edge)

Source from the content-addressed store, hash-verified

601
602// Check if a point is inside an edge's hover region (a rectangle extending outward from the edge)
603bool IsPointInEdgeHoverRegion(const ImVec2& point, const ImVec2& p0, const ImVec2& p1, const ImVec2& outward_dir, float width) {
604 ImVec2 dir = p1 - p0;
605 float len = ImSqrt(ImLengthSqr(dir));
606 if (len < 0.001f)
607 return false;
608 dir = dir / len;
609
610 // Transform point to edge's local coordinate system
611 ImVec2 local = point - p0;
612 float along = local.x * dir.x + local.y * dir.y;
613 float across = local.x * outward_dir.x + local.y * outward_dir.y;
614
615 // Check if within bounds (rectangle extends from edge outward)
616 return along >= 0 && along <= len && across >= 0 && across <= width;
617}
618
619// Compute the outward direction for an edge (perpendicular, pointing away from box center)
620ImVec2 ComputeEdgeOutwardDir(const ImVec2& p0, const ImVec2& p1, const ImVec2& box_center) {

Callers 1

GetMouseOverAxisFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected