diff --git a/Source/Engine/Navigation/NavMeshRuntime.cpp b/Source/Engine/Navigation/NavMeshRuntime.cpp index ef6326a07..73122acff 100644 --- a/Source/Engine/Navigation/NavMeshRuntime.cpp +++ b/Source/Engine/Navigation/NavMeshRuntime.cpp @@ -26,7 +26,8 @@ namespace } NavMeshRuntime::NavMeshRuntime(const NavMeshProperties& properties) - : Properties(properties) + : ScriptingObject(SpawnParams(Guid::Empty, NavMeshRuntime::TypeInitializer)) + , Properties(properties) { _navMesh = nullptr; _navMeshQuery = dtAllocNavMeshQuery(); diff --git a/Source/Engine/Navigation/NavMeshRuntime.h b/Source/Engine/Navigation/NavMeshRuntime.h index 6070ec0e1..612cba285 100644 --- a/Source/Engine/Navigation/NavMeshRuntime.h +++ b/Source/Engine/Navigation/NavMeshRuntime.h @@ -4,6 +4,7 @@ #include "Engine/Core/Types/BaseTypes.h" #include "Engine/Platform/CriticalSection.h" +#include "Engine/Scripting/ScriptingObject.h" #include "NavMeshData.h" #include "NavigationTypes.h" @@ -40,20 +41,21 @@ DECLARE_ENUM_OPERATORS(NavMeshPathFlags); /// /// The navigation mesh runtime object that builds the navmesh from all loaded scenes. /// -class FLAXENGINE_API NavMeshRuntime +API_CLASS(NoSpawn) class FLAXENGINE_API NavMeshRuntime : public ScriptingObject { + DECLARE_SCRIPTING_TYPE_MINIMAL(NavMeshRuntime); public: // Gets the first valid navigation mesh runtime. Return null if none created. - static NavMeshRuntime* Get(); + API_FUNCTION() static NavMeshRuntime* Get(); // Gets the navigation mesh runtime for a given navmesh name. Return null if missing. - static NavMeshRuntime* Get(const StringView& navMeshName); + API_FUNCTION() static NavMeshRuntime* Get(const StringView& navMeshName); // Gets the navigation mesh runtime for a given agent properties trying to pick the best matching navmesh. - static NavMeshRuntime* Get(const NavAgentProperties& agentProperties); + API_FUNCTION() static NavMeshRuntime* Get(API_PARAM(Ref) const NavAgentProperties& agentProperties); // Gets the navigation mesh runtime for a given navmesh properties. - static NavMeshRuntime* Get(const NavMeshProperties& navMeshProperties, bool createIfMissing = false); + API_FUNCTION() static NavMeshRuntime* Get(API_PARAM(Ref) const NavMeshProperties& navMeshProperties, bool createIfMissing = false); // The lookup table that maps areaId of the navmesh to the current properties (applied by the NavigationSettings). Cached to improve runtime performance. static float NavAreasCosts[64]; @@ -80,12 +82,12 @@ public: /// /// The navigation mesh properties. /// - NavMeshProperties Properties; + API_FIELD(ReadOnly) NavMeshProperties Properties; /// /// Gets the size of the tile (in world-units). Returns zero if not initialized yet. /// - FORCE_INLINE float GetTileSize() const + API_PROPERTY() FORCE_INLINE float GetTileSize() const { return _tileSize; } @@ -110,7 +112,7 @@ public: /// The result hit information. Valid only when query succeed. /// The maximum distance to search for wall (search radius). /// True if ray hits an matching object, otherwise false. - bool FindDistanceToWall(const Vector3& startPosition, NavMeshHit& hitInfo, float maxDistance = MAX_float) const; + API_FUNCTION() bool FindDistanceToWall(const Vector3& startPosition, NavMeshHit& hitInfo, float maxDistance = MAX_float) const; /// /// Finds the path between the two positions presented as a list of waypoints stored in the corners array. @@ -119,7 +121,7 @@ public: /// The end position. /// The result path. /// True if found valid path between given two points (it may be partial), otherwise false if failed. - bool FindPath(const Vector3& startPosition, const Vector3& endPosition, Array& resultPath) const + API_FUNCTION() bool FindPath(const Vector3& startPosition, const Vector3& endPosition, API_PARAM(Out) Array& resultPath) const { NavMeshPathFlags flags; return FindPath(startPosition, endPosition, resultPath, flags); @@ -131,9 +133,9 @@ public: /// The start position. /// The end position. /// The result path. - /// The result path flags. + /// The result path flags. /// True if found valid path between given two points (it may be partial), otherwise false if failed. - bool FindPath(const Vector3& startPosition, const Vector3& endPosition, Array& resultPath, NavMeshPathFlags& resultFlags) const; + bool FindPath(const Vector3& startPosition, const Vector3& endPosition, API_PARAM(Out) Array& resultPath, NavMeshPathFlags& resultFlags) const; /// /// Tests the path between the two positions (non-partial). @@ -141,7 +143,7 @@ public: /// The start position. /// The end position. /// True if found valid path between given two points, otherwise false if failed. - bool TestPath(const Vector3& startPosition, const Vector3& endPosition) const; + API_FUNCTION() bool TestPath(const Vector3& startPosition, const Vector3& endPosition) const; /// /// Projects the point to nav mesh surface (finds the nearest polygon). @@ -149,14 +151,14 @@ public: /// The source point. /// The result position on the navmesh (valid only if method returns true). /// True if found valid location on the navmesh, otherwise false. - bool ProjectPoint(const Vector3& point, Vector3& result) const; + API_FUNCTION() bool ProjectPoint(const Vector3& point, API_PARAM(Out) Vector3& result) const; /// /// Finds random location on nav mesh. /// /// The result position on the navmesh (valid only if method returns true). /// True if found valid location on the navmesh, otherwise false. - bool FindRandomPoint(Vector3& result) const; + API_FUNCTION() bool FindRandomPoint(API_PARAM(Out) Vector3& result) const; /// /// Finds random location on nav mesh within the reach of specified location. @@ -165,7 +167,7 @@ public: /// The search distance for a random point. Maximum distance for a result point from the center of the circle. /// The result position on the navmesh (valid only if method returns true). /// True if found valid location on the navmesh, otherwise false. - bool FindRandomPointAroundCircle(const Vector3& center, float radius, Vector3& result) const; + API_FUNCTION() bool FindRandomPointAroundCircle(const Vector3& center, float radius, API_PARAM(Out) Vector3& result) const; /// /// Casts a 'walkability' ray along the surface of the navigation mesh from the start position toward the end position. @@ -174,7 +176,7 @@ public: /// The end position. /// The result hit information. Valid only when query succeed. /// True if ray hits an matching object, otherwise false. - bool RayCast(const Vector3& startPosition, const Vector3& endPosition, NavMeshHit& hitInfo) const; + API_FUNCTION() bool RayCast(const Vector3& startPosition, const Vector3& endPosition, API_PARAM(Out) NavMeshHit& hitInfo) const; public: ///