Add support for dynamic updating navmesh when moving NavModifierVolume
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
|
||||
#include "NavModifierVolume.h"
|
||||
#include "NavigationSettings.h"
|
||||
#include "NavMeshBuilder.h"
|
||||
#include "Engine/Level/Scene/Scene.h"
|
||||
#include "Engine/Serialization/Serialization.h"
|
||||
#if USE_EDITOR
|
||||
#include "Editor/Editor.h"
|
||||
#include "Editor/Managed/ManagedEditor.h"
|
||||
#include "NavMeshBuilder.h"
|
||||
#endif
|
||||
|
||||
NavModifierVolume::NavModifierVolume(const SpawnParams& params)
|
||||
@@ -47,19 +47,35 @@ void NavModifierVolume::Deserialize(DeserializeStream& stream, ISerializeModifie
|
||||
DESERIALIZE(AreaName);
|
||||
}
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
void NavModifierVolume::OnBoundsChanged(const BoundingBox& prevBounds)
|
||||
{
|
||||
#if COMPILE_WITH_NAV_MESH_BUILDER
|
||||
// Auto-rebuild modified navmesh area
|
||||
if (IsDuringPlay() && IsActiveInHierarchy() && !Editor::IsPlayMode && Editor::Managed->CanAutoBuildNavMesh())
|
||||
if (
|
||||
IsDuringPlay() && IsActiveInHierarchy() && HasStaticFlag(StaticFlags::Navigation) &&
|
||||
(
|
||||
// Build at runtime for dynamic modifiers
|
||||
!HasStaticFlag(StaticFlags::Transform)
|
||||
#if USE_EDITOR
|
||||
// Build in editor when using auto-rebuild option
|
||||
|| (!Editor::IsPlayMode && Editor::Managed->CanAutoBuildNavMesh())
|
||||
#endif
|
||||
))
|
||||
{
|
||||
BoundingBox dirtyBounds;
|
||||
BoundingBox::Merge(prevBounds, _box, dirtyBounds);
|
||||
NavMeshBuilder::Build(GetScene(), dirtyBounds, ManagedEditor::ManagedEditorOptions.AutoRebuildNavMeshTimeoutMs);
|
||||
#if USE_EDITOR
|
||||
const float timeoutMs = ManagedEditor::ManagedEditorOptions.AutoRebuildNavMeshTimeoutMs;
|
||||
#else
|
||||
const float timeoutMs = 0.0f;
|
||||
#endif
|
||||
NavMeshBuilder::Build(GetScene(), dirtyBounds, timeoutMs);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
Color NavModifierVolume::GetWiresColor()
|
||||
{
|
||||
return Color::Red;
|
||||
|
||||
@@ -41,8 +41,8 @@ public:
|
||||
protected:
|
||||
|
||||
// [BoxVolume]
|
||||
#if USE_EDITOR
|
||||
void OnBoundsChanged(const BoundingBox& prevBounds) override;
|
||||
#if USE_EDITOR
|
||||
Color GetWiresColor() override;
|
||||
#endif
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user