Robmaister / SharpNav

Advanced Pathfinding for C#
sharpnav.com
Other
537 stars 129 forks source link

Exception "Span has no thickness" #14

Closed AqlaSolutions closed 10 years ago

AqlaSolutions commented 10 years ago

height = 5 span.Minimum = 5 span.Maximum = 6 After clamping minimum=maximum=5

    Cell.AddSpan(Span span):
        //clamp the span to the cell's range of [0, maxHeight]
        MathHelper.Clamp(ref span.Minimum, 0, height);
        MathHelper.Clamp(ref span.Maximum, 0, height);

        if (span.Minimum == span.Maximum)
            throw new ArgumentException("Span has no thickness.");
        else if (span.Maximum < span.Minimum)
            throw new ArgumentException("Span is inverted. Maximum is less than minimum.");

Any workarounds?

AqlaSolutions commented 10 years ago

Obj: g Navmesh v -8.831899 -0.5 13.27512 v 8.831899 -0.5 13.27512 v -8.831899 0.5 13.27512 v 8.831899 0.5 13.27512 v -8.831899 0.5 -13.27512 v 8.831899 0.5 -13.27512 v -8.831899 -0.5 -13.27512 v 8.831899 -0.5 -13.27512 v -8.831899 0.5 13.27512 v 8.831899 0.5 13.27512 v -8.831899 0.5 -13.27512 v 8.831899 0.5 -13.27512 v -8.831899 -0.5 -13.27512 v 8.831899 -0.5 13.27512 v 8.831899 -0.5 -13.27512 v -8.831899 -0.5 13.27512 v 8.831899 -0.5 13.27512 v 8.831899 0.5 -13.27512 v 8.831899 -0.5 -13.27512 v 8.831899 0.5 13.27512 v -8.831899 -0.5 -13.27512 v -8.831899 0.5 13.27512 v -8.831899 -0.5 13.27512 v -8.831899 0.5 -13.27512

vn 0 0 1 vn 0 0 1 vn 0 0 1 vn 0 0 1 vn 0 1 0 vn 0 1 0 vn 0 0 -1 vn 0 0 -1 vn 0 1 0 vn 0 1 0 vn 0 0 -1 vn 0 0 -1 vn 0 -1 0 vn 0 -1 0 vn 0 -1 0 vn 0 -1 0 vn 1 0 0 vn 1 0 0 vn 1 0 0 vn 1 0 0 vn -1 0 0 vn -1 0 0 vn -1 0 0 vn -1 0 0

vt 0 0 vt 1 0 vt 0 1 vt 1 1 vt 0 1 vt 1 1 vt 0 1 vt 1 1 vt 0 0 vt 1 0 vt 0 0 vt 1 0 vt 0 0 vt 1 1 vt 1 0 vt 0 1 vt 0 0 vt 1 1 vt 1 0 vt 0 1 vt 0 0 vt 1 1 vt 1 0 vt 0 1

usemtl Default-Diffuse usemap Default-Diffuse f 4/4/4 1/1/1 2/2/2 f 3/3/3 1/1/1 4/4/4 f 6/6/6 9/9/9 10/10/10 f 5/5/5 9/9/9 6/6/6 f 8/8/8 11/11/11 12/12/12 f 7/7/7 11/11/11 8/8/8 f 14/14/14 13/13/13 15/15/15 f 16/16/16 13/13/13 14/14/14 f 18/18/18 17/17/17 19/19/19 f 20/20/20 17/17/17 18/18/18 f 22/22/22 21/21/21 23/23/23 f 24/24/24 21/21/21 22/22/22

Robmaister commented 10 years ago

Sounds like an edge case. Thanks for including an .obj file, will investigate.

Robmaister commented 10 years ago

Yeah, so the bounding box I generate for a level is exactly the size of the level, and when you have a triangle exactly at the upper bound, it will think it's one voxel above the specified size. I'll fix this in a minute.

Robmaister commented 10 years ago

Provided .obj file can now be run through the Examples project without any problems. Thanks for finding this bug!