From c1216a4318260085bc2ed960a05fdf8be6d64e37 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 18 Jan 2021 11:42:17 +0100 Subject: [PATCH] Add `NavAreaProperties` --- Source/Engine/Navigation/Navigation.cpp | 5 +++ Source/Engine/Navigation/NavigationTypes.h | 40 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/Source/Engine/Navigation/Navigation.cpp b/Source/Engine/Navigation/Navigation.cpp index 5e73f40c7..d5a516870 100644 --- a/Source/Engine/Navigation/Navigation.cpp +++ b/Source/Engine/Navigation/Navigation.cpp @@ -133,6 +133,11 @@ bool NavAgentMask::operator==(const NavAgentMask& other) const return Mask == other.Mask; } +bool NavAreaProperties::operator==(const NavAreaProperties& other) const +{ + return Name == other.Name && Id == other.Id && Math::NearEqual(Cost, other.Cost); +} + bool NavMeshProperties::operator==(const NavMeshProperties& other) const { return Name == other.Name && Quaternion::NearEqual(Rotation, other.Rotation, 0.001f) && Agent == other.Agent; diff --git a/Source/Engine/Navigation/NavigationTypes.h b/Source/Engine/Navigation/NavigationTypes.h index d02b2acc4..e604580f6 100644 --- a/Source/Engine/Navigation/NavigationTypes.h +++ b/Source/Engine/Navigation/NavigationTypes.h @@ -137,3 +137,43 @@ DECLARE_SCRIPTING_TYPE_MINIMAL(NavMeshHit); /// API_FIELD() Vector3 Normal; }; + +/// +/// The navigation area properties container for navmesh building and navigation runtime. +/// +API_STRUCT() struct FLAXENGINE_API NavAreaProperties : ISerializable +{ +API_AUTO_SERIALIZATION(); +DECLARE_SCRIPTING_TYPE_MINIMAL(NavAreaProperties); + + /// + /// The area type name. Identifies different types of the areas. + /// + API_FIELD(Attributes="EditorOrder(0)") + String Name; + + /// + /// The area type color (for debugging). Alpha channel is used to blend with navmesh color (alpha 0 to use navmesh color only). + /// + API_FIELD(Attributes="EditorOrder(10)") + Color Color = Color::Red; + + /// + /// The area id. It must be unique for the project. Valid range 0-63. Value 0 is reserved for Null areas (empty, non-navigable areas). + /// + API_FIELD(Attributes="EditorOrder(20), Limit(0, 63)") + byte Id = 1; + + /// + /// The cost scale for the area traversal for agents. The higher the cost, the less likely agent wil choose the path that goes over it. For instance, areas that are harder to move like sand should have higher cost for proper path finding. + /// + API_FIELD(Attributes="EditorOrder(30), Limit(0, 100000, 0.1f)") + float Cost = 1; + + bool operator==(const NavAreaProperties& other) const; + + bool operator!=(const NavAreaProperties& other) const + { + return !operator==(other); + } +};