Add DefaultQueryExtent to navmesh properties
This commit is contained in:
@@ -16,9 +16,6 @@
|
|||||||
#define USE_NAV_MESH_ALLOC 1
|
#define USE_NAV_MESH_ALLOC 1
|
||||||
// TODO: try not using USE_NAV_MESH_ALLOC
|
// TODO: try not using USE_NAV_MESH_ALLOC
|
||||||
|
|
||||||
#define DEFAULT_NAV_QUERY_EXTENT_HORIZONTAL 50.0f
|
|
||||||
#define DEFAULT_NAV_QUERY_EXTENT_VERTICAL 250.0f
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
FORCE_INLINE void InitFilter(dtQueryFilter& filter)
|
FORCE_INLINE void InitFilter(dtQueryFilter& filter)
|
||||||
@@ -58,7 +55,7 @@ bool NavMeshRuntime::FindDistanceToWall(const Vector3& startPosition, NavMeshHit
|
|||||||
|
|
||||||
dtQueryFilter filter;
|
dtQueryFilter filter;
|
||||||
InitFilter(filter);
|
InitFilter(filter);
|
||||||
Vector3 extent(DEFAULT_NAV_QUERY_EXTENT_HORIZONTAL, DEFAULT_NAV_QUERY_EXTENT_VERTICAL, DEFAULT_NAV_QUERY_EXTENT_HORIZONTAL);
|
Vector3 extent = Properties.DefaultQueryExtent;
|
||||||
|
|
||||||
Vector3 startPositionNavMesh;
|
Vector3 startPositionNavMesh;
|
||||||
Vector3::Transform(startPosition, Properties.Rotation, startPositionNavMesh);
|
Vector3::Transform(startPosition, Properties.Rotation, startPositionNavMesh);
|
||||||
@@ -96,7 +93,7 @@ bool NavMeshRuntime::FindPath(const Vector3& startPosition, const Vector3& endPo
|
|||||||
|
|
||||||
dtQueryFilter filter;
|
dtQueryFilter filter;
|
||||||
InitFilter(filter);
|
InitFilter(filter);
|
||||||
Vector3 extent(DEFAULT_NAV_QUERY_EXTENT_HORIZONTAL, DEFAULT_NAV_QUERY_EXTENT_VERTICAL, DEFAULT_NAV_QUERY_EXTENT_HORIZONTAL);
|
Vector3 extent = Properties.DefaultQueryExtent;
|
||||||
|
|
||||||
Vector3 startPositionNavMesh, endPositionNavMesh;
|
Vector3 startPositionNavMesh, endPositionNavMesh;
|
||||||
Vector3::Transform(startPosition, Properties.Rotation, startPositionNavMesh);
|
Vector3::Transform(startPosition, Properties.Rotation, startPositionNavMesh);
|
||||||
@@ -164,7 +161,7 @@ bool NavMeshRuntime::TestPath(const Vector3& startPosition, const Vector3& endPo
|
|||||||
|
|
||||||
dtQueryFilter filter;
|
dtQueryFilter filter;
|
||||||
InitFilter(filter);
|
InitFilter(filter);
|
||||||
Vector3 extent(DEFAULT_NAV_QUERY_EXTENT_HORIZONTAL, DEFAULT_NAV_QUERY_EXTENT_VERTICAL, DEFAULT_NAV_QUERY_EXTENT_HORIZONTAL);
|
Vector3 extent = Properties.DefaultQueryExtent;
|
||||||
|
|
||||||
Vector3 startPositionNavMesh, endPositionNavMesh;
|
Vector3 startPositionNavMesh, endPositionNavMesh;
|
||||||
Vector3::Transform(startPosition, Properties.Rotation, startPositionNavMesh);
|
Vector3::Transform(startPosition, Properties.Rotation, startPositionNavMesh);
|
||||||
@@ -211,7 +208,7 @@ bool NavMeshRuntime::ProjectPoint(const Vector3& point, Vector3& result) const
|
|||||||
|
|
||||||
dtQueryFilter filter;
|
dtQueryFilter filter;
|
||||||
InitFilter(filter);
|
InitFilter(filter);
|
||||||
Vector3 extent(DEFAULT_NAV_QUERY_EXTENT_HORIZONTAL, DEFAULT_NAV_QUERY_EXTENT_VERTICAL, DEFAULT_NAV_QUERY_EXTENT_HORIZONTAL);
|
Vector3 extent = Properties.DefaultQueryExtent;
|
||||||
|
|
||||||
Vector3 pointNavMesh;
|
Vector3 pointNavMesh;
|
||||||
Vector3::Transform(point, Properties.Rotation, pointNavMesh);
|
Vector3::Transform(point, Properties.Rotation, pointNavMesh);
|
||||||
@@ -269,7 +266,7 @@ bool NavMeshRuntime::FindRandomPointAroundCircle(const Vector3& center, float ra
|
|||||||
|
|
||||||
dtQueryFilter filter;
|
dtQueryFilter filter;
|
||||||
InitFilter(filter);
|
InitFilter(filter);
|
||||||
Vector3 extent(DEFAULT_NAV_QUERY_EXTENT_HORIZONTAL, DEFAULT_NAV_QUERY_EXTENT_VERTICAL, DEFAULT_NAV_QUERY_EXTENT_HORIZONTAL);
|
Vector3 extent = Properties.DefaultQueryExtent;
|
||||||
|
|
||||||
Vector3 centerNavMesh;
|
Vector3 centerNavMesh;
|
||||||
Vector3::Transform(center, Properties.Rotation, centerNavMesh);
|
Vector3::Transform(center, Properties.Rotation, centerNavMesh);
|
||||||
@@ -307,7 +304,7 @@ bool NavMeshRuntime::RayCast(const Vector3& startPosition, const Vector3& endPos
|
|||||||
|
|
||||||
dtQueryFilter filter;
|
dtQueryFilter filter;
|
||||||
InitFilter(filter);
|
InitFilter(filter);
|
||||||
Vector3 extent(DEFAULT_NAV_QUERY_EXTENT_HORIZONTAL, DEFAULT_NAV_QUERY_EXTENT_VERTICAL, DEFAULT_NAV_QUERY_EXTENT_HORIZONTAL);
|
Vector3 extent = Properties.DefaultQueryExtent;
|
||||||
|
|
||||||
Vector3 startPositionNavMesh, endPositionNavMesh;
|
Vector3 startPositionNavMesh, endPositionNavMesh;
|
||||||
Vector3::Transform(startPosition, Properties.Rotation, startPositionNavMesh);
|
Vector3::Transform(startPosition, Properties.Rotation, startPositionNavMesh);
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ bool NavAreaProperties::operator==(const NavAreaProperties& other) const
|
|||||||
|
|
||||||
bool NavMeshProperties::operator==(const NavMeshProperties& other) const
|
bool NavMeshProperties::operator==(const NavMeshProperties& other) const
|
||||||
{
|
{
|
||||||
return Name == other.Name && Quaternion::NearEqual(Rotation, other.Rotation, 0.001f) && Agent == other.Agent;
|
return Name == other.Name && Quaternion::NearEqual(Rotation, other.Rotation, 0.001f) && Agent == other.Agent && Vector3::NearEqual(DefaultQueryExtent, other.DefaultQueryExtent);
|
||||||
}
|
}
|
||||||
|
|
||||||
class NavigationService : public EngineService
|
class NavigationService : public EngineService
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
|
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
|
|
||||||
namespace FlaxEditor.Content.Settings
|
namespace FlaxEditor.Content.Settings
|
||||||
@@ -22,6 +23,7 @@ namespace FlaxEditor.Content.Settings
|
|||||||
navMesh.Agent.Height = 144.0f;
|
navMesh.Agent.Height = 144.0f;
|
||||||
navMesh.Agent.StepHeight = 35.0f;
|
navMesh.Agent.StepHeight = 35.0f;
|
||||||
navMesh.Agent.MaxSlopeAngle = 60.0f;
|
navMesh.Agent.MaxSlopeAngle = 60.0f;
|
||||||
|
navMesh.DefaultQueryExtent = new Vector3(50.0f, 250.0f, 50.0f);
|
||||||
|
|
||||||
// Init nav areas
|
// Init nav areas
|
||||||
NavAreas = new NavAreaProperties[2];
|
NavAreas = new NavAreaProperties[2];
|
||||||
@@ -51,6 +53,7 @@ namespace FlaxEditor.Content.Settings
|
|||||||
navMesh.Agent.Height = 144.0f;
|
navMesh.Agent.Height = 144.0f;
|
||||||
navMesh.Agent.StepHeight = 35.0f;
|
navMesh.Agent.StepHeight = 35.0f;
|
||||||
navMesh.Agent.MaxSlopeAngle = 60.0f;
|
navMesh.Agent.MaxSlopeAngle = 60.0f;
|
||||||
|
navMesh.DefaultQueryExtent = new Vector3(50.0f, 250.0f, 50.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Deprecated on 12.01.2021, expires on 12.01.2022]
|
// [Deprecated on 12.01.2021, expires on 12.01.2022]
|
||||||
@@ -105,6 +108,23 @@ namespace FlaxEditor.Content.Settings
|
|||||||
|
|
||||||
namespace FlaxEngine
|
namespace FlaxEngine
|
||||||
{
|
{
|
||||||
|
partial struct NavMeshProperties
|
||||||
|
{
|
||||||
|
[OnDeserialized]
|
||||||
|
internal void OnDeserialized(StreamingContext context)
|
||||||
|
{
|
||||||
|
// [Deprecated on 07.04.2021, expires on 07.04.2022]
|
||||||
|
if (DefaultQueryExtent.IsZero)
|
||||||
|
DefaultQueryExtent = new Vector3(50.0f, 250.0f, 50.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
partial struct NavAgentProperties
|
partial struct NavAgentProperties
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -83,6 +83,12 @@ DECLARE_SCRIPTING_TYPE_MINIMAL(NavMeshProperties);
|
|||||||
API_FIELD(Attributes="EditorOrder(30)")
|
API_FIELD(Attributes="EditorOrder(30)")
|
||||||
NavAgentProperties Agent;
|
NavAgentProperties Agent;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The default extents for the nav queries that defines the search distance along each axis (x, y, z). Smaller values prevent queries from snapping to too far locations.
|
||||||
|
/// </summary>
|
||||||
|
API_FIELD(Attributes="EditorOrder(40)")
|
||||||
|
Vector3 DefaultQueryExtent = Vector3(50.0f, 250.0f, 50.0f);
|
||||||
|
|
||||||
bool operator==(const NavMeshProperties& other) const;
|
bool operator==(const NavMeshProperties& other) const;
|
||||||
|
|
||||||
bool operator!=(const NavMeshProperties& other) const
|
bool operator!=(const NavMeshProperties& other) const
|
||||||
|
|||||||
Reference in New Issue
Block a user