From 18ececd8733009afcd5c013c2e2fc986135816a3 Mon Sep 17 00:00:00 2001 From: local Date: Wed, 18 Jun 2025 21:37:34 -0700 Subject: [PATCH 1/9] expose additional debug drawing functions --- .../recast-navigation.idl | 38 +++++ .../src/DebugDraw/DebugDraw.cpp | 135 ++++++++++++++++++ .../src/DebugDraw/DebugDraw.h | 29 ++++ .../src/DebugDraw/RecastDebugDraw.cpp | 15 ++ .../src/DebugDraw/RecastDebugDraw.h | 5 + 5 files changed, 222 insertions(+) diff --git a/packages/recast-navigation-wasm/recast-navigation.idl b/packages/recast-navigation-wasm/recast-navigation.idl index 8c7d9c39..9895e101 100644 --- a/packages/recast-navigation-wasm/recast-navigation.idl +++ b/packages/recast-navigation-wasm/recast-navigation.idl @@ -1208,6 +1208,34 @@ interface duDebugDraw { }; interface DebugDraw { + unsigned long RGBA(long r, long g, long b, long a); + unsigned long RGBAf(float fr, float fg, float fb, float fa); + unsigned long IntToCol(long i, long a); + void IntToColVector(long i, float[] col); + unsigned long MultCol([Const] unsigned long col, [Const] unsigned long d); + unsigned long DarkenCol(unsigned long col); + unsigned long LerpCol(unsigned long ca, unsigned long cb, unsigned long u); + unsigned long TransCol(unsigned long c, unsigned long a); + + void CalcBoxColors(unsigned long[] colors, unsigned long colTop, unsigned long colSide); + void DebugDrawCylinderWire(duDebugDraw dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned long col, [Const] float lineWidth); + void DebugDrawBoxWire(duDebugDraw dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned long col, [Const] float lineWidth); + void DebugDrawArc(duDebugDraw dd, [Const] float x0, [Const] float y0, [Const] float z0, [Const] float x1, [Const] float y1, [Const] float z1, [Const] float h, [Const] float as0, [Const] float as1, unsigned long col, [Const] float lineWidth); + void DebugDrawArrow(duDebugDraw dd, [Const] float x0, [Const] float y0, [Const] float z0, [Const] float x1, [Const] float y1, [Const] float z1, [Const] float as0, [Const] float as1, unsigned long col, [Const] float lineWidth); + void DebugDrawCircle(duDebugDraw dd, [Const] float x, [Const] float y, [Const] float z, [Const] float r, unsigned long col, [Const] float lineWidth); + void DebugDrawCross(duDebugDraw dd, [Const] float x, [Const] float y, [Const] float z, [Const] float size, unsigned long col, [Const] float lineWidth); + void DebugDrawBox(duDebugDraw dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, [Const] unsigned long[] fcol); + void DebugDrawCylinder(duDebugDraw dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned long col); + void DebugDrawGridXZ(duDebugDraw dd, [Const] float ox, [Const] float oy, [Const] float oz, [Const] long w, [Const] long h, [Const] float size, [Const] unsigned long col, [Const] float lineWidth); + void AppendCylinderWire(duDebugDraw dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned long col); + void AppendBoxWire(duDebugDraw dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned long col); + void AppendBoxPoints(duDebugDraw dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned long col); + void AppendArc(duDebugDraw dd, [Const] float x0, [Const] float y0, [Const] float z0, [Const] float x1, [Const] float y1, [Const] float z1, [Const] float h, [Const] float as0, [Const] float as1, unsigned long col); + void AppendArrow(duDebugDraw dd, [Const] float x0, [Const] float y0, [Const] float z0, [Const] float x1, [Const] float y1, [Const] float z1, [Const] float as0, [Const] float as1, unsigned long col); + void AppendCircle(duDebugDraw dd, [Const] float x, [Const] float y, [Const] float z, [Const] float r, unsigned long col); + void AppendCross(duDebugDraw dd, [Const] float x, [Const] float y, [Const] float z, [Const] float size, unsigned long col); + void AppendBox(duDebugDraw dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, [Const] unsigned long[] fcol); + void AppendCylinder(duDebugDraw dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned long col); }; DebugDraw implements duDebugDraw; @@ -1226,6 +1254,10 @@ interface DebugDrawImpl { interface RecastDebugDraw { void RecastDebugDraw(); + void debugDrawTriMesh(duDebugDraw dd, [Const] FloatArray verts, long nverts, [Const] IntArray tris, [Const] FloatArray normals, long ntris, [Const] UnsignedCharArray flags, float texScale); + void debugDrawTriMeshNoFlags(duDebugDraw dd, [Const] FloatArray verts, long nverts, [Const] IntArray tris, [Const] FloatArray normals, long ntris, float texScale); + void debugDrawTriMeshSlope(duDebugDraw dd, [Const] FloatArray verts, long nverts, [Const] IntArray tris, [Const] FloatArray normals, long ntris, float walkableSlopeAngle, float texScale); + void debugDrawHeightfieldSolid(duDebugDraw dd, [Const, Ref] rcHeightfield hf); void debugDrawHeightfieldWalkable(duDebugDraw dd, [Const, Ref] rcHeightfield hf); @@ -1260,3 +1292,9 @@ interface DetourDebugDraw { void debugDrawTileCacheContours(duDebugDraw dd, [Const, Ref] dtTileCacheContourSet lcset, [Const] float[] orig, [Const] float cs, [Const] float ch); void debugDrawTileCachePolyMesh(duDebugDraw dd, [Const, Ref] dtTileCachePolyMesh pmesh, [Const] float[] orig, [Const] float cs, [Const] float ch); }; + +enum DrawNavMeshFlags { + "DrawNavMeshFlags::DU_DRAWNAVMESH_OFFMESHCONS", + "DrawNavMeshFlags::DU_DRAWNAVMESH_CLOSEDLIST", + "DrawNavMeshFlags::DU_DRAWNAVMESH_COLOR_TILES" +}; diff --git a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp index 0ae2fc8d..47992c0b 100644 --- a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp +++ b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp @@ -39,3 +39,138 @@ void DebugDraw::end() { handleEnd(); } + +unsigned int DebugDraw::RGBA(int r, int g, int b, int a) +{ + return duRGBA(r, g, b, a); +} + +unsigned int DebugDraw::RGBAf(float fr, float fg, float fb, float fa) +{ + return duRGBAf(fr, fg, fb, fa); +} + +unsigned int DebugDraw::IntToCol(int i, int a) +{ + return duIntToCol(i, a); +} + +void DebugDraw::IntToColVector(int i, float *col) +{ + return duIntToCol(i, col); +} + +unsigned int DebugDraw::MultCol(const unsigned int col, const unsigned int d) +{ + return duMultCol(col, d); +} + +unsigned int DebugDraw::DarkenCol(unsigned int col) +{ + return duDarkenCol(col); +} + +unsigned int DebugDraw::LerpCol(unsigned int ca, unsigned int cb, unsigned int u) +{ + return duLerpCol(ca, cb, u); +} + +unsigned int DebugDraw::TransCol(unsigned int c, unsigned int a) +{ + return duTransCol(c, a); +} + +void DebugDraw::CalcBoxColors(unsigned int *colors, unsigned int colTop, unsigned int colSide) +{ + duCalcBoxColors(colors, colTop, colSide); +} + +void DebugDraw::DebugDrawCylinderWire(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned int col, const float lineWidth) +{ + duDebugDrawCylinderWire(dd, minx, miny, minz, maxx, maxy, maxz, col, lineWidth); +} + +void DebugDraw::DebugDrawBoxWire(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned int col, const float lineWidth) +{ + duDebugDrawBoxWire(dd, minx, miny, minz, maxx, maxy, maxz, col, lineWidth); +} + +void DebugDraw::DebugDrawArc(struct duDebugDraw *dd, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, const float h, const float as0, const float as1, unsigned int col, const float lineWidth) +{ + duDebugDrawArc(dd, x0, y0, z0, x1, y1, z1, h, as0, as1, col, lineWidth); +} + +void DebugDraw::DebugDrawArrow(struct duDebugDraw *dd, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, const float as0, const float as1, unsigned int col, const float lineWidth) +{ + duDebugDrawArrow(dd, x0, y0, z0, x1, y1, z1, as0, as1, col, lineWidth); +} + +void DebugDraw::DebugDrawCircle(struct duDebugDraw *dd, const float x, const float y, const float z, const float r, unsigned int col, const float lineWidth) +{ + duDebugDrawCircle(dd, x, y, z, r, col, lineWidth); +} + +void DebugDraw::DebugDrawCross(struct duDebugDraw *dd, const float x, const float y, const float z, const float size, unsigned int col, const float lineWidth) +{ + duDebugDrawCross(dd, x, y, z, size, col, lineWidth); +} + +void DebugDraw::DebugDrawBox(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, const unsigned int *fcol) +{ + duDebugDrawBox(dd, minx, miny, minz, maxx, maxy, maxz, fcol); +} + +void DebugDraw::DebugDrawCylinder(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned int col) +{ + duDebugDrawCylinder(dd, minx, miny, minz, maxx, maxy, maxz, col); +} + +void DebugDraw::DebugDrawGridXZ(struct duDebugDraw *dd, const float ox, const float oy, const float oz, const int w, const int h, const float size, const unsigned int col, const float lineWidth) +{ + duDebugDrawGridXZ(dd, ox, oy, oz, w, h, size, col, lineWidth); +} + +void DebugDraw::AppendCylinderWire(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned int col) +{ + duAppendCylinderWire(dd, minx, miny, minz, maxx, maxy, maxz, col); +} + +void DebugDraw::AppendBoxWire(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned int col) +{ + duAppendBoxWire(dd, minx, miny, minz, maxx, maxy, maxz, col); +} + +void DebugDraw::AppendBoxPoints(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned int col) +{ + duAppendBoxPoints(dd, minx, miny, minz, maxx, maxy, maxz, col); +} + +void DebugDraw::AppendArc(struct duDebugDraw *dd, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, const float h, const float as0, const float as1, unsigned int col) +{ + duAppendArc(dd, x0, y0, z0, x1, y1, z1, h, as0, as1, col); +} + +void DebugDraw::AppendArrow(struct duDebugDraw *dd, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, const float as0, const float as1, unsigned int col) +{ + duAppendArrow(dd, x0, y0, z0, x1, y1, z1, as0, as1, col); +} + +void DebugDraw::AppendCircle(struct duDebugDraw *dd, const float x, const float y, const float z, const float r, unsigned int col) +{ + duAppendCircle(dd, x, y, z, r, col); +} + +void DebugDraw::AppendCross(struct duDebugDraw *dd, const float x, const float y, const float z, const float size, unsigned int col) +{ + duAppendCross(dd, x, y, z, size, col); +} + +void DebugDraw::AppendBox(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, const unsigned int *fcol) +{ + duAppendBox(dd, minx, miny, minz, maxx, maxy, maxz, fcol); +} + +void DebugDraw::AppendCylinder(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned int col) +{ + duAppendCylinder(dd, minx, miny, minz, maxx, maxy, maxz, col); +} diff --git a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h index f462f9b3..ce8b1210 100644 --- a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h +++ b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h @@ -22,4 +22,33 @@ class DebugDraw : public duDebugDraw virtual void handleVertexWithColor(const float x, const float y, const float z, unsigned int color) = 0; virtual void handleVertexWithColorAndUV(const float x, const float y, const float z, unsigned int color, const float u, const float v) = 0; virtual void handleEnd() = 0; + + unsigned int RGBA(int r, int g, int b, int a); + unsigned int RGBAf(float fr, float fg, float fb, float fa); + unsigned int IntToCol(int i, int a); + void IntToColVector(int i, float *col); + unsigned int MultCol(const unsigned int col, const unsigned int d); + unsigned int DarkenCol(unsigned int col); + unsigned int LerpCol(unsigned int ca, unsigned int cb, unsigned int u); + unsigned int TransCol(unsigned int c, unsigned int a); + + void CalcBoxColors(unsigned int *colors, unsigned int colTop, unsigned int colSide); + void DebugDrawCylinderWire(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned int col, const float lineWidth); + void DebugDrawBoxWire(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned int col, const float lineWidth); + void DebugDrawArc(struct duDebugDraw *dd, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, const float h, const float as0, const float as1, unsigned int col, const float lineWidth); + void DebugDrawArrow(struct duDebugDraw *dd, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, const float as0, const float as1, unsigned int col, const float lineWidth); + void DebugDrawCircle(struct duDebugDraw *dd, const float x, const float y, const float z, const float r, unsigned int col, const float lineWidth); + void DebugDrawCross(struct duDebugDraw *dd, const float x, const float y, const float z, const float size, unsigned int col, const float lineWidth); + void DebugDrawBox(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, const unsigned int *fcol); + void DebugDrawCylinder(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned int col); + void DebugDrawGridXZ(struct duDebugDraw *dd, const float ox, const float oy, const float oz, const int w, const int h, const float size, const unsigned int col, const float lineWidth); + void AppendCylinderWire(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned int col); + void AppendBoxWire(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned int col); + void AppendBoxPoints(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned int col); + void AppendArc(struct duDebugDraw *dd, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, const float h, const float as0, const float as1, unsigned int col); + void AppendArrow(struct duDebugDraw *dd, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, const float as0, const float as1, unsigned int col); + void AppendCircle(struct duDebugDraw *dd, const float x, const float y, const float z, const float r, unsigned int col); + void AppendCross(struct duDebugDraw *dd, const float x, const float y, const float z, const float size, unsigned int col); + void AppendBox(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, const unsigned int *fcol); + void AppendCylinder(struct duDebugDraw *dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, unsigned int col); }; diff --git a/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.cpp b/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.cpp index 069e6c24..a4173863 100644 --- a/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.cpp +++ b/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.cpp @@ -1,5 +1,20 @@ #include "RecastDebugDraw.h" +void RecastDebugDraw::debugDrawTriMesh(duDebugDraw* dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const UnsignedCharArray *flags, const float texScale) +{ + duDebugDrawTriMesh(dd, verts->data, nverts, tris->data, normals->data, ntris, flags->data, texScale); +} + +void RecastDebugDraw::debugDrawTriMeshNoFlags(duDebugDraw* dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const float texScale) +{ + duDebugDrawTriMesh(dd, verts->data, nverts, tris->data, normals->data, ntris, nullptr, texScale); +} + +void RecastDebugDraw::debugDrawTriMeshSlope(duDebugDraw* dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const float walkableSlopeAngle, const float texScale) +{ + duDebugDrawTriMeshSlope(dd, verts->data, nverts, tris->data, normals->data, ntris, walkableSlopeAngle, texScale); +} + void RecastDebugDraw::debugDrawHeightfieldSolid(duDebugDraw *dd, const rcHeightfield &hf) { duDebugDrawHeightfieldSolid(dd, hf); diff --git a/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.h b/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.h index 6c4b06ab..fec9aede 100644 --- a/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.h +++ b/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.h @@ -2,10 +2,15 @@ #include "../../recastnavigation/DebugUtils/Include/DebugDraw.h" #include "../../recastnavigation/DebugUtils/Include/RecastDebugDraw.h" +#include "../Arrays.h" class RecastDebugDraw { public: + void debugDrawTriMesh(duDebugDraw* dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const UnsignedCharArray *flags, const float texScale); + void debugDrawTriMeshNoFlags(duDebugDraw* dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const float texScale); + void debugDrawTriMeshSlope(duDebugDraw* dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const float walkableSlopeAngle, const float texScale); + void debugDrawHeightfieldSolid(duDebugDraw *dd, const rcHeightfield &hf); void debugDrawHeightfieldWalkable(duDebugDraw *dd, const rcHeightfield &hf); void debugDrawCompactHeightfieldSolid(duDebugDraw *dd, const rcCompactHeightfield &chf); From 1a2578fe97d8e2e0458fb3168243bb69769293ba Mon Sep 17 00:00:00 2001 From: local Date: Fri, 20 Jun 2025 02:38:26 -0700 Subject: [PATCH 2/9] expose additional debug drawing functions --- packages/recast-navigation-wasm/recast-navigation.idl | 7 +++++++ packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/packages/recast-navigation-wasm/recast-navigation.idl b/packages/recast-navigation-wasm/recast-navigation.idl index 9895e101..b0b6f190 100644 --- a/packages/recast-navigation-wasm/recast-navigation.idl +++ b/packages/recast-navigation-wasm/recast-navigation.idl @@ -1249,6 +1249,13 @@ interface DebugDrawImpl { void handleVertexWithColor([Const] float x, [Const] float y, [Const] float z, [Const] unsigned long color); void handleVertexWithColorAndUV([Const] float x, [Const] float y, [Const] float z, [Const] unsigned long color, [Const] float u, [Const] float v); void handleEnd(); + + /* + Uncomment this line after the JS examples implement this function, otherwise the error will be thrown: + + "a JSImplementation must implement all functions, you forgot DebugDrawImpl::handleAreaToCol." + */ + // unsigned long handleAreaToCol(unsigned long area); }; interface RecastDebugDraw { diff --git a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h index ce8b1210..9386d3e1 100644 --- a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h +++ b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h @@ -15,6 +15,7 @@ class DebugDraw : public duDebugDraw virtual void vertex(const float *pos, unsigned int color, const float *uv); virtual void vertex(const float x, const float y, const float z, unsigned int color, const float u, const float v); virtual void end(); + virtual unsigned int areaToCol(unsigned int area); virtual void handleDepthMask(bool state) = 0; virtual void handleTexture(bool state) = 0; @@ -22,6 +23,7 @@ class DebugDraw : public duDebugDraw virtual void handleVertexWithColor(const float x, const float y, const float z, unsigned int color) = 0; virtual void handleVertexWithColorAndUV(const float x, const float y, const float z, unsigned int color, const float u, const float v) = 0; virtual void handleEnd() = 0; + virtual unsigned int handleAreaToCol(unsigned int area) = 0; unsigned int RGBA(int r, int g, int b, int a); unsigned int RGBAf(float fr, float fg, float fb, float fa); From 298e1ecb9e20e749ca8045aecf8c4ee30fee474c Mon Sep 17 00:00:00 2001 From: local Date: Fri, 20 Jun 2025 02:42:48 -0700 Subject: [PATCH 3/9] expose additional debug drawing functions --- packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp index 47992c0b..e07631d6 100644 --- a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp +++ b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp @@ -40,6 +40,11 @@ void DebugDraw::end() handleEnd(); } +unsigned int DebugDraw::areaToCol(unsigned int area) +{ + return handleAreaToCol(area); +} + unsigned int DebugDraw::RGBA(int r, int g, int b, int a) { return duRGBA(r, g, b, a); From c87053cf1fb12bd7def3b6661217b6b3bf3cdd4b Mon Sep 17 00:00:00 2001 From: local Date: Fri, 20 Jun 2025 02:54:16 -0700 Subject: [PATCH 4/9] expose additional debug drawing functions --- packages/recast-navigation-wasm/recast-navigation.idl | 4 ++++ .../recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp | 8 ++++---- packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/recast-navigation-wasm/recast-navigation.idl b/packages/recast-navigation-wasm/recast-navigation.idl index b0b6f190..d53cdbac 100644 --- a/packages/recast-navigation-wasm/recast-navigation.idl +++ b/packages/recast-navigation-wasm/recast-navigation.idl @@ -1254,6 +1254,10 @@ interface DebugDrawImpl { Uncomment this line after the JS examples implement this function, otherwise the error will be thrown: "a JSImplementation must implement all functions, you forgot DebugDrawImpl::handleAreaToCol." + + Also uncomment the `handleAreaToCol()` code in + - `./src/DebugDraw.h` + - `./src/DebugDraw.cpp` */ // unsigned long handleAreaToCol(unsigned long area); }; diff --git a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp index e07631d6..c74298f7 100644 --- a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp +++ b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp @@ -40,10 +40,10 @@ void DebugDraw::end() handleEnd(); } -unsigned int DebugDraw::areaToCol(unsigned int area) -{ - return handleAreaToCol(area); -} +// unsigned int DebugDraw::areaToCol(unsigned int area) +// { +// return handleAreaToCol(area); +// } unsigned int DebugDraw::RGBA(int r, int g, int b, int a) { diff --git a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h index 9386d3e1..d8e8e75e 100644 --- a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h +++ b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h @@ -15,7 +15,7 @@ class DebugDraw : public duDebugDraw virtual void vertex(const float *pos, unsigned int color, const float *uv); virtual void vertex(const float x, const float y, const float z, unsigned int color, const float u, const float v); virtual void end(); - virtual unsigned int areaToCol(unsigned int area); + // virtual unsigned int areaToCol(unsigned int area); virtual void handleDepthMask(bool state) = 0; virtual void handleTexture(bool state) = 0; @@ -23,7 +23,7 @@ class DebugDraw : public duDebugDraw virtual void handleVertexWithColor(const float x, const float y, const float z, unsigned int color) = 0; virtual void handleVertexWithColorAndUV(const float x, const float y, const float z, unsigned int color, const float u, const float v) = 0; virtual void handleEnd() = 0; - virtual unsigned int handleAreaToCol(unsigned int area) = 0; + // virtual unsigned int handleAreaToCol(unsigned int area) = 0; unsigned int RGBA(int r, int g, int b, int a); unsigned int RGBAf(float fr, float fg, float fb, float fa); From 4ac990457bb8a3e1e82e88b398fd79443e068d70 Mon Sep 17 00:00:00 2001 From: local Date: Fri, 20 Jun 2025 20:09:04 -0700 Subject: [PATCH 5/9] expose additional debug drawing functions --- .../recast-navigation-wasm/recast-navigation.idl | 12 +----------- .../recast-navigation-wasm/src/DebugDraw/DebugDraw.h | 4 ++-- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/packages/recast-navigation-wasm/recast-navigation.idl b/packages/recast-navigation-wasm/recast-navigation.idl index d53cdbac..9572fbed 100644 --- a/packages/recast-navigation-wasm/recast-navigation.idl +++ b/packages/recast-navigation-wasm/recast-navigation.idl @@ -1249,17 +1249,7 @@ interface DebugDrawImpl { void handleVertexWithColor([Const] float x, [Const] float y, [Const] float z, [Const] unsigned long color); void handleVertexWithColorAndUV([Const] float x, [Const] float y, [Const] float z, [Const] unsigned long color, [Const] float u, [Const] float v); void handleEnd(); - - /* - Uncomment this line after the JS examples implement this function, otherwise the error will be thrown: - - "a JSImplementation must implement all functions, you forgot DebugDrawImpl::handleAreaToCol." - - Also uncomment the `handleAreaToCol()` code in - - `./src/DebugDraw.h` - - `./src/DebugDraw.cpp` - */ - // unsigned long handleAreaToCol(unsigned long area); + unsigned long handleAreaToCol(unsigned long area); }; interface RecastDebugDraw { diff --git a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h index d8e8e75e..9386d3e1 100644 --- a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h +++ b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h @@ -15,7 +15,7 @@ class DebugDraw : public duDebugDraw virtual void vertex(const float *pos, unsigned int color, const float *uv); virtual void vertex(const float x, const float y, const float z, unsigned int color, const float u, const float v); virtual void end(); - // virtual unsigned int areaToCol(unsigned int area); + virtual unsigned int areaToCol(unsigned int area); virtual void handleDepthMask(bool state) = 0; virtual void handleTexture(bool state) = 0; @@ -23,7 +23,7 @@ class DebugDraw : public duDebugDraw virtual void handleVertexWithColor(const float x, const float y, const float z, unsigned int color) = 0; virtual void handleVertexWithColorAndUV(const float x, const float y, const float z, unsigned int color, const float u, const float v) = 0; virtual void handleEnd() = 0; - // virtual unsigned int handleAreaToCol(unsigned int area) = 0; + virtual unsigned int handleAreaToCol(unsigned int area) = 0; unsigned int RGBA(int r, int g, int b, int a); unsigned int RGBAf(float fr, float fg, float fb, float fa); From 61e5a6151a2bd6b0b55d32fe1955c5243876c452 Mon Sep 17 00:00:00 2001 From: local Date: Fri, 20 Jun 2025 20:12:03 -0700 Subject: [PATCH 6/9] expose additional debug drawing functions --- packages/recast-navigation-core/src/debug-drawer-utils.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/recast-navigation-core/src/debug-drawer-utils.ts b/packages/recast-navigation-core/src/debug-drawer-utils.ts index a9298c74..326550f1 100644 --- a/packages/recast-navigation-core/src/debug-drawer-utils.ts +++ b/packages/recast-navigation-core/src/debug-drawer-utils.ts @@ -66,6 +66,11 @@ export class DebugDrawerUtils { this.vertex(x, y, z, color); }; + this.debugDrawImpl.handleAreaToCol = (_area: number): number => { + // unused for now... + return 0; + }; + const primitiveMap: Record = { [Raw.Module.DU_DRAW_LINES]: 'lines', [Raw.Module.DU_DRAW_TRIS]: 'tris', From afc3f6340af4e693c3e87803d03af827e3eadee7 Mon Sep 17 00:00:00 2001 From: local Date: Fri, 20 Jun 2025 20:13:43 -0700 Subject: [PATCH 7/9] expose additional debug drawing functions --- .../recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp index c74298f7..e07631d6 100644 --- a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp +++ b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp @@ -40,10 +40,10 @@ void DebugDraw::end() handleEnd(); } -// unsigned int DebugDraw::areaToCol(unsigned int area) -// { -// return handleAreaToCol(area); -// } +unsigned int DebugDraw::areaToCol(unsigned int area) +{ + return handleAreaToCol(area); +} unsigned int DebugDraw::RGBA(int r, int g, int b, int a) { From dea5a551aabf7edd064d9b37064fdf563cc04722 Mon Sep 17 00:00:00 2001 From: local Date: Fri, 20 Jun 2025 20:15:01 -0700 Subject: [PATCH 8/9] expose additional debug drawing functions --- .../recast-navigation-core/src/debug-drawer-utils.ts | 8 ++++---- .../recast-navigation-wasm/recast-navigation.idl | 12 +++++++++++- .../src/DebugDraw/DebugDraw.cpp | 8 ++++---- .../recast-navigation-wasm/src/DebugDraw/DebugDraw.h | 4 ++-- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/packages/recast-navigation-core/src/debug-drawer-utils.ts b/packages/recast-navigation-core/src/debug-drawer-utils.ts index 326550f1..a15d90e7 100644 --- a/packages/recast-navigation-core/src/debug-drawer-utils.ts +++ b/packages/recast-navigation-core/src/debug-drawer-utils.ts @@ -66,10 +66,10 @@ export class DebugDrawerUtils { this.vertex(x, y, z, color); }; - this.debugDrawImpl.handleAreaToCol = (_area: number): number => { - // unused for now... - return 0; - }; + // this.debugDrawImpl.handleAreaToCol = (_area: number): number => { + // // unused for now... + // return 0; + // }; const primitiveMap: Record = { [Raw.Module.DU_DRAW_LINES]: 'lines', diff --git a/packages/recast-navigation-wasm/recast-navigation.idl b/packages/recast-navigation-wasm/recast-navigation.idl index 9572fbed..d53cdbac 100644 --- a/packages/recast-navigation-wasm/recast-navigation.idl +++ b/packages/recast-navigation-wasm/recast-navigation.idl @@ -1249,7 +1249,17 @@ interface DebugDrawImpl { void handleVertexWithColor([Const] float x, [Const] float y, [Const] float z, [Const] unsigned long color); void handleVertexWithColorAndUV([Const] float x, [Const] float y, [Const] float z, [Const] unsigned long color, [Const] float u, [Const] float v); void handleEnd(); - unsigned long handleAreaToCol(unsigned long area); + + /* + Uncomment this line after the JS examples implement this function, otherwise the error will be thrown: + + "a JSImplementation must implement all functions, you forgot DebugDrawImpl::handleAreaToCol." + + Also uncomment the `handleAreaToCol()` code in + - `./src/DebugDraw.h` + - `./src/DebugDraw.cpp` + */ + // unsigned long handleAreaToCol(unsigned long area); }; interface RecastDebugDraw { diff --git a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp index e07631d6..c74298f7 100644 --- a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp +++ b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.cpp @@ -40,10 +40,10 @@ void DebugDraw::end() handleEnd(); } -unsigned int DebugDraw::areaToCol(unsigned int area) -{ - return handleAreaToCol(area); -} +// unsigned int DebugDraw::areaToCol(unsigned int area) +// { +// return handleAreaToCol(area); +// } unsigned int DebugDraw::RGBA(int r, int g, int b, int a) { diff --git a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h index 9386d3e1..d8e8e75e 100644 --- a/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h +++ b/packages/recast-navigation-wasm/src/DebugDraw/DebugDraw.h @@ -15,7 +15,7 @@ class DebugDraw : public duDebugDraw virtual void vertex(const float *pos, unsigned int color, const float *uv); virtual void vertex(const float x, const float y, const float z, unsigned int color, const float u, const float v); virtual void end(); - virtual unsigned int areaToCol(unsigned int area); + // virtual unsigned int areaToCol(unsigned int area); virtual void handleDepthMask(bool state) = 0; virtual void handleTexture(bool state) = 0; @@ -23,7 +23,7 @@ class DebugDraw : public duDebugDraw virtual void handleVertexWithColor(const float x, const float y, const float z, unsigned int color) = 0; virtual void handleVertexWithColorAndUV(const float x, const float y, const float z, unsigned int color, const float u, const float v) = 0; virtual void handleEnd() = 0; - virtual unsigned int handleAreaToCol(unsigned int area) = 0; + // virtual unsigned int handleAreaToCol(unsigned int area) = 0; unsigned int RGBA(int r, int g, int b, int a); unsigned int RGBAf(float fr, float fg, float fb, float fa); From 2585b7c2a25154f716a45e22cbeaa6000d82a51f Mon Sep 17 00:00:00 2001 From: local Date: Fri, 20 Jun 2025 20:19:05 -0700 Subject: [PATCH 9/9] expose additional debug drawing functions --- .../src/DebugDraw/RecastDebugDraw.cpp | 6 +++--- .../recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.h | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.cpp b/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.cpp index a4173863..35b5fd2d 100644 --- a/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.cpp +++ b/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.cpp @@ -1,16 +1,16 @@ #include "RecastDebugDraw.h" -void RecastDebugDraw::debugDrawTriMesh(duDebugDraw* dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const UnsignedCharArray *flags, const float texScale) +void RecastDebugDraw::debugDrawTriMesh(duDebugDraw *dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const UnsignedCharArray *flags, const float texScale) { duDebugDrawTriMesh(dd, verts->data, nverts, tris->data, normals->data, ntris, flags->data, texScale); } -void RecastDebugDraw::debugDrawTriMeshNoFlags(duDebugDraw* dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const float texScale) +void RecastDebugDraw::debugDrawTriMeshNoFlags(duDebugDraw *dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const float texScale) { duDebugDrawTriMesh(dd, verts->data, nverts, tris->data, normals->data, ntris, nullptr, texScale); } -void RecastDebugDraw::debugDrawTriMeshSlope(duDebugDraw* dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const float walkableSlopeAngle, const float texScale) +void RecastDebugDraw::debugDrawTriMeshSlope(duDebugDraw *dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const float walkableSlopeAngle, const float texScale) { duDebugDrawTriMeshSlope(dd, verts->data, nverts, tris->data, normals->data, ntris, walkableSlopeAngle, texScale); } diff --git a/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.h b/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.h index fec9aede..ec5e21d4 100644 --- a/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.h +++ b/packages/recast-navigation-wasm/src/DebugDraw/RecastDebugDraw.h @@ -2,14 +2,15 @@ #include "../../recastnavigation/DebugUtils/Include/DebugDraw.h" #include "../../recastnavigation/DebugUtils/Include/RecastDebugDraw.h" + #include "../Arrays.h" class RecastDebugDraw { public: - void debugDrawTriMesh(duDebugDraw* dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const UnsignedCharArray *flags, const float texScale); - void debugDrawTriMeshNoFlags(duDebugDraw* dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const float texScale); - void debugDrawTriMeshSlope(duDebugDraw* dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const float walkableSlopeAngle, const float texScale); + void debugDrawTriMesh(duDebugDraw *dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const UnsignedCharArray *flags, const float texScale); + void debugDrawTriMeshNoFlags(duDebugDraw *dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const float texScale); + void debugDrawTriMeshSlope(duDebugDraw *dd, const FloatArray *verts, int nverts, const IntArray *tris, const FloatArray *normals, int ntris, const float walkableSlopeAngle, const float texScale); void debugDrawHeightfieldSolid(duDebugDraw *dd, const rcHeightfield &hf); void debugDrawHeightfieldWalkable(duDebugDraw *dd, const rcHeightfield &hf);