Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f711a19
A little re-arranging to begin with
sebsjames Jan 30, 2026
241e278
half edge structs. Thinking about what to replace in existing code
sebsjames Jan 31, 2026
93cfc4f
Now stored vertex in the he_vertex scheme
sebsjames Feb 1, 2026
6daa861
WIP converting to use of mesh::face<>
sebsjames Feb 1, 2026
038bad3
compute nvc, nvd
sebsjames Feb 1, 2026
5edf3cc
A couple of example programs that have to change along with updates t…
sebsjames Feb 1, 2026
2d41d53
Removes normal from mesh::face<>, but now programs crash (see model_c…
sebsjames Feb 1, 2026
f78370a
These ifdeffed out sections are important
sebsjames Feb 1, 2026
c499b34
Semantics for the ifdeffed out bits
sebsjames Feb 2, 2026
b442b32
Completes the removal of normal as a member of mesh::face.
sebsjames Feb 2, 2026
5e36d8c
Minor changes to ensure compilation. Need to check draw_triangles_int…
sebsjames Feb 2, 2026
850d98e
WIP. Lots of changes to convert to using halfedges
sebsjames Feb 2, 2026
efa9bf9
More debug WIP
sebsjames Feb 2, 2026
a9163bb
Committing, so I can go back and try non-pointer version again.
sebsjames Feb 2, 2026
387ff85
Plain indices seem to be working sensibly
sebsjames Feb 2, 2026
3642dab
Refactor halfedge index variable name
sebsjames Feb 3, 2026
d2f3aa2
First draft conversion to halfedges. Next up: find the twin halfedges
sebsjames Feb 3, 2026
eaa7a03
A basic twin finding algo
sebsjames Feb 3, 2026
6cc054c
Re-instate the triangle swapping. Improve the twin-finding
sebsjames Feb 3, 2026
6de328c
Removes some cruft
sebsjames Feb 3, 2026
b9c7f5a
Fixes to ensure everything compiles on my PC
sebsjames Feb 3, 2026
060e339
Use latest maths
sebsjames Feb 3, 2026
25edca4
A skeleton structure for NavMesh save/load
sebsjames Feb 3, 2026
17450ef
Adds a visualmodel hash function and navmesh load/save skeletons
sebsjames Feb 3, 2026
eb84deb
Removes stabilised a) it doesn't work as planned b) it should be an a…
sebsjames Feb 3, 2026
1127b70
Adds hdfsave to NavMesh
sebsjames Feb 3, 2026
2ce8264
Uses new binary_read/write to save data
sebsjames Feb 4, 2026
043bd2c
has the geometry only
sebsjames Feb 4, 2026
c21d1dd
Refactoring mostly
sebsjames Feb 4, 2026
07b107d
Minor - be sure to show expected filename on stdout. Some debug messages
sebsjames Feb 4, 2026
b0b06d0
Change NavException. Debug output change. Realised I need to fill hal…
sebsjames Feb 4, 2026
f179f5b
Better hash combindation
sebsjames Feb 5, 2026
927908b
Corrects ordering of triangles in GridVIsual, triangle mode
sebsjames Feb 5, 2026
e5141c0
Corrects clockwiseness of triangles in computeFlatQuad
sebsjames Feb 5, 2026
0de1c8f
Thursday work on NavMesh boundary halfedges
sebsjames Feb 5, 2026
bcff8cc
More flexibility in NormalsVisual
sebsjames Feb 6, 2026
06fc4e7
cout changes in NormalsVisual
sebsjames Feb 6, 2026
3c34f88
Make some messages debug only
sebsjames Feb 6, 2026
d17caad
Current progress. Seem to be correctly creating the navmesh. Found a …
sebsjames Feb 6, 2026
f30baaa
Tidy up
sebsjames Feb 6, 2026
6af97b6
Now we are off-edge tolerant (well as long as client code catches off…
sebsjames Feb 6, 2026
fb83545
Tail end of Friday's debugging
sebsjames Feb 9, 2026
5afcb44
Avoid inf loop in find_neighbours. Break out of one-neighbour do-whil…
sebsjames Feb 9, 2026
b07f7e7
Removes NavException
sebsjames Feb 9, 2026
f87c065
Because I removed NavException
sebsjames Feb 9, 2026
4e0e274
More debugging. Also add teh ability to pass in a navmesh directory f…
sebsjames Feb 9, 2026
8c320e1
Monday debugging
sebsjames Feb 9, 2026
7823310
next/prev visualization options
sebsjames Feb 10, 2026
e62940a
next/prev visualization options
sebsjames Feb 10, 2026
6cb126b
Starting to write navmesh test code, but more importantly fixes for n…
sebsjames Feb 10, 2026
24c8ac1
Final fix on prev/next and boundaries
sebsjames Feb 10, 2026
cbf6214
Progress. Still have a problem in ground_smaller2.gltf, but boundarie…
sebsjames Feb 10, 2026
cf269d3
Ok, got code to know if a navmesh built from a model is good or not.
sebsjames Feb 11, 2026
7cf7aa3
Make a test_neighbours function and a leaner find_neighbours function…
sebsjames Feb 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ else()
endif()
endif()
set(COMPREHENSIVE_WARNING_FLAGS "-Wall -Wextra -Wpedantic -pedantic-errors -Werror -Wfatal-errors -Wno-psabi")
set(CMAKE_CXX_FLAGS "-g ${COMPREHENSIVE_WARNING_FLAGS} -O3")
set(CMAKE_CXX_FLAGS "-g ${COMPREHENSIVE_WARNING_FLAGS} -O0")
if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
# Make it possible to compile complex constexpr functions (gcc only)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fconstexpr-ops-limit=5000000000")
Expand Down
18 changes: 9 additions & 9 deletions examples/draw_triangles_intersections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ int main()

auto start_wr = (vmi * start).less_one_dim(); // wr to tvp
std::cout << "start_wr = " << start_wr << std::endl;
auto [hit, ti, tn] = tvp->navmesh->find_triangle_crossing (start_wr, dirn);
if (ti[0] == std::numeric_limits<uint32_t>::max()) {
auto [hit, ti] = tvp->navmesh->find_triangle_crossing (start_wr, dirn, vm);
if (ti == std::numeric_limits<uint32_t>::max()) {
std::cout << "NO HIT\n";
} else {
std::cout << "Indices: " << ti[0] << "," << ti[1] << "," << ti[2] << std::endl;
std::cout << "Indices: " << ti << std::endl;
std::cout << "Contains hit " << hit << std::endl;

sv = std::make_unique<mplot::SphereVisual<>>(hit, 0.07, mplot::colour::springgreen2);
Expand All @@ -346,11 +346,11 @@ int main()
}

auto start_wr_fr2 = (vmi * start_fr2).less_one_dim(); // wr to tvp
auto [hit_fr2, ti_fr2, tn_fr2] = tvp->navmesh->find_triangle_crossing (start_wr_fr2, dirn_fr2);
if (ti[0] == std::numeric_limits<uint32_t>::max()) {
auto [hit_fr2, ti_fr2] = tvp->navmesh->find_triangle_crossing (start_wr_fr2, dirn_fr2, vm);
if (ti_fr2 == std::numeric_limits<uint32_t>::max()) {
std::cout << "NO HIT\n";
} else {
std::cout << "Indices: " << ti_fr2[0] << "," << ti_fr2[1] << "," << ti_fr2[2] << std::endl;
std::cout << "Indices: " << ti_fr2 << std::endl;
std::cout << "Contains hit " << hit_fr2 << std::endl;

sv = std::make_unique<mplot::SphereVisual<>>(hit_fr2, 0.07, mplot::colour::springgreen2);
Expand All @@ -361,11 +361,11 @@ int main()

auto start_wr_bh = (vmi * start_bh).less_one_dim(); // wr to tvp
std::cout << "start_wr = " << start_wr << std::endl;
auto [hit_bh, ti_bh, tn_bh] = tvp->navmesh->find_triangle_crossing (start_wr_bh, dirn_bh);
if (ti_bh[0] == std::numeric_limits<uint32_t>::max()) {
auto [hit_bh, ti_bh] = tvp->navmesh->find_triangle_crossing (start_wr_bh, dirn_bh, vm);
if (ti_bh == std::numeric_limits<uint32_t>::max()) {
std::cout << "NO HIT\n";
} else {
std::cout << "Indices: " << ti_bh[0] << "," << ti_bh[1] << "," << ti_bh[2] << std::endl;
std::cout << "Indices: " << ti_bh << std::endl;
std::cout << "Contains hit " << hit_bh << std::endl;

sv = std::make_unique<mplot::SphereVisual<>>(hit_bh, 0.07, mplot::colour::springgreen2);
Expand Down
31 changes: 31 additions & 0 deletions examples/grid_border2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
#include <mplot/Visual.h>
#include <mplot/VisualDataModel.h>
#include <mplot/GridVisual.h>
#include <mplot/NormalsVisual.h>

int main()
{
mplot::Visual v(1600, 1000, "Flat GridVisual grids with borders");
v.lightingEffects();
v.rotateAboutNearest (true);

// Create a grid to show in the scene
constexpr unsigned int Nside = 4; // You can change this
Expand Down Expand Up @@ -172,6 +174,35 @@ int main()
gv->addLabel ("Triangles, border (smaller is as expected)", lblpos, mplot::TextFeatures(0.08f));
gv->finalize();
v.addVisualModel (gv);

offset[0] += grid.width_of_pixels() * 1.2f;
gv = std::make_unique<mplot::GridVisual<float>>(&grid, offset);
v.bindmodel (gv);
gv->gridVisMode = mplot::GridVisMode::Triangles;
gv->setScalarData (&data);
gv->cm.setType (mplot::ColourMapType::Cork);
gv->zScale.do_autoscale = false;
gv->zScale.null_scaling();
gv->colourScale.do_autoscale = false;
gv->colourScale.compute_scaling (-1, 1);
// Border specific parameters
gv->showborder (false);
gv->addLabel ("Triangles, no border, showing halfedges", lblpos, mplot::TextFeatures(0.08f));
gv->finalize();
auto gvp = v.addVisualModel (gv);

// Make a navmesh for this last one
gvp->make_navmesh();

// Add a Normals visual for the last one, too
auto nrm = std::make_unique<mplot::NormalsVisual<>> (gvp);
v.bindmodel (nrm);
nrm->options.set (mplot::normalsvisual_flags::show_halfedges);
nrm->options.set (mplot::normalsvisual_flags::show_boundary_next);
nrm->options.set (mplot::normalsvisual_flags::show_boundary_prev);
nrm->finalize();
v.addVisualModel (nrm);

v.keepOpen();

return 0;
Expand Down
10 changes: 3 additions & 7 deletions examples/model_crawler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ int main (int argc, char** argv)
// Find the triangle that we're initially located above with
// mplot::NavMesh::find_triangle_hit. This updates internal state in NavMesh. It could be
// executed automatically in compute_mesh_movement
auto[hp_scene, tn0, ti0] = gvp->navmesh->find_triangle_hit (ca_view, sph_view);
std::cout << "Find hit finds hit point " << hp_scene << std::endl;
auto[hp_scene, ti0] = gvp->navmesh->find_triangle_hit (ca_view, sph_view);
std::cout << "Find hit finds hit point " << hp_scene << " with ti0 halfedge: " << ti0 << std::endl;

int move_counter = 0;
constexpr int move_max = 1000;
Expand All @@ -106,12 +106,8 @@ int main (int argc, char** argv)
// Compute a new movement over the landscape mesh (the sphere)
try {
ca_view = gvp->navmesh->compute_mesh_movement (mv_ca, ca_view, sph_view, hoverheight);
} catch (mplot::NavException& e) {
if (e.m_type == mplot::NavException::type::off_edge) {
std::cout << "You can handle movements that go off the edge of a flat model\n";
}
} catch (std::exception& e) {
std::cout << "Exception navigating mesh at movement count " << move_counter << ": " << e.what() << std::endl;
throw e;
}

// Update the viewmatrix of the coord arrows, setting its position within the scene
Expand Down
6 changes: 3 additions & 3 deletions examples/triangle_intersect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ int main (int argc, char** argv)

auto start_wr = (vmi * start).less_one_dim(); // wr to tvp
std::cout << "start_wr = " << start_wr << std::endl;
auto [hit, ti, tn] = tvp->navmesh->find_triangle_crossing (start_wr, dirn);
if (ti[0] == std::numeric_limits<uint32_t>::max()) {
auto [hit, ti] = tvp->navmesh->find_triangle_crossing (start_wr, dirn, vm);
if (ti == std::numeric_limits<uint32_t>::max()) {
std::cout << "NO HIT\n";
} else {
std::cout << "Indices: " << ti[0] << "," << ti[1] << "," << ti[2] << std::endl;
std::cout << "Indices: " << ti << std::endl;
std::cout << "Contains hit " << hit << std::endl;

sv = std::make_unique<mplot::SphereVisual<>>(hit, start_sphr * 1.1f, mplot::colour::springgreen2);
Expand Down
4 changes: 2 additions & 2 deletions mplot/GridVisual.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,12 @@ namespace mplot
// Triangle 1
I ii = ri * dims[0] + ci;
this->indices[ind_idx++] = (ii);
this->indices[ind_idx++] = (ii + dims[0] + 1); // NNE
this->indices[ind_idx++] = (ii + 1); // NE
this->indices[ind_idx++] = (ii + dims[0] + 1); // NNE
// Triangle 2
this->indices[ind_idx++] = (ii);
this->indices[ind_idx++] = (ii + dims[0]); // NN
this->indices[ind_idx++] = (ii + dims[0] + 1); // NNE
this->indices[ind_idx++] = (ii + dims[0]); // NN
}
}
} else if (this->grid->get_order() == sm::gridorder::topleft_to_bottomright) {
Expand Down
Loading
Loading