private void PerformSwapInOut(UQtLeaf activeLeaf) { // 1. the initial in/out leaves generation List <UQtLeaf> inLeaves; List <UQtLeaf> outLeaves; UQtAlgo.GenerateSwappingLeaves(_root, activeLeaf, _holdingLeaves, out inLeaves, out outLeaves); // 2. filter out leaves which are already in the ideal states inLeaves.RemoveAll((leaf) => { return(_swapInQueue.Contains(leaf)); }); // 3. append these new items to in/out queue SwapIn(inLeaves); SwapOut(outLeaves); }
private static void GenerateLeavesByDist(UQtNode node, UQtLeaf active, float dist, ref List <UQtLeaf> leaves) { if (!Intersects(node.Bound, active.Bound.center, dist)) { return; } if (node is UQtLeaf) { leaves.Add(node as UQtLeaf); } else { foreach (var sub in node.SubNodes) { GenerateLeavesByDist(sub, active, dist, ref leaves); } } }
public static void GenerateSwappingLeaves(UQtNode node, UQtLeaf active, List<UQtLeaf> holdingLeaves, out List<UQtLeaf> inLeaves, out List<UQtLeaf> outLeaves) { List<UQtLeaf> inList = new List<UQtLeaf>(); GenerateLeavesByDist(node, active, UQtConfig.CellSwapInDist, ref inList); inList.RemoveAll((item) => holdingLeaves.Contains(item)); inLeaves = inList; List<UQtLeaf> outList = new List<UQtLeaf>(); GenerateLeavesByDist(node, active, UQtConfig.CellSwapOutDist, ref outList); List<UQtLeaf> outFilteredList = new List<UQtLeaf>(); foreach (var leaf in holdingLeaves) { if (!outList.Contains(leaf)) { outFilteredList.Add(leaf); } } outLeaves = outFilteredList; }
private bool UpdateFocus(Vector2 focusPoint) { _focusPoint = focusPoint; UQtLeaf newLeaf = UQtAlgo.FindLeafRecursively(_root, _focusPoint); if (newLeaf == _focusLeaf) { return(false); } if (FocusCellChanged != null) { FocusCellChanged(_focusLeaf, newLeaf); } _focusLeaf = newLeaf; return(true); }
public static void GenerateSwappingLeaves(UQtNode node, UQtLeaf active, List <UQtLeaf> holdingLeaves, out List <UQtLeaf> inLeaves, out List <UQtLeaf> outLeaves) { List <UQtLeaf> inList = new List <UQtLeaf>(); GenerateLeavesByDist(node, active, UQtConfig.CellSwapInDist, ref inList); inList.RemoveAll((item) => holdingLeaves.Contains(item)); inLeaves = inList; List <UQtLeaf> outList = new List <UQtLeaf>(); GenerateLeavesByDist(node, active, UQtConfig.CellSwapOutDist, ref outList); List <UQtLeaf> outFilteredList = new List <UQtLeaf>(); foreach (var leaf in holdingLeaves) { if (!outList.Contains(leaf)) { outFilteredList.Add(leaf); } } outLeaves = outFilteredList; }
public static UQtLeaf FindLeafRecursively(UQtNode node, Vector2 point) { if (!node.Bound.Contains(point)) { return(null); } if (node is UQtLeaf) { return(node as UQtLeaf); } foreach (var sub in node.SubNodes) { UQtLeaf leaf = FindLeafRecursively(sub, point); if (leaf != null) { return(leaf); } } UCore.Assert(false); // should never reaches here return(null); }
private static void GenerateLeavesByDist(UQtNode node, UQtLeaf active, float dist, ref List<UQtLeaf> leaves) { if (!Intersects(node.Bound, active.Bound.center, dist)) return; if (node is UQtLeaf) leaves.Add(node as UQtLeaf); else foreach (var sub in node.SubNodes) GenerateLeavesByDist(sub, active, dist, ref leaves); }
private bool UpdateFocus(Vector2 focusPoint) { _focusPoint = focusPoint; UQtLeaf newLeaf = UQtAlgo.FindLeafRecursively(_root, _focusPoint); if (newLeaf == _focusLeaf) return false; if (FocusCellChanged != null) FocusCellChanged(_focusLeaf, newLeaf); _focusLeaf = newLeaf; return true; }
private void PerformSwapInOut(UQtLeaf activeLeaf) { // 1. the initial in/out leaves generation List<UQtLeaf> inLeaves; List<UQtLeaf> outLeaves; UQtAlgo.GenerateSwappingLeaves(_root, activeLeaf, _holdingLeaves, out inLeaves, out outLeaves); // 2. filter out leaves which are already in the ideal states inLeaves.RemoveAll((leaf) => { return _swapInQueue.Contains(leaf); }); // 3. append these new items to in/out queue SwapIn(inLeaves); SwapOut(outLeaves); }