RecastProcessing.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <Recast.h>
  10. #include <RecastNavigation/RecastHelpers.h>
  11. #include <Misc/RecastNavigationDebugDraw.h>
  12. #include <Misc/RecastNavigationMeshConfig.h>
  13. namespace RecastNavigation
  14. {
  15. struct RecastProcessing
  16. {
  17. rcConfig m_config = {};
  18. AZStd::vector<AZ::u8> m_trianglesAreas;
  19. RecastPointer<rcHeightfield> m_solid;
  20. RecastPointer<rcCompactHeightfield> m_compactHeightfield;
  21. RecastPointer<rcContourSet> m_contourSet;
  22. RecastPointer<rcPolyMesh> m_polyMesh;
  23. RecastPointer<rcPolyMeshDetail> m_polyMeshDetail;
  24. const float* m_vertices = nullptr;
  25. int m_vertexCount = 0;
  26. const int* m_triangleData = nullptr;
  27. int m_triangleCount = 0;
  28. rcContext* m_context = nullptr;
  29. //! First step in building a navigation mesh.
  30. //! @param geom input geometry
  31. //! @param meshConfig navigation mesh configuration
  32. void InitializeMeshConfig(TileGeometry* geom, const RecastNavigationMeshConfig& meshConfig);
  33. //! Second step in building a navigation mesh.
  34. //! @return true if successful
  35. [[nodiscard]] bool RasterizeInputPolygonSoup();
  36. //! Thirst step in building a navigation mesh.
  37. //! Once all geometry is rasterized, we do initial pass of filtering to
  38. //! remove unwanted overhangs caused by the conservative rasterization
  39. //! as well as filter spans where the character cannot possibly stand.
  40. //! @param meshConfig navigation mesh configuration, must be the same as provided in @InitializeMeshConfig
  41. void FilterWalkableSurfaces(const RecastNavigationMeshConfig& meshConfig);
  42. //! Fourth step in building a navigation mesh.
  43. //! Compact the height field so that it is faster to handle from now on.
  44. //! This will result more cache coherent data as well as the neighbors
  45. //! between walkable cells will be calculated.
  46. //! @return true if successful
  47. [[nodiscard]] bool PartitionWalkableSurfaceToSimpleRegions();
  48. //! Fifth step in building a navigation mesh.
  49. //! @return true if successful
  50. [[nodiscard]] bool TraceAndSimplifyRegionContours();
  51. //! Sixth step in building a navigation mesh.
  52. //! @return true if successful
  53. [[nodiscard]] bool BuildPolygonsMeshFromContours();
  54. //! Seventh step in building a navigation mesh.
  55. //! @return true if successful
  56. [[nodiscard]] bool CreateDetailMesh();
  57. //! Eight and last step in building a navigation mesh.
  58. //! @param geom input geometry, must be the same as provided in @InitializeMeshConfig
  59. //! @param meshConfig navigation mesh configuration
  60. //! @return navigation tile data in Recast-binary format
  61. NavigationTileData CreateDetourData(TileGeometry* geom, const RecastNavigationMeshConfig& meshConfig);
  62. };
  63. } // namespace RecastNavigation