예제 #1
0
        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);
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        private GridCellRayHit GetGridCellHit(XZGrid hitGrid, Ray ray, float t)
        {
            XZGridCell hitGridCell = hitGrid.GetCellFromWorldPoint(ray.GetPoint(t));

            return(new GridCellRayHit(ray, t, hitGridCell));
        }
예제 #5
0
 public XZGridCell(int cellIndexX, int cellIndexZ, XZGrid parentGrid)
 {
     _cellIndexX = cellIndexX;
     _cellIndexZ = cellIndexZ;
     _parentGrid = parentGrid;
 }