Skip to content

Commit

Permalink
Add toggles for heightfield filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
twoscomplement authored and hymerman committed Jan 12, 2017
1 parent a2e16b8 commit 12e8950
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
4 changes: 4 additions & 0 deletions RecastDemo/Include/Sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ class Sample
float m_detailSampleDist;
float m_detailSampleMaxError;
int m_partitionType;

bool m_filterLowHangingObstacles;
bool m_filterLedgeSpans;
bool m_filterWalkableLowHeightSpans;

SampleTool* m_tool;
SampleToolState* m_toolStates[MAX_TOOLS];
Expand Down
14 changes: 13 additions & 1 deletion RecastDemo/Source/Sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ Sample::Sample() :
m_crowd(0),
m_navMeshDrawFlags(DU_DRAWNAVMESH_OFFMESHCONS|DU_DRAWNAVMESH_CLOSEDLIST),
m_tool(0),
m_ctx(0)
m_ctx(0),
m_filterLowHangingObstacles(true),
m_filterLedgeSpans(true),
m_filterWalkableLowHeightSpans(true)
{
resetCommonSettings();
m_navQuery = dtAllocNavMeshQuery();
Expand Down Expand Up @@ -201,6 +204,15 @@ void Sample::handleCommonSettings()
if (imguiCheck("Layers", m_partitionType == SAMPLE_PARTITION_LAYERS))
m_partitionType = SAMPLE_PARTITION_LAYERS;

imguiSeparator();
imguiLabel("Filtering");
if (imguiCheck("Low Hanging Obstacles", m_filterLowHangingObstacles))
m_filterLowHangingObstacles = !m_filterLowHangingObstacles;
if (imguiCheck("Ledge Spans", m_filterLedgeSpans))
m_filterLedgeSpans= !m_filterLedgeSpans;
if (imguiCheck("Walkable Low Height Spans", m_filterWalkableLowHeightSpans))
m_filterWalkableLowHeightSpans = !m_filterWalkableLowHeightSpans;

imguiSeparator();
imguiLabel("Polygonization");
imguiSlider("Max Edge Length", &m_edgeMaxLen, 0.0f, 50.0f, 1.0f);
Expand Down
9 changes: 6 additions & 3 deletions RecastDemo/Source/Sample_SoloMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,12 @@ bool Sample_SoloMesh::handleBuild()
// Once all geoemtry is rasterized, we do initial pass of filtering to
// remove unwanted overhangs caused by the conservative rasterization
// as well as filter spans where the character cannot possibly stand.
rcFilterLowHangingWalkableObstacles(m_ctx, m_cfg.walkableClimb, *m_solid);
rcFilterLedgeSpans(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid);
rcFilterWalkableLowHeightSpans(m_ctx, m_cfg.walkableHeight, *m_solid);
if (m_filterLowHangingObstacles)
rcFilterLowHangingWalkableObstacles(m_ctx, m_cfg.walkableClimb, *m_solid);
if (m_filterLedgeSpans)
rcFilterLedgeSpans(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid);
if (m_filterWalkableLowHeightSpans)
rcFilterWalkableLowHeightSpans(m_ctx, m_cfg.walkableHeight, *m_solid);


//
Expand Down
9 changes: 6 additions & 3 deletions RecastDemo/Source/Sample_TileMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1056,9 +1056,12 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const
// Once all geometry is rasterized, we do initial pass of filtering to
// remove unwanted overhangs caused by the conservative rasterization
// as well as filter spans where the character cannot possibly stand.
rcFilterLowHangingWalkableObstacles(m_ctx, m_cfg.walkableClimb, *m_solid);
rcFilterLedgeSpans(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid);
rcFilterWalkableLowHeightSpans(m_ctx, m_cfg.walkableHeight, *m_solid);
if (m_filterLowHangingObstacles)
rcFilterLowHangingWalkableObstacles(m_ctx, m_cfg.walkableClimb, *m_solid);
if (m_filterLedgeSpans)
rcFilterLedgeSpans(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid);
if (m_filterWalkableLowHeightSpans)
rcFilterWalkableLowHeightSpans(m_ctx, m_cfg.walkableHeight, *m_solid);

// Compact the heightfield so that it is faster to handle from now on.
// This will result more cache coherent data as well as the neighbours
Expand Down

0 comments on commit 12e8950

Please sign in to comment.