forked from bit/DotRecastNetSim
refactor: RcBuildContoursFlags
This commit is contained in:
parent
2169a18c85
commit
e718f6174e
|
@ -0,0 +1,10 @@
|
||||||
|
namespace DotRecast.Recast
|
||||||
|
{
|
||||||
|
/// Contour build flags.
|
||||||
|
/// @see rcBuildContours
|
||||||
|
public static class RcBuildContoursFlags
|
||||||
|
{
|
||||||
|
public const int RC_CONTOUR_TESS_WALL_EDGES = 0x01; //< Tessellate solid (impassable) edges during contour simplification.
|
||||||
|
public const int RC_CONTOUR_TESS_AREA_EDGES = 0x02; //< Tessellate edges between areas during contour simplification.
|
||||||
|
}
|
||||||
|
}
|
|
@ -237,7 +237,7 @@ namespace DotRecast.Recast
|
||||||
//
|
//
|
||||||
|
|
||||||
// Create contours.
|
// Create contours.
|
||||||
RcContourSet cset = RcContours.BuildContours(ctx, chf, cfg.MaxSimplificationError, cfg.MaxEdgeLen, RcConstants.RC_CONTOUR_TESS_WALL_EDGES);
|
RcContourSet cset = RcContours.BuildContours(ctx, chf, cfg.MaxSimplificationError, cfg.MaxEdgeLen, RcBuildContoursFlags.RC_CONTOUR_TESS_WALL_EDGES);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Step 6. Build polygons mesh from contours.
|
// Step 6. Build polygons mesh from contours.
|
||||||
|
|
|
@ -84,13 +84,6 @@ namespace DotRecast.Recast
|
||||||
/// @see rcPolyMesh::polys
|
/// @see rcPolyMesh::polys
|
||||||
public const int RC_MESH_NULL_IDX = 0xffff;
|
public const int RC_MESH_NULL_IDX = 0xffff;
|
||||||
|
|
||||||
public const int RC_CONTOUR_TESS_WALL_EDGES = 0x01;
|
|
||||||
|
|
||||||
/// < Tessellate solid (impassable) edges during contour
|
|
||||||
/// simplification.
|
|
||||||
public const int RC_CONTOUR_TESS_AREA_EDGES = 0x02;
|
|
||||||
|
|
||||||
|
|
||||||
public const int RC_LOG_WARNING = 1;
|
public const int RC_LOG_WARNING = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -374,7 +374,7 @@ namespace DotRecast.Recast
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split too long edges.
|
// Split too long edges.
|
||||||
if (maxEdgeLen > 0 && (buildFlags & (RC_CONTOUR_TESS_WALL_EDGES | RC_CONTOUR_TESS_AREA_EDGES)) != 0)
|
if (maxEdgeLen > 0 && (buildFlags & (RcBuildContoursFlags.RC_CONTOUR_TESS_WALL_EDGES | RcBuildContoursFlags.RC_CONTOUR_TESS_AREA_EDGES)) != 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < simplified.Count / 4;)
|
for (int i = 0; i < simplified.Count / 4;)
|
||||||
{
|
{
|
||||||
|
@ -395,11 +395,16 @@ namespace DotRecast.Recast
|
||||||
// Tessellate only outer edges or edges between areas.
|
// Tessellate only outer edges or edges between areas.
|
||||||
bool tess = false;
|
bool tess = false;
|
||||||
// Wall edges.
|
// Wall edges.
|
||||||
if ((buildFlags & RC_CONTOUR_TESS_WALL_EDGES) != 0 && (points[ci * 4 + 3] & RC_CONTOUR_REG_MASK) == 0)
|
if ((buildFlags & RcBuildContoursFlags.RC_CONTOUR_TESS_WALL_EDGES) != 0 && (points[ci * 4 + 3] & RC_CONTOUR_REG_MASK) == 0)
|
||||||
|
{
|
||||||
tess = true;
|
tess = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Edges between areas.
|
// Edges between areas.
|
||||||
if ((buildFlags & RC_CONTOUR_TESS_AREA_EDGES) != 0 && (points[ci * 4 + 3] & RC_AREA_BORDER) != 0)
|
if ((buildFlags & RcBuildContoursFlags.RC_CONTOUR_TESS_AREA_EDGES) != 0 && (points[ci * 4 + 3] & RC_AREA_BORDER) != 0)
|
||||||
|
{
|
||||||
tess = true;
|
tess = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (tess)
|
if (tess)
|
||||||
{
|
{
|
||||||
|
|
|
@ -239,8 +239,7 @@ public class RecastSoloMeshTest
|
||||||
//
|
//
|
||||||
|
|
||||||
// Create contours.
|
// Create contours.
|
||||||
RcContourSet m_cset = RcContours.BuildContours(m_ctx, m_chf, cfg.MaxSimplificationError, cfg.MaxEdgeLen,
|
RcContourSet m_cset = RcContours.BuildContours(m_ctx, m_chf, cfg.MaxSimplificationError, cfg.MaxEdgeLen, RcBuildContoursFlags.RC_CONTOUR_TESS_WALL_EDGES);
|
||||||
RcConstants.RC_CONTOUR_TESS_WALL_EDGES);
|
|
||||||
|
|
||||||
Assert.That(m_cset.conts.Count, Is.EqualTo(expContours), "Contours");
|
Assert.That(m_cset.conts.Count, Is.EqualTo(expContours), "Contours");
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue