コード例 #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
ファイル: XZGridCell.cs プロジェクト: PawelPajor/agaq-builder
 public XZGridCell(int cellIndexX, int cellIndexZ, XZGrid parentGrid)
 {
     _cellIndexX = cellIndexX;
     _cellIndexZ = cellIndexZ;
     _parentGrid = parentGrid;
 }