├── .editorconfig ├── .github ├── FUNDING.yml ├── release-drafter.yml └── workflows │ ├── codeql.yml │ ├── dotnet.yml │ ├── publish.yml │ └── release.yml ├── .gitignore ├── .vscode ├── launch.json └── tasks.json ├── BuildingAndIntegrating.md ├── CHANGELOG.md ├── DotRecast.sln ├── LICENSE.txt ├── README.md ├── resources ├── all_tiles_navmesh.bin ├── all_tiles_tilecache.bin ├── annotation_test.obj ├── bridge.obj ├── convex.obj ├── dungeon.obj ├── dungeon_all_tiles_navmesh.bin ├── dungeon_all_tiles_navmesh_32bit.bin ├── dungeon_all_tiles_tilecache.bin ├── fonts │ └── DroidSans.ttf ├── graph.zip ├── graph_v4_1_16.zip ├── house.obj ├── nav_test.obj ├── test.voxels ├── test_boundstree.zip └── test_tiles.voxels ├── src ├── DotRecast.Core │ ├── Buffers │ │ ├── RcCyclicBuffer.cs │ │ ├── RcCyclicBuffers.cs │ │ ├── RcObjectPool.cs │ │ └── RcRentedArray.cs │ ├── Collections │ │ ├── CollectionExtensions.cs │ │ ├── RcBinaryMinHeap.cs │ │ ├── RcFixedArray1.cs │ │ ├── RcFixedArray1024.cs │ │ ├── RcFixedArray128.cs │ │ ├── RcFixedArray16.cs │ │ ├── RcFixedArray2.cs │ │ ├── RcFixedArray256.cs │ │ ├── RcFixedArray32.cs │ │ ├── RcFixedArray4.cs │ │ ├── RcFixedArray512.cs │ │ ├── RcFixedArray64.cs │ │ ├── RcFixedArray8.cs │ │ ├── RcImmutableArray.Enumerable.cs │ │ ├── RcImmutableArray.Listable.cs │ │ ├── RcImmutableArray.Minimal.cs │ │ ├── RcImmutableArray.cs │ │ └── RcSortedQueue.cs │ ├── Compression │ │ └── FastLZ.cs │ ├── DotRecast.Core.csproj │ ├── IRcCompressor.cs │ ├── IRcRand.cs │ ├── Numerics │ │ ├── RcMatrix4x4f.cs │ │ ├── RcVec.cs │ │ ├── RcVec2f.cs │ │ ├── RcVec3f.cs │ │ └── RcVec3i.cs │ ├── RcArrays.cs │ ├── RcAtomicBoolean.cs │ ├── RcAtomicFloat.cs │ ├── RcAtomicInteger.cs │ ├── RcAtomicLong.cs │ ├── RcByteBuffer.cs │ ├── RcByteOrder.cs │ ├── RcByteUtils.cs │ ├── RcContext.cs │ ├── RcConvexUtils.cs │ ├── RcDirectory.cs │ ├── RcEdge.cs │ ├── RcFrequency.cs │ ├── RcHashCodes.cs │ ├── RcIO.cs │ ├── RcIntersections.cs │ ├── RcMath.cs │ ├── RcObjImporter.cs │ ├── RcObjImporterContext.cs │ ├── RcProcess.cs │ ├── RcRand.cs │ ├── RcScopedTimer.cs │ ├── RcSegmentVert.cs │ ├── RcSpans.cs │ ├── RcTelemetryTick.cs │ ├── RcThrowHelper.cs │ └── RcTimerLabel.cs ├── DotRecast.Detour.Crowd │ ├── DotRecast.Detour.Crowd.csproj │ ├── DtCrowd.cs │ ├── DtCrowdAgent.cs │ ├── DtCrowdAgentAnimation.cs │ ├── DtCrowdAgentConfig.cs │ ├── DtCrowdAgentDebugInfo.cs │ ├── DtCrowdAgentParams.cs │ ├── DtCrowdAgentState.cs │ ├── DtCrowdAgentUpdateFlags.cs │ ├── DtCrowdConfig.cs │ ├── DtCrowdConst.cs │ ├── DtCrowdNeighbour.cs │ ├── DtCrowdScopedTimer.cs │ ├── DtCrowdTelemetry.cs │ ├── DtCrowdTimerLabel.cs │ ├── DtLocalBoundary.cs │ ├── DtMoveRequestState.cs │ ├── DtObstacleAvoidanceDebugData.cs │ ├── DtObstacleAvoidanceParams.cs │ ├── DtObstacleAvoidanceQuery.cs │ ├── DtObstacleCircle.cs │ ├── DtObstacleSegment.cs │ ├── DtPathCorridor.cs │ ├── DtPathQuery.cs │ ├── DtPathQueryResult.cs │ ├── DtPathQueue.cs │ ├── DtProximityGrid.cs │ └── DtSegment.cs ├── DotRecast.Detour.Dynamic │ ├── Colliders │ │ ├── DtBoxCollider.cs │ │ ├── DtCapsuleCollider.cs │ │ ├── DtCollider.cs │ │ ├── DtCompositeCollider.cs │ │ ├── DtConvexTrimeshCollider.cs │ │ ├── DtCylinderCollider.cs │ │ ├── DtSphereCollider.cs │ │ ├── DtTrimeshCollider.cs │ │ └── IDtCollider.cs │ ├── DotRecast.Detour.Dynamic.csproj │ ├── DtDynamicNavMesh.cs │ ├── DtDynamicNavMeshConfig.cs │ ├── DtDynamicTile.cs │ ├── DtDynamicTileCheckpoint.cs │ ├── DtDynamicTileColliderAdditionJob.cs │ ├── DtDynamicTileColliderRemovalJob.cs │ ├── DtVoxelQuery.cs │ ├── IDtDaynmicTileJob.cs │ └── Io │ │ ├── DtVoxelFile.cs │ │ ├── DtVoxelFileReader.cs │ │ ├── DtVoxelFileWriter.cs │ │ └── DtVoxelTile.cs ├── DotRecast.Detour.Extras │ ├── BVTreeBuilder.cs │ ├── DotRecast.Detour.Extras.csproj │ ├── DtPolyUtils.cs │ ├── Jumplink │ │ ├── AbstractGroundSampler.cs │ │ ├── ClimbTrajectory.cs │ │ ├── EdgeExtractor.cs │ │ ├── EdgeSampler.cs │ │ ├── EdgeSamplerFactory.cs │ │ ├── GroundSample.cs │ │ ├── GroundSegment.cs │ │ ├── IGroundSampler.cs │ │ ├── ITrajectory.cs │ │ ├── JumpEdge.cs │ │ ├── JumpLink.cs │ │ ├── JumpLinkBuilder.cs │ │ ├── JumpLinkBuilderConfig.cs │ │ ├── JumpLinkType.cs │ │ ├── JumpSegment.cs │ │ ├── JumpSegmentBuilder.cs │ │ ├── JumpTrajectory.cs │ │ ├── NavMeshGroundSampler.cs │ │ └── TrajectorySampler.cs │ ├── ObjExporter.cs │ └── Unity │ │ └── Astar │ │ ├── BVTreeCreator.cs │ │ ├── GraphConnectionReader.cs │ │ ├── GraphData.cs │ │ ├── GraphMeshData.cs │ │ ├── GraphMeshDataReader.cs │ │ ├── GraphMeta.cs │ │ ├── GraphMetaReader.cs │ │ ├── LinkBuilder.cs │ │ ├── Meta.cs │ │ ├── MetaReader.cs │ │ ├── NodeIndexReader.cs │ │ ├── NodeLink2.cs │ │ ├── NodeLink2Reader.cs │ │ ├── OffMeshLinkCreator.cs │ │ ├── UnityAStarPathfindingImporter.cs │ │ ├── UnityAStarPathfindingReader.cs │ │ └── ZipBinaryReader.cs ├── DotRecast.Detour.TileCache │ ├── DotRecast.Detour.TileCache.csproj │ ├── DtCompressedTile.cs │ ├── DtCompressedTileFlags.cs │ ├── DtLayerMonotoneRegion.cs │ ├── DtObstacleBox.cs │ ├── DtObstacleCylinder.cs │ ├── DtObstacleOrientedBox.cs │ ├── DtObstacleRequest.cs │ ├── DtObstacleRequestAction.cs │ ├── DtObstacleState.cs │ ├── DtTempContour.cs │ ├── DtTileCache.cs │ ├── DtTileCacheAlloc.cs │ ├── DtTileCacheBuilder.cs │ ├── DtTileCacheContour.cs │ ├── DtTileCacheContourSet.cs │ ├── DtTileCacheLayer.cs │ ├── DtTileCacheLayerBuildResult.cs │ ├── DtTileCacheLayerBuilder.cs │ ├── DtTileCacheLayerHeader.cs │ ├── DtTileCacheObstacle.cs │ ├── DtTileCacheObstacleType.cs │ ├── DtTileCacheParams.cs │ ├── DtTileCachePolyMesh.cs │ ├── DtTileCacheStorageParams.cs │ ├── IDtTileCacheMeshProcess.cs │ └── Io │ │ ├── Compress │ │ ├── DtTileCacheCompressorFactory.cs │ │ ├── DtTileCacheFastLzCompressor.cs │ │ └── IDtTileCacheCompressorFactory.cs │ │ ├── DtTileCacheLayerHeaderReader.cs │ │ ├── DtTileCacheLayerHeaderWriter.cs │ │ ├── DtTileCacheReader.cs │ │ ├── DtTileCacheSetHeader.cs │ │ └── DtTileCacheWriter.cs ├── DotRecast.Detour │ ├── BVItem.cs │ ├── BVItemXComparer.cs │ ├── BVItemYComparer.cs │ ├── BVItemZComparer.cs │ ├── DetourBuilder.cs │ ├── DotRecast.Detour.csproj │ ├── DtBVNode.cs │ ├── DtCallbackPolyQuery.cs │ ├── DtCollectPolysQuery.cs │ ├── DtConnectPoly.cs │ ├── DtConvexConvexInFlag.cs │ ├── DtConvexConvexIntersection.cs │ ├── DtConvexConvexIntersections.cs │ ├── DtDefaultQueryHeuristic.cs │ ├── DtDetailTriEdgeFlags.cs │ ├── DtDetour.cs │ ├── DtFindNearestPolyQuery.cs │ ├── DtFindPathOption.cs │ ├── DtFindPathOptions.cs │ ├── DtLink.cs │ ├── DtMeshData.cs │ ├── DtMeshHeader.cs │ ├── DtMeshTile.cs │ ├── DtNavMesh.cs │ ├── DtNavMeshBuilder.cs │ ├── DtNavMeshCreateParams.cs │ ├── DtNavMeshParams.cs │ ├── DtNavMeshQuery.cs │ ├── DtNavMeshQueryMock.cs │ ├── DtNavMeshRaycast.cs │ ├── DtNoOpDtPolygonByCircleConstraint.cs │ ├── DtNode.cs │ ├── DtNodeFlags.cs │ ├── DtNodePool.cs │ ├── DtNodeQueue.cs │ ├── DtOffMeshConnection.cs │ ├── DtPathUtils.cs │ ├── DtPoly.cs │ ├── DtPolyDetail.cs │ ├── DtPolyPoint.cs │ ├── DtPolyTypes.cs │ ├── DtQueryData.cs │ ├── DtQueryDefaultFilter.cs │ ├── DtQueryEmptyFilter.cs │ ├── DtQueryNoOpFilter.cs │ ├── DtRaycastHit.cs │ ├── DtRaycastOptions.cs │ ├── DtSegInterval.cs │ ├── DtStatus.cs │ ├── DtStraightPath.cs │ ├── DtStraightPathFlags.cs │ ├── DtStraightPathOption.cs │ ├── DtStraightPathOptions.cs │ ├── DtStrictDtPolygonByCircleConstraint.cs │ ├── DtUtils.cs │ ├── IDtPolyQuery.cs │ ├── IDtPolygonByCircleConstraint.cs │ ├── IDtQueryFilter.cs │ ├── IDtQueryHeuristic.cs │ └── Io │ │ ├── DtMeshDataReader.cs │ │ ├── DtMeshDataWriter.cs │ │ ├── DtMeshSetReader.cs │ │ ├── DtMeshSetWriter.cs │ │ ├── DtNavMeshParamWriter.cs │ │ ├── DtNavMeshParamsReader.cs │ │ ├── NavMeshSetHeader.cs │ │ └── NavMeshTileHeader.cs ├── DotRecast.Recast.Demo │ ├── DemoSample.cs │ ├── DotRecast.Recast.Demo.csproj │ ├── Draw │ │ ├── ArrayBuffer.cs │ │ ├── DebugDraw.cs │ │ ├── DebugDrawPrimitives.cs │ │ ├── DrawMode.cs │ │ ├── GLCheckerTexture.cs │ │ ├── GLU.cs │ │ ├── IOpenGLDraw.cs │ │ ├── ModernOpenGLDraw.cs │ │ ├── NavMeshRenderer.cs │ │ ├── OpenGLVertex.cs │ │ └── RecastDebugDraw.cs │ ├── DtVoxelTileLZ4DemoCompressor.cs │ ├── KeyModState.cs │ ├── Logging │ │ └── Sinks │ │ │ ├── LogMessageBrokerSink.cs │ │ │ └── SerilogSinkExtensions.cs │ ├── Messages │ │ ├── GeomLoadBeganEvent.cs │ │ ├── IRecastDemoChannel.cs │ │ ├── IRecastDemoMessage.cs │ │ ├── NavMeshBuildBeganEvent.cs │ │ ├── NavMeshLoadBeganEvent.cs │ │ ├── NavMeshSaveBeganEvent.cs │ │ └── RaycastEvent.cs │ ├── Program.cs │ ├── RecastDemo.cs │ ├── Tools │ │ ├── ConvexVolumeSampleTool.cs │ │ ├── CrowdAgentProfilingSampleTool.cs │ │ ├── CrowdSampleTool.cs │ │ ├── DynamicUpdateSampleTool.cs │ │ ├── GizmoRenderer.cs │ │ ├── ISampleTool.cs │ │ ├── JumpLinkBuilderSampleTool.cs │ │ ├── ObstacleSampleTool.cs │ │ ├── OffMeshConnectionSampleTool.cs │ │ ├── TestNavmeshSampleTool.cs │ │ └── TileSampleTool.cs │ └── UI │ │ ├── IRcView.cs │ │ ├── ImFilePicker.cs │ │ ├── RcCanvas.cs │ │ ├── RcCanvasLayout.cs │ │ ├── RcLogView.cs │ │ ├── RcMenuView.cs │ │ ├── RcSettingsView.cs │ │ ├── RcToolsetView.cs │ │ └── ViewModels │ │ └── LogMessageItem.cs ├── DotRecast.Recast.Toolset │ ├── Builder │ │ ├── DemoNavMeshBuilder.cs │ │ ├── NavMeshBuildResult.cs │ │ ├── SampleAreaModifications.cs │ │ ├── SoloNavMeshBuilder.cs │ │ └── TileNavMeshBuilder.cs │ ├── DotRecast.Recast.Toolset.csproj │ ├── Geom │ │ ├── DemoDtTileCacheMeshProcess.cs │ │ └── DemoInputGeomProvider.cs │ ├── Gizmos │ │ ├── IRcGizmoMeshFilter.cs │ │ ├── RcBoxGizmo.cs │ │ ├── RcCapsuleGizmo.cs │ │ ├── RcCompositeGizmo.cs │ │ ├── RcCylinderGizmo.cs │ │ ├── RcGizmo.cs │ │ ├── RcGizmoFactory.cs │ │ ├── RcGizmoHelper.cs │ │ ├── RcSphereGizmo.cs │ │ └── RcTrimeshGizmo.cs │ ├── IRcToolable.cs │ ├── RcNavMeshBuildSettings.cs │ └── Tools │ │ ├── RcConvexVolumeTool.cs │ │ ├── RcCrowdAgentData.cs │ │ ├── RcCrowdAgentProfilingTool.cs │ │ ├── RcCrowdAgentProfilingToolConfig.cs │ │ ├── RcCrowdAgentTrail.cs │ │ ├── RcCrowdAgentType.cs │ │ ├── RcCrowdTool.cs │ │ ├── RcCrowdToolMode.cs │ │ ├── RcDynamicColliderShape.cs │ │ ├── RcDynamicUpdateTool.cs │ │ ├── RcDynamicUpdateToolMode.cs │ │ ├── RcJumpLinkBuilderTool.cs │ │ ├── RcJumpLinkBuilderToolConfig.cs │ │ ├── RcObstacleTool.cs │ │ ├── RcOffMeshConnectionTool.cs │ │ ├── RcTestNavMeshTool.cs │ │ ├── RcTestNavmeshToolMode.cs │ │ └── RcTileTool.cs └── DotRecast.Recast │ ├── DotRecast.Recast.csproj │ ├── EdgeValues.cs │ ├── Geom │ ├── BoundsItem.cs │ ├── BoundsItemXComparer.cs │ ├── BoundsItemYComparer.cs │ ├── IInputGeomProvider.cs │ ├── RcChunkyTriMesh.cs │ ├── RcChunkyTriMeshNode.cs │ ├── RcChunkyTriMeshs.cs │ ├── RcOffMeshConnection.cs │ ├── RcTriMesh.cs │ └── SimpleInputGeomProvider.cs │ ├── IRcBuilderProgressListener.cs │ ├── RcAreaModification.cs │ ├── RcAreas.cs │ ├── RcAxis.cs │ ├── RcBuildContoursFlags.cs │ ├── RcBuilder.cs │ ├── RcBuilderConfig.cs │ ├── RcBuilderResult.cs │ ├── RcCompactCell.cs │ ├── RcCompactHeightfield.cs │ ├── RcCompactSpan.cs │ ├── RcCompactSpanBuilder.cs │ ├── RcCompacts.cs │ ├── RcConfig.cs │ ├── RcContour.cs │ ├── RcContourHole.cs │ ├── RcContourHoleComparer.cs │ ├── RcContourRegion.cs │ ├── RcContourSet.cs │ ├── RcContours.cs │ ├── RcConvexVolume.cs │ ├── RcDirtyEntry.cs │ ├── RcFilledVolumeRasterization.cs │ ├── RcFilters.cs │ ├── RcHeightPatch.cs │ ├── RcHeightfield.cs │ ├── RcHeightfieldLayer.cs │ ├── RcHeightfieldLayerSet.cs │ ├── RcLayerRegion.cs │ ├── RcLayerSweepSpan.cs │ ├── RcLayers.cs │ ├── RcLevelStackEntry.cs │ ├── RcMeshDetails.cs │ ├── RcMeshs.cs │ ├── RcPartition.cs │ ├── RcPartitionType.cs │ ├── RcPolyMesh.cs │ ├── RcPolyMeshDetail.cs │ ├── RcPolyMeshRaycast.cs │ ├── RcPotentialDiagonal.cs │ ├── RcPotentialDiagonalComparer.cs │ ├── RcRasterizations.cs │ ├── RcRecast.cs │ ├── RcRegion.cs │ ├── RcRegions.cs │ ├── RcSpan.cs │ ├── RcSpanPool.cs │ ├── RcSweepSpan.cs │ └── RcVoxelizations.cs ├── test ├── DotRecast.Core.Test │ ├── DotRecast.Core.Test.csproj │ ├── RcBinaryMinHeapTest.cs │ ├── RcCyclicBufferTest.cs │ ├── RcHashCodesTest.cs │ ├── RcIoTests.cs │ ├── RcMathTest.cs │ ├── RcRentedArrayTest.cs │ ├── RcSortedQueueTest.cs │ ├── RcSpanTest.cs │ ├── RcStackArrayTest.cs │ ├── Vector2Test.cs │ └── Vector3Test.cs ├── DotRecast.Detour.Crowd.Test │ ├── AbstractCrowdTest.cs │ ├── Crowd1Test.cs │ ├── Crowd4Test.cs │ ├── Crowd4VelocityTest.cs │ ├── DotRecast.Detour.Crowd.Test.csproj │ ├── DtPathCorridorTest.cs │ ├── SampleAreaModifications.cs │ └── TestMeshDataFactory.cs ├── DotRecast.Detour.Dynamic.Test │ ├── DotRecast.Detour.Dynamic.Test.csproj │ ├── DynamicNavMeshTest.cs │ ├── Io │ │ ├── DtVoxelTileLZ4ForTestCompressor.cs │ │ ├── VoxelFileReaderTest.cs │ │ └── VoxelFileReaderWriterTest.cs │ ├── SampleAreaModifications.cs │ └── VoxelQueryTest.cs ├── DotRecast.Detour.Extras.Test │ ├── DotRecast.Detour.Extras.Test.csproj │ └── Unity │ │ └── Astar │ │ └── UnityAStarPathfindingImporterTest.cs ├── DotRecast.Detour.Test │ ├── AbstractDetourTest.cs │ ├── ConvexConvexIntersectionTest.cs │ ├── DotRecast.Detour.Test.csproj │ ├── DtNodePoolTest.cs │ ├── DtNodeQueueTest.cs │ ├── FindCollectPolyTest.cs │ ├── FindDistanceToWallTest.cs │ ├── FindLocalNeighbourhoodTest.cs │ ├── FindNearestPolyTest.cs │ ├── FindPathTest.cs │ ├── FindPolysAroundCircleTest.cs │ ├── FindPolysAroundShapeTest.cs │ ├── GetPolyWallSegmentsTest.cs │ ├── Io │ │ ├── MeshDataReaderWriterTest.cs │ │ ├── MeshSetReaderTest.cs │ │ └── MeshSetReaderWriterTest.cs │ ├── MoveAlongSurfaceTest.cs │ ├── NavMeshBuilderTest.cs │ ├── PolygonByCircleConstraintTest.cs │ ├── RandomPointTest.cs │ ├── SampleAreaModifications.cs │ ├── TestDetourBuilder.cs │ ├── TestMeshDataFactory.cs │ ├── TestTiledNavMeshBuilder.cs │ └── TiledFindPathTest.cs ├── DotRecast.Detour.TileCache.Test │ ├── AbstractTileCacheTest.cs │ ├── DotRecast.Detour.TileCache.Test.csproj │ ├── Io │ │ ├── DtTileCacheLZ4ForTestCompressor.cs │ │ ├── TileCacheReaderTest.cs │ │ └── TileCacheReaderWriterTest.cs │ ├── SampleAreaModifications.cs │ ├── TempObstaclesTest.cs │ ├── TestTileCacheMeshProcess.cs │ ├── TestTileLayerBuilder.cs │ ├── TileCacheFindPathTest.cs │ ├── TileCacheNavigationTest.cs │ ├── TileCacheTest.cs │ └── TileCacheTestSetUpFixture.cs └── DotRecast.Recast.Test │ ├── DotRecast.Recast.Test.csproj │ ├── RecastLayersTest.cs │ ├── RecastSoloMeshTest.cs │ ├── RecastTest.cs │ ├── RecastTileMeshTest.cs │ └── SampleAreaModifications.cs └── tool ├── DotRecast.Tool.Benchmark ├── DotRecast.Core │ ├── ArrayBenchmarks.cs │ ├── PriorityQueueBenchmarks.cs │ └── VectorBenchmarks.cs ├── DotRecast.Detour │ └── PolygonByCircleConstraintBenchmarks.cs ├── DotRecast.Tool.Benchmark.csproj └── Program.cs └── DotRecast.Tool.PublishToUniRecast ├── CsProj.cs ├── DotRecast.Tool.PublishToUniRecast.csproj └── Program.cs /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | ############################### 4 | # Core EditorConfig Options # 5 | ############################### 6 | 7 | # All files 8 | [*] 9 | indent_style = space 10 | charset = utf-8 11 | 12 | [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct,proto,json,yml,yaml}] 13 | indent_size = 2 14 | 15 | [*.cs] 16 | indent_size = 4 17 | dotnet_sort_system_directives_first = true 18 | 19 | # Wrapping preferences 20 | csharp_preserve_single_line_statements = false 21 | csharp_preserve_single_line_blocks = true 22 | 23 | # ReSharper properties 24 | resharper_csharp_wrap_lines = false 25 | resharper_csharp_space_before_trailing_comment = true 26 | resharper_csharp_space_after_operator_keyword = true 27 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: ikpil 4 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name-template: '$RESOLVED_VERSION' 2 | tag-template: '$RESOLVED_VERSION' 3 | template: | 4 | # What's Changed 5 | 6 | $CHANGES 7 | 8 | **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$RESOLVED_VERSION 9 | 10 | categories: 11 | - title: 'Changes' 12 | labels: 13 | - 'feature' 14 | - 'feat' 15 | 16 | - title: 'Bug Fixes' 17 | labels: 18 | - 'bug' 19 | - 'fix' 20 | 21 | version-resolver: 22 | major: 23 | labels: 24 | - 'type: breaking' 25 | minor: 26 | labels: 27 | - 'type: feature' 28 | patch: 29 | labels: 30 | - 'type: bug' 31 | - 'type: maintenance' 32 | - 'type: docs' 33 | - 'type: dependencies' 34 | - 'type: security' 35 | 36 | exclude-labels: 37 | - 'skip-changelog' -------------------------------------------------------------------------------- /.github/workflows/dotnet.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a .NET project 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net 3 | 4 | name: .NET 5 | 6 | on: 7 | push: 8 | branches: 9 | - 'main' 10 | - 'pr/**' 11 | paths: 12 | - '**.cs' 13 | - '**.csproj' 14 | - '**.sln' 15 | - '**.yml' 16 | pull_request: 17 | branches: 18 | - 'pr/**' 19 | paths: 20 | - '**.cs' 21 | - '**.csproj' 22 | - '**.sln' 23 | - '**.yml' 24 | 25 | jobs: 26 | build-and-test: 27 | name: test-${{matrix.os}}-${{matrix.dotnet-version}} 28 | runs-on: ${{ matrix.os }} 29 | strategy: 30 | matrix: 31 | dotnet-version: [ '8', '9' ] 32 | os: [ windows-latest, ubuntu-latest, macos-latest ] 33 | 34 | steps: 35 | - uses: actions/checkout@v4 36 | with: 37 | fetch-depth: 0 # Get all history to allow automatic versioning using MinVer 38 | 39 | - name: Setup .NET 40 | uses: actions/setup-dotnet@v4 41 | with: 42 | dotnet-version: | 43 | 8 44 | 9 45 | 46 | - name: Restore dependencies 47 | run: dotnet restore 48 | 49 | - name: Build 50 | run: dotnet build -c Release --no-restore --framework net${{ matrix.dotnet-version }}.0 51 | 52 | - name: Test 53 | run: dotnet test -c Release --no-build --verbosity normal --framework net${{ matrix.dotnet-version }}.0 54 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Nuget Publish 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | version: 7 | description: version 8 | required: true 9 | type: string 10 | 11 | jobs: 12 | publish-to-nuget: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: version pattern 16 | id: check-version 17 | run: | 18 | version="${{ github.event.inputs.version }}" 19 | if [[ $version =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then 20 | echo "Input matches pattern: $version" 21 | else 22 | echo "Input does not match pattern: $version" 23 | exit 1 24 | fi 25 | 26 | - name: version check 27 | if: success() 28 | run: echo ok 29 | 30 | - name: Checkout 31 | uses: actions/checkout@v4 32 | with: 33 | fetch-depth: 0 # Get all history to allow automatic versioning using MinVer 34 | 35 | - name: Setup Dotnet 36 | uses: actions/setup-dotnet@v4 37 | with: 38 | dotnet-version: '9.x' 39 | 40 | - name: restore dependencies 41 | run: dotnet restore 42 | 43 | - name: Build 44 | run: dotnet build -c Release --no-restore 45 | 46 | - name: Test 47 | run: dotnet test -c Release --no-build --verbosity normal 48 | 49 | - name: Pack 50 | run: dotnet pack -p:PackageVersion=${{ github.event.inputs.version }} -c Release --nologo --output working-nuget 51 | 52 | - name: Publish the package to nuget.org 53 | run: dotnet nuget push ./working-nuget/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json 54 | env: 55 | NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }} 56 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | // Use IntelliSense to find out which attributes exist for C# debugging 6 | // Use hover for the description of the existing attributes 7 | // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/src/DotRecast.Recast.Demo/bin/Debug/net9.0/DotRecast.Recast.Demo.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}/src/DotRecast.Recast.Demo", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "internalConsole", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach" 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/DotRecast.sln", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary;ForceNoAlign" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/DotRecast.sln", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary;ForceNoAlign" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "--project", 36 | "${workspaceFolder}/DotRecast.sln" 37 | ], 38 | "problemMatcher": "$msCompile" 39 | } 40 | ] 41 | } -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Mikko Mononen memon@inside.org, Piotr Piastucki, choi ikpil ikpil@naver.com 2 | 3 | 4 | This software is provided 'as-is', without any express or implied 5 | warranty. In no event will the authors be held liable for any damages 6 | arising from the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | -------------------------------------------------------------------------------- /resources/all_tiles_navmesh.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikpil/DotRecast/e2e989579594cbb6605b94dd922fe35abff2051d/resources/all_tiles_navmesh.bin -------------------------------------------------------------------------------- /resources/all_tiles_tilecache.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikpil/DotRecast/e2e989579594cbb6605b94dd922fe35abff2051d/resources/all_tiles_tilecache.bin -------------------------------------------------------------------------------- /resources/dungeon_all_tiles_navmesh.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikpil/DotRecast/e2e989579594cbb6605b94dd922fe35abff2051d/resources/dungeon_all_tiles_navmesh.bin -------------------------------------------------------------------------------- /resources/dungeon_all_tiles_navmesh_32bit.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikpil/DotRecast/e2e989579594cbb6605b94dd922fe35abff2051d/resources/dungeon_all_tiles_navmesh_32bit.bin -------------------------------------------------------------------------------- /resources/dungeon_all_tiles_tilecache.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikpil/DotRecast/e2e989579594cbb6605b94dd922fe35abff2051d/resources/dungeon_all_tiles_tilecache.bin -------------------------------------------------------------------------------- /resources/fonts/DroidSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikpil/DotRecast/e2e989579594cbb6605b94dd922fe35abff2051d/resources/fonts/DroidSans.ttf -------------------------------------------------------------------------------- /resources/graph.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikpil/DotRecast/e2e989579594cbb6605b94dd922fe35abff2051d/resources/graph.zip -------------------------------------------------------------------------------- /resources/graph_v4_1_16.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikpil/DotRecast/e2e989579594cbb6605b94dd922fe35abff2051d/resources/graph_v4_1_16.zip -------------------------------------------------------------------------------- /resources/test.voxels: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikpil/DotRecast/e2e989579594cbb6605b94dd922fe35abff2051d/resources/test.voxels -------------------------------------------------------------------------------- /resources/test_boundstree.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikpil/DotRecast/e2e989579594cbb6605b94dd922fe35abff2051d/resources/test_boundstree.zip -------------------------------------------------------------------------------- /resources/test_tiles.voxels: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikpil/DotRecast/e2e989579594cbb6605b94dd922fe35abff2051d/resources/test_tiles.voxels -------------------------------------------------------------------------------- /src/DotRecast.Core/Buffers/RcObjectPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace DotRecast.Core.Buffers 5 | { 6 | // This implementation is thread unsafe 7 | public class RcObjectPool where T : class 8 | { 9 | private readonly Queue _items = new Queue(); 10 | private readonly Func _createFunc; 11 | 12 | public RcObjectPool(Func createFunc) 13 | { 14 | _createFunc = createFunc; 15 | } 16 | 17 | public T Get() 18 | { 19 | if (_items.TryDequeue(out var result)) 20 | return result; 21 | 22 | return _createFunc(); 23 | } 24 | 25 | public void Return(T obj) 26 | { 27 | _items.Enqueue(obj); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/Collections/RcFixedArray1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | #pragma warning disable CS0169 6 | 7 | namespace DotRecast.Core.Collections 8 | { 9 | [StructLayout(LayoutKind.Sequential)] 10 | public struct RcFixedArray1 where T : unmanaged 11 | { 12 | public const int Size = 1; 13 | 14 | private T _v0000; 15 | 16 | public int Length => Size; 17 | 18 | public ref T this[int index] 19 | { 20 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 21 | get => ref AsSpan()[index]; 22 | } 23 | 24 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 25 | public void CopyFrom(ReadOnlySpan source, int length) 26 | { 27 | source.Slice(0, length).CopyTo(AsSpan()); 28 | } 29 | 30 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 31 | public Span AsSpan() 32 | { 33 | return MemoryMarshal.CreateSpan(ref _v0000, Size); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/Collections/RcFixedArray16.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | #pragma warning disable CS0169 6 | 7 | namespace DotRecast.Core.Collections 8 | { 9 | [StructLayout(LayoutKind.Sequential)] 10 | public struct RcFixedArray16 where T : unmanaged 11 | { 12 | public const int Size = 16; 13 | 14 | private T _v0000; 15 | private T _v0001; 16 | private T _v0002; 17 | private T _v0003; 18 | private T _v0004; 19 | private T _v0005; 20 | private T _v0006; 21 | private T _v0007; 22 | private T _v0008; 23 | private T _v0009; 24 | private T _v0010; 25 | private T _v0011; 26 | private T _v0012; 27 | private T _v0013; 28 | private T _v0014; 29 | private T _v0015; 30 | 31 | public int Length => Size; 32 | 33 | public ref T this[int index] 34 | { 35 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 36 | get => ref AsSpan()[index]; 37 | } 38 | 39 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 40 | public void CopyFrom(ReadOnlySpan source, int length) 41 | { 42 | source.Slice(0, length).CopyTo(AsSpan()); 43 | } 44 | 45 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 46 | public Span AsSpan() 47 | { 48 | return MemoryMarshal.CreateSpan(ref _v0000, Size); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/Collections/RcFixedArray2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | #pragma warning disable CS0169 6 | 7 | namespace DotRecast.Core.Collections 8 | { 9 | [StructLayout(LayoutKind.Sequential)] 10 | public struct RcFixedArray2 where T : unmanaged 11 | { 12 | public const int Size = 2; 13 | 14 | private T _v0000; 15 | private T _v0001; 16 | 17 | public int Length => Size; 18 | 19 | public ref T this[int index] 20 | { 21 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 22 | get => ref AsSpan()[index]; 23 | } 24 | 25 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 26 | public void CopyFrom(ReadOnlySpan source, int length) 27 | { 28 | source.Slice(0, length).CopyTo(AsSpan()); 29 | } 30 | 31 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 32 | public Span AsSpan() 33 | { 34 | return MemoryMarshal.CreateSpan(ref _v0000, Size); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/Collections/RcFixedArray4.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | #pragma warning disable CS0169 6 | 7 | namespace DotRecast.Core.Collections 8 | { 9 | [StructLayout(LayoutKind.Sequential)] 10 | public struct RcFixedArray4 where T : unmanaged 11 | { 12 | public const int Size = 4; 13 | 14 | private T _v0000; 15 | private T _v0001; 16 | private T _v0002; 17 | private T _v0003; 18 | 19 | public int Length => Size; 20 | 21 | public ref T this[int index] 22 | { 23 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 24 | get => ref AsSpan()[index]; 25 | } 26 | 27 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 28 | public void CopyFrom(ReadOnlySpan source, int length) 29 | { 30 | source.Slice(0, length).CopyTo(AsSpan()); 31 | } 32 | 33 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 34 | public Span AsSpan() 35 | { 36 | return MemoryMarshal.CreateSpan(ref _v0000, Size); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/Collections/RcFixedArray8.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | #pragma warning disable CS0169 6 | 7 | namespace DotRecast.Core.Collections 8 | { 9 | [StructLayout(LayoutKind.Sequential)] 10 | public struct RcFixedArray8 where T : unmanaged 11 | { 12 | public const int Size = 8; 13 | 14 | private T _v0000; 15 | private T _v0001; 16 | private T _v0002; 17 | private T _v0003; 18 | private T _v0004; 19 | private T _v0005; 20 | private T _v0006; 21 | private T _v0007; 22 | 23 | public int Length => Size; 24 | 25 | public ref T this[int index] 26 | { 27 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 28 | get => ref AsSpan()[index]; 29 | } 30 | 31 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 32 | public void CopyFrom(ReadOnlySpan source, int length) 33 | { 34 | source.Slice(0, length).CopyTo(AsSpan()); 35 | } 36 | 37 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 38 | public Span AsSpan() 39 | { 40 | return MemoryMarshal.CreateSpan(ref _v0000, Size); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/Collections/RcImmutableArray.Minimal.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Core.Collections 2 | { 3 | public readonly partial struct RcImmutableArray 4 | { 5 | #pragma warning disable CA1825 6 | public static readonly RcImmutableArray Empty = new RcImmutableArray(new T[0]); 7 | #pragma warning restore CA1825 8 | 9 | private readonly T[] _array; 10 | 11 | internal RcImmutableArray(T[] items) 12 | { 13 | _array = items; 14 | } 15 | 16 | public T this[int index] => _array![index]; 17 | public int Length => _array!.Length; 18 | } 19 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/Collections/RcImmutableArray.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Core.Collections 2 | { 3 | public static class RcImmutableArray 4 | { 5 | public static RcImmutableArray Create() 6 | { 7 | return RcImmutableArray.Empty; 8 | } 9 | 10 | public static RcImmutableArray Create(T item1) 11 | { 12 | T[] array = new[] { item1 }; 13 | return new RcImmutableArray(array); 14 | } 15 | 16 | public static RcImmutableArray Create(T item1, T item2) 17 | { 18 | T[] array = new[] { item1, item2 }; 19 | return new RcImmutableArray(array); 20 | } 21 | 22 | public static RcImmutableArray Create(T item1, T item2, T item3) 23 | { 24 | T[] array = new[] { item1, item2, item3 }; 25 | return new RcImmutableArray(array); 26 | } 27 | 28 | public static RcImmutableArray Create(T item1, T item2, T item3, T item4) 29 | { 30 | T[] array = new[] { item1, item2, item3, item4 }; 31 | return new RcImmutableArray(array); 32 | } 33 | 34 | public static RcImmutableArray Create(params T[] items) 35 | { 36 | if (items == null || items.Length == 0) 37 | { 38 | return RcImmutableArray.Empty; 39 | } 40 | 41 | var tmp = new T[items.Length]; 42 | RcArrays.Copy(items, tmp, items.Length); 43 | return new RcImmutableArray(tmp); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/DotRecast.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1;net8.0;net9.0 5 | DotRecast.Core 6 | README.md 7 | ikpil 8 | DotRecast - a port of Recast Detour, Industry-standard navigation mesh toolset for .NET, C#, Unity3D, games, servers 9 | git 10 | https://github.com/ikpil/DotRecast 11 | https://github.com/ikpil/DotRecast 12 | game gamedev ai csharp server unity navigation game-development unity3d pathfinding pathfinder recast detour navmesh crowd-simulation recastnavigation 13 | https://github.com/ikpil/DotRecast/blob/main/CHANGELOG.md 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/DotRecast.Core/IRcCompressor.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Core 22 | { 23 | public interface IRcCompressor 24 | { 25 | byte[] Decompress(byte[] data); 26 | byte[] Decompress(byte[] buf, int offset, int len, int outputlen); 27 | 28 | byte[] Compress(byte[] buf); 29 | } 30 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/IRcRand.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Core 2 | { 3 | public interface IRcRand 4 | { 5 | float Next(); 6 | double NextDouble(); 7 | int NextInt32(); 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/Numerics/RcVec3i.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Core.Numerics 2 | { 3 | public struct RcVec3i 4 | { 5 | public int X; 6 | public int Y; 7 | public int Z; 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcArrays.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | 4 | namespace DotRecast.Core 5 | { 6 | public static class RcArrays 7 | { 8 | // Type Safe Copy 9 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 10 | public static void Copy(T[] sourceArray, long sourceIndex, T[] destinationArray, long destinationIndex, long length) 11 | { 12 | Array.Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length); 13 | } 14 | 15 | // Type Safe Copy 16 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 17 | public static void Copy(T[] sourceArray, T[] destinationArray, long length) 18 | { 19 | Array.Copy(sourceArray, destinationArray, length); 20 | } 21 | 22 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 23 | public static T[] CopyOf(T[] source, int startIdx, int length) 24 | { 25 | var slice = source.AsSpan(startIdx, length); 26 | return slice.ToArray(); 27 | } 28 | 29 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 30 | public static T[] CopyOf(T[] source, long length) 31 | { 32 | return CopyOf(source, 0, (int)length); 33 | } 34 | 35 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 36 | public static T[][] Create2D(int len1, int len2) 37 | { 38 | var temp = new T[len1][]; 39 | 40 | for (int i = 0; i < len1; ++i) 41 | { 42 | temp[i] = new T[len2]; 43 | } 44 | 45 | return temp; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcAtomicBoolean.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | 3 | namespace DotRecast.Core 4 | { 5 | public class RcAtomicBoolean 6 | { 7 | private volatile int _location; 8 | 9 | public bool Set(bool v) 10 | { 11 | return 0 != Interlocked.Exchange(ref _location, v ? 1 : 0); 12 | } 13 | 14 | public bool Get() 15 | { 16 | return 0 != _location; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcAtomicFloat.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | 3 | namespace DotRecast.Core 4 | { 5 | public class RcAtomicFloat 6 | { 7 | private volatile float _location; 8 | 9 | public RcAtomicFloat(float location) 10 | { 11 | _location = location; 12 | } 13 | 14 | public float Get() 15 | { 16 | return _location; 17 | } 18 | 19 | public float Exchange(float exchange) 20 | { 21 | return Interlocked.Exchange(ref _location, exchange); 22 | } 23 | 24 | public float CompareExchange(float value, float comparand) 25 | { 26 | return Interlocked.CompareExchange(ref _location, value, comparand); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcAtomicInteger.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | 3 | namespace DotRecast.Core 4 | { 5 | public class RcAtomicInteger 6 | { 7 | private volatile int _location; 8 | 9 | public RcAtomicInteger() : this(0) 10 | { 11 | } 12 | 13 | public RcAtomicInteger(int location) 14 | { 15 | _location = location; 16 | } 17 | 18 | public int IncrementAndGet() 19 | { 20 | return Interlocked.Increment(ref _location); 21 | } 22 | 23 | public int GetAndIncrement() 24 | { 25 | var next = Interlocked.Increment(ref _location); 26 | return next - 1; 27 | } 28 | 29 | 30 | public int DecrementAndGet() 31 | { 32 | return Interlocked.Decrement(ref _location); 33 | } 34 | 35 | public int Read() 36 | { 37 | return _location; 38 | } 39 | 40 | public int GetSoft() 41 | { 42 | return _location; 43 | } 44 | 45 | public int Exchange(int exchange) 46 | { 47 | return Interlocked.Exchange(ref _location, exchange); 48 | } 49 | 50 | public int Decrease(int value) 51 | { 52 | return Interlocked.Add(ref _location, -value); 53 | } 54 | 55 | public int CompareExchange(int value, int comparand) 56 | { 57 | return Interlocked.CompareExchange(ref _location, value, comparand); 58 | } 59 | 60 | public int Add(int value) 61 | { 62 | return Interlocked.Add(ref _location, value); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcAtomicLong.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace DotRecast.Core 5 | { 6 | public class RcAtomicLong : IComparable 7 | { 8 | private long _location; 9 | 10 | public RcAtomicLong() : this(0) 11 | { 12 | } 13 | 14 | public RcAtomicLong(long location) 15 | { 16 | _location = location; 17 | } 18 | 19 | public int CompareTo(RcAtomicLong other) 20 | { 21 | return Read().CompareTo(other.Read()); 22 | } 23 | 24 | public long IncrementAndGet() 25 | { 26 | return Interlocked.Increment(ref _location); 27 | } 28 | 29 | public long DecrementAndGet() 30 | { 31 | return Interlocked.Decrement(ref _location); 32 | } 33 | 34 | public long Read() 35 | { 36 | return Interlocked.Read(ref _location); 37 | } 38 | 39 | public long Exchange(long exchange) 40 | { 41 | return Interlocked.Exchange(ref _location, exchange); 42 | } 43 | 44 | public long Decrease(long value) 45 | { 46 | return Interlocked.Add(ref _location, -value); 47 | } 48 | 49 | public long CompareExchange(long value, long comparand) 50 | { 51 | return Interlocked.CompareExchange(ref _location, value, comparand); 52 | } 53 | 54 | public long AddAndGet(long value) 55 | { 56 | return Interlocked.Add(ref _location, value); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcByteOrder.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Core 2 | { 3 | public enum RcByteOrder 4 | { 5 | /// Default on most Windows systems 6 | LITTLE_ENDIAN, 7 | BIG_ENDIAN, 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcEdge.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Core 2 | { 3 | public class RcEdge 4 | { 5 | public int[] vert = new int[2]; 6 | public int[] polyEdge = new int[2]; 7 | public int[] poly = new int[2]; 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcFrequency.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace DotRecast.Core 5 | { 6 | public static class RcFrequency 7 | { 8 | public static readonly double Frequency = (double)TimeSpan.TicksPerSecond / Stopwatch.Frequency; 9 | public static long Ticks => unchecked((long)(Stopwatch.GetTimestamp() * Frequency)); 10 | } 11 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcHashCodes.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | namespace DotRecast.Core 4 | { 5 | public static class RcHashCodes 6 | { 7 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 8 | public static int CombineHashCodes(int h1, int h2) 9 | { 10 | return (((h1 << 5) + h1) ^ h2); 11 | } 12 | 13 | // From Thomas Wang, https://gist.github.com/badboy/6267743 14 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 15 | public static uint WangHash(uint a) 16 | { 17 | a = (~a) + (a << 18); // a = (a << 18) - a - 1; 18 | a = a ^ (a >> 31); 19 | a = a * 21; // a = (a + (a << 2)) + (a << 4); 20 | a = a ^ (a >> 11); 21 | a = a + (a << 6); 22 | a = a ^ (a >> 22); 23 | return (uint)a; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcMath.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | using System.Runtime.CompilerServices; 22 | 23 | namespace DotRecast.Core 24 | { 25 | public static class RcMath 26 | { 27 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 28 | public static float Sqr(float f) 29 | { 30 | return f * f; 31 | } 32 | 33 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 34 | public static float Lerp(float value1, float value2, float amount) 35 | { 36 | return (value1 * (1.0f - amount)) + (value2 * amount); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcObjImporterContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace DotRecast.Core 4 | { 5 | public class RcObjImporterContext 6 | { 7 | public List vertexPositions = new List(); 8 | public List meshFaces = new List(); 9 | } 10 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcProcess.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace DotRecast.Core 6 | { 7 | public static class RcProcess 8 | { 9 | public static void OpenUrl(string url) 10 | { 11 | try 12 | { 13 | // OS에 따라 다른 명령 실행 14 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) 15 | { 16 | var psi = new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true }; 17 | Process.Start(psi); 18 | } 19 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) 20 | { 21 | Process.Start("open", url); 22 | } 23 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) 24 | { 25 | Process.Start("xdg-open", url); 26 | } 27 | } 28 | catch (Exception ex) 29 | { 30 | Console.WriteLine($"Error opening web browser: {ex.Message}"); 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcRand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DotRecast.Core 4 | { 5 | public class RcRand : IRcRand 6 | { 7 | private readonly Random _r; 8 | 9 | public RcRand() : this(new Random()) 10 | { 11 | } 12 | 13 | public RcRand(Random r) 14 | { 15 | _r = r; 16 | } 17 | 18 | public RcRand(long seed) 19 | { 20 | _r = new Random((int)seed); // TODO: @ikpil, check random seed value 21 | } 22 | 23 | public float Next() 24 | { 25 | return (float)_r.NextDouble(); 26 | } 27 | 28 | public double NextDouble() 29 | { 30 | return _r.NextDouble(); 31 | } 32 | 33 | public int NextInt32() 34 | { 35 | return _r.Next(); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcScopedTimer.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Core 2 | { 3 | public readonly ref struct RcScopedTimer 4 | { 5 | private readonly RcContext _context; 6 | private readonly RcTimerLabel _label; 7 | 8 | internal RcScopedTimer(RcContext context, RcTimerLabel label) 9 | { 10 | _context = context; 11 | _label = label; 12 | 13 | _context.StartTimer(_label); 14 | } 15 | 16 | public void Dispose() 17 | { 18 | _context.StopTimer(_label); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcSegmentVert.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Core 4 | { 5 | public struct RcSegmentVert 6 | { 7 | public RcVec3f vmin; 8 | public RcVec3f vmax; 9 | 10 | public RcSegmentVert(float v0, float v1, float v2, float v3, float v4, float v5) 11 | { 12 | vmin.X = v0; 13 | vmin.Y = v1; 14 | vmin.Z = v2; 15 | 16 | vmax.X = v3; 17 | vmax.Y = v4; 18 | vmax.Z = v5; 19 | } 20 | 21 | } 22 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcSpans.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | 4 | namespace DotRecast.Core 5 | { 6 | public static class RcSpans 7 | { 8 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 9 | public static void Copy(ReadOnlySpan src, Span dst) 10 | { 11 | src.CopyTo(dst); 12 | } 13 | 14 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 15 | public static void Copy(ReadOnlySpan src, int srcIdx, Span dst, int dstIdx, int length) 16 | { 17 | var slicedSrc = src.Slice(srcIdx, length); 18 | var slicedDst = dst.Slice(dstIdx); 19 | slicedSrc.CopyTo(slicedDst); 20 | } 21 | 22 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 23 | public static void Move(Span src, int srcIdx, int dstIdx, int length) 24 | { 25 | var slicedSrc = src.Slice(srcIdx, length); 26 | var slicedDst = src.Slice(dstIdx, length); 27 | slicedSrc.CopyTo(slicedDst); 28 | } 29 | 30 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 31 | public static void Fill(Span span, T value, int start, int count) 32 | { 33 | span.Slice(start, count).Fill(value); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/DotRecast.Core/RcTelemetryTick.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DotRecast.Core 4 | { 5 | public readonly struct RcTelemetryTick 6 | { 7 | public readonly string Key; 8 | public readonly long Ticks; 9 | public long Millis => Ticks / TimeSpan.TicksPerMillisecond; 10 | public long Micros => Ticks / 10; // TimeSpan.TicksPerMicrosecond; 11 | 12 | public RcTelemetryTick(string key, long ticks) 13 | { 14 | Key = key; 15 | Ticks = ticks; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DotRecast.Detour.Crowd.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1;net8.0;net9.0 5 | DotRecast.Detour.Crowd 6 | README.md 7 | ikpil 8 | DotRecast - a port of Recast Detour, Industry-standard navigation mesh toolset for .NET, C#, Unity3D, games, servers 9 | git 10 | https://github.com/ikpil/DotRecast 11 | https://github.com/ikpil/DotRecast 12 | game gamedev ai csharp server unity navigation game-development unity3d pathfinding pathfinder recast detour navmesh crowd-simulation recastnavigation 13 | https://github.com/ikpil/DotRecast/blob/main/CHANGELOG.md 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DtCrowdAgentAnimation.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | using DotRecast.Core.Numerics; 22 | 23 | namespace DotRecast.Detour.Crowd 24 | { 25 | public class DtCrowdAgentAnimation 26 | { 27 | public bool active; 28 | public RcVec3f initPos = new RcVec3f(); 29 | public RcVec3f startPos = new RcVec3f(); 30 | public RcVec3f endPos = new RcVec3f(); 31 | public long polyRef; 32 | public float t, tmax; 33 | } 34 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DtCrowdAgentConfig.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.Crowd 2 | { 3 | public class DtCrowdAgentConfig 4 | { 5 | public int expandOptions = 1; 6 | public bool anticipateTurns = true; 7 | public bool optimizeVis = true; 8 | public bool optimizeTopo = true; 9 | public bool obstacleAvoidance = true; 10 | public int obstacleAvoidanceType = 3; 11 | public bool separation; 12 | public float separationWeight = 2f; 13 | 14 | public int GetUpdateFlags() 15 | { 16 | int updateFlags = 0; 17 | if (anticipateTurns) 18 | { 19 | updateFlags |= DtCrowdAgentUpdateFlags.DT_CROWD_ANTICIPATE_TURNS; 20 | } 21 | 22 | if (optimizeVis) 23 | { 24 | updateFlags |= DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_VIS; 25 | } 26 | 27 | if (optimizeTopo) 28 | { 29 | updateFlags |= DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO; 30 | } 31 | 32 | if (obstacleAvoidance) 33 | { 34 | updateFlags |= DtCrowdAgentUpdateFlags.DT_CROWD_OBSTACLE_AVOIDANCE; 35 | } 36 | 37 | if (separation) 38 | { 39 | updateFlags |= DtCrowdAgentUpdateFlags.DT_CROWD_SEPARATION; 40 | } 41 | 42 | return updateFlags; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DtCrowdAgentDebugInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | using DotRecast.Core.Numerics; 22 | 23 | namespace DotRecast.Detour.Crowd 24 | { 25 | public class DtCrowdAgentDebugInfo 26 | { 27 | public DtCrowdAgent agent; 28 | public RcVec3f optStart = new RcVec3f(); 29 | public RcVec3f optEnd = new RcVec3f(); 30 | public DtObstacleAvoidanceDebugData vod; 31 | } 32 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DtCrowdAgentState.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.Crowd 2 | { 3 | /// The type of navigation mesh polygon the agent is currently traversing. 4 | /// @ingroup crowd 5 | public enum DtCrowdAgentState 6 | { 7 | DT_CROWDAGENT_STATE_INVALID, // < The agent is not in a valid state. 8 | DT_CROWDAGENT_STATE_WALKING, // < The agent is traversing a normal navigation mesh polygon. 9 | DT_CROWDAGENT_STATE_OFFMESH, // < The agent is traversing an off-mesh connection. 10 | }; 11 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DtCrowdAgentUpdateFlags.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.Crowd 2 | { 3 | /// Crowd agent update flags. 4 | /// @ingroup crowd 5 | /// @see dtCrowdAgentParams::updateFlags 6 | public static class DtCrowdAgentUpdateFlags 7 | { 8 | public const int DT_CROWD_ANTICIPATE_TURNS = 1; 9 | public const int DT_CROWD_OBSTACLE_AVOIDANCE = 2; 10 | public const int DT_CROWD_SEPARATION = 4; 11 | public const int DT_CROWD_OPTIMIZE_VIS = 8; //< Use #dtPathCorridor::optimizePathVisibility() to optimize the agent path. 12 | public const int DT_CROWD_OPTIMIZE_TOPO = 16; //< Use dtPathCorridor::optimizePathTopology() to optimize the agent path. 13 | } 14 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DtCrowdConst.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.Crowd 2 | { 3 | public static class DtCrowdConst 4 | { 5 | /// The maximum number of neighbors that a crowd agent can take into account 6 | /// for steering decisions. 7 | /// @ingroup crowd 8 | public const int DT_CROWDAGENT_MAX_NEIGHBOURS = 6; 9 | 10 | /// The maximum number of corners a crowd agent will look ahead in the path. 11 | /// This value is used for sizing the crowd agent corner buffers. 12 | /// Due to the behavior of the crowd manager, the actual number of useful 13 | /// corners will be one less than this number. 14 | /// @ingroup crowd 15 | public const int DT_CROWDAGENT_MAX_CORNERS = 4; 16 | 17 | /// The maximum number of crowd avoidance configurations supported by the 18 | /// crowd manager. 19 | /// @ingroup crowd 20 | /// @see dtObstacleAvoidanceParams, dtCrowd::SetObstacleAvoidanceParams(), dtCrowd::GetObstacleAvoidanceParams(), 21 | /// dtCrowdAgentParams::obstacleAvoidanceType 22 | public const int DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS = 8; 23 | 24 | /// The maximum number of query filter types supported by the crowd manager. 25 | /// @ingroup crowd 26 | /// @see dtQueryFilter, dtCrowd::GetFilter() dtCrowd::GetEditableFilter(), 27 | /// dtCrowdAgentParams::queryFilterType 28 | public const int DT_CROWD_MAX_QUERY_FILTER_TYPE = 16; 29 | 30 | public const int MAX_ITERS_PER_UPDATE = 100; 31 | public const int MAX_PATHQUEUE_NODES = 4096; 32 | public const int MAX_COMMON_NODES = 512; 33 | public const int MAX_PATH_RESULT = 256; 34 | } 35 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DtCrowdNeighbour.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.Crowd 2 | { 3 | /// Provides neighbor data for agents managed by the crowd. 4 | /// @ingroup crowd 5 | /// @see dtCrowdAgent::neis, dtCrowd 6 | public readonly struct DtCrowdNeighbour 7 | { 8 | public readonly DtCrowdAgent agent; // < The index of the neighbor in the crowd. 9 | public readonly float dist; // < The distance between the current agent and the neighbor. 10 | 11 | public DtCrowdNeighbour(DtCrowdAgent agent, float dist) 12 | { 13 | this.agent = agent; 14 | this.dist = dist; 15 | } 16 | }; 17 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DtCrowdScopedTimer.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.Crowd 2 | { 3 | internal readonly ref struct DtCrowdScopedTimer 4 | { 5 | private readonly DtCrowdTimerLabel _label; 6 | private readonly DtCrowdTelemetry _telemetry; 7 | 8 | internal DtCrowdScopedTimer(DtCrowdTelemetry telemetry, DtCrowdTimerLabel label) 9 | { 10 | _telemetry = telemetry; 11 | _label = label; 12 | 13 | _telemetry.Start(_label); 14 | } 15 | 16 | public void Dispose() 17 | { 18 | _telemetry.Stop(_label); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DtMoveRequestState.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.Crowd 2 | { 3 | public enum DtMoveRequestState 4 | { 5 | DT_CROWDAGENT_TARGET_NONE, 6 | DT_CROWDAGENT_TARGET_FAILED, 7 | DT_CROWDAGENT_TARGET_VALID, 8 | DT_CROWDAGENT_TARGET_REQUESTING, 9 | DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE, 10 | DT_CROWDAGENT_TARGET_WAITING_FOR_PATH, 11 | DT_CROWDAGENT_TARGET_VELOCITY, 12 | }; 13 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DtObstacleAvoidanceParams.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.Crowd 2 | { 3 | public class DtObstacleAvoidanceParams 4 | { 5 | public float velBias; 6 | public float weightDesVel; 7 | public float weightCurVel; 8 | public float weightSide; 9 | public float weightToi; 10 | public float horizTime; 11 | public int gridSize; // < grid 12 | public int adaptiveDivs; // < adaptive 13 | public int adaptiveRings; // < adaptive 14 | public int adaptiveDepth; // < adaptive 15 | 16 | public DtObstacleAvoidanceParams() 17 | { 18 | velBias = 0.4f; 19 | weightDesVel = 2.0f; 20 | weightCurVel = 0.75f; 21 | weightSide = 0.75f; 22 | weightToi = 2.5f; 23 | horizTime = 2.5f; 24 | gridSize = 33; 25 | adaptiveDivs = 7; 26 | adaptiveRings = 2; 27 | adaptiveDepth = 5; 28 | } 29 | 30 | public DtObstacleAvoidanceParams(DtObstacleAvoidanceParams option) 31 | { 32 | velBias = option.velBias; 33 | weightDesVel = option.weightDesVel; 34 | weightCurVel = option.weightCurVel; 35 | weightSide = option.weightSide; 36 | weightToi = option.weightToi; 37 | horizTime = option.horizTime; 38 | gridSize = option.gridSize; 39 | adaptiveDivs = option.adaptiveDivs; 40 | adaptiveRings = option.adaptiveRings; 41 | adaptiveDepth = option.adaptiveDepth; 42 | } 43 | }; 44 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DtObstacleCircle.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Detour.Crowd 4 | { 5 | /// < Max number of adaptive rings. 6 | public class DtObstacleCircle 7 | { 8 | /** Position of the obstacle */ 9 | public RcVec3f p = new RcVec3f(); 10 | 11 | /** Velocity of the obstacle */ 12 | public RcVec3f vel = new RcVec3f(); 13 | 14 | /** Velocity of the obstacle */ 15 | public RcVec3f dvel = new RcVec3f(); 16 | 17 | /** Radius of the obstacle */ 18 | public float rad; 19 | 20 | /** Use for side selection during sampling. */ 21 | public RcVec3f dp = new RcVec3f(); 22 | 23 | /** Use for side selection during sampling. */ 24 | public RcVec3f np = new RcVec3f(); 25 | } 26 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DtObstacleSegment.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Detour.Crowd 4 | { 5 | public class DtObstacleSegment 6 | { 7 | /** End points of the obstacle segment */ 8 | public RcVec3f p = new RcVec3f(); 9 | 10 | /** End points of the obstacle segment */ 11 | public RcVec3f q = new RcVec3f(); 12 | 13 | public bool touch; 14 | } 15 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DtPathQuery.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | using DotRecast.Core.Numerics; 22 | 23 | namespace DotRecast.Detour.Crowd 24 | { 25 | public class DtPathQuery 26 | { 27 | /// Path find start and end location. 28 | public RcVec3f startPos = new RcVec3f(); 29 | public RcVec3f endPos = new RcVec3f(); 30 | public long startRef; 31 | public long endRef; 32 | 33 | public readonly DtPathQueryResult result = new DtPathQueryResult(); 34 | public IDtQueryFilter filter; // < TODO: This is potentially dangerous! 35 | 36 | public DtNavMeshQuery navQuery; 37 | } 38 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DtPathQueryResult.cs: -------------------------------------------------------------------------------- 1 | /* 2 | recast4j copyright (c) 2021 Piotr Piastucki piotr@jtilia.org 3 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | */ 19 | 20 | namespace DotRecast.Detour.Crowd 21 | { 22 | public class DtPathQueryResult 23 | { 24 | public DtStatus status; 25 | public long[] path; 26 | public int npath; 27 | } 28 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Crowd/DtSegment.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Detour.Crowd 4 | { 5 | public class DtSegment 6 | { 7 | /** Segment start/end */ 8 | public RcVec3f[] s = new RcVec3f[2]; 9 | 10 | /** Distance for pruning. */ 11 | public float d; 12 | } 13 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Dynamic/Colliders/IDtCollider.cs: -------------------------------------------------------------------------------- 1 | /* 2 | recast4j copyright (c) 2021 Piotr Piastucki piotr@jtilia.org 3 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | */ 19 | 20 | using DotRecast.Core; 21 | using DotRecast.Recast; 22 | 23 | namespace DotRecast.Detour.Dynamic.Colliders 24 | { 25 | public interface IDtCollider 26 | { 27 | float[] Bounds(); 28 | void Rasterize(RcHeightfield hf, RcContext context); 29 | } 30 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Dynamic/DotRecast.Detour.Dynamic.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1;net8.0;net9.0 5 | DotRecast.Detour.Dynamic 6 | README.md 7 | ikpil 8 | DotRecast - a port of Recast Detour, Industry-standard navigation mesh toolset for .NET, C#, Unity3D, games, servers 9 | git 10 | https://github.com/ikpil/DotRecast 11 | https://github.com/ikpil/DotRecast 12 | game gamedev ai csharp server unity navigation game-development unity3d pathfinding pathfinder recast detour navmesh crowd-simulation recastnavigation 13 | https://github.com/ikpil/DotRecast/blob/main/CHANGELOG.md 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/DotRecast.Detour.Dynamic/IDtDaynmicTileJob.cs: -------------------------------------------------------------------------------- 1 | /* 2 | recast4j copyright (c) 2021 Piotr Piastucki piotr@jtilia.org 3 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | */ 19 | 20 | using System.Collections.Generic; 21 | 22 | namespace DotRecast.Detour.Dynamic 23 | { 24 | public interface IDtDaynmicTileJob 25 | { 26 | ICollection AffectedTiles(); 27 | 28 | void Process(DtDynamicTile tile); 29 | } 30 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/DotRecast.Detour.Extras.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1;net8.0;net9.0 5 | DotRecast.Detour.Extras 6 | README.md 7 | ikpil 8 | DotRecast - a port of Recast Detour, Industry-standard navigation mesh toolset for .NET, C#, Unity3D, games, servers 9 | git 10 | https://github.com/ikpil/DotRecast 11 | https://github.com/ikpil/DotRecast 12 | game gamedev ai csharp server unity navigation game-development unity3d pathfinding pathfinder recast detour navmesh crowd-simulation recastnavigation 13 | https://github.com/ikpil/DotRecast/blob/main/CHANGELOG.md 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/Jumplink/ClimbTrajectory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DotRecast.Core; 3 | using DotRecast.Core.Numerics; 4 | 5 | namespace DotRecast.Detour.Extras.Jumplink 6 | { 7 | public class ClimbTrajectory : ITrajectory 8 | { 9 | public RcVec3f Apply(RcVec3f start, RcVec3f end, float u) 10 | { 11 | return new RcVec3f() 12 | { 13 | X = RcMath.Lerp(start.X, end.X, Math.Min(2f * u, 1f)), 14 | Y = RcMath.Lerp(start.Y, end.Y, Math.Max(0f, 2f * u - 1f)), 15 | Z = RcMath.Lerp(start.Z, end.Z, Math.Min(2f * u, 1f)) 16 | }; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using DotRecast.Core.Numerics; 3 | 4 | namespace DotRecast.Detour.Extras.Jumplink 5 | { 6 | public class EdgeSampler 7 | { 8 | public readonly GroundSegment start = new GroundSegment(); 9 | public readonly List end = new List(); 10 | public readonly ITrajectory trajectory; 11 | 12 | public readonly RcVec3f ax = new RcVec3f(); 13 | public readonly RcVec3f ay = new RcVec3f(); 14 | public readonly RcVec3f az = new RcVec3f(); 15 | 16 | public EdgeSampler(JumpEdge edge, ITrajectory trajectory) 17 | { 18 | this.trajectory = trajectory; 19 | ax = RcVec3f.Subtract(edge.sq, edge.sp); 20 | ax = RcVec3f.Normalize(ax); 21 | 22 | az = new RcVec3f(ax.Z, 0, -ax.X); 23 | az = RcVec3f.Normalize(az); 24 | 25 | ay = new RcVec3f(0, 1, 0); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/Jumplink/GroundSample.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Detour.Extras.Jumplink 4 | { 5 | public class GroundSample 6 | { 7 | public RcVec3f p; 8 | public bool validTrajectory; 9 | public bool validHeight; 10 | } 11 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/Jumplink/GroundSegment.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Detour.Extras.Jumplink 4 | { 5 | public class GroundSegment 6 | { 7 | public RcVec3f p; 8 | public RcVec3f q; 9 | public GroundSample[] gsamples; 10 | public float height; 11 | } 12 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/Jumplink/IGroundSampler.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Recast; 2 | 3 | namespace DotRecast.Detour.Extras.Jumplink 4 | { 5 | public interface IGroundSampler 6 | { 7 | void Sample(JumpLinkBuilderConfig acfg, RcBuilderResult result, EdgeSampler es); 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/Jumplink/ITrajectory.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Detour.Extras.Jumplink 4 | { 5 | public interface ITrajectory 6 | { 7 | RcVec3f Apply(RcVec3f start, RcVec3f end, float u); 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/Jumplink/JumpEdge.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Detour.Extras.Jumplink 4 | { 5 | public class JumpEdge 6 | { 7 | public RcVec3f sp = new RcVec3f(); 8 | public RcVec3f sq = new RcVec3f(); 9 | } 10 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/Jumplink/JumpLink.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.Extras.Jumplink 2 | { 3 | public class JumpLink 4 | { 5 | public const int MAX_SPINE = 8; 6 | public readonly int nspine = MAX_SPINE; 7 | public readonly float[] spine0 = new float[MAX_SPINE * 3]; 8 | public readonly float[] spine1 = new float[MAX_SPINE * 3]; 9 | public GroundSample[] startSamples; 10 | public GroundSample[] endSamples; 11 | public GroundSegment start; 12 | public GroundSegment end; 13 | public ITrajectory trajectory; 14 | } 15 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilderConfig.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.Extras.Jumplink 2 | { 3 | public class JumpLinkBuilderConfig 4 | { 5 | public readonly float cellSize; 6 | public readonly float cellHeight; 7 | public readonly float agentClimb; 8 | public readonly float agentRadius; 9 | public readonly float groundTolerance; 10 | public readonly float agentHeight; 11 | public readonly float startDistance; 12 | public readonly float endDistance; 13 | public readonly float jumpHeight; 14 | public readonly float minHeight; 15 | public readonly float heightRange; 16 | 17 | public JumpLinkBuilderConfig(float cellSize, float cellHeight, float agentRadius, float agentHeight, 18 | float agentClimb, float groundTolerance, float startDistance, float endDistance, float minHeight, 19 | float maxHeight, float jumpHeight) 20 | { 21 | this.cellSize = cellSize; 22 | this.cellHeight = cellHeight; 23 | this.agentRadius = agentRadius; 24 | this.agentClimb = agentClimb; 25 | this.groundTolerance = groundTolerance; 26 | this.agentHeight = agentHeight; 27 | this.startDistance = startDistance; 28 | this.endDistance = endDistance; 29 | this.minHeight = minHeight; 30 | heightRange = maxHeight - minHeight; 31 | this.jumpHeight = jumpHeight; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/Jumplink/JumpLinkType.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.Extras.Jumplink 2 | { 3 | public class JumpLinkType 4 | { 5 | public const int EDGE_JUMP_BIT = 1 << 0; 6 | public const int EDGE_CLIMB_DOWN_BIT = 1 << 1; 7 | public const int EDGE_JUMP_OVER_BIT = 1 << 2; 8 | 9 | public static readonly JumpLinkType EDGE_JUMP = new JumpLinkType(EDGE_JUMP_BIT); 10 | public static readonly JumpLinkType EDGE_CLIMB_DOWN = new JumpLinkType(EDGE_CLIMB_DOWN_BIT); 11 | public static readonly JumpLinkType EDGE_JUMP_OVER = new JumpLinkType(EDGE_JUMP_OVER_BIT); 12 | 13 | public readonly int Bit; 14 | 15 | private JumpLinkType(int bit) 16 | { 17 | Bit = bit; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/Jumplink/JumpSegment.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.Extras.Jumplink 2 | { 3 | public class JumpSegment 4 | { 5 | public int groundSegment; 6 | public int startSample; 7 | public int samples; 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/Unity/Astar/BVTreeCreator.cs: -------------------------------------------------------------------------------- 1 | /* 2 | recast4j Copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 3 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | */ 19 | 20 | namespace DotRecast.Detour.Extras.Unity.Astar 21 | { 22 | public class BVTreeCreator 23 | { 24 | private readonly BVTreeBuilder builder = new BVTreeBuilder(); 25 | 26 | public void Build(GraphMeshData graphData) 27 | { 28 | foreach (DtMeshData d in graphData.tiles) 29 | { 30 | builder.Build(d); 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/Unity/Astar/NodeIndexReader.cs: -------------------------------------------------------------------------------- 1 | /* 2 | recast4j Copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 3 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | */ 19 | 20 | using System.IO.Compression; 21 | using DotRecast.Core; 22 | 23 | namespace DotRecast.Detour.Extras.Unity.Astar 24 | { 25 | class NodeIndexReader : ZipBinaryReader 26 | { 27 | public int[] Read(ZipArchive file, string filename) 28 | { 29 | RcByteBuffer buffer = ToByteBuffer(file, filename); 30 | int maxNodeIndex = buffer.GetInt(); 31 | int[] int2Node = new int[maxNodeIndex + 1]; 32 | int node = 0; 33 | while (buffer.Remaining() > 0) 34 | { 35 | int index = buffer.GetInt(); 36 | int2Node[index] = node++; 37 | } 38 | 39 | return int2Node; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/Unity/Astar/NodeLink2.cs: -------------------------------------------------------------------------------- 1 | /* 2 | recast4j Copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 3 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | */ 19 | 20 | using DotRecast.Core.Numerics; 21 | 22 | namespace DotRecast.Detour.Extras.Unity.Astar 23 | { 24 | public class NodeLink2 25 | { 26 | public readonly long linkID; 27 | public readonly int startNode; 28 | public readonly int endNode; 29 | public readonly RcVec3f clamped1; 30 | public readonly RcVec3f clamped2; 31 | 32 | public NodeLink2(long linkID, int startNode, int endNode, RcVec3f clamped1, RcVec3f clamped2) : base() 33 | { 34 | this.linkID = linkID; 35 | this.startNode = startNode; 36 | this.endNode = endNode; 37 | this.clamped1 = clamped1; 38 | this.clamped2 = clamped2; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.Extras/Unity/Astar/ZipBinaryReader.cs: -------------------------------------------------------------------------------- 1 | /* 2 | recast4j Copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 3 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | */ 19 | 20 | using System.IO; 21 | using System.IO.Compression; 22 | using DotRecast.Core; 23 | 24 | namespace DotRecast.Detour.Extras.Unity.Astar 25 | { 26 | public abstract class ZipBinaryReader 27 | { 28 | protected RcByteBuffer ToByteBuffer(ZipArchive file, string filename) 29 | { 30 | ZipArchiveEntry graphReferences = file.GetEntry(filename); 31 | using var entryStream = graphReferences.Open(); 32 | using var br = new BinaryReader(entryStream); 33 | RcByteBuffer buffer = RcIO.ToByteBuffer(br); 34 | buffer.Order(RcByteOrder.LITTLE_ENDIAN); 35 | return buffer; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DotRecast.Detour.TileCache.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1;net8.0;net9.0 5 | DotRecast.Detour.TileCache 6 | README.md 7 | ikpil 8 | DotRecast - a port of Recast Detour, Industry-standard navigation mesh toolset for .NET, C#, Unity3D, games, servers 9 | git 10 | https://github.com/ikpil/DotRecast 11 | https://github.com/ikpil/DotRecast 12 | game gamedev ai csharp server unity navigation game-development unity3d pathfinding pathfinder recast detour navmesh crowd-simulation recastnavigation 13 | https://github.com/ikpil/DotRecast/blob/main/CHANGELOG.md 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtCompressedTile.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Detour.TileCache 22 | { 23 | public class DtCompressedTile 24 | { 25 | public readonly int index; 26 | public int salt; // Counter describing modifications to the tile. 27 | public DtTileCacheLayerHeader header; 28 | 29 | public byte[] data; 30 | public int compressed; // offset of compressed data 31 | public int flags; 32 | public DtCompressedTile next; 33 | 34 | public DtCompressedTile(int index) 35 | { 36 | this.index = index; 37 | salt = 1; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtCompressedTileFlags.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.TileCache 2 | { 3 | /// Flags for addTile 4 | public class DtCompressedTileFlags 5 | { 6 | public const int DT_COMPRESSEDTILE_FREE_DATA = 0x01; //< Navmesh owns the tile memory and should free it. In C#, it is not used. 7 | } 8 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtLayerMonotoneRegion.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.TileCache 2 | { 3 | public class DtLayerMonotoneRegion 4 | { 5 | public const int DT_LAYER_MAX_NEIS = 16; 6 | 7 | public int area; 8 | public byte[] neis = new byte[DT_LAYER_MAX_NEIS]; 9 | public byte nneis; 10 | public byte regId; 11 | public byte areaId; 12 | }; 13 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtObstacleBox.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Detour.TileCache 4 | { 5 | public class DtObstacleBox 6 | { 7 | public RcVec3f bmin; 8 | public RcVec3f bmax; 9 | } 10 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtObstacleCylinder.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Detour.TileCache 4 | { 5 | public class DtObstacleCylinder 6 | { 7 | public RcVec3f pos; 8 | public float radius; 9 | public float height; 10 | } 11 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtObstacleOrientedBox.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Detour.TileCache 4 | { 5 | public class DtObstacleOrientedBox 6 | { 7 | public RcVec3f center; 8 | public RcVec3f extents; 9 | public readonly float[] rotAux = new float[2]; // { Cos(0.5f*angle)*Sin(-0.5f*angle); Cos(0.5f*angle)*Cos(0.5f*angle) - 0.5 } 10 | } 11 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtObstacleRequest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Detour.TileCache 22 | { 23 | public readonly struct DtObstacleRequest 24 | { 25 | public readonly DtObstacleRequestAction action; 26 | public readonly long refs; 27 | 28 | public DtObstacleRequest(DtObstacleRequestAction action, long refs) 29 | { 30 | this.action = action; 31 | this.refs = refs; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtObstacleRequestAction.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Detour.TileCache 22 | { 23 | public enum DtObstacleRequestAction 24 | { 25 | REQUEST_ADD, 26 | REQUEST_REMOVE 27 | } 28 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtObstacleState.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Detour.TileCache 22 | { 23 | public enum DtObstacleState 24 | { 25 | DT_OBSTACLE_EMPTY, 26 | DT_OBSTACLE_PROCESSING, 27 | DT_OBSTACLE_PROCESSED, 28 | DT_OBSTACLE_REMOVING 29 | } 30 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtTempContour.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace DotRecast.Detour.TileCache 4 | { 5 | public class DtTempContour 6 | { 7 | public List verts; 8 | public int nverts; 9 | public List poly; 10 | 11 | public DtTempContour() 12 | { 13 | verts = new List(); 14 | nverts = 0; 15 | poly = new List(); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtTileCacheAlloc.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.TileCache 2 | { 3 | // TODO: @ikpil, better pooling system 4 | public class DtTileCacheAlloc 5 | { 6 | public virtual T[] Alloc(long size) 7 | { 8 | return new T[size]; 9 | } 10 | 11 | public virtual void Free(T ptr) 12 | { 13 | // .. 14 | } 15 | 16 | public virtual void Reset() 17 | { 18 | // .. 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtTileCacheContour.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Detour.TileCache 22 | { 23 | public class DtTileCacheContour 24 | { 25 | public int nverts; 26 | public int[] verts; 27 | public byte reg; 28 | public byte area; 29 | } 30 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtTileCacheContourSet.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Detour.TileCache 22 | { 23 | public class DtTileCacheContourSet 24 | { 25 | public int nconts; 26 | public DtTileCacheContour[] conts; 27 | } 28 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtTileCacheLayer.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Detour.TileCache 22 | { 23 | public class DtTileCacheLayer 24 | { 25 | // This value specifies how many layers (or "floors") each navmesh tile is expected to have. 26 | public const int EXPECTED_LAYERS_PER_TILE = 4; 27 | 28 | public DtTileCacheLayerHeader header; 29 | public byte regCount; // < Region count. 30 | public byte[] heights; // unsigned char 31 | public byte[] areas; // unsigned char 32 | public byte[] cons; // unsigned char 33 | public byte[] regs; // unsigned char 34 | } 35 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtTileCacheLayerBuildResult.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace DotRecast.Detour.TileCache 4 | { 5 | public class DtTileCacheLayerBuildResult 6 | { 7 | public readonly int tx; 8 | public readonly int ty; 9 | public readonly List layers; 10 | 11 | public DtTileCacheLayerBuildResult(int tx, int ty, List layers) 12 | { 13 | this.tx = tx; 14 | this.ty = ty; 15 | this.layers = layers; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtTileCacheObstacleType.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.TileCache 2 | { 3 | public enum DtTileCacheObstacleType 4 | { 5 | DT_OBSTACLE_CYLINDER, 6 | DT_OBSTACLE_BOX, // AABB 7 | DT_OBSTACLE_ORIENTED_BOX // OBB 8 | }; 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtTileCacheParams.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | using DotRecast.Core.Numerics; 22 | 23 | namespace DotRecast.Detour.TileCache 24 | { 25 | public struct DtTileCacheParams 26 | { 27 | public RcVec3f orig; 28 | public float cs, ch; 29 | public int width, height; 30 | public float walkableHeight; 31 | public float walkableRadius; 32 | public float walkableClimb; 33 | public float maxSimplificationError; 34 | public int maxTiles; 35 | public int maxObstacles; 36 | } 37 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtTileCachePolyMesh.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Detour.TileCache 22 | { 23 | public class DtTileCachePolyMesh 24 | { 25 | public int nvp; 26 | public int nverts; // < Number of vertices. 27 | public int npolys; // < Number of polygons. 28 | public int[] verts; // < Vertices of the mesh, 3 elements per vertex. 29 | public int[] polys; // < Polygons of the mesh, nvp*2 elements per polygon. 30 | public int[] flags; // < Per polygon flags. 31 | public int[] areas; // < Area ID of polygons. 32 | 33 | public DtTileCachePolyMesh(int nvp) 34 | { 35 | this.nvp = nvp; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/DtTileCacheStorageParams.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | using DotRecast.Core; 22 | 23 | namespace DotRecast.Detour.TileCache 24 | { 25 | public readonly struct DtTileCacheStorageParams 26 | { 27 | public readonly RcByteOrder Order; 28 | public readonly bool Compatibility; 29 | 30 | public DtTileCacheStorageParams(RcByteOrder order, bool compatibility) 31 | { 32 | Order = order; 33 | Compatibility = compatibility; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/IDtTileCacheMeshProcess.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Detour.TileCache 22 | { 23 | public interface IDtTileCacheMeshProcess 24 | { 25 | void Process(DtNavMeshCreateParams option); 26 | } 27 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/Io/Compress/DtTileCacheCompressorFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using DotRecast.Core; 3 | 4 | namespace DotRecast.Detour.TileCache.Io.Compress 5 | { 6 | public class DtTileCacheCompressorFactory : IDtTileCacheCompressorFactory 7 | { 8 | public static readonly DtTileCacheCompressorFactory Shared = new DtTileCacheCompressorFactory(); 9 | 10 | private readonly Dictionary _compressors = new Dictionary(); 11 | 12 | public bool TryAdd(int type, IRcCompressor compressor) 13 | { 14 | if (0 == type) 15 | return false; 16 | 17 | _compressors[type] = compressor; 18 | return true; 19 | } 20 | 21 | public IRcCompressor Create(int compatibility) 22 | { 23 | // default 24 | if (0 == compatibility) 25 | { 26 | return DtTileCacheFastLzCompressor.Shared; 27 | } 28 | 29 | if (!_compressors.TryGetValue(compatibility, out var comp)) 30 | { 31 | return null; 32 | } 33 | 34 | return comp; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/Io/Compress/IDtTileCacheCompressorFactory.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | using DotRecast.Core; 22 | 23 | namespace DotRecast.Detour.TileCache.Io.Compress 24 | { 25 | public interface IDtTileCacheCompressorFactory 26 | { 27 | IRcCompressor Create(int compatibility); 28 | } 29 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour.TileCache/Io/DtTileCacheSetHeader.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Detour.TileCache.Io 22 | { 23 | public struct DtTileCacheSetHeader 24 | { 25 | public const int TILECACHESET_MAGIC = 'T' << 24 | 'S' << 16 | 'E' << 8 | 'T'; // 'TSET'; 26 | public const int TILECACHESET_VERSION = 1; 27 | public const int TILECACHESET_VERSION_RECAST4J = 0x8801; 28 | 29 | public int magic; 30 | public int version; 31 | public int numTiles; 32 | public DtNavMeshParams meshParams; 33 | public DtTileCacheParams cacheParams; 34 | } 35 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/BVItem.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Detour 4 | { 5 | public class BVItem 6 | { 7 | public RcVec3i bmin; 8 | public RcVec3i bmax; 9 | public int i; 10 | }; 11 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/BVItemXComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace DotRecast.Detour 4 | { 5 | public class BVItemXComparer : IComparer 6 | { 7 | public static readonly BVItemXComparer Shared = new BVItemXComparer(); 8 | 9 | private BVItemXComparer() 10 | { 11 | } 12 | 13 | public int Compare(BVItem a, BVItem b) 14 | { 15 | return a.bmin.X.CompareTo(b.bmin.X); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/BVItemYComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace DotRecast.Detour 4 | { 5 | public class BVItemYComparer : IComparer 6 | { 7 | public static readonly BVItemYComparer Shared = new BVItemYComparer(); 8 | 9 | private BVItemYComparer() 10 | { 11 | } 12 | 13 | public int Compare(BVItem a, BVItem b) 14 | { 15 | return a.bmin.Y.CompareTo(b.bmin.Y); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/BVItemZComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace DotRecast.Detour 4 | { 5 | public class BVItemZComparer : IComparer 6 | { 7 | public static readonly BVItemZComparer Shared = new BVItemZComparer(); 8 | 9 | private BVItemZComparer() 10 | { 11 | } 12 | 13 | public int Compare(BVItem a, BVItem b) 14 | { 15 | return a.bmin.Z.CompareTo(b.bmin.Z); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DetourBuilder.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Detour 22 | { 23 | public class DetourBuilder 24 | { 25 | public DtMeshData Build(DtNavMeshCreateParams option, int tileX, int tileY) 26 | { 27 | DtMeshData data = DtNavMeshBuilder.CreateNavMeshData(option); 28 | if (data != null) 29 | { 30 | data.header.x = tileX; 31 | data.header.y = tileY; 32 | } 33 | 34 | return data; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DotRecast.Detour.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1;net8.0;net9.0 5 | DotRecast.Detour 6 | README.md 7 | ikpil 8 | DotRecast - a port of Recast Detour, Industry-standard navigation mesh toolset for .NET, C#, Unity3D, games, servers 9 | git 10 | https://github.com/ikpil/DotRecast 11 | https://github.com/ikpil/DotRecast 12 | game gamedev ai csharp server unity navigation game-development unity3d pathfinding pathfinder recast detour navmesh crowd-simulation recastnavigation 13 | https://github.com/ikpil/DotRecast/blob/main/CHANGELOG.md 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtBVNode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | using DotRecast.Core.Numerics; 22 | 23 | namespace DotRecast.Detour 24 | { 25 | /// Bounding volume node. 26 | /// @note This structure is rarely if ever used by the end user. 27 | /// @see dtMeshTile 28 | public class DtBVNode 29 | { 30 | public RcVec3i bmin; //< Minimum bounds of the node's AABB. [(x, y, z)] 31 | public RcVec3i bmax; //< Maximum bounds of the node's AABB. [(x, y, z)] 32 | public int i; //< The node's index. (Negative for escape sequence.) 33 | } 34 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtCallbackPolyQuery.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DotRecast.Detour 4 | { 5 | public class DtCallbackPolyQuery : IDtPolyQuery 6 | { 7 | private readonly Action _callback; 8 | 9 | public DtCallbackPolyQuery(Action callback) 10 | { 11 | _callback = callback; 12 | } 13 | 14 | public void Process(DtMeshTile tile, ReadOnlySpan polys, ReadOnlySpan polyRefs, int count) 15 | { 16 | for (int i = 0; i < count; ++i) 17 | { 18 | int polyIdx = polys[i]; 19 | DtPoly poly = tile.data.polys[polyIdx]; 20 | _callback?.Invoke(tile, poly, polyRefs[i]); 21 | } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtCollectPolysQuery.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DotRecast.Core; 3 | 4 | namespace DotRecast.Detour 5 | { 6 | public class DtCollectPolysQuery : IDtPolyQuery 7 | { 8 | private long[] m_polys; 9 | private int m_maxPolys; 10 | private int m_numCollected; 11 | private bool m_overflow; 12 | 13 | public DtCollectPolysQuery(long[] polys, int maxPolys) 14 | { 15 | m_polys = polys; 16 | m_maxPolys = maxPolys; 17 | } 18 | 19 | public int NumCollected() 20 | { 21 | return m_numCollected; 22 | } 23 | 24 | public bool Overflowed() 25 | { 26 | return m_overflow; 27 | } 28 | 29 | public void Process(DtMeshTile tile, ReadOnlySpan polys, ReadOnlySpan polyRefs, int count) 30 | { 31 | int numLeft = m_maxPolys - m_numCollected; 32 | int toCopy = count; 33 | if (toCopy > numLeft) 34 | { 35 | m_overflow = true; 36 | toCopy = numLeft; 37 | } 38 | 39 | RcSpans.Copy(polyRefs, 0, m_polys, m_numCollected, toCopy); 40 | m_numCollected += toCopy; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtConnectPoly.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour 2 | { 3 | public readonly struct DtConnectPoly 4 | { 5 | public readonly long refs; 6 | public readonly float tmin; 7 | public readonly float tmax; 8 | 9 | public DtConnectPoly(long refs, float tmin, float tmax) 10 | { 11 | this.refs = refs; 12 | this.tmin = tmin; 13 | this.tmax = tmax; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtConvexConvexInFlag.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour 2 | { 3 | public enum DtConvexConvexInFlag 4 | { 5 | Pin, 6 | Qin, 7 | Unknown, 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtConvexConvexIntersection.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour 2 | { 3 | public enum DtConvexConvexIntersection 4 | { 5 | None, 6 | Single, 7 | Overlap, 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtDefaultQueryHeuristic.cs: -------------------------------------------------------------------------------- 1 | /* 2 | recast4j copyright (c) 2021 Piotr Piastucki piotr@jtilia.org 3 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | */ 19 | 20 | using DotRecast.Core.Numerics; 21 | 22 | 23 | namespace DotRecast.Detour 24 | { 25 | public class DtDefaultQueryHeuristic : IDtQueryHeuristic 26 | { 27 | public const float H_SCALE = 0.999f; // Search heuristic scale. 28 | public static readonly DtDefaultQueryHeuristic Default = new DtDefaultQueryHeuristic(H_SCALE); 29 | 30 | private readonly float scale; 31 | 32 | public DtDefaultQueryHeuristic(float scale) 33 | { 34 | this.scale = scale; 35 | } 36 | 37 | public float GetCost(RcVec3f neighbourPos, RcVec3f endPos) 38 | { 39 | return RcVec3f.Distance(neighbourPos, endPos) * scale; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtDetailTriEdgeFlags.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour 2 | { 3 | public static class DtDetailTriEdgeFlags 4 | { 5 | public const int DT_DETAIL_EDGE_BOUNDARY = 0x01; 6 | } 7 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtFindPathOption.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour 2 | { 3 | public readonly struct DtFindPathOption 4 | { 5 | public static readonly DtFindPathOption NoOption = new DtFindPathOption(DtDefaultQueryHeuristic.Default, 0, 0); 6 | 7 | public static readonly DtFindPathOption AnyAngle = new DtFindPathOption(DtDefaultQueryHeuristic.Default, DtFindPathOptions.DT_FINDPATH_ANY_ANGLE, float.MaxValue); 8 | public static readonly DtFindPathOption ZeroScale = new DtFindPathOption(new DtDefaultQueryHeuristic(0.0f), 0, 0); 9 | 10 | public readonly IDtQueryHeuristic heuristic; 11 | public readonly int options; 12 | public readonly float raycastLimit; 13 | 14 | public DtFindPathOption(IDtQueryHeuristic heuristic, int options, float raycastLimit) 15 | { 16 | this.heuristic = heuristic; 17 | this.options = options; 18 | this.raycastLimit = raycastLimit; 19 | } 20 | 21 | public DtFindPathOption(int options, float raycastLimit) 22 | : this(DtDefaultQueryHeuristic.Default, options, raycastLimit) 23 | { 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtFindPathOptions.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour 2 | { 3 | /// Options for dtNavMeshQuery::initSlicedFindPath and updateSlicedFindPath 4 | public static class DtFindPathOptions 5 | { 6 | public const int DT_FINDPATH_ANY_ANGLE = 0x02; //< use raycasts during pathfind to "shortcut" (raycast still consider costs) 7 | } 8 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtLink.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Detour 22 | { 23 | /// Defines a link between polygons. 24 | /// @note This structure is rarely if ever used by the end user. 25 | /// @see dtMeshTile 26 | public class DtLink 27 | { 28 | public long refs; //< Neighbour reference. (The neighbor that is linked to.) 29 | public int next; //< Index of the next link. 30 | public byte edge; //< Index of the polygon edge that owns this link. 31 | public byte side; //< If a boundary link, defines on which side the link is. 32 | public byte bmin; //< If a boundary link, defines the minimum sub-edge area. 33 | public byte bmax; //< If a boundary link, defines the maximum sub-edge area. 34 | } 35 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtNavMeshQueryMock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using DotRecast.Core.Numerics; 4 | 5 | namespace DotRecast.Detour 6 | { 7 | public class DtNavMeshQueryMock : DtNavMeshQuery 8 | { 9 | private readonly DtStraightPath[] _straightPath; 10 | private readonly DtStatus _status; 11 | 12 | public DtNavMeshQueryMock(DtStraightPath[] straightPath, DtStatus status) 13 | : base(null) 14 | { 15 | _straightPath = straightPath; 16 | _status = status; 17 | } 18 | 19 | public override DtStatus FindStraightPath(RcVec3f startPos, RcVec3f endPos, 20 | Span path, int pathSize, 21 | Span straightPath, out int straightPathCount, int maxStraightPath, 22 | int options) 23 | { 24 | straightPathCount = 0; 25 | for (int i = 0; i < _straightPath.Length && i < maxStraightPath; ++i) 26 | { 27 | straightPath[i] = _straightPath[i]; 28 | straightPathCount += 1; 29 | } 30 | 31 | return _status; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtNoOpDtPolygonByCircleConstraint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DotRecast.Core.Numerics; 3 | 4 | namespace DotRecast.Detour 5 | { 6 | public class DtNoOpDtPolygonByCircleConstraint : IDtPolygonByCircleConstraint 7 | { 8 | public static readonly DtNoOpDtPolygonByCircleConstraint Shared = new DtNoOpDtPolygonByCircleConstraint(); 9 | 10 | private DtNoOpDtPolygonByCircleConstraint() 11 | { 12 | } 13 | 14 | public bool Apply(Span polyVerts, RcVec3f circleCenter, float radius, Span constrainedVerts, out int constrainedVertCount) 15 | { 16 | polyVerts.CopyTo(constrainedVerts); 17 | constrainedVertCount = polyVerts.Length; 18 | return true; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtNodeFlags.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour 2 | { 3 | public static class DtNodeFlags 4 | { 5 | public const int DT_NODE_OPEN = 0x01; 6 | public const int DT_NODE_CLOSED = 0x02; 7 | public const int DT_NODE_PARENT_DETACHED = 0x04; // parent of the node is not adjacent. Found using raycast. 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtPolyPoint.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Detour 4 | { 5 | public readonly struct DtPolyPoint 6 | { 7 | public readonly long refs; 8 | public readonly RcVec3f pt; 9 | 10 | public DtPolyPoint(long polyRefs, RcVec3f polyPt) 11 | { 12 | refs = polyRefs; 13 | pt = polyPt; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtPolyTypes.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour 2 | { 3 | /// Flags representing the type of a navigation mesh polygon. 4 | public static class DtPolyTypes 5 | { 6 | public const int DT_POLYTYPE_GROUND = 0; // The polygon is a standard convex polygon that is part of the surface of the mesh. 7 | public const int DT_POLYTYPE_OFFMESH_CONNECTION = 1; // The polygon is an off-mesh connection consisting of two vertices. 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtQueryData.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | using DotRecast.Core.Numerics; 22 | 23 | namespace DotRecast.Detour 24 | { 25 | public struct DtQueryData 26 | { 27 | public DtStatus status; 28 | public DtNode lastBestNode; 29 | public float lastBestNodeCost; 30 | public long startRef; 31 | public long endRef; 32 | public RcVec3f startPos; 33 | public RcVec3f endPos; 34 | public IDtQueryFilter filter; 35 | public int options; 36 | public float raycastLimitSqr; 37 | } 38 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtQueryEmptyFilter.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Detour 4 | { 5 | public class DtQueryEmptyFilter : IDtQueryFilter 6 | { 7 | public static readonly DtQueryEmptyFilter Shared = new DtQueryEmptyFilter(); 8 | 9 | private DtQueryEmptyFilter() 10 | { 11 | } 12 | 13 | public bool PassFilter(long refs, DtMeshTile tile, DtPoly poly) 14 | { 15 | return false; 16 | } 17 | 18 | public float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, DtMeshTile prevTile, DtPoly prevPoly, long curRef, 19 | DtMeshTile curTile, DtPoly curPoly, long nextRef, DtMeshTile nextTile, DtPoly nextPoly) 20 | { 21 | return 0; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtQueryNoOpFilter.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Detour 4 | { 5 | public class DtQueryNoOpFilter : IDtQueryFilter 6 | { 7 | public static readonly DtQueryNoOpFilter Shared = new DtQueryNoOpFilter(); 8 | 9 | private DtQueryNoOpFilter() 10 | { 11 | } 12 | 13 | public bool PassFilter(long refs, DtMeshTile tile, DtPoly poly) 14 | { 15 | return true; 16 | } 17 | 18 | public float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, DtMeshTile prevTile, DtPoly prevPoly, long curRef, 19 | DtMeshTile curTile, DtPoly curPoly, long nextRef, DtMeshTile nextTile, DtPoly nextPoly) 20 | { 21 | return 0; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtRaycastOptions.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour 2 | { 3 | /// Options for dtNavMeshQuery::raycast 4 | public static class DtRaycastOptions 5 | { 6 | public const int DT_RAYCAST_USE_COSTS = 0x01; //< Raycast should calculate movement cost along the ray and fill RaycastHit::cost 7 | } 8 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtSegInterval.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour 2 | { 3 | public readonly struct DtSegInterval 4 | { 5 | public readonly long refs; 6 | public readonly int tmin; 7 | public readonly int tmax; 8 | 9 | public DtSegInterval(long refs, int tmin, int tmax) 10 | { 11 | this.refs = refs; 12 | this.tmin = tmin; 13 | this.tmax = tmax; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtStraightPathFlags.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour 2 | { 3 | /// Vertex flags returned by dtNavMeshQuery::findStraightPath. 4 | public static class DtStraightPathFlags 5 | { 6 | public const byte DT_STRAIGHTPATH_START = 0x01; //< The vertex is the start position in the path. 7 | public const byte DT_STRAIGHTPATH_END = 0x02; //< The vertex is the end position in the path. 8 | public const byte DT_STRAIGHTPATH_OFFMESH_CONNECTION = 0x04; //< The vertex is the start of an off-mesh connection. 9 | } 10 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtStraightPathOption.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Collections; 2 | 3 | namespace DotRecast.Detour 4 | { 5 | public class DtStraightPathOption 6 | { 7 | public static readonly DtStraightPathOption None = new DtStraightPathOption(0, "None"); 8 | public static readonly DtStraightPathOption AreaCrossings = new DtStraightPathOption(DtStraightPathOptions.DT_STRAIGHTPATH_AREA_CROSSINGS, "Area"); 9 | public static readonly DtStraightPathOption AllCrossings = new DtStraightPathOption(DtStraightPathOptions.DT_STRAIGHTPATH_ALL_CROSSINGS, "All"); 10 | 11 | public static readonly RcImmutableArray Values = RcImmutableArray.Create( 12 | None, AreaCrossings, AllCrossings 13 | ); 14 | 15 | public readonly int Value; 16 | public readonly string Label; 17 | 18 | private DtStraightPathOption(int value, string label) 19 | { 20 | Value = value; 21 | Label = label; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/DtStraightPathOptions.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour 2 | { 3 | /// Options for dtNavMeshQuery::findStraightPath. 4 | public static class DtStraightPathOptions 5 | { 6 | public const int DT_STRAIGHTPATH_AREA_CROSSINGS = 0x01; //< Add a vertex at every polygon edge crossing where area changes. 7 | public const int DT_STRAIGHTPATH_ALL_CROSSINGS = 0x02; //< Add a vertex at every polygon edge crossing. 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/IDtPolyQuery.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DotRecast.Detour 4 | { 5 | /// Provides custom polygon query behavior. 6 | /// Used by dtNavMeshQuery::queryPolygons. 7 | /// @ingroup detour 8 | public interface IDtPolyQuery 9 | { 10 | /// Called for each batch of unique polygons touched by the search area in dtNavMeshQuery::queryPolygons. 11 | /// This can be called multiple times for a single query. 12 | void Process(DtMeshTile tile, ReadOnlySpan polys, ReadOnlySpan polyRefs, int count); 13 | } 14 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/IDtPolygonByCircleConstraint.cs: -------------------------------------------------------------------------------- 1 | /* 2 | recast4j copyright (c) 2021 Piotr Piastucki piotr@jtilia.org 3 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | */ 19 | 20 | using System; 21 | using DotRecast.Core.Numerics; 22 | 23 | namespace DotRecast.Detour 24 | { 25 | public interface IDtPolygonByCircleConstraint 26 | { 27 | bool Apply(Span polyVerts, RcVec3f circleCenter, float radius, Span constrainedVerts, out int constrainedVertCount); 28 | } 29 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/IDtQueryFilter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | using DotRecast.Core.Numerics; 22 | 23 | namespace DotRecast.Detour 24 | { 25 | public interface IDtQueryFilter 26 | { 27 | bool PassFilter(long refs, DtMeshTile tile, DtPoly poly); 28 | 29 | float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, DtMeshTile prevTile, DtPoly prevPoly, long curRef, DtMeshTile curTile, 30 | DtPoly curPoly, long nextRef, DtMeshTile nextTile, DtPoly nextPoly); 31 | } 32 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/IDtQueryHeuristic.cs: -------------------------------------------------------------------------------- 1 | /* 2 | recast4j copyright (c) 2021 Piotr Piastucki piotr@jtilia.org 3 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | */ 19 | 20 | using DotRecast.Core.Numerics; 21 | 22 | namespace DotRecast.Detour 23 | { 24 | public interface IDtQueryHeuristic 25 | { 26 | float GetCost(RcVec3f neighbourPos, RcVec3f endPos); 27 | } 28 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/Io/DtNavMeshParamWriter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using DotRecast.Core; 3 | 4 | namespace DotRecast.Detour.Io 5 | { 6 | public class DtNavMeshParamWriter 7 | { 8 | public void Write(BinaryWriter stream, DtNavMeshParams option, RcByteOrder order) 9 | { 10 | RcIO.Write(stream, option.orig.X, order); 11 | RcIO.Write(stream, option.orig.Y, order); 12 | RcIO.Write(stream, option.orig.Z, order); 13 | RcIO.Write(stream, option.tileWidth, order); 14 | RcIO.Write(stream, option.tileHeight, order); 15 | RcIO.Write(stream, option.maxTiles, order); 16 | RcIO.Write(stream, option.maxPolys, order); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/Io/DtNavMeshParamsReader.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core; 2 | 3 | namespace DotRecast.Detour.Io 4 | { 5 | public class DtNavMeshParamsReader 6 | { 7 | public DtNavMeshParams Read(RcByteBuffer bb) 8 | { 9 | DtNavMeshParams option = new DtNavMeshParams(); 10 | option.orig.X = bb.GetFloat(); 11 | option.orig.Y = bb.GetFloat(); 12 | option.orig.Z = bb.GetFloat(); 13 | option.tileWidth = bb.GetFloat(); 14 | option.tileHeight = bb.GetFloat(); 15 | option.maxTiles = bb.GetInt(); 16 | option.maxPolys = bb.GetInt(); 17 | return option; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/Io/NavMeshSetHeader.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Recast4J Copyright (c) 2015-2018 Piotr Piastucki piotr@jtilia.org 3 | 4 | This software is provided 'as-is', without any express or implied 5 | warranty. In no event will the authors be held liable for any damages 6 | arising from the use of this software. 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 1. The origin of this software must not be misrepresented; you must not 11 | claim that you wrote the original software. If you use this software 12 | in a product, an acknowledgment in the product documentation would be 13 | appreciated but is not required. 14 | 2. Altered source versions must be plainly marked as such, and must not be 15 | misrepresented as being the original software. 16 | 3. This notice may not be removed or altered from any source distribution. 17 | */ 18 | 19 | namespace DotRecast.Detour.Io 20 | { 21 | public struct NavMeshSetHeader 22 | { 23 | public const int NAVMESHSET_MAGIC = 'M' << 24 | 'S' << 16 | 'E' << 8 | 'T'; // 'MSET'; 24 | public const int NAVMESHSET_VERSION = 1; 25 | public const int NAVMESHSET_VERSION_RECAST4J_1 = 0x8801; 26 | public const int NAVMESHSET_VERSION_RECAST4J = 0x8802; 27 | 28 | public int magic; 29 | public int version; 30 | public int numTiles; 31 | public DtNavMeshParams option; 32 | public int maxVertsPerPoly; 33 | } 34 | } -------------------------------------------------------------------------------- /src/DotRecast.Detour/Io/NavMeshTileHeader.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.Io 2 | { 3 | public struct NavMeshTileHeader 4 | { 5 | public long tileRef; 6 | public int dataSize; 7 | } 8 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/Draw/ArrayBuffer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DotRecast.Core; 3 | 4 | namespace DotRecast.Recast.Demo.Draw; 5 | 6 | public class ArrayBuffer 7 | { 8 | private int _size; 9 | private T[] _items; 10 | public int Count => _size; 11 | 12 | public ArrayBuffer() : this(512) { } 13 | 14 | public ArrayBuffer(int capacity) 15 | { 16 | if (capacity <= 0) 17 | throw new ArgumentOutOfRangeException(); 18 | 19 | _size = 0; 20 | _items = new T[capacity]; 21 | } 22 | 23 | public void Add(T item) 24 | { 25 | if (_items.Length <= _size) 26 | { 27 | var temp = new T[(int)(_size * 1.5)]; 28 | RcArrays.Copy(_items, 0, temp, 0, _items.Length); 29 | _items = temp; 30 | } 31 | 32 | _items[_size++] = item; 33 | } 34 | 35 | public void Clear() 36 | { 37 | _size = 0; 38 | } 39 | 40 | public Span AsArray() 41 | { 42 | return _items.AsSpan(0, _size); 43 | } 44 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/Draw/DebugDrawPrimitives.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Recast.Demo.Draw; 22 | 23 | public enum DebugDrawPrimitives 24 | { 25 | POINTS, 26 | LINES, 27 | TRIS, 28 | QUADS 29 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/Draw/IOpenGLDraw.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Recast.Demo.Draw; 4 | 5 | public interface IOpenGLDraw 6 | { 7 | void Init(); 8 | 9 | void Clear(); 10 | 11 | void Begin(DebugDrawPrimitives prim, float size); 12 | 13 | void End(); 14 | 15 | void Vertex(float x, float y, float z, int color); 16 | 17 | void Vertex(float[] pos, int color); 18 | void Vertex(RcVec3f pos, int color); 19 | 20 | void Vertex(RcVec3f pos, int color, RcVec2f uv); 21 | 22 | void Vertex(float x, float y, float z, int color, float u, float v); 23 | 24 | void Fog(bool state); 25 | 26 | void DepthMask(bool state); 27 | 28 | void Texture(GLCheckerTexture g_tex, bool state); 29 | 30 | void ProjectionMatrix(ref RcMatrix4x4f projectionMatrix); 31 | 32 | void ViewMatrix(ref RcMatrix4x4f viewMatrix); 33 | 34 | void Fog(float start, float end); 35 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/DtVoxelTileLZ4DemoCompressor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DotRecast.Core; 3 | using K4os.Compression.LZ4; 4 | 5 | namespace DotRecast.Recast.Demo; 6 | 7 | public class DtVoxelTileLZ4DemoCompressor : IRcCompressor 8 | { 9 | public static readonly DtVoxelTileLZ4DemoCompressor Shared = new(); 10 | 11 | private DtVoxelTileLZ4DemoCompressor() 12 | { 13 | } 14 | 15 | public byte[] Decompress(byte[] data) 16 | { 17 | int compressedSize = RcByteUtils.GetIntBE(data, 0); 18 | return LZ4Pickler.Unpickle(data.AsSpan(4, compressedSize)); 19 | } 20 | 21 | public byte[] Decompress(byte[] buf, int offset, int len, int outputlen) 22 | { 23 | return LZ4Pickler.Unpickle(buf, offset, len); 24 | } 25 | 26 | public byte[] Compress(byte[] data) 27 | { 28 | byte[] compressed = LZ4Pickler.Pickle(data, LZ4Level.L12_MAX); 29 | byte[] result = new byte[4 + compressed.Length]; 30 | RcByteUtils.PutInt(compressed.Length, result, 0, RcByteOrder.BIG_ENDIAN); 31 | RcArrays.Copy(compressed, 0, result, 4, compressed.Length); 32 | return result; 33 | } 34 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/KeyModState.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Demo; 2 | 3 | public static class KeyModState 4 | { 5 | public const int None = 0; 6 | public const int Shift = 1; 7 | public const int Control = 2; 8 | public const int Alt = 4; 9 | public const int Super = 8; 10 | public const int CapsLock = 16; 11 | public const int NumLock = 32; 12 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/Logging/Sinks/LogMessageBrokerSink.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using Serilog.Core; 4 | using Serilog.Events; 5 | using Serilog.Formatting; 6 | 7 | namespace DotRecast.Recast.Demo.Logging.Sinks; 8 | 9 | public class LogMessageBrokerSink : ILogEventSink 10 | { 11 | public static event Action OnEmitted; 12 | 13 | private readonly ITextFormatter _formatter; 14 | 15 | public LogMessageBrokerSink(ITextFormatter formatter) 16 | { 17 | _formatter = formatter; 18 | } 19 | 20 | public void Emit(LogEvent logEvent) 21 | { 22 | using var writer = new StringWriter(); 23 | _formatter.Format(logEvent, writer); 24 | OnEmitted?.Invoke((int)logEvent.Level, writer.ToString()); 25 | } 26 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/Logging/Sinks/SerilogSinkExtensions.cs: -------------------------------------------------------------------------------- 1 | using Serilog; 2 | using Serilog.Configuration; 3 | using Serilog.Events; 4 | using Serilog.Formatting.Display; 5 | 6 | namespace DotRecast.Recast.Demo.Logging.Sinks; 7 | 8 | public static class SerilogSinkExtensions 9 | { 10 | public static LoggerConfiguration LogMessageBroker( 11 | this LoggerSinkConfiguration sinkConfiguration, 12 | LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose, 13 | string outputTemplate = "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}") 14 | { 15 | var formatter = new MessageTemplateTextFormatter(outputTemplate); 16 | return sinkConfiguration.Sink(new LogMessageBrokerSink(formatter)); 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/Messages/GeomLoadBeganEvent.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Demo.Messages; 2 | 3 | public class GeomLoadBeganEvent : IRecastDemoMessage 4 | { 5 | public string FilePath { get; init; } 6 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/Messages/IRecastDemoChannel.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Demo.Messages; 2 | 3 | public interface IRecastDemoChannel 4 | { 5 | void SendMessage(IRecastDemoMessage message); 6 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/Messages/IRecastDemoMessage.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Demo.Messages; 2 | 3 | public class IRecastDemoMessage 4 | { 5 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/Messages/NavMeshBuildBeganEvent.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Demo.Messages; 2 | 3 | public class NavMeshBuildBeganEvent : IRecastDemoMessage 4 | { 5 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/Messages/NavMeshLoadBeganEvent.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Demo.Messages; 2 | 3 | public class NavMeshLoadBeganEvent : IRecastDemoMessage 4 | { 5 | public string FilePath { get; init; } 6 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/Messages/NavMeshSaveBeganEvent.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Demo.Messages; 2 | 3 | public class NavMeshSaveBeganEvent : IRecastDemoMessage 4 | { 5 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/Messages/RaycastEvent.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Recast.Demo.Messages; 4 | 5 | public class RaycastEvent : IRecastDemoMessage 6 | { 7 | public RcVec3f Start { get; init; } 8 | public RcVec3f End { get; init; } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/Tools/ISampleTool.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | using DotRecast.Core.Numerics; 22 | using DotRecast.Recast.Demo.Draw; 23 | using DotRecast.Recast.Toolset; 24 | 25 | namespace DotRecast.Recast.Demo.Tools; 26 | 27 | public interface ISampleTool 28 | { 29 | void SetSample(DemoSample sample); 30 | void OnSampleChanged(); 31 | 32 | IRcToolable GetTool(); 33 | void Layout(); 34 | void HandleClick(RcVec3f s, RcVec3f p, bool shift); 35 | void HandleRender(NavMeshRenderer renderer); 36 | void HandleUpdate(float dt); 37 | void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift); 38 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/UI/IRcView.cs: -------------------------------------------------------------------------------- 1 | /* 2 | recast4j Copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 3 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | */ 19 | 20 | namespace DotRecast.Recast.Demo.UI; 21 | 22 | public interface IRcView 23 | { 24 | void Bind(RcCanvas canvas); 25 | void Update(double dt); 26 | void Draw(double dt); 27 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/UI/RcCanvasLayout.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Demo.UI; 2 | 3 | public class RcCanvasLayout 4 | { 5 | public int PropertiesMenuWidth = 330; 6 | public int ToolMenuWidth = 310; 7 | public int LogViewHeight = 270; 8 | 9 | public float WidthPadding = 10.0f; 10 | public float TopPadding = 30.0f; 11 | public float BottomPadding = 40.0f; 12 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/UI/RcMenuView.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core; 2 | using ImGuiNET; 3 | 4 | namespace DotRecast.Recast.Demo.UI; 5 | 6 | public class RcMenuView : IRcView 7 | { 8 | private RcCanvas _canvas; 9 | 10 | public void Bind(RcCanvas canvas) 11 | { 12 | _canvas = canvas; 13 | } 14 | 15 | public void Update(double dt) 16 | { 17 | //throw new System.NotImplementedException(); 18 | } 19 | 20 | public void Draw(double dt) 21 | { 22 | if (ImGui.BeginMainMenuBar()) 23 | { 24 | if (ImGui.BeginMenu("Help")) 25 | { 26 | if (ImGui.MenuItem("Repository")) 27 | { 28 | RcProcess.OpenUrl("https://github.com/ikpil/DotRecast"); 29 | } 30 | 31 | if (ImGui.MenuItem("Nuget")) 32 | { 33 | RcProcess.OpenUrl("https://www.nuget.org/packages/DotRecast.Core/"); 34 | } 35 | 36 | ImGui.Separator(); 37 | if (ImGui.MenuItem("Issue Tracker")) 38 | { 39 | RcProcess.OpenUrl("https://github.com/ikpil/DotRecast/issues"); 40 | } 41 | 42 | if (ImGui.MenuItem("Release Notes")) 43 | { 44 | RcProcess.OpenUrl("https://github.com/ikpil/DotRecast/blob/main/CHANGELOG.md"); 45 | } 46 | 47 | ImGui.EndMenu(); 48 | } 49 | 50 | ImGui.EndMainMenuBar(); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Demo/UI/ViewModels/LogMessageItem.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Demo.UI.ViewModels; 2 | 3 | public class LogMessageItem 4 | { 5 | public int Level { get; init; } 6 | public string Message { get; init; } 7 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/Builder/NavMeshBuildResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using DotRecast.Detour; 4 | 5 | namespace DotRecast.Recast.Toolset.Builder 6 | { 7 | public class NavMeshBuildResult 8 | { 9 | public readonly bool Success; 10 | public readonly RcConfig Cfg; 11 | public readonly IList RecastBuilderResults; 12 | public readonly DtNavMesh NavMesh; 13 | 14 | public NavMeshBuildResult() 15 | { 16 | Success = false; 17 | RecastBuilderResults = Array.Empty(); 18 | NavMesh = null; 19 | } 20 | 21 | // for solo 22 | public NavMeshBuildResult(RcConfig cfg, IList recastBuilderResults, DtNavMesh navMesh) 23 | { 24 | Success = true; 25 | Cfg = cfg; 26 | RecastBuilderResults = recastBuilderResults; 27 | NavMesh = navMesh; 28 | } 29 | 30 | // for tiles 31 | public NavMeshBuildResult(RcConfig cfg, IList recastBuilderResults) 32 | { 33 | Success = true; 34 | Cfg = cfg; 35 | RecastBuilderResults = recastBuilderResults; 36 | NavMesh = null; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/DotRecast.Recast.Toolset.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1;net8.0;net9.0 5 | DotRecast.Recast.Toolset 6 | README.md 7 | ikpil 8 | DotRecast - a port of Recast Detour, Industry-standard navigation mesh toolset for .NET, C#, Unity3D, games, servers 9 | git 10 | https://github.com/ikpil/DotRecast 11 | https://github.com/ikpil/DotRecast 12 | game gamedev ai csharp server unity navigation game-development unity3d pathfinding pathfinder recast detour navmesh crowd-simulation recastnavigation 13 | https://github.com/ikpil/DotRecast/blob/main/CHANGELOG.md 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/Gizmos/IRcGizmoMeshFilter.cs: -------------------------------------------------------------------------------- 1 | //using DotRecast.Recast.Demo.Draw; 2 | 3 | namespace DotRecast.Recast.Toolset.Gizmos 4 | { 5 | public interface IRcGizmoMeshFilter 6 | { 7 | //void Render(RecastDebugDraw debugDraw); 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/Gizmos/RcCompositeGizmo.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Toolset.Gizmos 2 | { 3 | public class RcCompositeGizmo : IRcGizmoMeshFilter 4 | { 5 | public readonly IRcGizmoMeshFilter[] gizmoMeshes; 6 | 7 | public RcCompositeGizmo(params IRcGizmoMeshFilter[] gizmoMeshes) 8 | { 9 | this.gizmoMeshes = gizmoMeshes; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/Gizmos/RcGizmo.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Detour.Dynamic.Colliders; 2 | 3 | namespace DotRecast.Recast.Toolset.Gizmos 4 | { 5 | public class RcGizmo 6 | { 7 | public readonly IRcGizmoMeshFilter Gizmo; 8 | public readonly IDtCollider Collider; 9 | 10 | public RcGizmo(IDtCollider collider, IRcGizmoMeshFilter gizmo) 11 | { 12 | Collider = collider; 13 | Gizmo = gizmo; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/Gizmos/RcGizmoFactory.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Recast.Toolset.Gizmos 4 | { 5 | public static class RcGizmoFactory 6 | { 7 | public static RcBoxGizmo Box(RcVec3f center, RcVec3f[] halfEdges) 8 | { 9 | return new RcBoxGizmo(center, halfEdges); 10 | } 11 | 12 | public static RcSphereGizmo Sphere(RcVec3f center, float radius) 13 | { 14 | return new RcSphereGizmo(center, radius); 15 | } 16 | 17 | public static RcCapsuleGizmo Capsule(RcVec3f start, RcVec3f end, float radius) 18 | { 19 | return new RcCapsuleGizmo(start, end, radius); 20 | } 21 | 22 | public static RcCylinderGizmo Cylinder(RcVec3f start, RcVec3f end, float radius) 23 | { 24 | return new RcCylinderGizmo(start, end, radius); 25 | } 26 | 27 | public static RcTrimeshGizmo Trimesh(float[] verts, int[] faces) 28 | { 29 | return new RcTrimeshGizmo(verts, faces); 30 | } 31 | 32 | public static RcCompositeGizmo Composite(params IRcGizmoMeshFilter[] gizmos) 33 | { 34 | return new RcCompositeGizmo(gizmos); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/Gizmos/RcSphereGizmo.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | using static DotRecast.Recast.Toolset.Gizmos.RcGizmoHelper; 3 | 4 | namespace DotRecast.Recast.Toolset.Gizmos 5 | { 6 | public class RcSphereGizmo : IRcGizmoMeshFilter 7 | { 8 | public readonly float[] vertices; 9 | public readonly int[] triangles; 10 | public readonly float radius; 11 | public readonly RcVec3f center; 12 | 13 | public RcSphereGizmo(RcVec3f center, float radius) 14 | { 15 | this.center = center; 16 | this.radius = radius; 17 | vertices = GenerateSphericalVertices(); 18 | triangles = GenerateSphericalTriangles(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/Gizmos/RcTrimeshGizmo.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Toolset.Gizmos 2 | { 3 | public class RcTrimeshGizmo : IRcGizmoMeshFilter 4 | { 5 | public readonly float[] vertices; 6 | public readonly int[] triangles; 7 | 8 | public RcTrimeshGizmo(float[] vertices, int[] triangles) 9 | { 10 | this.vertices = vertices; 11 | this.triangles = triangles; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/IRcToolable.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Toolset 2 | { 3 | public interface IRcToolable 4 | { 5 | string GetName(); 6 | } 7 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/RcNavMeshBuildSettings.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Toolset 2 | { 3 | public class RcNavMeshBuildSettings 4 | { 5 | public float cellSize = 0.3f; 6 | public float cellHeight = 0.2f; 7 | 8 | public float agentHeight = 2.0f; 9 | public float agentRadius = 0.6f; 10 | public float agentMaxClimb = 0.9f; 11 | public float agentMaxSlope = 45f; 12 | 13 | public float agentMaxAcceleration = 8.0f; 14 | public float agentMaxSpeed = 3.5f; 15 | 16 | public int minRegionSize = 8; 17 | public int mergedRegionSize = 20; 18 | 19 | public int partitioning = RcPartitionType.WATERSHED.Value; 20 | 21 | public bool filterLowHangingObstacles = true; 22 | public bool filterLedgeSpans = true; 23 | public bool filterWalkableLowHeightSpans = true; 24 | 25 | public float edgeMaxLen = 12f; 26 | public float edgeMaxError = 1.3f; 27 | public int vertsPerPoly = 6; 28 | 29 | public float detailSampleDist = 6f; 30 | public float detailSampleMaxError = 1f; 31 | 32 | public bool tiled = false; 33 | public int tileSize = 32; 34 | 35 | public bool keepInterResults = true; // full memory 36 | public bool buildAll = true; 37 | } 38 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentData.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Recast.Toolset.Tools 4 | { 5 | public class RcCrowdAgentData 6 | { 7 | public readonly RcCrowdAgentType type; 8 | public readonly RcVec3f home = new RcVec3f(); 9 | 10 | public RcCrowdAgentData(RcCrowdAgentType type, RcVec3f home) 11 | { 12 | this.type = type; 13 | this.home = home; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentProfilingToolConfig.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Toolset.Tools 2 | { 3 | public class RcCrowdAgentProfilingToolConfig 4 | { 5 | public int expandSimOptions = 1; 6 | public int expandCrowdOptions = 1; 7 | public int agents = 1000; 8 | public int randomSeed = 270; 9 | public int numberOfZones = 4; 10 | public float zoneRadius = 20f; 11 | public float percentMobs = 80f; 12 | public float percentTravellers = 15f; 13 | public int pathQueueSize = 32; 14 | public int maxIterations = 300; 15 | 16 | public bool showAgents = true; 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentTrail.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Toolset.Tools 2 | { 3 | public class RcCrowdAgentTrail 4 | { 5 | public const int AGENT_MAX_TRAIL = 64; 6 | public float[] trail = new float[AGENT_MAX_TRAIL * 3]; 7 | public int htrail; 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentType.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Toolset.Tools 2 | { 3 | public enum RcCrowdAgentType 4 | { 5 | VILLAGER, 6 | TRAVELLER, 7 | MOB, 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/Tools/RcCrowdToolMode.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Collections; 2 | 3 | namespace DotRecast.Recast.Toolset.Tools 4 | { 5 | public class RcCrowdToolMode 6 | { 7 | public static readonly RcCrowdToolMode CREATE = new RcCrowdToolMode(0, "Create Agents"); 8 | public static readonly RcCrowdToolMode MOVE_TARGET = new RcCrowdToolMode(1, "Move Target"); 9 | public static readonly RcCrowdToolMode SELECT = new RcCrowdToolMode(2, "Select Agent"); 10 | public static readonly RcCrowdToolMode TOGGLE_POLYS = new RcCrowdToolMode(3, "Toggle Polys"); 11 | 12 | public static readonly RcImmutableArray Values = RcImmutableArray.Create( 13 | CREATE, 14 | MOVE_TARGET, 15 | SELECT, 16 | TOGGLE_POLYS 17 | ); 18 | 19 | public readonly int Idx; 20 | public readonly string Label; 21 | 22 | private RcCrowdToolMode(int idx, string label) 23 | { 24 | Idx = idx; 25 | Label = label; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/Tools/RcDynamicColliderShape.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast.Toolset.Tools 2 | { 3 | public enum RcDynamicColliderShape 4 | { 5 | SPHERE, 6 | CAPSULE, 7 | BOX, 8 | CYLINDER, 9 | COMPOSITE, 10 | CONVEX, 11 | TRIMESH_BRIDGE, 12 | TRIMESH_HOUSE 13 | } 14 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateToolMode.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Collections; 2 | 3 | namespace DotRecast.Recast.Toolset.Tools 4 | { 5 | public class RcDynamicUpdateToolMode 6 | { 7 | public static readonly RcDynamicUpdateToolMode BUILD = new RcDynamicUpdateToolMode(0, "Build"); 8 | public static readonly RcDynamicUpdateToolMode COLLIDERS = new RcDynamicUpdateToolMode(1, "Colliders"); 9 | public static readonly RcDynamicUpdateToolMode RAYCAST = new RcDynamicUpdateToolMode(2, "Raycast"); 10 | 11 | public static readonly RcImmutableArray Values = RcImmutableArray.Create( 12 | BUILD, COLLIDERS, RAYCAST 13 | ); 14 | 15 | public readonly int Idx; 16 | public readonly string Label; 17 | 18 | private RcDynamicUpdateToolMode(int idx, string label) 19 | { 20 | Idx = idx; 21 | Label = label; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast.Toolset/Tools/RcJumpLinkBuilderToolConfig.cs: -------------------------------------------------------------------------------- 1 | /* 2 | recast4j copyright (c) 2020-2021 Piotr Piastucki piotr@jtilia.org 3 | 4 | This software is provided 'as-is', without any express or implied 5 | warranty. In no event will the authors be held liable for any damages 6 | arising from the use of this software. 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 1. The origin of this software must not be misrepresented; you must not 11 | claim that you wrote the original software. If you use this software 12 | in a product, an acknowledgment in the product documentation would be 13 | appreciated but is not required. 14 | 2. Altered source versions must be plainly marked as such, and must not be 15 | misrepresented as being the original software. 16 | 3. This notice may not be removed or altered from any source distribution. 17 | */ 18 | 19 | using DotRecast.Detour.Extras.Jumplink; 20 | 21 | namespace DotRecast.Recast.Toolset.Tools 22 | { 23 | public class RcJumpLinkBuilderToolConfig 24 | { 25 | public int buildTypes = JumpLinkType.EDGE_CLIMB_DOWN.Bit | JumpLinkType.EDGE_JUMP.Bit; 26 | public bool buildOffMeshConnections = false; 27 | 28 | public float groundTolerance = 0.3f; 29 | public float climbDownDistance = 0.4f; 30 | public float climbDownMaxHeight = 3.2f; 31 | public float climbDownMinHeight = 1.5f; 32 | public float edgeJumpEndDistance = 2f; 33 | public float edgeJumpHeight = 0.4f; 34 | public float edgeJumpDownMaxHeight = 2.5f; 35 | public float edgeJumpUpMaxHeight = 0.3f; 36 | } 37 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/DotRecast.Recast.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1;net8.0;net9.0 5 | DotRecast.Recast 6 | README.md 7 | ikpil 8 | DotRecast - a port of Recast Detour, Industry-standard navigation mesh toolset for .NET, C#, Unity3D, games, servers 9 | git 10 | https://github.com/ikpil/DotRecast 11 | https://github.com/ikpil/DotRecast 12 | game gamedev ai csharp server unity navigation game-development unity3d pathfinding pathfinder recast detour navmesh crowd-simulation recastnavigation 13 | https://github.com/ikpil/DotRecast/blob/main/CHANGELOG.md 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/DotRecast.Recast/EdgeValues.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast 2 | { 3 | public static class EdgeValues 4 | { 5 | public const int EV_UNDEF = -1; 6 | public const int EV_HULL = -2; 7 | } 8 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/Geom/BoundsItem.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Recast.Geom 4 | { 5 | public class BoundsItem 6 | { 7 | public RcVec2f bmin; 8 | public RcVec2f bmax; 9 | public int i; 10 | } 11 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/Geom/BoundsItemXComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace DotRecast.Recast.Geom 4 | { 5 | public class BoundsItemXComparer : IComparer 6 | { 7 | public static readonly BoundsItemXComparer Shared = new BoundsItemXComparer(); 8 | 9 | private BoundsItemXComparer() 10 | { 11 | } 12 | 13 | public int Compare(BoundsItem a, BoundsItem b) 14 | { 15 | return a.bmin.X.CompareTo(b.bmin.X); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/Geom/BoundsItemYComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace DotRecast.Recast.Geom 4 | { 5 | public class BoundsItemYComparer : IComparer 6 | { 7 | public static readonly BoundsItemYComparer Shared = new BoundsItemYComparer(); 8 | 9 | private BoundsItemYComparer() 10 | { 11 | } 12 | 13 | public int Compare(BoundsItem a, BoundsItem b) 14 | { 15 | return a.bmin.Y.CompareTo(b.bmin.Y); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/Geom/RcChunkyTriMesh.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | using System.Collections.Generic; 22 | 23 | namespace DotRecast.Recast.Geom 24 | { 25 | public class RcChunkyTriMesh 26 | { 27 | public List nodes; 28 | public int ntris; 29 | public int maxTrisPerChunk; 30 | } 31 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/Geom/RcChunkyTriMeshNode.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Recast.Geom 4 | { 5 | public class RcChunkyTriMeshNode 6 | { 7 | public RcVec2f bmin; 8 | public RcVec2f bmax; 9 | public int i; 10 | public int[] tris; 11 | } 12 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/IRcBuilderProgressListener.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast 2 | { 3 | public interface IRcBuilderProgressListener 4 | { 5 | void OnProgress(int completed, int total); 6 | } 7 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcAxis.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast 2 | { 3 | public static class RcAxis 4 | { 5 | public const int RC_AXIS_X = 0; 6 | public const int RC_AXIS_Y = 1; 7 | public const int RC_AXIS_Z = 2; 8 | }; 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcBuildContoursFlags.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast 2 | { 3 | /// Contour build flags. 4 | /// @see rcBuildContours 5 | public static class RcBuildContoursFlags 6 | { 7 | public const int RC_CONTOUR_TESS_WALL_EDGES = 0x01; //< Tessellate solid (impassable) edges during contour simplification. 8 | public const int RC_CONTOUR_TESS_AREA_EDGES = 0x02; //< Tessellate edges between areas during contour simplification. 9 | } 10 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcBuilderResult.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core; 2 | 3 | namespace DotRecast.Recast 4 | { 5 | public class RcBuilderResult 6 | { 7 | public readonly int TileX; 8 | public readonly int TileZ; 9 | 10 | public readonly RcHeightfield SolidHeightfiled; 11 | public readonly RcCompactHeightfield CompactHeightfield; 12 | public readonly RcContourSet ContourSet; 13 | public readonly RcPolyMesh Mesh; 14 | public readonly RcPolyMeshDetail MeshDetail; 15 | public readonly RcContext Context; 16 | 17 | public RcBuilderResult(int tileX, int tileZ, RcHeightfield solidHeightfiled, RcCompactHeightfield compactHeightfield, RcContourSet contourSet, RcPolyMesh mesh, RcPolyMeshDetail meshDetail, RcContext ctx) 18 | { 19 | TileX = tileX; 20 | TileZ = tileZ; 21 | SolidHeightfiled = solidHeightfiled; 22 | CompactHeightfield = compactHeightfield; 23 | ContourSet = contourSet; 24 | Mesh = mesh; 25 | MeshDetail = meshDetail; 26 | Context = ctx; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcCompactCell.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Recast 22 | { 23 | /** Provides information on the content of a cell column in a compact heightfield. */ 24 | public readonly struct RcCompactCell 25 | { 26 | /** Index to the first span in the column. */ 27 | public readonly int index; 28 | 29 | /** Number of spans in the column. */ 30 | public readonly int count; 31 | 32 | public RcCompactCell(int index, int count) 33 | { 34 | this.index = index; 35 | this.count = count; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcCompactSpanBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast 2 | { 3 | public class RcCompactSpanBuilder 4 | { 5 | public int y; 6 | public int reg; 7 | public int con; 8 | public int h; 9 | 10 | public static RcCompactSpanBuilder NewBuilder(ref RcCompactSpan span) 11 | { 12 | var builder = NewBuilder(); 13 | builder.y = span.y; 14 | builder.reg = span.reg; 15 | builder.con = span.con; 16 | builder.h = span.h; 17 | return builder; 18 | } 19 | 20 | public static RcCompactSpanBuilder NewBuilder() 21 | { 22 | return new RcCompactSpanBuilder(); 23 | } 24 | 25 | private RcCompactSpanBuilder() 26 | { 27 | } 28 | 29 | public RcCompactSpanBuilder WithReg(int reg) 30 | { 31 | this.reg = reg; 32 | return this; 33 | } 34 | 35 | public RcCompactSpan Build() 36 | { 37 | return new RcCompactSpan(this); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcContour.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Recast 22 | { 23 | /// Represents a simple, non-overlapping contour in field space. 24 | public class RcContour 25 | { 26 | public int[] verts; //< Simplified contour vertex and connection data. [Size: 4 * #nverts] 27 | public int nverts; //< The number of vertices in the simplified contour. 28 | public int[] rverts; //< Raw contour vertex and connection data. [Size: 4 * #nrverts] 29 | public int nrverts; //< The number of vertices in the raw contour. 30 | public int reg; //< The region id of the contour. 31 | public int area; //< The area id of the contour. 32 | } 33 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcContourHole.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast 2 | { 3 | public class RcContourHole 4 | { 5 | public int leftmost; 6 | public int minx; 7 | public int minz; 8 | public RcContour contour; 9 | } 10 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcContourHoleComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace DotRecast.Recast 4 | { 5 | public class RcContourHoleComparer : IComparer 6 | { 7 | public static readonly RcContourHoleComparer Shared = new RcContourHoleComparer(); 8 | 9 | private RcContourHoleComparer() 10 | { 11 | } 12 | 13 | public int Compare(RcContourHole a, RcContourHole b) 14 | { 15 | if (a.minx == b.minx) 16 | { 17 | return a.minz.CompareTo(b.minz); 18 | } 19 | else 20 | { 21 | return a.minx.CompareTo(b.minx); 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcContourRegion.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast 2 | { 3 | public class RcContourRegion 4 | { 5 | public RcContour outline; 6 | public RcContourHole[] holes; 7 | public int nholes; 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcConvexVolume.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Recast 22 | { 23 | public class RcConvexVolume 24 | { 25 | public float[] verts; 26 | public float hmin; 27 | public float hmax; 28 | public RcAreaModification areaMod; 29 | } 30 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcDirtyEntry.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast 2 | { 3 | // Struct to keep track of entries in the region table that have been changed. 4 | public readonly struct RcDirtyEntry 5 | { 6 | public readonly int index; 7 | public readonly int region; 8 | public readonly int distance2; 9 | 10 | public RcDirtyEntry(int tempIndex, int tempRegion, int tempDistance2) 11 | { 12 | index = tempIndex; 13 | region = tempRegion; 14 | distance2 = tempDistance2; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcHeightPatch.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast 2 | { 3 | public class RcHeightPatch 4 | { 5 | public int xmin; 6 | public int ymin; 7 | public int width; 8 | public int height; 9 | public int[] data; 10 | } 11 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcHeightfieldLayer.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Core.Numerics; 2 | 3 | namespace DotRecast.Recast 4 | { 5 | /// Represents a heightfield layer within a layer set. 6 | /// @see rcHeightfieldLayerSet 7 | public class RcHeightfieldLayer 8 | { 9 | public RcVec3f bmin = new RcVec3f(); // < The minimum bounds in world space. [(x, y, z)] 10 | public RcVec3f bmax = new RcVec3f(); // < The maximum bounds in world space. [(x, y, z)] 11 | public float cs; // < The size of each cell. (On the xz-plane.) 12 | public float ch; // < The height of each cell. (The minimum increment along the y-axis.) 13 | public int width; // < The width of the heightfield. (Along the x-axis in cell units.) 14 | public int height; // < The height of the heightfield. (Along the z-axis in cell units.) 15 | public int minx; // < The minimum x-bounds of usable data. 16 | public int maxx; // < The maximum x-bounds of usable data. 17 | public int miny; // < The minimum y-bounds of usable data. (Along the z-axis.) 18 | public int maxy; // < The maximum y-bounds of usable data. (Along the z-axis.) 19 | public int hmin; // < The minimum height bounds of usable data. (Along the y-axis.) 20 | public int hmax; // < The maximum height bounds of usable data. (Along the y-axis.) 21 | public int[] heights; // < The heightfield. [Size: width * height] 22 | public int[] areas; // < Area ids. [Size: Same as #heights] 23 | public int[] cons; // < Packed neighbor connection information. [Size: Same as #heights] 24 | } 25 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcHeightfieldLayerSet.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | 22 | namespace DotRecast.Recast 23 | { 24 | /// Represents a set of heightfield layers. 25 | /// @ingroup recast 26 | /// @see rcAllocHeightfieldLayerSet, rcFreeHeightfieldLayerSet 27 | public class RcHeightfieldLayerSet 28 | { 29 | public RcHeightfieldLayer[] layers; // < The layers in the set. [Size: #nlayers] 30 | } 31 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcLayerRegion.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace DotRecast.Recast 4 | { 5 | public class RcLayerRegion 6 | { 7 | public readonly int index; 8 | public List layers; 9 | public List neis; 10 | public int ymin, ymax; 11 | public byte layerId; // Layer ID 12 | public bool @base; // Flag indicating if the region is the base of merged regions. 13 | 14 | public RcLayerRegion(int i) 15 | { 16 | index = i; 17 | layers = new List(); 18 | neis = new List(); 19 | ymin = 0xFFFF; 20 | layerId = 0xff; 21 | } 22 | }; 23 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcLayerSweepSpan.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast 2 | { 3 | public class RcLayerSweepSpan 4 | { 5 | public int ns; // number samples 6 | public byte id; // region id 7 | public byte nei; // neighbour id 8 | }; 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcLevelStackEntry.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast 2 | { 3 | public readonly struct RcLevelStackEntry 4 | { 5 | public readonly int x; 6 | public readonly int y; 7 | public readonly int index; 8 | 9 | public RcLevelStackEntry(int tempX, int tempY, int tempIndex) 10 | { 11 | x = tempX; 12 | y = tempY; 13 | index = tempIndex; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcPartition.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast 2 | { 3 | public enum RcPartition 4 | { 5 | WATERSHED = 0, 6 | MONOTONE = 1, 7 | LAYERS = 2, 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcPartitionType.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | 3 | namespace DotRecast.Recast 4 | { 5 | public class RcPartitionType 6 | { 7 | public static readonly RcPartitionType WATERSHED = new RcPartitionType(RcPartition.WATERSHED); 8 | public static readonly RcPartitionType MONOTONE = new RcPartitionType(RcPartition.MONOTONE); 9 | public static readonly RcPartitionType LAYERS = new RcPartitionType(RcPartition.LAYERS); 10 | 11 | public static readonly RcPartitionType[] Values = { WATERSHED, MONOTONE, LAYERS }; 12 | 13 | public readonly RcPartition EnumType; 14 | public readonly int Value; 15 | public readonly string Name; 16 | 17 | private RcPartitionType(RcPartition et) 18 | { 19 | EnumType = et; 20 | Value = (int)et; 21 | Name = et.ToString(); 22 | } 23 | 24 | public static RcPartition OfValue(int value) 25 | { 26 | return Values.FirstOrDefault(x => x.Value == value)?.EnumType ?? RcPartition.WATERSHED; 27 | } 28 | 29 | public static RcPartitionType Of(RcPartition partition) 30 | { 31 | return Values.FirstOrDefault(x => x.EnumType == partition) ?? WATERSHED; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcPolyMeshDetail.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Recast 22 | { 23 | /// Contains triangle meshes that represent detailed height data associated 24 | /// with the polygons in its associated polygon mesh object. 25 | /// @ingroup recast 26 | public class RcPolyMeshDetail 27 | { 28 | public int[] meshes; //< The sub-mesh data. [Size: 4*#nmeshes] 29 | public float[] verts; //< The mesh vertices. [Size: 3*#nverts] 30 | public int[] tris; //< The mesh triangles. [Size: 4*#ntris] 31 | public int nmeshes; //< The number of sub-meshes defined by #meshes. 32 | public int nverts; //< The number of vertices in #verts. 33 | public int ntris; //< The number of triangles in #tris. 34 | } 35 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcPotentialDiagonal.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast 2 | { 3 | public readonly struct RcPotentialDiagonal 4 | { 5 | public readonly int vert; 6 | public readonly int dist; 7 | 8 | public RcPotentialDiagonal(int vert, int dist) 9 | { 10 | this.vert = vert; 11 | this.dist = dist; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcPotentialDiagonalComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace DotRecast.Recast 4 | { 5 | public class RcPotentialDiagonalComparer : IComparer 6 | { 7 | public static readonly RcPotentialDiagonalComparer Shared = new RcPotentialDiagonalComparer(); 8 | 9 | private RcPotentialDiagonalComparer() 10 | { 11 | } 12 | 13 | public int Compare(RcPotentialDiagonal va, RcPotentialDiagonal vb) 14 | { 15 | RcPotentialDiagonal a = va; 16 | RcPotentialDiagonal b = vb; 17 | return a.dist.CompareTo(b.dist); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcRegion.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace DotRecast.Recast 4 | { 5 | public class RcRegion 6 | { 7 | public int spanCount; // Number of spans belonging to this region 8 | public int id; // ID of the region 9 | public int areaType; // Are type. 10 | public bool remap; 11 | public bool visited; 12 | public bool overlap; 13 | public bool connectsToBorder; 14 | public int ymin, ymax; 15 | public List connections; 16 | public List floors; 17 | 18 | public RcRegion(int i) 19 | { 20 | id = i; 21 | ymin = 0xFFFF; 22 | connections = new List(); 23 | floors = new List(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcSpan.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org 4 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | */ 20 | 21 | namespace DotRecast.Recast 22 | { 23 | /// Represents a span in a heightfield. 24 | /// @see rcHeightfield 25 | public class RcSpan 26 | { 27 | public int smin; //< The lower limit of the span. [Limit: < #smax] 28 | public int smax; //< The upper limit of the span. [Limit: <= #RC_SPAN_MAX_HEIGHT] 29 | public int area; //< The area id assigned to the span. 30 | public RcSpan next; //< The next span higher up in column. 31 | } 32 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcSpanPool.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2010 Mikko Mononen memon@inside.org 3 | DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | */ 19 | 20 | namespace DotRecast.Recast 21 | { 22 | /// A memory pool used for quick allocation of spans within a heightfield. 23 | /// @see rcHeightfield 24 | public class RcSpanPool 25 | { 26 | public RcSpanPool next; //< The next span pool. 27 | public readonly RcSpan[] items; //< Array of spans in the pool. 28 | 29 | public RcSpanPool() 30 | { 31 | items = new RcSpan[RcRecast.RC_SPANS_PER_POOL]; 32 | for (int i = 0; i < items.Length; ++i) 33 | { 34 | items[i] = new RcSpan(); 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/DotRecast.Recast/RcSweepSpan.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Recast 2 | { 3 | public class RcSweepSpan 4 | { 5 | public int rid; // row id 6 | public int id; // region id 7 | public int ns; // number samples 8 | public int nei; // neighbour id 9 | } 10 | } -------------------------------------------------------------------------------- /test/DotRecast.Core.Test/DotRecast.Core.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0;net9.0 5 | false 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | all 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | 18 | 19 | all 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /test/DotRecast.Core.Test/RcIoTests.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using NUnit.Framework; 3 | 4 | namespace DotRecast.Core.Test; 5 | 6 | public class RcIoTests 7 | { 8 | [Test] 9 | public void Test() 10 | { 11 | const long tileRef = 281474976710656L; 12 | const int dataSize = 344; 13 | 14 | byte[] actual; 15 | 16 | { 17 | using MemoryStream ms = new MemoryStream(); 18 | using BinaryWriter bw = new BinaryWriter(ms); 19 | 20 | RcIO.Write(bw, tileRef, RcByteOrder.LITTLE_ENDIAN); 21 | RcIO.Write(bw, dataSize, RcByteOrder.LITTLE_ENDIAN); 22 | 23 | bw.Flush(); 24 | actual= ms.ToArray(); 25 | } 26 | 27 | { 28 | using MemoryStream ms = new MemoryStream(actual); 29 | using BinaryReader br = new BinaryReader(ms); 30 | var byteBuffer = RcIO.ToByteBuffer(br); 31 | byteBuffer.Order(RcByteOrder.LITTLE_ENDIAN); 32 | 33 | Assert.That(byteBuffer.GetLong(), Is.EqualTo(tileRef)); 34 | Assert.That(byteBuffer.GetInt(), Is.EqualTo(dataSize)); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /test/DotRecast.Core.Test/RcMathTest.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace DotRecast.Core.Test; 4 | 5 | public class RcMathTest 6 | { 7 | [Test] 8 | public void TestSqr() 9 | { 10 | Assert.That(RcMath.Sqr(0), Is.EqualTo(0)); 11 | Assert.That(RcMath.Sqr(5), Is.EqualTo(25)); 12 | Assert.That(RcMath.Sqr(-5), Is.EqualTo(25)); 13 | Assert.That(RcMath.Sqr(float.PositiveInfinity), Is.EqualTo(float.PositiveInfinity)); 14 | Assert.That(RcMath.Sqr(float.NegativeInfinity), Is.EqualTo(float.PositiveInfinity)); 15 | Assert.That(RcMath.Sqr(float.NaN), Is.EqualTo(float.NaN)); 16 | } 17 | 18 | [Test] 19 | public void TestLerp() 20 | { 21 | // 22 | Assert.That(RcMath.Lerp(-10, 10, 2f), Is.EqualTo(30)); 23 | Assert.That(RcMath.Lerp(-10, 10, 1f), Is.EqualTo(10)); 24 | Assert.That(RcMath.Lerp(-10, 10, 0.5f), Is.EqualTo(0)); 25 | Assert.That(RcMath.Lerp(-10, 10, 0.25f), Is.EqualTo(-5)); 26 | Assert.That(RcMath.Lerp(-10, 10, 0), Is.EqualTo(-10)); 27 | Assert.That(RcMath.Lerp(-10, 10, -0.5f), Is.EqualTo(-20)); 28 | Assert.That(RcMath.Lerp(-10, 10, -1f), Is.EqualTo(-30)); 29 | 30 | // 31 | Assert.That(RcMath.Lerp(10, 10, 0.5f), Is.EqualTo(10)); 32 | Assert.That(RcMath.Lerp(10, 10, 0.8f), Is.EqualTo(10)); 33 | 34 | // 35 | Assert.That(RcMath.Lerp(10, -10, 0.75f), Is.EqualTo(-5)); 36 | } 37 | } -------------------------------------------------------------------------------- /test/DotRecast.Core.Test/Vector2Test.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Numerics; 3 | using DotRecast.Core.Numerics; 4 | using NUnit.Framework; 5 | 6 | namespace DotRecast.Core.Test; 7 | 8 | public class Vector2Test 9 | { 10 | [Test] 11 | [Repeat(100000)] 12 | public void TestImplicitCasting() 13 | { 14 | var v1 = new Vector2(Random.Shared.NextSingle(), Random.Shared.NextSingle()); 15 | var v2 = new RcVec2f(Random.Shared.NextSingle(), Random.Shared.NextSingle()); 16 | 17 | Assert.That(Vector2.Distance(v1, v2), Is.EqualTo(RcVec2f.Distance(v1, v2))); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /test/DotRecast.Detour.Crowd.Test/DotRecast.Detour.Crowd.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0;net9.0 5 | false 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | all 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | 18 | 19 | all 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /test/DotRecast.Detour.Dynamic.Test/DotRecast.Detour.Dynamic.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0;net9.0 5 | false 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | all 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | 18 | 19 | all 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /test/DotRecast.Detour.Extras.Test/DotRecast.Detour.Extras.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0;net9.0 5 | false 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | all 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | 18 | 19 | all 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /test/DotRecast.Detour.Test/DotRecast.Detour.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0;net9.0 5 | false 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | all 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | 18 | 19 | all 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /test/DotRecast.Detour.TileCache.Test/DotRecast.Detour.TileCache.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0;net9.0 5 | false 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | all 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | 18 | 19 | all 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /test/DotRecast.Detour.TileCache.Test/TestTileCacheMeshProcess.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Detour.TileCache.Test; 2 | 3 | public class TestTileCacheMeshProcess : IDtTileCacheMeshProcess 4 | { 5 | public void Process(DtNavMeshCreateParams option) 6 | { 7 | for (int i = 0; i < option.polyCount; ++i) 8 | { 9 | option.polyFlags[i] = 1; 10 | } 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /test/DotRecast.Detour.TileCache.Test/TileCacheTestSetUpFixture.cs: -------------------------------------------------------------------------------- 1 | using DotRecast.Detour.TileCache.Io.Compress; 2 | using DotRecast.Detour.TileCache.Test.Io; 3 | using NUnit.Framework; 4 | 5 | namespace DotRecast.Detour.TileCache.Test; 6 | 7 | [SetUpFixture] 8 | public class TileCacheTestSetUpFixture 9 | { 10 | [OneTimeSetUp] 11 | public void OneTimeSetUp() 12 | { 13 | // add lz4 14 | DtTileCacheCompressorFactory.Shared.TryAdd(1, DtTileCacheLZ4ForTestCompressor.Shared); 15 | } 16 | } -------------------------------------------------------------------------------- /test/DotRecast.Recast.Test/DotRecast.Recast.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0;net9.0 5 | false 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | all 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | 18 | 19 | all 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /tool/DotRecast.Tool.Benchmark/DotRecast.Detour/PolygonByCircleConstraintBenchmarks.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using DotRecast.Core.Collections; 3 | using DotRecast.Core.Numerics; 4 | using DotRecast.Detour; 5 | 6 | namespace DotRecast.Tool.Benchmark.DotRecast.Detour; 7 | 8 | 9 | 10 | [MemoryDiagnoser] 11 | public class PolygonByCircleConstraintBenchmarks 12 | { 13 | private readonly IDtPolygonByCircleConstraint _constraint = DtStrictDtPolygonByCircleConstraint.Shared; 14 | 15 | [Params(100, 10000)] 16 | public int Count; 17 | 18 | [Benchmark] 19 | public void ShouldHandlePolygonFullyInsideCircle() 20 | { 21 | float[] polygon = { -2, 0, 2, 2, 0, 2, 2, 0, -2, -2, 0, -2 }; 22 | 23 | for (int i = 0; i < Count; ++i) 24 | { 25 | RcVec3f center = new RcVec3f(1, 0, 1); 26 | RcFixedArray256 constrained = new RcFixedArray256(); 27 | 28 | _constraint.Apply(polygon, center, 6, constrained.AsSpan(), out var ncverts); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /tool/DotRecast.Tool.Benchmark/DotRecast.Tool.Benchmark.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net8.0;net9.0 6 | true 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /tool/DotRecast.Tool.Benchmark/Program.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using BenchmarkDotNet.Running; 3 | 4 | namespace DotRecast.Tool.Benchmark; 5 | 6 | public static class Program 7 | { 8 | public static int Main(string[] args) 9 | { 10 | var switcher = BenchmarkSwitcher.FromAssembly(Assembly.GetExecutingAssembly()); 11 | 12 | if (args == null || args.Length == 0) 13 | { 14 | switcher.RunAll(); 15 | } 16 | else 17 | { 18 | switcher.Run(args); 19 | } 20 | 21 | return 0; 22 | } 23 | } -------------------------------------------------------------------------------- /tool/DotRecast.Tool.PublishToUniRecast/CsProj.cs: -------------------------------------------------------------------------------- 1 | namespace DotRecast.Tool.PublishToUniRecast; 2 | 3 | public class CsProj 4 | { 5 | public readonly string RootPath; 6 | public readonly string Name; 7 | public readonly string TargetPath; 8 | 9 | public CsProj(string rootPath, string name, string targetPath) 10 | { 11 | RootPath = rootPath; 12 | Name = name; 13 | TargetPath = targetPath; 14 | } 15 | } -------------------------------------------------------------------------------- /tool/DotRecast.Tool.PublishToUniRecast/DotRecast.Tool.PublishToUniRecast.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net8.0;net9.0 6 | false 7 | 8 | 9 | 10 | --------------------------------------------------------------------------------