void drawFieldOfView()
    {
        int   stepCount     = Mathf.RoundToInt(viewAngle * meshResolution);
        float stepAngleSize = viewAngle / stepCount;

        List <Vector3> viewPoints  = new List <Vector3> ();
        viewCastInfo   oldViewCast = new viewCastInfo();

        for (int i = 0; i <= stepCount; i++)
        {
            float        angle       = transform.eulerAngles.y - viewAngle / 2 + stepAngleSize * i;
            viewCastInfo newViewCast = viewCast(angle);

            if (i > 0)
            {
                bool edgeDstThresholdExceeded = Mathf.Abs(oldViewCast.dst - newViewCast.dst) > edgeDstThreshold;
                if (oldViewCast.hit != newViewCast.hit || (oldViewCast.hit && newViewCast.hit && edgeDstThresholdExceeded))
                {
                    edgeInfo edge = FindEdge(oldViewCast, newViewCast);
                    if (edge.pointA != Vector3.zero)
                    {
                        viewPoints.Add(edge.pointA);
                    }
                    if (edge.pointB != Vector3.zero)
                    {
                        viewPoints.Add(edge.pointB);
                    }
                }
            }

            viewPoints.Add(newViewCast.point);
            oldViewCast = newViewCast;
        }

        int vertexCount = viewPoints.Count + 1;

        Vector3[] vertices  = new Vector3[vertexCount];
        int[]     triangles = new int[(vertexCount - 2) * 3];

        vertices [0] = Vector3.zero;
        for (int i = 0; i < vertexCount - 1; i++)
        {
            vertices [i + 1] = transform.InverseTransformPoint(viewPoints [i]);

            if (i < vertexCount - 2)
            {
                triangles [i * 3]     = 0;
                triangles [i * 3 + 1] = i + 1;
                triangles [i * 3 + 2] = i + 2;
            }
        }

        viewMesh.Clear();
        viewMesh.vertices  = vertices;
        viewMesh.triangles = triangles;
        viewMesh.RecalculateNormals();
    }
        public async Task <IHttpActionResult> PostAddEdge(string id, edgeInfo info)
        {
            if (info == null)
            {
                return(BadRequest());
            }

            DocumentCollection graph = await client.CreateDocumentCollectionIfNotExistsAsync(
                UriFactory.CreateDatabaseUri("graphdb"),
                new DocumentCollection { Id = "Persons" },
                new RequestOptions { OfferThroughput = 400 });

            string grem = $"g.V('{id}').count()";
            IDocumentQuery <dynamic> query = client.CreateGremlinQuery <dynamic>(graph, grem);

            while (query.HasMoreResults)
            {
                foreach (dynamic result in await query.ExecuteNextAsync())
                {
                    if (result == 0)
                    {
                        return(NotFound());
                    }
                }
            }
            grem  = $"g.V('{info.v}').count()";
            query = client.CreateGremlinQuery <dynamic>(graph, grem);
            while (query.HasMoreResults)
            {
                foreach (dynamic result in await query.ExecuteNextAsync())
                {
                    if (result == 0)
                    {
                        grem  = $"g.addV('person').property('id', '{info.v}').property('Name', '{info.v}')";
                        query = client.CreateGremlinQuery <dynamic>(graph, grem);
                        await query.ExecuteNextAsync();
                    }
                }
            }

            grem  = $"g.V('{id}').addE('{info.label}').to(g.V('{info.v}'))";
            query = client.CreateGremlinQuery <dynamic>(graph, grem);
            await query.ExecuteNextAsync();

            return(Ok());
        }