swordlegend / recastnavigation

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

Crash issues #129

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I´ve encountered two issues recently porting the demo code to my own project.

1. In Sample_SoloMeshSimple.cpp the borderSize is not set in the configuration 
and used by while it is used by rcBuildRegions().

2. I encounter a crash in paintRectRegion() when using a small 1x1x1 cube 
(MinMax = -0.5 <-> 0.5) as input geometry. Increasing the x/z size resolves the 
crash. I´m sure that this happens due to incompatible settings but it 
shouldn´t crash anyway.
My configuration is:

    rcConfig m_cfg;
    m_cfg.cs = 0.3f;
    m_cfg.ch = 0.2f;
    m_cfg.walkableSlopeAngle = 45.0f;
    m_cfg.walkableHeight = (int)ceilf(2.0f / m_cfg.ch);
    m_cfg.walkableClimb = (int)floorf(0.9f / m_cfg.ch);
    m_cfg.walkableRadius = (int)ceilf(0.6f / m_cfg.cs);
    m_cfg.maxEdgeLen = (int)(12.0f / m_cfg.cs);
    m_cfg.maxSimplificationError = 1.3f;
    m_cfg.minRegionArea = (int)rcSqr(8);        // Note: area = size*size
    m_cfg.mergeRegionArea = (int)rcSqr(20); // Note: area = size*size
    m_cfg.maxVertsPerPoly = (int)6.0f;
    m_cfg.borderSize = m_cfg.walkableRadius + 3; // Reserve enough padding.
    m_cfg.detailSampleDist = 6.0f < 0.9f ? 0 : m_cfg.cs * 6.0f;
    m_cfg.detailSampleMaxError = m_cfg.ch * 1.0f;

Original issue reported on code.google.com by xadhoom...@googlemail.com on 14 Oct 2010 at 9:53

GoogleCodeExporter commented 9 years ago
When building single mesh borderSize should be zero. In the sample I memset the 
whole structure to 0 before setting the values:

        // Init build configuration from GUI
        memset(&m_cfg, 0, sizeof(m_cfg));
        m_cfg.cs = m_cellSize;
        ....

Original comment by memono...@gmail.com on 14 Oct 2010 at 12:53

GoogleCodeExporter commented 9 years ago
As for pt 2. what does rcCalcGridSize() return?

Original comment by memono...@gmail.com on 14 Oct 2010 at 12:55

GoogleCodeExporter commented 9 years ago
Thank you for your answer. I can confirm that I did not set the border value to 
zero. I´ve overlooked this detail unfortunately.

Changing the border value to zero also stops the crashes mentioned in (2). 
Using the initial value (m_cfg.walkableRadius + 3) crashed.

rcCalcGridSize returns 3 3 for width and height (Min: -0.5 -0.5 -0.5, Max: 0.5 
0.5 0.5, m_cfg.cs: 0.3f, m_cfg.ch: 0.2f).

It seems that the crash occurs with small meshes and my initial border value 
(m_cfg.walkableRadius + 3).

Original comment by xadhoom...@googlemail.com on 14 Oct 2010 at 2:47

GoogleCodeExporter commented 9 years ago
I made the border calculation more safe so they will not crash in your small 
cube case either (R237).
The correct solution in your case was to initialize borderSize to 0.

Original comment by memono...@gmail.com on 15 Oct 2010 at 7:10

GoogleCodeExporter commented 9 years ago
I´m currently integrating Recast into Unity. Given the possiblity to select 
any kind of meshes for recasting alongwith a (maybe inconsistent) set of 
parameter configurations provided by the user interface its quite important 
that Recast is able to handle these.

Thank you very much!
Mirko

Original comment by xadhoom...@googlemail.com on 15 Oct 2010 at 7:24