Skip to content

navmap_core: keep_vertices in simplify, cut_along_lines and refine - #47

Open
jmguerreroh wants to merge 1 commit into
EasyNavigation:rollingfrom
jmguerreroh:navmap-core-subdivide
Open

jmguerreroh wants to merge 1 commit into
EasyNavigation:rollingfrom
jmguerreroh:navmap-core-subdivide

Conversation

@jmguerreroh

Copy link
Copy Markdown
Contributor

Branch base: rolling. Files: navmap_core (Simplify, new Subdivide.hpp/.cpp and their
tests). What a level-of-detail maps manager needs to cut a large NavMap into tiles, simplify them
apart and put them back together, and to add detail where obstacles appear.

Independent of #45 and #46. It touches the end of SimplifyParams, as #46 does: whichever is
merged second needs a one-line rebase.

SimplifyParams::keep_vertices

Vertices (ids of the input map) that simplify() never removes: other vertices may collapse
onto them, they never collapse. For example, where the borders of maps simplified apart must
meet.

cut_along_lines(nm, {xs, ys})

Splits the NavCels the lines x = c and y = c cross, so that none crosses one (for example, to cut
a map into tiles along a grid). A vertex within snap of a line is moved onto it, and new
vertices are put exactly on it: every vertex on a line has exactly the line's coordinate. The
point where an edge crosses a line is computed once, so the NavCels on both sides share it and
there are no cracks.

refine(nm, points, max_edge) and refine(nm, max_edge_at)

Longest-edge bisection (Rivara). An edge is split at its middle in every NavCel that has it,
after first splitting the longer edges of its neighbours if needed, so the mesh stays conforming
and the NavCels keep their shape.

  • With points: the NavCels under the points get no edge longer than max_edge. A point on an
    edge or a vertex refines the NavCels on every side.
  • With a function: it gives the largest edge each NavCel may have (for example, every NavCel
    within some distance of an obstacle). All the work happens in one pass; if no NavCel is too
    large, the map is left untouched.

Both carry layer values, surfaces and vertex colours (interpolated). NavCels at the end of a link
are not split.

Tests

test_subdivide, 7 tests:

  • No cracks: no vertex lies in the middle of another NavCel's edge.
  • Area: the area is preserved.
  • Cutting: no NavCel crosses a line, and vertices on a line have exactly its coordinate.
  • Refining: refinement stays local, layers are carried, points off the map are ignored,
    links are respected, and a point on an edge refines both sides.
  • Region refinement: every NavCel within the region meets its bound.

Plus KeptVerticesAreNeverRemoved in test_simplify.

colcon test --packages-select navmap_core on this branch: 347 tests (with the linters), no
failures.

- SimplifyParams::keep_vertices: vertices never removed (others may collapse onto them), e.g.
  where the borders of maps simplified apart must meet.
- cut_along_lines (Subdivide.hpp): splits the NavCels the lines x = c, y = c cross, so none
  crosses one; vertices on a line get exactly its coordinate, new ones are shared (no cracks).
- refine: longest-edge bisection of the NavCels under some points, or of a region given by the
  largest edge each NavCel may have; conforming, layers, surfaces and colours carried.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant