//! returned hitFrame is in Scene coordinates! public SnapResult FindHitSnapPoint(Ray3f ray) { float fNearest = float.PositiveInfinity; ISnapPoint hitO = null; ISnapSegment hitSeg = null; int min_priority = int.MaxValue; foreach (var pt in Points) { if (!pt.IsEnabled()) { continue; } float fHitDist; if (pt.FindRayIntersection(ray, out fHitDist)) { if (fHitDist < fNearest || (pt.Priority < min_priority && MathUtil.EpsilonEqual(fHitDist, fNearest, 0.0001f))) { fNearest = fHitDist; hitO = pt; min_priority = pt.Priority; } } } foreach (var seg in Segments) { if (!seg.IsEnabled()) { continue; } float fHitDist; if (seg.FindRayIntersection(ray, out fHitDist) && fHitDist < fNearest) { fNearest = fHitDist; hitSeg = seg; hitO = null; } } if (hitO != null) { return(new SnapResult(hitO)); } else if (hitSeg != null) { Vector3f snapPosW = hitSeg.FindSnapPoint(ray); return(new SnapResult(hitSeg, scene.ToSceneP(snapPosW))); } return(null); }
public SnapResult(ISnapSegment seg, Vector3f hitScene) { FrameS = seg.GetHitFrameS(hitScene); Type = SnapType.Segment; Segment = seg; }