I've added Gizmos to RVONavmesh : possible bug?

In my “quest” to learn more about RVOObstacle, I’ve implemented Gizmos to the RVONavmesh script. I don’t know if I’ve done something wrong, but there are strange effects on some lines (see picture below).

`
/** Draws Gizmos */
public void OnDrawGizmos()
{
OnDrawGizmos(false);
}

/** Draws Gizmos */
public void OnDrawGizmosSelected()
{
    OnDrawGizmos(true);
}

/** Draws Gizmos */
public void OnDrawGizmos(bool selected)
{
    Gizmos.color = new Color(0.615f, 1, 0.06f, selected ? 1.0f : 0.7f);

    foreach (ObstacleVertex ov in obstacles)
    {
        if (ov.next == null)
            throw new System.InvalidOperationException("obstacles[...].next == null");
        
        Gizmos.DrawLine(ov.position, ov.next.position);

        if (selected)
        {
            // Draw the little arrow to show the direction of the obstacle
            Vector3 a = ov.position;
            Vector3 b = ov.next.position;

            Vector3 avg = (a + b) * 0.5f;
            Vector3 tang = (b - a).normalized;
            if (tang != Vector3.zero)
            {
                Vector3 normal = Vector3.Cross(Vector3.up, tang);

                Gizmos.DrawLine(avg, avg + normal);
                Gizmos.DrawLine(avg + normal, avg + normal * 0.5f + tang * 0.5f);
                Gizmos.DrawLine(avg + normal, avg + normal * 0.5f - tang * 0.5f);
            }
        }
    }
}

`

RVONavmesh gizmo

Nope no bug.
Some edges need to be split for better lookup.
If you instead do this it would work:
ObstacleVertex c, start = obstacles[0]; c = start; do { c = c.next; Debug.DrawLine (c.position, c.next.position, Color.red); } while (c != start);

Thank you for your answer, now it works. And like described in your documentation, line obstacle have 2 sides.

So I have a new question : why double sides for the limit of the walkable zone ?

If, for any reason, an agent is outside, we probably want him back, and isn’t it two times more obstacles computations for nothing?

The reason is simple: I didn’t have time to do something fancy when I first implemented it. Optimally I would make a toggle so you can specify inside, outside or both sides.
I will implement a more optimized (I can make it use less memory with a better implementation) and customizable version in a future version.

Thank you for this quick answer. I really have a lot of fun with your package, and I learn a tons of new things.

If I can help or freely contribute to your project, feel free to contact me at patmail at aftermoon dot net. I plan to work more on the RVONavmesh equivalent for GridGraph and would be happy to have your advice on this subject.

CU

Pat

Hi

Thank you for offering me that!
If you want, I could give you git access so you could branch it and make your own improvements directly to it. Interested?

Nice work on the RVONavmesh by the way! It’s nice to see people making improvements and sharing them with others! :smiley:

GIT access, yes I’m interested, another new subject for me to learn, it will change me of years of SVN :wink:

Cool! I have sent you an email.