performance/Tutorial_TimeSlicing.cpp

performance/Tutorial_TimeSlicing.cpp
/*
* Copyright 2015 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"
//RUN_THIS_FILE
namespace
{
#define TEST_ENV_CLASS OneWorldEnv
TEST_ENV {}
// This Tutorial shows how to configure the budget for each query queue that is created by default by Navigation.
TEST
{
KT_LOG_TITLE_BEGIN("TUTORIAL - How to configure TimeSlicing in Navigation");
CHECK(env.LoadAndAddNavData("GeneratedNavData/canyon/canyon_1m_zup.NavData") != KY_NULL);
Kaim::World* navWorld = env.GetWorld();
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(KY_NULL, Kaim::AsyncQueryDispatchId_Default);
Kaim::QueryQueue* pathFinderQueue = navWorld->GetAsyncQueryDispatcher()->GetQueue(KY_NULL, Kaim::AsyncQueryDispatchId_PathFinder);
Kaim::QueryQueue* dynamicNavMeshQueue = navWorld->GetAsyncQueryDispatcher()->GetQueue(KY_NULL, Kaim::AsyncQueryDispatchId_DynamicNavMesh);
Kaim::QueryQueue* pathFollowerQueue = navWorld->GetAsyncQueryDispatcher()->GetQueue(KY_NULL, Kaim::AsyncQueryDispatchId_PathFollower);
defaultQueue->SetBudgetMs(defaultBudget);
pathFinderQueue->SetBudgetMs(pathFinderBudget);
dynamicNavMeshQueue->SetBudgetMs(dynamicNavMeshBudget);
pathFollowerQueue->SetBudgetMs(pathFollowerBudget);
CHECK(defaultQueue->GetBudgetMs() == defaultBudget);
CHECK(pathFinderQueue->GetBudgetMs() == pathFinderBudget);
CHECK(dynamicNavMeshQueue->GetBudgetMs() == dynamicNavMeshBudget);
CHECK(pathFollowerQueue->GetBudgetMs() == pathFollowerBudget);
}
}