public static void Unregister(AmbientProbeGroup group) { if (groups.Contains(group)) { groups.Remove(group); } }
/// <summary> /// Return a struct with the nearest and 2nd nearest probe if the position is within any group's bounds /// </summary> /// <param name="position"></param> /// <returns></returns> public static ProbeInterpolation GetInterpolationData(Vector3 position) { ProbeInterpolation data = new ProbeInterpolation(); AmbientProbeGroup nearestGroup = GetNearestGroup(position); if (!nearestGroup) { return(data); } data.group = nearestGroup; data.source = GetNearestProbe(nearestGroup, position); data.dest = GetNearestProbe(nearestGroup, position, data.source); //Distance value can exceed 1, but this is fine, the lerp will still return the destination if (data.source != null && data.dest != null) { data.dist01 = (data.dest.position - position).magnitude / (data.dest.position - data.source.position).magnitude; } data.dist01 = Mathf.Abs(data.dist01); return(data); }
public static void Register(AmbientProbeGroup group) { if (groups.Contains(group) == false) { groups.Add(group); } }
public override void OnInspectorGUI() { EditorGUILayout.Space(); if (GUILayout.Button(new GUIContent("Edit probes", EditorGUIUtility.IconContent("LightProbeProxyVolume Gizmo").image), GUILayout.MaxWidth(125f), GUILayout.MaxHeight(30f))) { selected = script; AmbientProbesEditor.OpenWindow(); } EditorGUILayout.Space(); base.OnInspectorGUI(); }
//Note: Groups shouldn't have too many probes, otherwise some form of space partitioning is required! private static AmbientProbe GetNearestProbe(AmbientProbeGroup group, Vector3 position, AmbientProbe ignore = null) { AmbientProbe nearest = null; float minDist = 99999; for (int i = 0; i < group.probes.Count; i++) { //Assign the already closest probe to ignore, so we can get the 2nd clostest if (ignore != null && group.probes[i] == ignore) { continue; } if ((position - group.probes[i].position).sqrMagnitude < minDist) { nearest = group.probes[i]; minDist = (position - group.probes[i].position).sqrMagnitude; } } return(nearest); }
private void OnEnable() { script = (AmbientProbeGroup)target; selected = script; }