private XZGrid GetClosestHitGridAndMinT(List <XZGrid> allSnapGrids, Ray ray, out float minT) { minT = float.MaxValue; XZGrid closestSnapGrid = null; foreach (XZGrid snapGrid in allSnapGrids) { float t; if (snapGrid.Plane.Raycast(ray, out t) & t < minT) { minT = t; closestSnapGrid = snapGrid; } } return(closestSnapGrid); }
public GridCellRayHit GetGridCellRayHit() { Ray ray = GetWorldRay(); float minT; XZGrid closestGrid = GetClosestHitGridAndMinT(new List <XZGrid> { RuntimeEditorApplication.Instance.XZGrid }, ray, out minT); if (closestGrid != null) { return(GetGridCellHit(closestGrid, ray, minT)); } else { return(null); } }
public GridCellRayHit GetGridCellRayHit() { Ray ray; if (!InputDevice.Instance.GetPickRay(EditorCamera.Instance.Camera, out ray)) { return(null); } float minT; XZGrid closestGrid = GetClosestHitGridAndMinT(new List <XZGrid> { RuntimeEditorApplication.Instance.XZGrid }, ray, out minT); if (closestGrid != null) { return(GetGridCellHit(closestGrid, ray, minT)); } else { return(null); } }
private GridCellRayHit GetGridCellHit(XZGrid hitGrid, Ray ray, float t) { XZGridCell hitGridCell = hitGrid.GetCellFromWorldPoint(ray.GetPoint(t)); return(new GridCellRayHit(ray, t, hitGridCell)); }
public XZGridCell(int cellIndexX, int cellIndexZ, XZGrid parentGrid) { _cellIndexX = cellIndexX; _cellIndexZ = cellIndexZ; _parentGrid = parentGrid; }