Skip to content

Conversation

@Jklawreszuk
Copy link
Collaborator

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:

  • More maintainable code - entire module is now written in one language = more contributors will undertand the code
    • Also this is another step towards eliminating the need to install the MSVC compiler.
  • I removed the need to the use of pointers and manual allocation/dealloc

PR was tested on the TopDownRPG sample.

Related Issue

#1394

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

@VaclavElias
Copy link
Contributor

I started a Copilot reriew, if it helps at all..

Copy link
Contributor

Copilot AI left a 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[] to DtMeshData (breaking change)
  • Removed IDisposable pattern from RecastNavigationMesh class
  • Modernized C# syntax with collection expressions [] and field keyword
  • 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

Copy link
Contributor

@Doprez Doprez left a 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.

Copy link
Collaborator

@Eideren Eideren left a 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.

Comment on lines 38 to 44
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);
Copy link
Collaborator

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 ?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

@Jklawreszuk Jklawreszuk Dec 7, 2025

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.

@Eideren Eideren merged commit f8f091e into stride3d:master Dec 7, 2025
5 checks passed
@Jklawreszuk Jklawreszuk deleted the dotrecast-port branch December 7, 2025 18:53
@Eideren
Copy link
Collaborator

Eideren commented Dec 7, 2025

Thanks !

@Doprez Doprez mentioned this pull request Dec 12, 2025
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants