bot: switch look/body angles updates to thread worker

build: msvc projects now again targets msvc by default
This commit is contained in:
jeefo 2023-06-28 19:48:51 +03:00
commit 5ce2032acd
No known key found for this signature in database
GPG key ID: 927BCA0779BEA8ED
8 changed files with 59 additions and 35 deletions

View file

@ -337,7 +337,18 @@ void Bot::updateBodyAngles () {
}
void Bot::updateLookAngles () {
const float delta = cr::clamp (game.time () - m_lookUpdateTime, cr::kFloatEqualEpsilon, 1.0f / 30.0f);
worker.enqueue ([this] () {
syncUpdateLookAngles ();
});
}
void Bot::syncUpdateLookAngles () {
if (!m_lookAnglesLock.tryLock ()) {
return; // allow only single instance of syncUpdateLookAngles per-bot
}
ScopedUnlock <Mutex> unlock (m_lookAnglesLock);
const float delta = cr::clamp (game.time () - m_lookUpdateTime, cr::kFloatEqualEpsilon, kViewFrameUpdate);
m_lookUpdateTime = game.time ();
// adjust all body and view angles to face an absolute vector