mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 23:36:41 +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 {
|
} else {
|
||||||
// I am not looking at anyone else, so just look forward
|
// I am not looking at anyone else, so just look forward
|
||||||
if (isHMD) {
|
if (isHMD) {
|
||||||
glm::mat4 headPose = getActiveDisplayPlugin()->getHeadPose();
|
glm::mat4 headPose = _avatarUpdate->getHeadPose();
|
||||||
glm::quat headRotation = glm::quat_cast(headPose);
|
glm::quat headRotation = glm::quat_cast(headPose);
|
||||||
lookAtSpot = _myCamera.getPosition() +
|
lookAtSpot = _myCamera.getPosition() +
|
||||||
_myAvatar->getOrientation() * (headRotation * glm::vec3(0.0f, 0.0f, -TREE_SCALE));
|
_myAvatar->getOrientation() * (headRotation * glm::vec3(0.0f, 0.0f, -TREE_SCALE));
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "AvatarManager.h"
|
#include "AvatarManager.h"
|
||||||
#include "AvatarUpdate.h"
|
#include "AvatarUpdate.h"
|
||||||
|
#include <display-plugins/DisplayPlugin.h>
|
||||||
#include "InterfaceLogging.h"
|
#include "InterfaceLogging.h"
|
||||||
|
|
||||||
// GenericThread accepts an optional "parent" argument, defaulting to nullptr.
|
// 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.
|
setObjectName("Avatar Update"); // GenericThread::initialize uses this to set the thread name.
|
||||||
Settings settings;
|
Settings settings;
|
||||||
const int DEFAULT_TARGET_AVATAR_SIMRATE = 60;
|
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();
|
_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.
|
// 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
|
// 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() {
|
void AvatarUpdate::initTimer() {
|
||||||
const qint64 AVATAR_UPDATE_INTERVAL_MSECS = 1000 / _targetSimrate;
|
|
||||||
_timer = new QTimer(this);
|
_timer = new QTimer(this);
|
||||||
connect(_timer, &QTimer::timeout, this, &AvatarUpdate::process);
|
connect(_timer, &QTimer::timeout, this, &AvatarUpdate::process);
|
||||||
_timer->start(AVATAR_UPDATE_INTERVAL_MSECS);
|
_timer->start(_targetInterval / USECS_PER_MSEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarUpdate::synchronousProcess() {
|
void AvatarUpdate::synchronousProcess() {
|
||||||
|
|
||||||
// Keep our own updated value, so that our asynchronous code can consult it.
|
// Keep our own updated value, so that our asynchronous code can consult it.
|
||||||
_isHMDMode = Application::getInstance()->isHMDMode();
|
_isHMDMode = Application::getInstance()->isHMDMode();
|
||||||
|
_headPose = Application::getInstance()->getActiveDisplayPlugin()->getHeadPose();
|
||||||
|
|
||||||
if (_updateBillboard) {
|
if (_updateBillboard) {
|
||||||
Application::getInstance()->getMyAvatar()->doUpdateBillboard();
|
Application::getInstance()->getMyAvatar()->doUpdateBillboard();
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
private:
|
private:
|
||||||
virtual bool process(); // No reason for other classes to invoke this.
|
virtual bool process(); // No reason for other classes to invoke this.
|
||||||
void initTimer();
|
void initTimer();
|
||||||
int _targetSimrate;
|
quint64 _targetInterval;
|
||||||
bool _updateBillboard;
|
bool _updateBillboard;
|
||||||
QTimer* _timer;
|
QTimer* _timer;
|
||||||
quint64 _lastAvatarUpdate;
|
quint64 _lastAvatarUpdate;
|
||||||
|
@ -58,11 +58,13 @@ private:
|
||||||
QThread* _thread;
|
QThread* _thread;
|
||||||
void initThread();
|
void initThread();
|
||||||
|
|
||||||
// Goes away if Applicaiton::isHMDMode() is made thread safe:
|
// Goes away if Applicaiton::isHMDMode() and friends are made thread safe:
|
||||||
public:
|
public:
|
||||||
bool isHMDMode() { return _isHMDMode; }
|
bool isHMDMode() { return _isHMDMode; }
|
||||||
|
glm::mat4 getHeadPose() { return _headPose; }
|
||||||
private:
|
private:
|
||||||
bool _isHMDMode;
|
bool _isHMDMode;
|
||||||
|
glm::mat4 _headPose;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue