performance/Tutorial_TimeSlicing.cpp

performance/Tutorial_TimeSlicing.cpp
/*
* Copyright 2016 Autodesk, Inc. All rights reserved.
* Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
* or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
*/
#include "common/oneworldenv.h"
namespace
{
#define KT_TEST_ENV_CLASS OneWorldEnv
KT_TEST_ENV {}
// This Tutorial shows how to configure the budget for each query queue that is created by default by Navigation.
KT_TEST
{
KT_LOG_TITLE_BEGIN("TUTORIAL - How to configure TimeSlicing in Navigation");
KT_ASSERT(KT_ENV.AddNavData("generated/canyon/canyon.NavData") != nullptr);
Kaim::World* navWorld = KT_ENV.GetNavWorld();
const KyFloat32 defaultBudget = 0.5f;
const KyFloat32 pathFinderBudget = 2.0f;
const KyFloat32 dynamicNavMeshBudget = 1.0f;
const KyFloat32 pathFollowerBudget = 0.5f;
Kaim::QueryQueue* defaultQueue = navWorld->GetAsyncQueryDispatcher()->GetQueue(nullptr, Kaim::AsyncQueryDispatchId_Default);
Kaim::QueryQueue* pathFinderQueue = navWorld->GetAsyncQueryDispatcher()->GetQueue(nullptr, Kaim::AsyncQueryDispatchId_PathFinder);
Kaim::QueryQueue* dynamicNavMeshQueue = navWorld->GetAsyncQueryDispatcher()->GetQueue(nullptr, Kaim::AsyncQueryDispatchId_DynamicNavMesh);
Kaim::QueryQueue* pathFollowerQueue = navWorld->GetAsyncQueryDispatcher()->GetQueue(nullptr, Kaim::AsyncQueryDispatchId_PathFollower);
defaultQueue->SetBudgetMs(defaultBudget);
pathFinderQueue->SetBudgetMs(pathFinderBudget);
dynamicNavMeshQueue->SetBudgetMs(dynamicNavMeshBudget);
pathFollowerQueue->SetBudgetMs(pathFollowerBudget);
KT_ASSERT(defaultQueue->GetBudgetMs() == defaultBudget);
KT_ASSERT(pathFinderQueue->GetBudgetMs() == pathFinderBudget);
KT_ASSERT(dynamicNavMeshQueue->GetBudgetMs() == dynamicNavMeshBudget);
KT_ASSERT(pathFollowerQueue->GetBudgetMs() == pathFollowerBudget);
}
}