mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 11:37:58 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into json-skip-default-values
This commit is contained in:
commit
a0ad7a22a6
20 changed files with 557 additions and 31 deletions
|
@ -114,7 +114,23 @@ void AssignmentClient::stopAssignmentClient() {
|
||||||
qDebug() << "Exiting.";
|
qDebug() << "Exiting.";
|
||||||
_requestTimer.stop();
|
_requestTimer.stop();
|
||||||
_statsTimerACM.stop();
|
_statsTimerACM.stop();
|
||||||
QCoreApplication::quit();
|
if (_currentAssignment) {
|
||||||
|
_currentAssignment->aboutToQuit();
|
||||||
|
QThread* currentAssignmentThread = _currentAssignment->thread();
|
||||||
|
currentAssignmentThread->quit();
|
||||||
|
currentAssignmentThread->wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AssignmentClient::aboutToQuit() {
|
||||||
|
stopAssignmentClient();
|
||||||
|
// clear the log handler so that Qt doesn't call the destructor on LogHandler
|
||||||
|
qInstallMessageHandler(0);
|
||||||
|
// clear out pointer to the assignment so the destructor gets called. if we don't do this here,
|
||||||
|
// it will get destroyed along with all the other "static" stuff. various static member variables
|
||||||
|
// will be destroyed first and things go wrong.
|
||||||
|
_currentAssignment.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -197,6 +213,7 @@ void AssignmentClient::readPendingDatagrams() {
|
||||||
|
|
||||||
// start the deployed assignment
|
// start the deployed assignment
|
||||||
AssignmentThread* workerThread = new AssignmentThread(_currentAssignment, this);
|
AssignmentThread* workerThread = new AssignmentThread(_currentAssignment, this);
|
||||||
|
workerThread->setObjectName("worker");
|
||||||
|
|
||||||
connect(workerThread, &QThread::started, _currentAssignment.data(), &ThreadedAssignment::run);
|
connect(workerThread, &QThread::started, _currentAssignment.data(), &ThreadedAssignment::run);
|
||||||
connect(_currentAssignment.data(), &ThreadedAssignment::finished, workerThread, &QThread::quit);
|
connect(_currentAssignment.data(), &ThreadedAssignment::finished, workerThread, &QThread::quit);
|
||||||
|
|
|
@ -34,6 +34,9 @@ private slots:
|
||||||
void sendStatsPacketToACM();
|
void sendStatsPacketToACM();
|
||||||
void stopAssignmentClient();
|
void stopAssignmentClient();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void aboutToQuit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setUpStatsToMonitor(int ppid);
|
void setUpStatsToMonitor(int ppid);
|
||||||
Assignment _requestAssignment;
|
Assignment _requestAssignment;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
#include <LogHandler.h>
|
#include <LogHandler.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
@ -180,14 +181,19 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QThread::currentThread()->setObjectName("main thread");
|
||||||
|
|
||||||
|
DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
|
||||||
|
|
||||||
if (numForks || minForks || maxForks) {
|
if (numForks || minForks || maxForks) {
|
||||||
AssignmentClientMonitor monitor(numForks, minForks, maxForks, requestAssignmentType, assignmentPool,
|
AssignmentClientMonitor monitor(numForks, minForks, maxForks, requestAssignmentType, assignmentPool,
|
||||||
walletUUID, assignmentServerHostname, assignmentServerPort);
|
walletUUID, assignmentServerHostname, assignmentServerPort);
|
||||||
|
connect(this, &QCoreApplication::aboutToQuit, &monitor, &AssignmentClientMonitor::aboutToQuit);
|
||||||
exec();
|
exec();
|
||||||
} else {
|
} else {
|
||||||
AssignmentClient client(ppid, requestAssignmentType, assignmentPool,
|
AssignmentClient client(ppid, requestAssignmentType, assignmentPool,
|
||||||
walletUUID, assignmentServerHostname, assignmentServerPort);
|
walletUUID, assignmentServerHostname, assignmentServerPort);
|
||||||
|
connect(this, &QCoreApplication::aboutToQuit, &client, &AssignmentClient::aboutToQuit);
|
||||||
exec();
|
exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,17 @@ AssignmentClientMonitor::~AssignmentClientMonitor() {
|
||||||
stopChildProcesses();
|
stopChildProcesses();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AssignmentClientMonitor::waitOnChildren(int msecs) {
|
||||||
|
QMutableListIterator<QProcess*> i(_childProcesses);
|
||||||
|
while (i.hasNext()) {
|
||||||
|
QProcess* childProcess = i.next();
|
||||||
|
bool finished = childProcess->waitForFinished(msecs);
|
||||||
|
if (finished) {
|
||||||
|
i.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AssignmentClientMonitor::stopChildProcesses() {
|
void AssignmentClientMonitor::stopChildProcesses() {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
||||||
|
@ -78,11 +89,22 @@ void AssignmentClientMonitor::stopChildProcesses() {
|
||||||
QByteArray diePacket = byteArrayWithPopulatedHeader(PacketTypeStopNode);
|
QByteArray diePacket = byteArrayWithPopulatedHeader(PacketTypeStopNode);
|
||||||
nodeList->writeUnverifiedDatagram(diePacket, *node->getActiveSocket());
|
nodeList->writeUnverifiedDatagram(diePacket, *node->getActiveSocket());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// try to give all the children time to shutdown
|
||||||
|
waitOnChildren(15000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AssignmentClientMonitor::aboutToQuit() {
|
||||||
|
stopChildProcesses();
|
||||||
|
// clear the log handler so that Qt doesn't call the destructor on LogHandler
|
||||||
|
qInstallMessageHandler(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssignmentClientMonitor::spawnChildClient() {
|
void AssignmentClientMonitor::spawnChildClient() {
|
||||||
QProcess *assignmentClient = new QProcess(this);
|
QProcess *assignmentClient = new QProcess(this);
|
||||||
|
|
||||||
|
_childProcesses.append(assignmentClient);
|
||||||
|
|
||||||
// unparse the parts of the command-line that the child cares about
|
// unparse the parts of the command-line that the child cares about
|
||||||
QStringList _childArguments;
|
QStringList _childArguments;
|
||||||
if (_assignmentPool != "") {
|
if (_assignmentPool != "") {
|
||||||
|
@ -119,8 +141,6 @@ void AssignmentClientMonitor::spawnChildClient() {
|
||||||
qDebug() << "Spawned a child client with PID" << assignmentClient->pid();
|
qDebug() << "Spawned a child client with PID" << assignmentClient->pid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AssignmentClientMonitor::checkSpares() {
|
void AssignmentClientMonitor::checkSpares() {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
QUuid aSpareId = "";
|
QUuid aSpareId = "";
|
||||||
|
@ -156,6 +176,8 @@ void AssignmentClientMonitor::checkSpares() {
|
||||||
nodeList->writeUnverifiedDatagram(diePacket, childNode);
|
nodeList->writeUnverifiedDatagram(diePacket, childNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
waitOnChildren(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,16 @@ public:
|
||||||
QString assignmentPool, QUuid walletUUID, QString assignmentServerHostname,
|
QString assignmentPool, QUuid walletUUID, QString assignmentServerHostname,
|
||||||
quint16 assignmentServerPort);
|
quint16 assignmentServerPort);
|
||||||
~AssignmentClientMonitor();
|
~AssignmentClientMonitor();
|
||||||
|
|
||||||
|
void waitOnChildren(int msecs);
|
||||||
void stopChildProcesses();
|
void stopChildProcesses();
|
||||||
private slots:
|
private slots:
|
||||||
void readPendingDatagrams();
|
void readPendingDatagrams();
|
||||||
void checkSpares();
|
void checkSpares();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void aboutToQuit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void spawnChildClient();
|
void spawnChildClient();
|
||||||
QTimer _checkSparesTimer; // every few seconds see if it need fewer or more spare children
|
QTimer _checkSparesTimer; // every few seconds see if it need fewer or more spare children
|
||||||
|
@ -52,6 +56,7 @@ private:
|
||||||
QString _assignmentServerHostname;
|
QString _assignmentServerHostname;
|
||||||
quint16 _assignmentServerPort;
|
quint16 _assignmentServerPort;
|
||||||
|
|
||||||
|
QList<QProcess*> _childProcesses;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AssignmentClientMonitor_h
|
#endif // hifi_AssignmentClientMonitor_h
|
||||||
|
|
|
@ -45,6 +45,9 @@ AvatarMixer::AvatarMixer(const QByteArray& packet) :
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarMixer::~AvatarMixer() {
|
AvatarMixer::~AvatarMixer() {
|
||||||
|
if (_broadcastTimer) {
|
||||||
|
_broadcastTimer->deleteLater();
|
||||||
|
}
|
||||||
_broadcastThread.quit();
|
_broadcastThread.quit();
|
||||||
_broadcastThread.wait();
|
_broadcastThread.wait();
|
||||||
}
|
}
|
||||||
|
@ -343,13 +346,13 @@ void AvatarMixer::run() {
|
||||||
nodeList->linkedDataCreateCallback = attachAvatarDataToNode;
|
nodeList->linkedDataCreateCallback = attachAvatarDataToNode;
|
||||||
|
|
||||||
// setup the timer that will be fired on the broadcast thread
|
// setup the timer that will be fired on the broadcast thread
|
||||||
QTimer* broadcastTimer = new QTimer();
|
_broadcastTimer = new QTimer();
|
||||||
broadcastTimer->setInterval(AVATAR_DATA_SEND_INTERVAL_MSECS);
|
_broadcastTimer->setInterval(AVATAR_DATA_SEND_INTERVAL_MSECS);
|
||||||
broadcastTimer->moveToThread(&_broadcastThread);
|
_broadcastTimer->moveToThread(&_broadcastThread);
|
||||||
|
|
||||||
// connect appropriate signals and slots
|
// connect appropriate signals and slots
|
||||||
connect(broadcastTimer, &QTimer::timeout, this, &AvatarMixer::broadcastAvatarData, Qt::DirectConnection);
|
connect(_broadcastTimer, &QTimer::timeout, this, &AvatarMixer::broadcastAvatarData, Qt::DirectConnection);
|
||||||
connect(&_broadcastThread, SIGNAL(started()), broadcastTimer, SLOT(start()));
|
connect(&_broadcastThread, SIGNAL(started()), _broadcastTimer, SLOT(start()));
|
||||||
|
|
||||||
// start the broadcastThread
|
// start the broadcastThread
|
||||||
_broadcastThread.start();
|
_broadcastThread.start();
|
||||||
|
|
|
@ -47,6 +47,8 @@ private:
|
||||||
int _numStatFrames;
|
int _numStatFrames;
|
||||||
int _sumBillboardPackets;
|
int _sumBillboardPackets;
|
||||||
int _sumIdentityPackets;
|
int _sumIdentityPackets;
|
||||||
|
|
||||||
|
QTimer* _broadcastTimer = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AvatarMixer_h
|
#endif // hifi_AvatarMixer_h
|
||||||
|
|
|
@ -27,6 +27,11 @@ EntityServer::EntityServer(const QByteArray& packet)
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityServer::~EntityServer() {
|
EntityServer::~EntityServer() {
|
||||||
|
if (_pruneDeletedEntitiesTimer) {
|
||||||
|
_pruneDeletedEntitiesTimer->stop();
|
||||||
|
_pruneDeletedEntitiesTimer->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
EntityTree* tree = (EntityTree*)_tree;
|
EntityTree* tree = (EntityTree*)_tree;
|
||||||
tree->removeNewlyCreatedHook(this);
|
tree->removeNewlyCreatedHook(this);
|
||||||
}
|
}
|
||||||
|
@ -48,10 +53,10 @@ Octree* EntityServer::createTree() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityServer::beforeRun() {
|
void EntityServer::beforeRun() {
|
||||||
QTimer* pruneDeletedEntitiesTimer = new QTimer(this);
|
_pruneDeletedEntitiesTimer = new QTimer();
|
||||||
connect(pruneDeletedEntitiesTimer, SIGNAL(timeout()), this, SLOT(pruneDeletedEntities()));
|
connect(_pruneDeletedEntitiesTimer, SIGNAL(timeout()), this, SLOT(pruneDeletedEntities()));
|
||||||
const int PRUNE_DELETED_MODELS_INTERVAL_MSECS = 1 * 1000; // once every second
|
const int PRUNE_DELETED_MODELS_INTERVAL_MSECS = 1 * 1000; // once every second
|
||||||
pruneDeletedEntitiesTimer->start(PRUNE_DELETED_MODELS_INTERVAL_MSECS);
|
_pruneDeletedEntitiesTimer->start(PRUNE_DELETED_MODELS_INTERVAL_MSECS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityServer::entityCreated(const EntityItem& newEntity, const SharedNodePointer& senderNode) {
|
void EntityServer::entityCreated(const EntityItem& newEntity, const SharedNodePointer& senderNode) {
|
||||||
|
|
|
@ -51,6 +51,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EntitySimulation* _entitySimulation;
|
EntitySimulation* _entitySimulation;
|
||||||
|
QTimer* _pruneDeletedEntitiesTimer = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_EntityServer_h
|
#endif // hifi_EntityServer_h
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
|
|
||||||
NodeToSenderStatsMap& getSingleSenderStats() { return _singleSenderStats; }
|
NodeToSenderStatsMap& getSingleSenderStats() { return _singleSenderStats; }
|
||||||
|
|
||||||
void shuttingDown() { _shuttingDown = true;}
|
virtual void terminating() { _shuttingDown = true; ReceivedPacketProcessor::terminating(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -266,16 +266,19 @@ OctreeServer::~OctreeServer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_jurisdictionSender) {
|
if (_jurisdictionSender) {
|
||||||
|
_jurisdictionSender->terminating();
|
||||||
_jurisdictionSender->terminate();
|
_jurisdictionSender->terminate();
|
||||||
_jurisdictionSender->deleteLater();
|
_jurisdictionSender->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_octreeInboundPacketProcessor) {
|
if (_octreeInboundPacketProcessor) {
|
||||||
|
_octreeInboundPacketProcessor->terminating();
|
||||||
_octreeInboundPacketProcessor->terminate();
|
_octreeInboundPacketProcessor->terminate();
|
||||||
_octreeInboundPacketProcessor->deleteLater();
|
_octreeInboundPacketProcessor->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_persistThread) {
|
if (_persistThread) {
|
||||||
|
_persistThread->terminating();
|
||||||
_persistThread->terminate();
|
_persistThread->terminate();
|
||||||
_persistThread->deleteLater();
|
_persistThread->deleteLater();
|
||||||
}
|
}
|
||||||
|
@ -1095,8 +1098,6 @@ void OctreeServer::readConfiguration() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OctreeServer::run() {
|
void OctreeServer::run() {
|
||||||
qInstallMessageHandler(LogHandler::verboseMessageHandler);
|
|
||||||
|
|
||||||
_safeServerName = getMyServerName();
|
_safeServerName = getMyServerName();
|
||||||
|
|
||||||
// Before we do anything else, create our tree...
|
// Before we do anything else, create our tree...
|
||||||
|
@ -1219,8 +1220,15 @@ void OctreeServer::forceNodeShutdown(SharedNodePointer node) {
|
||||||
void OctreeServer::aboutToFinish() {
|
void OctreeServer::aboutToFinish() {
|
||||||
qDebug() << qPrintable(_safeServerName) << "server STARTING about to finish...";
|
qDebug() << qPrintable(_safeServerName) << "server STARTING about to finish...";
|
||||||
qDebug() << qPrintable(_safeServerName) << "inform Octree Inbound Packet Processor that we are shutting down...";
|
qDebug() << qPrintable(_safeServerName) << "inform Octree Inbound Packet Processor that we are shutting down...";
|
||||||
_octreeInboundPacketProcessor->shuttingDown();
|
|
||||||
|
if (_octreeInboundPacketProcessor) {
|
||||||
|
_octreeInboundPacketProcessor->terminating();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_jurisdictionSender) {
|
||||||
|
_jurisdictionSender->terminating();
|
||||||
|
}
|
||||||
|
|
||||||
DependencyManager::get<NodeList>()->eachNode([this](const SharedNodePointer& node) {
|
DependencyManager::get<NodeList>()->eachNode([this](const SharedNodePointer& node) {
|
||||||
qDebug() << qPrintable(_safeServerName) << "server about to finish while node still connected node:" << *node;
|
qDebug() << qPrintable(_safeServerName) << "server about to finish while node still connected node:" << *node;
|
||||||
forceNodeShutdown(node);
|
forceNodeShutdown(node);
|
||||||
|
@ -1228,6 +1236,7 @@ void OctreeServer::aboutToFinish() {
|
||||||
|
|
||||||
if (_persistThread) {
|
if (_persistThread) {
|
||||||
_persistThread->aboutToFinish();
|
_persistThread->aboutToFinish();
|
||||||
|
_persistThread->terminating();
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << qPrintable(_safeServerName) << "server ENDING about to finish...";
|
qDebug() << qPrintable(_safeServerName) << "server ENDING about to finish...";
|
||||||
|
|
416
examples/avatarSelector.js
Normal file
416
examples/avatarSelector.js
Normal file
|
@ -0,0 +1,416 @@
|
||||||
|
//
|
||||||
|
// avatarSelector.js
|
||||||
|
// examples
|
||||||
|
//
|
||||||
|
// Created by David Rowe on 21 Apr 2015.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Based on lobby.js created by Stephen Birarda on 17 Oct 2014.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
|
|
||||||
|
var panelWall = false;
|
||||||
|
var orbShell = false;
|
||||||
|
var descriptionText = false;
|
||||||
|
var showText = false;
|
||||||
|
|
||||||
|
// used for formating the description text, in meters
|
||||||
|
var textWidth = 4;
|
||||||
|
var textHeight = .5;
|
||||||
|
var numberOfLines = 2;
|
||||||
|
var textMargin = 0.0625;
|
||||||
|
var lineHeight = (textHeight - (2 * textMargin)) / numberOfLines;
|
||||||
|
|
||||||
|
var avatarStickPosition = {};
|
||||||
|
|
||||||
|
var orbNaturalExtentsMin = { x: -1.230354, y: -1.22077, z: -1.210487 };
|
||||||
|
var orbNaturalExtentsMax = { x: 1.230353, y: 1.229819, z: 1.210487 };
|
||||||
|
var panelsNaturalExtentsMin = { x: -1.223182, y: -0.348487, z: 0.0451369 };
|
||||||
|
var panelsNaturalExtentsMax = { x: 1.223039, y: 0.602978, z: 1.224298 };
|
||||||
|
|
||||||
|
var orbNaturalDimensions = Vec3.subtract(orbNaturalExtentsMax, orbNaturalExtentsMin);
|
||||||
|
var panelsNaturalDimensions = Vec3.subtract(panelsNaturalExtentsMax, panelsNaturalExtentsMin);
|
||||||
|
|
||||||
|
var SCALING_FACTOR = 10;
|
||||||
|
var orbDimensions = Vec3.multiply(orbNaturalDimensions, SCALING_FACTOR);
|
||||||
|
var panelsDimensions = Vec3.multiply(panelsNaturalDimensions, SCALING_FACTOR);
|
||||||
|
|
||||||
|
var orbNaturalCenter = Vec3.sum(orbNaturalExtentsMin, Vec3.multiply(orbNaturalDimensions, 0.5));
|
||||||
|
var panelsNaturalCenter = Vec3.sum(panelsNaturalExtentsMin, Vec3.multiply(panelsNaturalDimensions, 0.5));
|
||||||
|
var orbCenter = Vec3.multiply(orbNaturalCenter, SCALING_FACTOR);
|
||||||
|
var panelsCenter = Vec3.multiply(panelsNaturalCenter, SCALING_FACTOR);
|
||||||
|
var panelsCenterShift = Vec3.subtract(panelsCenter, orbCenter);
|
||||||
|
|
||||||
|
var ORB_SHIFT = { x: 0, y: -1.4, z: -0.8 };
|
||||||
|
|
||||||
|
var LOBBY_PANEL_WALL_URL = HIFI_PUBLIC_BUCKET + "models/sets/Lobby/PanelWallForInterface.fbx";
|
||||||
|
var LOBBY_BLANK_PANEL_TEXTURE_URL = HIFI_PUBLIC_BUCKET + "models/sets/Lobby/Texture.jpg";
|
||||||
|
var LOBBY_SHELL_URL = HIFI_PUBLIC_BUCKET + "models/sets/Lobby/LobbyShellForInterface.fbx";
|
||||||
|
|
||||||
|
var droneSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/drone.stereo.raw")
|
||||||
|
var currentDrone = null;
|
||||||
|
|
||||||
|
var latinSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/latin.stereo.raw")
|
||||||
|
var latinInjector = null;
|
||||||
|
var elevatorSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/elevator.stereo.raw")
|
||||||
|
var elevatorInjector = null;
|
||||||
|
var currentMuzakInjector = null;
|
||||||
|
var currentSound = null;
|
||||||
|
|
||||||
|
function textOverlayPosition() {
|
||||||
|
var TEXT_DISTANCE_OUT = 6;
|
||||||
|
var TEXT_DISTANCE_DOWN = -2;
|
||||||
|
return Vec3.sum(Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), TEXT_DISTANCE_OUT)),
|
||||||
|
Vec3.multiply(Quat.getUp(Camera.orientation), TEXT_DISTANCE_DOWN));
|
||||||
|
}
|
||||||
|
|
||||||
|
var panelPlaceOrder = [
|
||||||
|
7, 8, 9, 10, 11, 12, 13,
|
||||||
|
0, 1, 2, 3, 4, 5, 6,
|
||||||
|
14, 15, 16, 17, 18, 19, 20
|
||||||
|
];
|
||||||
|
|
||||||
|
// Avatar index is 0-based
|
||||||
|
function avatarIndexToPanelIndex(avatarIndex) {
|
||||||
|
return panelPlaceOrder.indexOf(avatarIndex) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Panel index is 1-based
|
||||||
|
function panelIndexToPlaceIndex(panelIndex) {
|
||||||
|
return panelPlaceOrder[panelIndex - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
var MAX_NUM_PANELS = 21;
|
||||||
|
var DRONE_VOLUME = 0.3;
|
||||||
|
|
||||||
|
function drawLobby() {
|
||||||
|
if (!panelWall) {
|
||||||
|
print("Adding overlays for the avatar selector panel wall and orb shell.");
|
||||||
|
|
||||||
|
var cameraEuler = Quat.safeEulerAngles(Camera.orientation);
|
||||||
|
var towardsMe = Quat.angleAxis(cameraEuler.y + 180, { x: 0, y: 1, z: 0 });
|
||||||
|
|
||||||
|
var orbPosition = Vec3.sum(Camera.position, Vec3.multiplyQbyV(towardsMe, ORB_SHIFT));
|
||||||
|
|
||||||
|
var panelWallProps = {
|
||||||
|
url: LOBBY_PANEL_WALL_URL,
|
||||||
|
position: Vec3.sum(orbPosition, Vec3.multiplyQbyV(towardsMe, panelsCenterShift)),
|
||||||
|
rotation: towardsMe,
|
||||||
|
dimensions: panelsDimensions
|
||||||
|
};
|
||||||
|
|
||||||
|
var orbShellProps = {
|
||||||
|
url: LOBBY_SHELL_URL,
|
||||||
|
position: orbPosition,
|
||||||
|
rotation: towardsMe,
|
||||||
|
dimensions: orbDimensions,
|
||||||
|
ignoreRayIntersection: true
|
||||||
|
};
|
||||||
|
|
||||||
|
var windowDimensions = Controller.getViewportDimensions();
|
||||||
|
|
||||||
|
var descriptionTextProps = {
|
||||||
|
position: textOverlayPosition(),
|
||||||
|
dimensions: { x: textWidth, y: textHeight },
|
||||||
|
backgroundColor: { red: 0, green: 0, blue: 0 },
|
||||||
|
color: { red: 255, green: 255, blue: 255 },
|
||||||
|
topMargin: textMargin,
|
||||||
|
leftMargin: textMargin,
|
||||||
|
bottomMargin: textMargin,
|
||||||
|
rightMargin: textMargin,
|
||||||
|
text: "",
|
||||||
|
lineHeight: lineHeight,
|
||||||
|
alpha: 0.9,
|
||||||
|
backgroundAlpha: 0.9,
|
||||||
|
ignoreRayIntersection: true,
|
||||||
|
visible: false,
|
||||||
|
isFacingAvatar: true
|
||||||
|
};
|
||||||
|
|
||||||
|
avatarStickPosition = MyAvatar.position;
|
||||||
|
|
||||||
|
panelWall = Overlays.addOverlay("model", panelWallProps);
|
||||||
|
orbShell = Overlays.addOverlay("model", orbShellProps);
|
||||||
|
descriptionText = Overlays.addOverlay("text3d", descriptionTextProps);
|
||||||
|
|
||||||
|
if (droneSound.downloaded) {
|
||||||
|
// start the drone sound
|
||||||
|
if (!currentDrone) {
|
||||||
|
currentDrone = Audio.playSound(droneSound, { stereo: true, loop: true, localOnly: true, volume: DRONE_VOLUME });
|
||||||
|
} else {
|
||||||
|
currentDrone.restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// start one of our muzak sounds
|
||||||
|
playRandomMuzak();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var avatars = {};
|
||||||
|
|
||||||
|
function changeLobbyTextures() {
|
||||||
|
var req = new XMLHttpRequest();
|
||||||
|
req.open("GET", "https://metaverse.highfidelity.com/api/v1/marketplace?category=head+%26+body&limit=21", false);
|
||||||
|
req.send(); // Data returned is randomized.
|
||||||
|
|
||||||
|
avatars = JSON.parse(req.responseText).data.items;
|
||||||
|
|
||||||
|
var NUM_PANELS = avatars.length;
|
||||||
|
|
||||||
|
var textureProp = {
|
||||||
|
textures: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (var j = 0; j < NUM_PANELS; j++) {
|
||||||
|
var panelIndex = avatarIndexToPanelIndex(j);
|
||||||
|
textureProp["textures"]["file" + panelIndex] = avatars[j].preview_url;
|
||||||
|
};
|
||||||
|
|
||||||
|
Overlays.editOverlay(panelWall, textureProp);
|
||||||
|
}
|
||||||
|
|
||||||
|
var MUZAK_VOLUME = 0.1;
|
||||||
|
|
||||||
|
function playCurrentSound(secondOffset) {
|
||||||
|
if (currentSound == latinSound) {
|
||||||
|
if (!latinInjector) {
|
||||||
|
latinInjector = Audio.playSound(latinSound, { localOnly: true, secondOffset: secondOffset, volume: MUZAK_VOLUME });
|
||||||
|
} else {
|
||||||
|
latinInjector.restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
currentMuzakInjector = latinInjector;
|
||||||
|
} else if (currentSound == elevatorSound) {
|
||||||
|
if (!elevatorInjector) {
|
||||||
|
elevatorInjector = Audio.playSound(elevatorSound, { localOnly: true, secondOffset: secondOffset, volume: MUZAK_VOLUME });
|
||||||
|
} else {
|
||||||
|
elevatorInjector.restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
currentMuzakInjector = elevatorInjector;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function playNextMuzak() {
|
||||||
|
if (panelWall) {
|
||||||
|
if (currentSound == latinSound) {
|
||||||
|
if (elevatorSound.downloaded) {
|
||||||
|
currentSound = elevatorSound;
|
||||||
|
}
|
||||||
|
} else if (currentSound == elevatorSound) {
|
||||||
|
if (latinSound.downloaded) {
|
||||||
|
currentSound = latinSound;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
playCurrentSound(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function playRandomMuzak() {
|
||||||
|
currentSound = null;
|
||||||
|
|
||||||
|
if (latinSound.downloaded && elevatorSound.downloaded) {
|
||||||
|
currentSound = Math.random() < 0.5 ? latinSound : elevatorSound;
|
||||||
|
} else if (latinSound.downloaded) {
|
||||||
|
currentSound = latinSound;
|
||||||
|
} else if (elevatorSound.downloaded) {
|
||||||
|
currentSound = elevatorSound;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentSound) {
|
||||||
|
// pick a random number of seconds from 0-10 to offset the muzak
|
||||||
|
var secondOffset = Math.random() * 10;
|
||||||
|
|
||||||
|
playCurrentSound(secondOffset);
|
||||||
|
} else {
|
||||||
|
currentMuzakInjector = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanupLobby() {
|
||||||
|
toggleEnvironmentRendering(true);
|
||||||
|
|
||||||
|
// for each of the 21 placeholder textures, set them back to default so the cached model doesn't have changed textures
|
||||||
|
var panelTexturesReset = {};
|
||||||
|
panelTexturesReset["textures"] = {};
|
||||||
|
|
||||||
|
for (var j = 0; j < MAX_NUM_PANELS; j++) {
|
||||||
|
panelTexturesReset["textures"]["file" + (j + 1)] = LOBBY_BLANK_PANEL_TEXTURE_URL;
|
||||||
|
};
|
||||||
|
|
||||||
|
Overlays.editOverlay(panelWall, panelTexturesReset);
|
||||||
|
|
||||||
|
Overlays.deleteOverlay(panelWall);
|
||||||
|
Overlays.deleteOverlay(orbShell);
|
||||||
|
Overlays.deleteOverlay(descriptionText);
|
||||||
|
|
||||||
|
panelWall = false;
|
||||||
|
orbShell = false;
|
||||||
|
|
||||||
|
if (currentDrone) {
|
||||||
|
currentDrone.stop();
|
||||||
|
currentDrone = null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentMuzakInjector) {
|
||||||
|
currentMuzakInjector.stop();
|
||||||
|
currentMuzakInjector = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
avatars = {};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function actionStartEvent(event) {
|
||||||
|
if (panelWall) {
|
||||||
|
// we've got an action event and our panel wall is up
|
||||||
|
// check if we hit a panel and if we should jump there
|
||||||
|
var result = Overlays.findRayIntersection(event.actionRay);
|
||||||
|
if (result.intersects && result.overlayID == panelWall) {
|
||||||
|
|
||||||
|
var panelName = result.extraInfo;
|
||||||
|
|
||||||
|
var panelStringIndex = panelName.indexOf("Panel");
|
||||||
|
if (panelStringIndex != -1) {
|
||||||
|
var panelIndex = parseInt(panelName.slice(5));
|
||||||
|
var avatarIndex = panelIndexToPlaceIndex(panelIndex);
|
||||||
|
if (avatarIndex < avatars.length) {
|
||||||
|
var actionPlace = avatars[avatarIndex];
|
||||||
|
|
||||||
|
print("Changing avatar to " + actionPlace.name
|
||||||
|
+ " after click on panel " + panelIndex + " with avatar index " + avatarIndex);
|
||||||
|
|
||||||
|
MyAvatar.useFullAvatarURL(actionPlace.content_url);
|
||||||
|
|
||||||
|
maybeCleanupLobby();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var control = false;
|
||||||
|
|
||||||
|
function keyPressEvent(event) {
|
||||||
|
if (event.text === "CONTROL") {
|
||||||
|
control = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (control && event.text === "a") {
|
||||||
|
if (!panelWall) {
|
||||||
|
toggleEnvironmentRendering(false);
|
||||||
|
drawLobby();
|
||||||
|
changeLobbyTextures();
|
||||||
|
} else {
|
||||||
|
cleanupLobby();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function keyReleaseEvent(event) {
|
||||||
|
if (event.text === "CONTROL") {
|
||||||
|
control = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var CLEANUP_EPSILON_DISTANCE = 0.05;
|
||||||
|
|
||||||
|
function maybeCleanupLobby() {
|
||||||
|
if (panelWall && Vec3.length(Vec3.subtract(avatarStickPosition, MyAvatar.position)) > CLEANUP_EPSILON_DISTANCE) {
|
||||||
|
cleanupLobby();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleEnvironmentRendering(shouldRender) {
|
||||||
|
Scene.shouldRenderAvatars = shouldRender;
|
||||||
|
Scene.shouldRenderEntities = shouldRender;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleLookAt(pickRay) {
|
||||||
|
if (panelWall && descriptionText) {
|
||||||
|
// we've got an action event and our panel wall is up
|
||||||
|
// check if we hit a panel and if we should jump there
|
||||||
|
var result = Overlays.findRayIntersection(pickRay);
|
||||||
|
if (result.intersects && result.overlayID == panelWall) {
|
||||||
|
var panelName = result.extraInfo;
|
||||||
|
var panelStringIndex = panelName.indexOf("Panel");
|
||||||
|
if (panelStringIndex != -1) {
|
||||||
|
var panelIndex = parseInt(panelName.slice(5));
|
||||||
|
var avatarIndex = panelIndexToPlaceIndex(panelIndex);
|
||||||
|
if (avatarIndex < avatars.length) {
|
||||||
|
var actionPlace = avatars[avatarIndex];
|
||||||
|
|
||||||
|
if (actionPlace.description == "") {
|
||||||
|
Overlays.editOverlay(descriptionText, { text: actionPlace.name, visible: showText });
|
||||||
|
} else {
|
||||||
|
// handle line wrapping
|
||||||
|
var allWords = actionPlace.description.split(" ");
|
||||||
|
var currentGoodLine = "";
|
||||||
|
var currentTestLine = "";
|
||||||
|
var formatedDescription = "";
|
||||||
|
var wordsFormated = 0;
|
||||||
|
var currentTestWord = 0;
|
||||||
|
var wordsOnLine = 0;
|
||||||
|
while (wordsFormated < allWords.length) {
|
||||||
|
// first add the "next word" to the line and test it.
|
||||||
|
currentTestLine = currentGoodLine;
|
||||||
|
if (wordsOnLine > 0) {
|
||||||
|
currentTestLine += " " + allWords[currentTestWord];
|
||||||
|
} else {
|
||||||
|
currentTestLine = allWords[currentTestWord];
|
||||||
|
}
|
||||||
|
var lineLength = Overlays.textSize(descriptionText, currentTestLine).width;
|
||||||
|
if (lineLength < textWidth || wordsOnLine == 0) {
|
||||||
|
wordsFormated++;
|
||||||
|
currentTestWord++;
|
||||||
|
wordsOnLine++;
|
||||||
|
currentGoodLine = currentTestLine;
|
||||||
|
} else {
|
||||||
|
formatedDescription += currentGoodLine + "\n";
|
||||||
|
wordsOnLine = 0;
|
||||||
|
currentGoodLine = "";
|
||||||
|
currentTestLine = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
formatedDescription += currentGoodLine;
|
||||||
|
Overlays.editOverlay(descriptionText, { text: formatedDescription, visible: showText });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Overlays.editOverlay(descriptionText, { text: "", visible: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function update(deltaTime) {
|
||||||
|
maybeCleanupLobby();
|
||||||
|
if (panelWall) {
|
||||||
|
Overlays.editOverlay(descriptionText, { position: textOverlayPosition() });
|
||||||
|
|
||||||
|
// if the reticle is up then we may need to play the next muzak
|
||||||
|
if (currentMuzakInjector && !currentMuzakInjector.isPlaying) {
|
||||||
|
playNextMuzak();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function mouseMoveEvent(event) {
|
||||||
|
if (panelWall) {
|
||||||
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
|
handleLookAt(pickRay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller.actionStartEvent.connect(actionStartEvent);
|
||||||
|
Controller.keyPressEvent.connect(keyPressEvent);
|
||||||
|
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||||
|
Script.update.connect(update);
|
||||||
|
Script.scriptEnding.connect(maybeCleanupLobby);
|
||||||
|
Controller.mouseMoveEvent.connect(mouseMoveEvent);
|
|
@ -592,7 +592,11 @@ var idleMouseTimerId = null;
|
||||||
var IDLE_MOUSE_TIMEOUT = 200;
|
var IDLE_MOUSE_TIMEOUT = 200;
|
||||||
var DEFAULT_ENTITY_DRAG_DROP_DISTANCE = 2.0;
|
var DEFAULT_ENTITY_DRAG_DROP_DISTANCE = 2.0;
|
||||||
|
|
||||||
function mouseMoveEvent(event) {
|
var lastMouseMoveEvent = null;
|
||||||
|
function mouseMoveEventBuffered(event) {
|
||||||
|
lastMouseMoveEvent = event;
|
||||||
|
}
|
||||||
|
function mouseMove(event) {
|
||||||
mouseHasMovedSincePress = true;
|
mouseHasMovedSincePress = true;
|
||||||
|
|
||||||
if (placingEntityID) {
|
if (placingEntityID) {
|
||||||
|
@ -661,6 +665,10 @@ function highlightEntityUnderCursor(position, accurateRay) {
|
||||||
|
|
||||||
|
|
||||||
function mouseReleaseEvent(event) {
|
function mouseReleaseEvent(event) {
|
||||||
|
if (lastMouseMoveEvent) {
|
||||||
|
mouseMove(lastMouseMoveEvent);
|
||||||
|
lastMouseMoveEvent = null;
|
||||||
|
}
|
||||||
if (propertyMenu.mouseReleaseEvent(event) || toolBar.mouseReleaseEvent(event)) {
|
if (propertyMenu.mouseReleaseEvent(event) || toolBar.mouseReleaseEvent(event)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -772,7 +780,7 @@ function mouseClickEvent(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.mousePressEvent.connect(mousePressEvent);
|
Controller.mousePressEvent.connect(mousePressEvent);
|
||||||
Controller.mouseMoveEvent.connect(mouseMoveEvent);
|
Controller.mouseMoveEvent.connect(mouseMoveEventBuffered);
|
||||||
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
||||||
|
|
||||||
|
|
||||||
|
@ -882,6 +890,10 @@ Script.update.connect(function (deltaTime) {
|
||||||
lastOrientation = Camera.orientation;
|
lastOrientation = Camera.orientation;
|
||||||
lastPosition = Camera.position;
|
lastPosition = Camera.position;
|
||||||
}
|
}
|
||||||
|
if (lastMouseMoveEvent) {
|
||||||
|
mouseMove(lastMouseMoveEvent);
|
||||||
|
lastMouseMoveEvent = null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function insideBox(center, dimensions, point) {
|
function insideBox(center, dimensions, point) {
|
||||||
|
|
|
@ -59,7 +59,13 @@ function mousePressEvent(event) {
|
||||||
isGrabbing = true;
|
isGrabbing = true;
|
||||||
savedGravity = props.gravity;
|
savedGravity = props.gravity;
|
||||||
Overlays.editOverlay(dropLine, {
|
Overlays.editOverlay(dropLine, {
|
||||||
visible: true
|
visible: true,
|
||||||
|
start: props.position,
|
||||||
|
end: Vec3.sum(props.position, {
|
||||||
|
x: 0,
|
||||||
|
y: -DROP_DISTANCE,
|
||||||
|
z: 0
|
||||||
|
})
|
||||||
});
|
});
|
||||||
Entities.editEntity(grabbedEntity, {
|
Entities.editEntity(grabbedEntity, {
|
||||||
gravity: {
|
gravity: {
|
||||||
|
|
|
@ -1153,7 +1153,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
case Qt::Key_A:
|
case Qt::Key_A:
|
||||||
if (isShifted) {
|
if (isShifted) {
|
||||||
Menu::getInstance()->triggerOption(MenuOption::Atmosphere);
|
Menu::getInstance()->triggerOption(MenuOption::Atmosphere);
|
||||||
} else {
|
} else if (!isMeta) {
|
||||||
_myAvatar->setDriveKeys(ROT_LEFT, 1.0f);
|
_myAvatar->setDriveKeys(ROT_LEFT, 1.0f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -237,8 +237,6 @@ protected:
|
||||||
HifiSockAddr _localSockAddr;
|
HifiSockAddr _localSockAddr;
|
||||||
HifiSockAddr _publicSockAddr;
|
HifiSockAddr _publicSockAddr;
|
||||||
HifiSockAddr _stunSockAddr;
|
HifiSockAddr _stunSockAddr;
|
||||||
|
|
||||||
QTimer* _silentNodeTimer;
|
|
||||||
|
|
||||||
// XXX can BandwidthRecorder be used for this?
|
// XXX can BandwidthRecorder be used for this?
|
||||||
int _numCollectedPackets;
|
int _numCollectedPackets;
|
||||||
|
|
|
@ -47,6 +47,8 @@ public:
|
||||||
/// How many received packets waiting are to be processed
|
/// How many received packets waiting are to be processed
|
||||||
int packetsToProcessCount() const { return _packets.size(); }
|
int packetsToProcessCount() const { return _packets.size(); }
|
||||||
|
|
||||||
|
virtual void terminating();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void nodeKilled(SharedNodePointer node);
|
void nodeKilled(SharedNodePointer node);
|
||||||
|
|
||||||
|
@ -71,8 +73,6 @@ protected:
|
||||||
/// Override to do work after the packets processing loop. Default does nothing.
|
/// Override to do work after the packets processing loop. Default does nothing.
|
||||||
virtual void postProcess() { }
|
virtual void postProcess() { }
|
||||||
|
|
||||||
virtual void terminating();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
QVector<NetworkPacket> _packets;
|
QVector<NetworkPacket> _packets;
|
||||||
|
|
|
@ -30,6 +30,17 @@ void ThreadedAssignment::setFinished(bool isFinished) {
|
||||||
_isFinished = isFinished;
|
_isFinished = isFinished;
|
||||||
|
|
||||||
if (_isFinished) {
|
if (_isFinished) {
|
||||||
|
if (_domainServerTimer) {
|
||||||
|
_domainServerTimer->stop();
|
||||||
|
delete _domainServerTimer;
|
||||||
|
_domainServerTimer = nullptr;
|
||||||
|
}
|
||||||
|
if (_statsTimer) {
|
||||||
|
_statsTimer->stop();
|
||||||
|
delete _statsTimer;
|
||||||
|
_statsTimer = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
aboutToFinish();
|
aboutToFinish();
|
||||||
|
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
@ -63,15 +74,15 @@ void ThreadedAssignment::commonInit(const QString& targetName, NodeType_t nodeTy
|
||||||
// this is a temp fix for Qt 5.3 - rebinding the node socket gives us readyRead for the socket on this thread
|
// this is a temp fix for Qt 5.3 - rebinding the node socket gives us readyRead for the socket on this thread
|
||||||
nodeList->rebindNodeSocket();
|
nodeList->rebindNodeSocket();
|
||||||
|
|
||||||
QTimer* domainServerTimer = new QTimer(this);
|
_domainServerTimer = new QTimer();
|
||||||
connect(domainServerTimer, SIGNAL(timeout()), this, SLOT(checkInWithDomainServerOrExit()));
|
connect(_domainServerTimer, SIGNAL(timeout()), this, SLOT(checkInWithDomainServerOrExit()));
|
||||||
domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);
|
_domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);
|
||||||
|
|
||||||
if (shouldSendStats) {
|
if (shouldSendStats) {
|
||||||
// send a stats packet every 1 second
|
// send a stats packet every 1 second
|
||||||
QTimer* statsTimer = new QTimer(this);
|
_statsTimer = new QTimer();
|
||||||
connect(statsTimer, &QTimer::timeout, this, &ThreadedAssignment::sendStatsPacket);
|
connect(_statsTimer, &QTimer::timeout, this, &ThreadedAssignment::sendStatsPacket);
|
||||||
statsTimer->start(1000);
|
_statsTimer->start(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,15 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
/// threaded run of assignment
|
/// threaded run of assignment
|
||||||
virtual void run() = 0;
|
virtual void run() = 0;
|
||||||
|
Q_INVOKABLE virtual void stop() { setFinished(true); }
|
||||||
virtual void readPendingDatagrams() = 0;
|
virtual void readPendingDatagrams() = 0;
|
||||||
virtual void sendStatsPacket();
|
virtual void sendStatsPacket();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void aboutToQuit() {
|
||||||
|
QMetaObject::invokeMethod(this, "stop");
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
|
|
||||||
|
@ -38,6 +45,8 @@ protected:
|
||||||
void commonInit(const QString& targetName, NodeType_t nodeType, bool shouldSendStats = true);
|
void commonInit(const QString& targetName, NodeType_t nodeType, bool shouldSendStats = true);
|
||||||
bool _isFinished;
|
bool _isFinished;
|
||||||
QThread* _datagramProcessingThread;
|
QThread* _datagramProcessingThread;
|
||||||
|
QTimer* _domainServerTimer = nullptr;
|
||||||
|
QTimer* _statsTimer = nullptr;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void checkInWithDomainServerOrExit();
|
void checkInWithDomainServerOrExit();
|
||||||
|
|
|
@ -228,6 +228,7 @@ void OctreePersistThread::aboutToFinish() {
|
||||||
qCDebug(octree) << "Persist thread about to finish...";
|
qCDebug(octree) << "Persist thread about to finish...";
|
||||||
persist();
|
persist();
|
||||||
qCDebug(octree) << "Persist thread done with about to finish...";
|
qCDebug(octree) << "Persist thread done with about to finish...";
|
||||||
|
_stopThread = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OctreePersistThread::persist() {
|
void OctreePersistThread::persist() {
|
||||||
|
|
Loading…
Reference in a new issue