Merge pull request #3751 from ZappoMan/entityBugs

various entity bug fixes
This commit is contained in:
Philip Rosedale 2014-11-06 19:42:23 -08:00
commit 3323ac11ff
3 changed files with 37 additions and 7 deletions

View file

@ -185,7 +185,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_trayIcon(new QSystemTrayIcon(_window)),
_lastNackTime(usecTimestampNow()),
_lastSendDownstreamAudioStats(usecTimestampNow()),
_isVSyncOn(true)
_isVSyncOn(true),
_aboutToQuit(false)
{
// read the ApplicationInfo.ini file for Name/Version/Domain information
@ -255,6 +256,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
connect(&domainHandler, SIGNAL(connectedToDomain(const QString&)), SLOT(connectedToDomain(const QString&)));
connect(&domainHandler, SIGNAL(connectedToDomain(const QString&)), SLOT(updateWindowTitle()));
connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle()));
connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails()));
connect(&domainHandler, &DomainHandler::settingsReceived, this, &Application::domainSettingsReceived);
connect(&domainHandler, &DomainHandler::hostnameChanged, Menu::getInstance(), &Menu::clearLoginDialogDisplayedFlag);
@ -389,6 +391,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript);
connect(this, SIGNAL(aboutToQuit()), this, SLOT(saveScripts()));
connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
// check first run...
QVariant firstRunValue = _settings->value("firstRun",QVariant(true));
@ -422,6 +425,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
this->installEventFilter(this);
}
void Application::aboutToQuit() {
_aboutToQuit = true;
}
Application::~Application() {
qInstallMessageHandler(NULL);
@ -1254,7 +1261,9 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) {
showMouse = false;
}
_entities.mouseMoveEvent(event, deviceID);
if (!_aboutToQuit) {
_entities.mouseMoveEvent(event, deviceID);
}
_controllerScriptingInterface.emitMouseMoveEvent(event, deviceID); // send events to any registered scripts
@ -1277,7 +1286,9 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) {
void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
_entities.mousePressEvent(event, deviceID);
if (!_aboutToQuit) {
_entities.mousePressEvent(event, deviceID);
}
_controllerScriptingInterface.emitMousePressEvent(event); // send events to any registered scripts
@ -1318,7 +1329,9 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
_entities.mouseReleaseEvent(event, deviceID);
if (!_aboutToQuit) {
_entities.mouseReleaseEvent(event, deviceID);
}
_controllerScriptingInterface.emitMouseReleaseEvent(event); // send events to any registered scripts
@ -3565,9 +3578,8 @@ void Application::changeDomainHostname(const QString &newDomainHostname) {
}
}
void Application::domainChanged(const QString& domainHostname) {
updateWindowTitle();
void Application::clearDomainOctreeDetails() {
qDebug() << "Clearing domain octree details...";
// reset the environment so that we don't erroneously end up with multiple
_environment.resetToDefault();
@ -3576,7 +3588,13 @@ void Application::domainChanged(const QString& domainHostname) {
_voxelServerJurisdictions.clear();
_voxelServerJurisdictions.unlock();
_entityServerJurisdictions.lockForWrite();
_entityServerJurisdictions.clear();
_entityServerJurisdictions.unlock();
_octreeSceneStatsLock.lockForWrite();
_octreeServerSceneStats.clear();
_octreeSceneStatsLock.unlock();
// reset the model renderer
_entities.clear();
@ -3585,6 +3603,11 @@ void Application::domainChanged(const QString& domainHostname) {
_voxels.killLocalVoxels();
}
void Application::domainChanged(const QString& domainHostname) {
updateWindowTitle();
clearDomainOctreeDetails();
}
void Application::connectedToDomain(const QString& hostname) {
AccountManager& accountManager = AccountManager::getInstance();
const QUuid& domainID = NodeList::getInstance()->getDomainHandler().getUUID();

View file

@ -306,6 +306,7 @@ public:
unsigned int getRenderTargetFramerate() const;
bool isVSyncOn() const;
bool isVSyncEditable() const;
bool isAboutToQuit() const { return _aboutToQuit; }
void registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine);
@ -377,8 +378,10 @@ public slots:
void resetSensors();
private slots:
void clearDomainOctreeDetails();
void timer();
void idle();
void aboutToQuit();
void connectedToDomain(const QString& hostname);
@ -625,6 +628,8 @@ private:
quint64 _lastSendDownstreamAudioStats;
bool _isVSyncOn;
bool _aboutToQuit;
};
#endif // hifi_Application_h

View file

@ -196,6 +196,7 @@ void EntityTreeRenderer::update() {
void EntityTreeRenderer::checkEnterLeaveEntities() {
if (_tree) {
_tree->lockForRead();
glm::vec3 avatarPosition = Application::getInstance()->getAvatar()->getPosition() / (float) TREE_SCALE;
if (avatarPosition != _lastAvatarPosition) {
@ -240,6 +241,7 @@ void EntityTreeRenderer::checkEnterLeaveEntities() {
_currentEntitiesInside = entitiesContainingAvatar;
_lastAvatarPosition = avatarPosition;
}
_tree->unlock();
}
}