swordlegend / recastnavigation

Automatically exported from code.google.com/p/recastnavigation
zlib License
0 stars 0 forks source link

It's possible to create a Span of zero height #73

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
During rcRasterizeTriangles(), it's possible to have a triangle that ends up 
with a Span of zero height.  
This occurs if a triangle is laying *exactly* on the bottom of the bounding box 
(bmin[1]).

I think the fix is just to enforce a Span's minimal height to be at least one 
cell, in rasterizeTri().  
Changing the ismax to clamp from (1, 0x7fff) does the trick for me.

    unsigned short ismin = (unsigned short)rcClamp((int)floorf(smin * ich), 0, 0x7fff);
    unsigned short ismax = (unsigned short)rcClamp((int)ceilf(smax * ich), 1, 0x7fff);

What is the expected output? What do you see instead?
Expected all Spans to have at least a max-min distance of 1.  Getting some 
Spans that have a max-min 
distance of 0.

What version of the product are you using? On what operating system?
From the SVN trunk on XP.

Please provide any additional information below.
There could also be a snag in the rcBuildCompactHeightfield() method where it 
clamps the Span's bottom and 
top values (but I haven't verified this yet!).

Thanks for a fix!
-Erik

Original issue reported on code.google.com by R.Erik.J...@gmail.com on 4 May 2010 at 10:31

GoogleCodeExporter commented 9 years ago
Thread here:
http://groups.google.com/group/recastnavigation/browse_thread/thread/7ba4c655538
ed2f4

Original comment by R.Erik.J...@gmail.com on 4 May 2010 at 10:32

GoogleCodeExporter commented 9 years ago
Fixed in R163.

Original comment by memono...@gmail.com on 5 May 2010 at 1:16

GoogleCodeExporter commented 9 years ago
The new fix fixes also cases where ceil(x)==floor(x), which could create zero 
height spans too. the solution was 
to clamp smax between smin+1 and 0x7fff.

Original comment by memono...@gmail.com on 5 May 2010 at 1:17