Add SceneNavigation for scene data for navigation system

This commit is contained in:
Wojtek Figat
2021-06-27 22:41:43 +02:00
parent d9fe1b257f
commit e61ebaa71b
11 changed files with 182 additions and 178 deletions

View File

@@ -30,13 +30,37 @@ bool SceneAsset::IsInternalType() const
return true;
}
BoundingBox SceneNavigation::GetNavigationBounds()
{
if (Volumes.IsEmpty())
return BoundingBox::Empty;
PROFILE_CPU_NAMED("GetNavigationBounds");
auto box = Volumes[0]->GetBox();
for (int32 i = 1; i < Volumes.Count(); i++)
BoundingBox::Merge(box, Volumes[i]->GetBox(), box);
return box;
}
NavMeshBoundsVolume* SceneNavigation::FindNavigationBoundsOverlap(const BoundingBox& bounds)
{
NavMeshBoundsVolume* result = nullptr;
for (int32 i = 0; i < Volumes.Count(); i++)
{
if (Volumes[i]->GetBox().Intersects(bounds))
{
result = Volumes[i];
break;
}
}
return result;
}
#define CSG_COLLIDER_NAME TEXT("CSG.Collider")
#define CSG_MODEL_NAME TEXT("CSG.Model")
Scene::Scene(const SpawnParams& params)
: Actor(params)
, Rendering(this)
, Ticking(this)
, LightmapsData(this)
, CSGData(this)
{
@@ -65,31 +89,6 @@ void Scene::SetLightmapSettings(const LightmapSettings& value)
Info.LightmapSettings = value;
}
BoundingBox Scene::GetNavigationBounds()
{
if (NavigationVolumes.IsEmpty())
return BoundingBox::Empty;
PROFILE_CPU_NAMED("GetNavigationBounds");
auto box = NavigationVolumes[0]->GetBox();
for (int32 i = 1; i < NavigationVolumes.Count(); i++)
BoundingBox::Merge(box, NavigationVolumes[i]->GetBox(), box);
return box;
}
NavMeshBoundsVolume* Scene::FindNavigationBoundsOverlap(const BoundingBox& bounds)
{
NavMeshBoundsVolume* result = nullptr;
for (int32 i = 0; i < NavigationVolumes.Count(); i++)
{
if (NavigationVolumes[i]->GetBox().Intersects(bounds))
{
result = NavigationVolumes[i];
break;
}
}
return result;
}
void Scene::ClearLightmaps()
{
LightmapsData.ClearLightmaps();
@@ -283,7 +282,7 @@ void Scene::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
CSGData.DeserializeIfExists(stream, "CSG", modifier);
// [Deprecated on 13.01.2021, expires on 13.01.2023]
if (modifier->EngineBuild <= 6215 && NavigationMeshes.IsEmpty())
if (modifier->EngineBuild <= 6215 && Navigation.Meshes.IsEmpty())
{
const auto e = SERIALIZE_FIND_MEMBER(stream, "NavMesh");
if (e != stream.MemberEnd())