Skip to main content

CorePlotting::CpuLineBatchIntersector

CorePlotting::CpuLineBatchIntersector

#include <CpuLineBatchIntersector.hpp>

Inherits from CorePlotting::ILineBatchIntersector

Public Functions

Name
virtual LineIntersectionResult intersect(LineBatchData const & batch, LineIntersectionQuery const & query) const override
Find all lines in batch whose segments intersect the query line.
bool segmentsIntersect(glm::vec2 a1, glm::vec2 a2, glm::vec2 b1, glm::vec2 b2, float tolerance)
Test whether two line segments intersect (or are within tolerance).
float distancePointToSegment(glm::vec2 point, glm::vec2 seg_start, glm::vec2 seg_end)
Shortest distance from a point to a line segment.

Additional inherited members

Public Functions inherited from CorePlotting::ILineBatchIntersector

Name
virtual ~ILineBatchIntersector() =default

Public Functions Documentation

function intersect

virtual LineIntersectionResult intersect(
    LineBatchData const & batch,
    LineIntersectionQuery const & query
) const override

Find all lines in batch whose segments intersect the query line.

Parameters:

  • batch The batch of line segments to test against.
  • query The query line and transform parameters.

Return: Indices of intersected lines (0-based into batch.lines).

Reimplements: CorePlotting::ILineBatchIntersector::intersect

Only visible lines (visibility_mask == 1) are tested.

function segmentsIntersect

static bool segmentsIntersect(
    glm::vec2 a1,
    glm::vec2 a2,
    glm::vec2 b1,
    glm::vec2 b2,
    float tolerance
)

Test whether two line segments intersect (or are within tolerance).

Uses the same algorithm as the GPU compute shader:

  1. Distance-from-endpoint checks (thick-line tolerance).
  2. Geometric cross-product based segment-segment intersection.

function distancePointToSegment

static float distancePointToSegment(
    glm::vec2 point,
    glm::vec2 seg_start,
    glm::vec2 seg_end
)

Shortest distance from a point to a line segment.


Updated on 2026-11-13 at 20:25:42 +0000