mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 14:33:31 +02:00
displayPlugin is not thread safe, and switch from simulate rate to interval in prep for sleep.
This commit is contained in:
parent
b8ca604bf8
commit
38bc8634de
3 changed files with 10 additions and 7 deletions
|
@ -2588,7 +2588,7 @@ void Application::updateMyAvatarLookAtPosition() {
|
|||
} else {
|
||||
// I am not looking at anyone else, so just look forward
|
||||
if (isHMD) {
|
||||
glm::mat4 headPose = getActiveDisplayPlugin()->getHeadPose();
|
||||
glm::mat4 headPose = _avatarUpdate->getHeadPose();
|
||||
glm::quat headRotation = glm::quat_cast(headPose);
|
||||
lookAtSpot = _myCamera.getPosition() +
|
||||
_myAvatar->getOrientation() * (headRotation * glm::vec3(0.0f, 0.0f, -TREE_SCALE));
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "Application.h"
|
||||
#include "AvatarManager.h"
|
||||
#include "AvatarUpdate.h"
|
||||
#include <display-plugins/DisplayPlugin.h>
|
||||
#include "InterfaceLogging.h"
|
||||
|
||||
// GenericThread accepts an optional "parent" argument, defaulting to nullptr.
|
||||
|
@ -27,9 +28,9 @@ AvatarUpdate::AvatarUpdate() : QObject(nullptr), _timer(nullptr), _lastAvatarUp
|
|||
setObjectName("Avatar Update"); // GenericThread::initialize uses this to set the thread name.
|
||||
Settings settings;
|
||||
const int DEFAULT_TARGET_AVATAR_SIMRATE = 60;
|
||||
_targetSimrate = settings.value("AvatarUpdateTargetSimrate", DEFAULT_TARGET_AVATAR_SIMRATE).toInt();
|
||||
_targetInterval = USECS_PER_SECOND / settings.value("AvatarUpdateTargetSimrate", DEFAULT_TARGET_AVATAR_SIMRATE).toInt();
|
||||
_type = settings.value("AvatarUpdateType", UpdateType::Synchronous).toInt();
|
||||
qCDebug(interfaceapp) << "AvatarUpdate using" << _type << "at" << _targetSimrate << "sims/second";
|
||||
qCDebug(interfaceapp) << "AvatarUpdate using" << _type << "at" << _targetInterval << "microseconds";
|
||||
}
|
||||
// We could have the constructor call initialize(), but GenericThread::initialize can take parameters.
|
||||
// Keeping it separately called by the client allows that client to pass those without our
|
||||
|
@ -59,16 +60,16 @@ void AvatarUpdate::threadRoutine() {
|
|||
}
|
||||
}
|
||||
void AvatarUpdate::initTimer() {
|
||||
const qint64 AVATAR_UPDATE_INTERVAL_MSECS = 1000 / _targetSimrate;
|
||||
_timer = new QTimer(this);
|
||||
connect(_timer, &QTimer::timeout, this, &AvatarUpdate::process);
|
||||
_timer->start(AVATAR_UPDATE_INTERVAL_MSECS);
|
||||
_timer->start(_targetInterval / USECS_PER_MSEC);
|
||||
}
|
||||
|
||||
void AvatarUpdate::synchronousProcess() {
|
||||
|
||||
// Keep our own updated value, so that our asynchronous code can consult it.
|
||||
_isHMDMode = Application::getInstance()->isHMDMode();
|
||||
_headPose = Application::getInstance()->getActiveDisplayPlugin()->getHeadPose();
|
||||
|
||||
if (_updateBillboard) {
|
||||
Application::getInstance()->getMyAvatar()->doUpdateBillboard();
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
private:
|
||||
virtual bool process(); // No reason for other classes to invoke this.
|
||||
void initTimer();
|
||||
int _targetSimrate;
|
||||
quint64 _targetInterval;
|
||||
bool _updateBillboard;
|
||||
QTimer* _timer;
|
||||
quint64 _lastAvatarUpdate;
|
||||
|
@ -58,11 +58,13 @@ private:
|
|||
QThread* _thread;
|
||||
void initThread();
|
||||
|
||||
// Goes away if Applicaiton::isHMDMode() is made thread safe:
|
||||
// Goes away if Applicaiton::isHMDMode() and friends are made thread safe:
|
||||
public:
|
||||
bool isHMDMode() { return _isHMDMode; }
|
||||
glm::mat4 getHeadPose() { return _headPose; }
|
||||
private:
|
||||
bool _isHMDMode;
|
||||
glm::mat4 _headPose;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue