-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: Port Stride.Navigation native code to C# using DotRecast #2987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I started a Copilot reriew, if it helps at all.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR successfully ports the Stride.Navigation module's native C++ code to managed C# using the DotRecast library. This represents a significant architectural improvement that eliminates the need for platform-specific native binaries and MSVC compiler, making the codebase more maintainable and accessible to contributors. The changes include:
- Complete removal of C++ source files (Navigation.cpp, NavigationBuilder.cpp, NavigationMesh.cpp) and headers
- New C# implementations: NavigationBuilder.cs, InternalNavigationMesh.cs, and DtMeshDataSerializer.cs
- Updated existing C# files to work with the new managed implementation
Key Changes
- Replaced native P/Invoke calls with DotRecast library APIs
- Changed navigation mesh tile data from
byte[]toDtMeshData(breaking change) - Removed
IDisposablepattern fromRecastNavigationMeshclass - Modernized C# syntax with collection expressions
[]andfieldkeyword - Added custom serialization for
DtMeshData
Reviewed changes
Copilot reviewed 48 out of 48 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| NavigationBuilder.cs | New C# implementation replacing C++ NavigationBuilder |
| InternalNavigationMesh.cs | New wrapper for DotRecast navigation mesh operations |
| DtMeshDataSerializer.cs | New custom serializer for DotRecast mesh data structures |
| RecastNavigationMesh.cs | Updated to use managed InternalNavigationMesh |
| NavigationMeshTile.cs | Changed Data type from byte[] to DtMeshData with custom serializer |
| NavigationProcessor.cs | Removed Dispose() calls, modernized syntax |
| NavigationComponent.cs | Updated to use field keyword for auto-properties |
| Various utility files | Modernized with collection expressions and pattern matching |
| C++ files, headers, build scripts | All removed |
| Recast library files | All removed |
Doprez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, also tested with existing scenes I had for Bullet and didnt see any new issues come up.
Eideren
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a bunch of areas that could use some polish, but given that those come from c++, might as well leave it at that for now.
| public void RemoveTile(Point coord) | ||
| { | ||
| if (!tileCoordinates.Contains(coord)) | ||
| return false; | ||
| if (!tileCoordinates.Contains(coord)) | ||
| return; | ||
|
|
||
| tileCoordinates.Remove(coord); | ||
| return Navigation.RemoveTile(navmesh, coord); | ||
| navmesh.RemoveTile(coord); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you comment on this change in return type ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic behind this was that the consuming method (AddOrReplaceTile) did not take the return value into account in any way, so I changed it into void type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But now that I think about it, and considering that this is a public method, I should actually undo it.
|
Thanks ! |
PR Details
PR ports C++ code to manageable .NET code using the DotRecast library. Additionally, I simplified/removed many code fragments in the module.
The benefits I see from this changes:
PR was tested on the TopDownRPG sample.
Related Issue
#1394
Types of changes
Checklist