X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-scene3d%2Fpublic-api%2Falgorithm%2Fnavigation-mesh.h;h=727f9fca7f0b2019df3a4441846103246510dba2;hb=3926f84dcc75c3eb8058626f2df3a9e4e1f9b7b7;hp=12f3387415d755602336a28aa9ec8270ff4f8192;hpb=f63f39657b29c562e38b2a28b09d8d2734cf2632;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-scene3d/public-api/algorithm/navigation-mesh.h b/dali-scene3d/public-api/algorithm/navigation-mesh.h index 12f3387..727f9fc 100644 --- a/dali-scene3d/public-api/algorithm/navigation-mesh.h +++ b/dali-scene3d/public-api/algorithm/navigation-mesh.h @@ -17,19 +17,20 @@ * limitations under the License. */ -// INTERNAL INCLUDES -#include - // EXTERNAL INCLUDES +#include #include #include #include #include #include -#include +#include #include +// INTERNAL INCLUDES +#include + namespace Dali::Scene3D::Internal::Algorithm { class NavigationMesh; @@ -41,15 +42,20 @@ class NavigationMeshFactory; } constexpr auto NAVIGATION_MESH_MAX_VERTICES_PER_FACE = 3u; -constexpr auto NAVIGATION_MESH_MAX_EDGES_PER_FACE = 3u; -constexpr auto NAVIGATION_MESH_MAX_COMPONENTS_3D = 3u; -constexpr auto NAVIGATION_MESH_MAX_COMPONENTS_2D = 2u; +constexpr auto NAVIGATION_MESH_MAX_EDGES_PER_FACE = 3u; +constexpr auto NAVIGATION_MESH_MAX_COMPONENTS_3D = 3u; +constexpr auto NAVIGATION_MESH_MAX_COMPONENTS_2D = 2u; namespace Dali::Scene3D::Algorithm { // Using PImpling but not usual DALi handles as this object isn't supposed to be refcounted using NavigationMeshImpl = Dali::Scene3D::Internal::Algorithm::NavigationMesh; +// Make each to change each index value's type here. +using VertexIndex = uint16_t; +using EdgeIndex = uint16_t; +using FaceIndex = uint16_t; + /** * @class NavigationMesh * @@ -72,18 +78,17 @@ using NavigationMeshImpl = Dali::Scene3D::Internal::Algorithm::NavigationMesh; class DALI_SCENE3D_API NavigationMesh { public: - /** * @struct Face * - * Describes a single polygon + * Describes a single polygon's face */ struct Face { - uint16_t vertex[NAVIGATION_MESH_MAX_VERTICES_PER_FACE]; ///< Vertices per face - uint16_t edge[NAVIGATION_MESH_MAX_EDGES_PER_FACE]; ///< Edges per face - float normal[NAVIGATION_MESH_MAX_COMPONENTS_3D]; ///< Normal vector - float center[NAVIGATION_MESH_MAX_COMPONENTS_3D]; ///< Barycentric coordinates + VertexIndex vertex[NAVIGATION_MESH_MAX_VERTICES_PER_FACE]; ///< Vertices per face + EdgeIndex edge[NAVIGATION_MESH_MAX_EDGES_PER_FACE]; ///< Edges per face + float normal[NAVIGATION_MESH_MAX_COMPONENTS_3D]; ///< Normal vector + float center[NAVIGATION_MESH_MAX_COMPONENTS_3D]; ///< Barycentric coordinates }; /** @@ -93,8 +98,8 @@ public: */ struct Edge { - uint16_t vertex[NAVIGATION_MESH_MAX_COMPONENTS_2D]; ///< Vertices making the edge - uint16_t face[NAVIGATION_MESH_MAX_COMPONENTS_2D]; ///< Faces on both sides of edge + VertexIndex vertex[NAVIGATION_MESH_MAX_COMPONENTS_2D]; ///< Vertices making the edge + FaceIndex face[NAVIGATION_MESH_MAX_COMPONENTS_2D]; ///< Faces on both sides of edge }; /** @@ -107,7 +112,7 @@ public: { union { - float co[NAVIGATION_MESH_MAX_COMPONENTS_3D]; ///< Coordinates of vertex + float coordinates[NAVIGATION_MESH_MAX_COMPONENTS_3D]; ///< Coordinates of vertex struct { float x, y, z; @@ -118,7 +123,6 @@ public: NavigationMesh() = delete; public: - /** * @brief Destructor */ @@ -149,11 +153,11 @@ public: * @brief Looks for the floor under specified position * @param[in] position Position to investigate * @param[in] outPosition Position on the floor in found - * @param[in] faceIndex Index of NavigationMesh face associated with floor + * @param[out] faceIndex Index of NavigationMesh face associated with floor * * @return True if floor has been found, False otherwise */ - bool FindFloor(const Dali::Vector3& position, Dali::Vector3& outPosition, uint32_t& faceIndex); + bool FindFloor(const Dali::Vector3& position, Dali::Vector3& outPosition, FaceIndex& faceIndex); /** * @brief Looks for a floor starting from specified face @@ -169,29 +173,28 @@ public: * * @return True on success, false otherwise */ - bool FindFloorForFace(const Dali::Vector3& position, uint32_t faceIndex, bool dontCheckNeighbours, Dali::Vector3& outPosition); - + bool FindFloorForFace(const Dali::Vector3& position, FaceIndex faceIndex, bool dontCheckNeighbours, Dali::Vector3& outPosition); /** * @brief Returns pointer to Face structure * @param[in] index Index of face to retrieve * @return Pointer to valid Face structure or nullptr */ - [[nodiscard]] const Face* GetFace(int index) const; + [[nodiscard]] const Face* GetFace(FaceIndex index) const; /** * @brief Returns edge structure * @param[in] index Index of edge to retrieve * @return Pointer to valid Edge structure or nullptr */ - [[nodiscard]] const Edge* GetEdge(int index) const; + [[nodiscard]] const Edge* GetEdge(EdgeIndex index) const; /** * @brief Returns vertex structure * @param[in] index Index of vertex to retrieve * @return Pointer to valid Vertex structure or nullptr */ - [[nodiscard]] const Vertex* GetVertex(int index) const; + [[nodiscard]] const Vertex* GetVertex(VertexIndex index) const; /** * @brief Sets static transform for the navigation mesh object @@ -228,7 +231,7 @@ public: * @param[in] point Point to transform * @return Point transformed to the local space */ - Dali::Vector3 PointSceneToLocal(const Dali::Vector3& point); + Dali::Vector3 PointSceneToLocal(const Dali::Vector3& point) const; /** * @brief Transforms point into the parent transform space @@ -238,7 +241,7 @@ public: * @param[in] point Point to transform * @return Point transformed into the parent space */ - Dali::Vector3 PointLocalToScene(const Dali::Vector3& point); + Dali::Vector3 PointLocalToScene(const Dali::Vector3& point) const; /** * @brief Returns direction of the gravity vector @@ -249,12 +252,11 @@ public: */ Dali::Vector3 GetGravityVector() const; - static constexpr uint16_t NULL_FACE{0xffff}; ///< Represents null polygon - static constexpr uint16_t NULL_EDGE{0xffff}; ///< represents null edge + static constexpr FaceIndex NULL_FACE{std::numeric_limits::max()}; ///< Represents null face + static constexpr EdgeIndex NULL_EDGE{std::numeric_limits::max()}; ///< Represents null edge public: - - DALI_INTERNAL explicit NavigationMesh( NavigationMeshImpl* impl ); + DALI_INTERNAL explicit NavigationMesh(NavigationMeshImpl* impl); std::unique_ptr mImpl; };