private EdgeData GetApproximationEdge(RayData startEdgeRayData, RayData endEdgeRayData) { if (_approximationPrecision <= 0) { return(null); } Vector3 center = transform.position; float maxAngle = Vector3.Angle(startEdgeRayData.m_direction, endEdgeRayData.m_direction); float curAngle = _approximationPrecision; RayData edgeRayData = new RayData(center, startEdgeRayData.m_angle + _approximationPrecision, _radius); UpdateRaycast(edgeRayData); while (RayData.IsHittingSameObject(startEdgeRayData, edgeRayData)) { curAngle += _approximationPrecision; if (curAngle > maxAngle) { edgeRayData = null; break; } edgeRayData.UpdateDirection(_approximationPrecision); UpdateRaycast(edgeRayData); } if (edgeRayData == null) { return(null); } EdgeData edgeData = new EdgeData(); edgeData.m_secondRay = edgeRayData; edgeData.m_firstRay = new RayData(center, edgeRayData.m_angle - _approximationPrecision, _radius); UpdateRaycast(edgeData.m_firstRay); return(edgeData); }
private EdgeData GetBisectionEdge(RayData startEdgeRayData, RayData endEdgeRayData) { if (!startEdgeRayData.m_hit && !endEdgeRayData.m_hit) { return(GetApproximationEdge(startEdgeRayData, endEdgeRayData)); } if (RayData.IsHittingSameObject(startEdgeRayData, endEdgeRayData)) { return(null); } Vector3 center = transform.position; EdgeData edgeData = new EdgeData(); float angle = 0; RayData edgeRayData = null; for (int i = 0; i < _bisectionCount; i++) { angle = (startEdgeRayData.m_angle + endEdgeRayData.m_angle) / 2; edgeRayData = new RayData(center, angle, _radius); UpdateRaycast(edgeRayData); if (RayData.IsHittingSameObject(startEdgeRayData, edgeRayData)) { startEdgeRayData = edgeRayData; } else { endEdgeRayData = edgeRayData; } } edgeData.m_firstRay = startEdgeRayData; edgeData.m_secondRay = endEdgeRayData; return(edgeData); }