Replies: 4 comments
-
Hi, to provide some context - some c++ APIs can be difficult to create javascript bindings for directly with emscripten's webidl binder, paricularly APIs that have output pointers like addTile. To work around this, this library adds some wrapper code so signatures are compatible with emscripten's webidl binder. In this case, the addTile has this wrapper, using a "UnsignedIntRef" class in place of dtTileRef so it is bind-able. see:
I'm not sure if emscripten's embind javascript binder makes this simpler - but it certainly was a bit painful creating these wrappers for emscriptens webidl binder! |
Beta Was this translation helpful? Give feedback.
-
Hi. Thanks for your comments. I still don't understand why "datasize" is not part of the wrapper https://github.com/isaac-mason/recast-navigation-js/blob/main/packages/recast-navigation-wasm/src/NavMesh.h#L63 , but that doesn't matter as it works. I really appreciate your work. We are working on a cross-platform (Unity and Switft/Java native) implementation and I am able to use the (export) output from this web port in https://github.com/ikpil/DotRecast (with some minor adjustings as the c# port interprets the output as 64bit). So thank you for your work, it is really appreciated! |
Beta Was this translation helpful? Give feedback.
-
Hi, that is just because in this wrapper the navMeshData is a UnsignedCharArray class that contains a size. This is where the upstream library addTile is called: https://github.com/isaac-mason/recast-navigation-js/blob/main/packages/recast-navigation-wasm/src/NavMesh.cpp#L19 |
Beta Was this translation helpful? Give feedback.
-
Glad you found this useful 🙂 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In DetourNavMesh.cpp the method addTile is defined as
dtStatus dtNavMesh::addTile(unsigned char* data, int dataSize, int flags, dtTileRef lastRef, dtTileRef* result)
In nav-mesh.d.ts the method addTile is defined as
addTile(navMeshData: UnsignedCharArray, flags: number, lastRef: number): {
status: number;
tileRef: number;
};
I seems to work but I don't understand this as dataSize is used/read in the method but not provided in the call.
Is this mismatch something I can ignore?
Beta Was this translation helpful? Give feedback.
All reactions