Skip to content

Commit ebf52fb

Browse files
committed
QueryRayLine
1 parent 896d264 commit ebf52fb

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/Aardvark.Geometry.PointSet/Queries/QueriesRayLine3d.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,21 @@ public static IEnumerable<Chunk> QueryPointsNearLineSegment(
102102
if (node.Positions.Length == 0) yield break;
103103

104104
var centerGlobal = node.DataBounds.Center;
105-
var s0Local = lineSegment.P0 - centerGlobal;
106-
var s1Local = lineSegment.P1 - centerGlobal;
107-
var rayLocal = new Ray3d(s0Local, (s1Local - s0Local).Normalized);
105+
var s0 = lineSegment.P0;
106+
var s1 = lineSegment.P1;
107+
var ray = new Ray3d(s0, (s1 - s0).Normalized);
108108

109109
var worstCaseDist = node.DataBounds.Size3d.Length * 0.5 + maxDistanceToRay;
110-
// var d0 = rayLocal.GetMinimalDistanceTo(node.BoundigBoxExactLocal.Center);
111-
// if (d0 > worstCaseDist) yield break;
110+
var d0 = ray.GetMinimalDistanceTo(node.DataBounds.Center);
111+
if (d0 > worstCaseDist) yield break;
112112

113113
var nodeCell = new Cell(node.CellBounds);
114114
if (node.Children.Length == 0 || nodeCell.Exponent == minCellExponent)
115115
{
116116
if (node.KdTree != null)
117117
{
118+
var s0Local = s0 - node.KdTree.Value.Offset;
119+
var s1Local = s1 - node.KdTree.Value.Offset;
118120
var indexArray = node.KdTree.Value.Tree.GetClosestToLine(
119121
(V3f)s0Local, (V3f)s1Local,
120122
(float)maxDistanceToRay,
@@ -130,12 +132,12 @@ public static IEnumerable<Chunk> QueryPointsNearLineSegment(
130132
else
131133
{
132134
// do it without kd-tree ;-)
133-
var psLocal = node.Positions;
135+
var ps = node.Positions;
134136

135137
var res = new List<int>();
136-
for (var i = 0; i < psLocal.Length; i++)
138+
for (var i = 0; i < ps.Length; i++)
137139
{
138-
var d = rayLocal.GetMinimalDistanceTo(psLocal[i]);
140+
var d = ray.GetMinimalDistanceTo(ps[i]);
139141
if (d > maxDistanceToRay) continue;
140142
res.Add(i);
141143
}

0 commit comments

Comments
 (0)