示例#1
0
    /// <summary>
    /// Tests if the middle of the segment is inside of an existing polygon.
    /// </summary>
    /// <param name="a"> Start point of the segment</param>
    /// <param name="b">End point of the segment</param>
    /// <returns>True if the segment is inside an existing polygon</returns>
    private bool IsInsideExistingPoly(PolyPoint a, PolyPoint b)
    {
        float   middleX     = (a.X + b.X) / 2.0f;
        float   middleY     = (a.Y + b.Y) / 2.0f;
        Vector2 middlePoint = new Vector2(middleX, middleY);

        Polygon poly;

        if (_cadastre.IsPointInsideExistingPolygon(middlePoint, out poly))
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
示例#2
0
    /// CONSTRUIRE Là OU ON CLICK !!!
    private void MouseRaycast()
    {
        RaycastHit hit;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 1000))
        {
            // Did we click inside a polygon
            Polygon hitPolygon = null;
            if (_cadastre.IsPointInsideExistingPolygon(hit.point, out hitPolygon))
            {
                _selectedZone = hitPolygon;
                BuildingCreator.Instance.TryCreateNewBuilding(hit.point, hitPolygon);
            }
            else
            {
                _selectedZone = null;
                _drawingTool.HandleNewClick(hit.point);
            }
        }
    }