private bool IsVisiblePoint(Vector3 center, Vector3 pos, out NormalizedPoint point) { var delta = pos - center; var sqrMag = delta.sqrMagnitude; if (sqrMag >= m_MinDistanceSqr && sqrMag <= m_MaxDistanceSqr) { var lonLat = Geometry.GetLonLat(m_ReferenceFrame, delta); if (m_LonLatRect.Contains(lonLat)) { float d = Mathf.Sqrt(sqrMag) - m_MinDistance; // > 0 // lon/lat -> norm. x/y point.Position = Rect.PointToNormalized(m_LonLatRect, lonLat); point.Position.z = d / m_DistanceRange; point.Position.z = m_ApplyWeight ? Normalization.InvSigmoid(point.Position.z, m_NormalizationWeight) : 1 - point.Position.z; // 0 at max, 1 at min distance point.DistanceRatio = m_DistanceRange / d; // 1 at max distance return(true); } } point = default; return(false); }
private void DrawNormalizationCurve() { Rect rect = GUILayoutUtility.GetRect(10, 1000, 50, 50); int w = Mathf.CeilToInt(rect.width / 50); float y = rect.height / 2; if (Event.current.type == EventType.Repaint) { GUI.BeginClip(rect); GL.PushMatrix(); GL.Clear(true, false, Color.black); m_GLMaterial.SetPass(0); GL.Begin(GL.QUADS); GL.Color(Color.black); GL.Vertex3(0, 0, 0); GL.Vertex3(rect.width, 0, 0); GL.Vertex3(rect.width, rect.height, 0); GL.Vertex3(0, rect.height, 0); GL.End(); float weight = m_Comp.NormalizationWeight; GL.Begin(GL.LINES); GL.Color(m_CurveColor); for (int x = 0; x <= rect.width; x++) { float t = x / rect.width; float s = Normalization.InvSigmoid(t, weight); GL.Vertex3(x, rect.height, 0); GL.Vertex3(x, rect.height - s * rect.height, 0); } GL.Color(Color.grey); for (int i = 1; i < w; i++) { float t = i / (float)w; float x = Mathf.Lerp(0, rect.width, t); GL.Vertex3(x, y, 0); GL.Vertex3(x, y - 5, 0); } GL.End(); GL.PopMatrix(); GUI.EndClip(); } for (int i = 1; i < w; i++) { float t = i / (float)w; float x = Mathf.Lerp(0, rect.width, t); float d = Mathf.Lerp(m_Comp.MinDistance, m_Comp.MaxDistance, t); EditorGUI.LabelField(new Rect(x + 4, rect.yMax - y, 80, 20), string.Format("{0:0.00}", d)); } }