Пример #1
0
    void ChangeHeights()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            var pos  = hit.point;
            var minD = float.MaxValue;
            CoastlinesGen.Node nearestSite = null;
            foreach (var node in newGraph.nodes)
            {
                var d = Vector3.Distance(pos, node.point);
                if (minD > d)
                {
                    minD        = d;
                    nearestSite = node;
                }
            }

            if (nearestSite == null)
            {
                return;
            }

            var p = nearestSite.edges[0].startPoint;
            Debug.Log("adding height to " + p);

            heightMap.AddTo(p);
            CreateChunks();
        }
    }