mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:58:51 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi
This commit is contained in:
commit
ee0b6fad55
35 changed files with 146 additions and 129 deletions
|
@ -101,6 +101,9 @@ void Agent::run() {
|
||||||
|
|
||||||
// give this AvatarData object to the script engine
|
// give this AvatarData object to the script engine
|
||||||
_scriptEngine.setAvatarData(&scriptedAvatar, "Avatar");
|
_scriptEngine.setAvatarData(&scriptedAvatar, "Avatar");
|
||||||
|
|
||||||
|
// register ourselves to the script engine
|
||||||
|
_scriptEngine.registerGlobalObject("Agent", this);
|
||||||
|
|
||||||
_scriptEngine.setScriptContents(scriptContents);
|
_scriptEngine.setScriptContents(scriptContents);
|
||||||
_scriptEngine.run();
|
_scriptEngine.run();
|
||||||
|
|
|
@ -21,9 +21,14 @@
|
||||||
|
|
||||||
class Agent : public ThreadedAssignment {
|
class Agent : public ThreadedAssignment {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(bool isAvatar READ isAvatar WRITE setIsAvatar)
|
||||||
public:
|
public:
|
||||||
Agent(const QByteArray& packet);
|
Agent(const QByteArray& packet);
|
||||||
|
|
||||||
|
void setIsAvatar(bool isAvatar) { _scriptEngine.setIsAvatar(isAvatar); }
|
||||||
|
bool isAvatar() const { return _scriptEngine.isAvatar(); }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,8 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
||||||
timer->start(ASSIGNMENT_REQUEST_INTERVAL_MSECS);
|
timer->start(ASSIGNMENT_REQUEST_INTERVAL_MSECS);
|
||||||
|
|
||||||
// connect our readPendingDatagrams method to the readyRead() signal of the socket
|
// connect our readPendingDatagrams method to the readyRead() signal of the socket
|
||||||
connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));
|
connect(&nodeList->getNodeSocket(), &QUdpSocket::readyRead, this, &AssignmentClient::readPendingDatagrams,
|
||||||
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssignmentClient::sendAssignmentRequest() {
|
void AssignmentClient::sendAssignmentRequest() {
|
||||||
|
|
|
@ -62,4 +62,4 @@ function maybePlaySound() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect a call back that happens every frame
|
// Connect a call back that happens every frame
|
||||||
Agent.willSendVisualDataCallback.connect(maybePlaySound);
|
Script.willSendVisualDataCallback.connect(maybePlaySound);
|
|
@ -132,7 +132,7 @@ function draw() {
|
||||||
print(scriptB);
|
print(scriptB);
|
||||||
numberParticlesAdded++;
|
numberParticlesAdded++;
|
||||||
} else {
|
} else {
|
||||||
Agent.stop();
|
Script.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
print("Particles Stats: " + Particles.getLifetimeInSeconds() + " seconds," +
|
print("Particles Stats: " + Particles.getLifetimeInSeconds() + " seconds," +
|
||||||
|
@ -150,5 +150,5 @@ function draw() {
|
||||||
// register the call back so it fires before each data send
|
// register the call back so it fires before each data send
|
||||||
print("here...\n");
|
print("here...\n");
|
||||||
Particles.setPacketsPerSecond(40000);
|
Particles.setPacketsPerSecond(40000);
|
||||||
Agent.willSendVisualDataCallback.connect(draw);
|
Script.willSendVisualDataCallback.connect(draw);
|
||||||
print("and here...\n");
|
print("and here...\n");
|
||||||
|
|
|
@ -82,7 +82,7 @@ function touchEndEvent(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// register the call back so it fires before each data send
|
// register the call back so it fires before each data send
|
||||||
Agent.willSendVisualDataCallback.connect(checkController);
|
Script.willSendVisualDataCallback.connect(checkController);
|
||||||
|
|
||||||
// Map keyPress and mouse move events to our callbacks
|
// Map keyPress and mouse move events to our callbacks
|
||||||
Controller.keyPressEvent.connect(keyPressEvent);
|
Controller.keyPressEvent.connect(keyPressEvent);
|
||||||
|
@ -199,4 +199,4 @@ function scriptEnding() {
|
||||||
Controller.releaseTouchEvents();
|
Controller.releaseTouchEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
Agent.scriptEnding.connect(scriptEnding);
|
Script.scriptEnding.connect(scriptEnding);
|
||||||
|
|
|
@ -20,7 +20,7 @@ function scriptEnding() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// register the call back so it fires before each data send
|
// register the call back so it fires before each data send
|
||||||
Agent.willSendVisualDataCallback.connect(displayCount);
|
Script.willSendVisualDataCallback.connect(displayCount);
|
||||||
|
|
||||||
// register our scriptEnding callback
|
// register our scriptEnding callback
|
||||||
Agent.scriptEnding.connect(scriptEnding);
|
Script.scriptEnding.connect(scriptEnding);
|
||||||
|
|
|
@ -69,4 +69,4 @@ function checkSticks() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect a call back that happens every frame
|
// Connect a call back that happens every frame
|
||||||
Agent.willSendVisualDataCallback.connect(checkSticks);
|
Script.willSendVisualDataCallback.connect(checkSticks);
|
|
@ -44,7 +44,6 @@ var particleID = Particles.addParticle(originalProperties);
|
||||||
|
|
||||||
function moveParticle() {
|
function moveParticle() {
|
||||||
if (count >= moveUntil) {
|
if (count >= moveUntil) {
|
||||||
//Agent.stop();
|
|
||||||
|
|
||||||
// delete it...
|
// delete it...
|
||||||
if (count == moveUntil) {
|
if (count == moveUntil) {
|
||||||
|
@ -54,8 +53,8 @@ function moveParticle() {
|
||||||
|
|
||||||
// stop it...
|
// stop it...
|
||||||
if (count >= stopAfter) {
|
if (count >= stopAfter) {
|
||||||
print("calling Agent.stop()");
|
print("calling Script.stop()");
|
||||||
Agent.stop();
|
Script.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
|
@ -86,5 +85,5 @@ function moveParticle() {
|
||||||
|
|
||||||
|
|
||||||
// register the call back so it fires before each data send
|
// register the call back so it fires before each data send
|
||||||
Agent.willSendVisualDataCallback.connect(moveParticle);
|
Script.willSendVisualDataCallback.connect(moveParticle);
|
||||||
|
|
||||||
|
|
|
@ -65,8 +65,8 @@ function findParticles() {
|
||||||
// run for a while, then clean up
|
// run for a while, then clean up
|
||||||
// stop it...
|
// stop it...
|
||||||
if (iteration >= 100) {
|
if (iteration >= 100) {
|
||||||
print("calling Agent.stop()");
|
print("calling Script.stop()");
|
||||||
Agent.stop();
|
Script.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
print("--------------------------");
|
print("--------------------------");
|
||||||
|
@ -122,7 +122,7 @@ function findParticles() {
|
||||||
|
|
||||||
|
|
||||||
// register the call back so it fires before each data send
|
// register the call back so it fires before each data send
|
||||||
Agent.willSendVisualDataCallback.connect(findParticles);
|
Script.willSendVisualDataCallback.connect(findParticles);
|
||||||
|
|
||||||
// register our scriptEnding callback
|
// register our scriptEnding callback
|
||||||
Agent.scriptEnding.connect(scriptEnding);
|
Script.scriptEnding.connect(scriptEnding);
|
||||||
|
|
|
@ -60,8 +60,8 @@ function makeFountain() {
|
||||||
totalParticles++;
|
totalParticles++;
|
||||||
}
|
}
|
||||||
if (totalParticles > 100) {
|
if (totalParticles > 100) {
|
||||||
Agent.stop();
|
Script.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// register the call back so it fires before each data send
|
// register the call back so it fires before each data send
|
||||||
Agent.willSendVisualDataCallback.connect(makeFountain);
|
Script.willSendVisualDataCallback.connect(makeFountain);
|
|
@ -128,6 +128,6 @@ print("step()...");
|
||||||
}
|
}
|
||||||
|
|
||||||
print("here");
|
print("here");
|
||||||
Agent.willSendVisualDataCallback.connect(step);
|
Script.willSendVisualDataCallback.connect(step);
|
||||||
Voxels.setPacketsPerSecond(200);
|
Voxels.setPacketsPerSecond(200);
|
||||||
print("now here");
|
print("now here");
|
||||||
|
|
|
@ -99,4 +99,4 @@ function checkController() {
|
||||||
|
|
||||||
|
|
||||||
// register the call back so it fires before each data send
|
// register the call back so it fires before each data send
|
||||||
Agent.willSendVisualDataCallback.connect(checkController);
|
Script.willSendVisualDataCallback.connect(checkController);
|
||||||
|
|
|
@ -70,5 +70,5 @@ MyAvatar.bodyPitch = 0;
|
||||||
MyAvatar.bodyRoll = 0;
|
MyAvatar.bodyRoll = 0;
|
||||||
|
|
||||||
// would be nice to change to update
|
// would be nice to change to update
|
||||||
Agent.willSendVisualDataCallback.connect(update);
|
Script.willSendVisualDataCallback.connect(update);
|
||||||
Agent.scriptEnding.connect(scriptEnding);
|
Script.scriptEnding.connect(scriptEnding);
|
||||||
|
|
|
@ -41,4 +41,4 @@ function moveVoxel() {
|
||||||
|
|
||||||
Voxels.setPacketsPerSecond(300);
|
Voxels.setPacketsPerSecond(300);
|
||||||
// Connect a call back that happens every frame
|
// Connect a call back that happens every frame
|
||||||
Agent.willSendVisualDataCallback.connect(moveVoxel);
|
Script.willSendVisualDataCallback.connect(moveVoxel);
|
|
@ -93,4 +93,4 @@ function checkController() {
|
||||||
|
|
||||||
|
|
||||||
// register the call back so it fires before each data send
|
// register the call back so it fires before each data send
|
||||||
Agent.willSendVisualDataCallback.connect(checkController);
|
Script.willSendVisualDataCallback.connect(checkController);
|
||||||
|
|
|
@ -95,7 +95,7 @@ function moveBird() {
|
||||||
var nowTimeInSeconds = new Date().getTime() / 1000;
|
var nowTimeInSeconds = new Date().getTime() / 1000;
|
||||||
if ((nowTimeInSeconds - startTimeInSeconds) >= birdLifetime) {
|
if ((nowTimeInSeconds - startTimeInSeconds) >= birdLifetime) {
|
||||||
print("our bird is dying, stop our script");
|
print("our bird is dying, stop our script");
|
||||||
Agent.stop();
|
Script.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,4 +171,4 @@ function moveBird() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// register the call back so it fires before each data send
|
// register the call back so it fires before each data send
|
||||||
Agent.willSendVisualDataCallback.connect(moveBird);
|
Script.willSendVisualDataCallback.connect(moveBird);
|
||||||
|
|
|
@ -37,8 +37,8 @@ var ballParticleID = Particles.addParticle(ballProperties);
|
||||||
function endAfterAWhile() {
|
function endAfterAWhile() {
|
||||||
// stop it...
|
// stop it...
|
||||||
if (count >= stopAfter) {
|
if (count >= stopAfter) {
|
||||||
print("calling Agent.stop()");
|
print("calling Script.stop()");
|
||||||
Agent.stop();
|
Script.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
print("count =" + count);
|
print("count =" + count);
|
||||||
|
@ -47,5 +47,5 @@ function endAfterAWhile() {
|
||||||
|
|
||||||
|
|
||||||
// register the call back so it fires before each data send
|
// register the call back so it fires before each data send
|
||||||
Agent.willSendVisualDataCallback.connect(endAfterAWhile);
|
Script.willSendVisualDataCallback.connect(endAfterAWhile);
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,4 @@ function maybePlaySound() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect a call back that happens every frame
|
// Connect a call back that happens every frame
|
||||||
Agent.willSendVisualDataCallback.connect(maybePlaySound);
|
Script.willSendVisualDataCallback.connect(maybePlaySound);
|
|
@ -37,7 +37,7 @@ function rideWithParticle() {
|
||||||
y: propertiesA.position.y + 2,
|
y: propertiesA.position.y + 2,
|
||||||
z: propertiesA.position.z };
|
z: propertiesA.position.z };
|
||||||
} else {
|
} else {
|
||||||
Agent.stop();
|
Script.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
iteration++;
|
iteration++;
|
||||||
|
@ -46,5 +46,5 @@ function rideWithParticle() {
|
||||||
|
|
||||||
|
|
||||||
// register the call back so it fires before each data send
|
// register the call back so it fires before each data send
|
||||||
Agent.willSendVisualDataCallback.connect(rideWithParticle);
|
Script.willSendVisualDataCallback.connect(rideWithParticle);
|
||||||
|
|
||||||
|
|
|
@ -226,4 +226,4 @@ function checkController() {
|
||||||
|
|
||||||
|
|
||||||
// register the call back so it fires before each data send
|
// register the call back so it fires before each data send
|
||||||
Agent.willSendVisualDataCallback.connect(checkController);
|
Script.willSendVisualDataCallback.connect(checkController);
|
||||||
|
|
|
@ -130,4 +130,4 @@ function moveBird() {
|
||||||
|
|
||||||
Voxels.setPacketsPerSecond(10000);
|
Voxels.setPacketsPerSecond(10000);
|
||||||
// Connect a call back that happens every frame
|
// Connect a call back that happens every frame
|
||||||
Agent.willSendVisualDataCallback.connect(moveBird);
|
Script.willSendVisualDataCallback.connect(moveBird);
|
|
@ -17,6 +17,7 @@ class AbstractLoggerInterface : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
AbstractLoggerInterface(QObject* parent = NULL) : QObject(parent) {};
|
||||||
inline bool extraDebugging() { return _extraDebugging; };
|
inline bool extraDebugging() { return _extraDebugging; };
|
||||||
inline void setExtraDebugging(bool debugging) { _extraDebugging = debugging; };
|
inline void setExtraDebugging(bool debugging) { _extraDebugging = debugging; };
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
_resetRecentMaxPacketsSoon(true),
|
_resetRecentMaxPacketsSoon(true),
|
||||||
_swatch(NULL),
|
_swatch(NULL),
|
||||||
_pasteMode(false),
|
_pasteMode(false),
|
||||||
_logger(new FileLogger()),
|
_logger(new FileLogger(this)),
|
||||||
_persistThread(NULL)
|
_persistThread(NULL)
|
||||||
{
|
{
|
||||||
_myAvatar = _avatarManager.getMyAvatar();
|
_myAvatar = _avatarManager.getMyAvatar();
|
||||||
|
@ -321,19 +321,14 @@ Application::~Application() {
|
||||||
_persistThread->deleteLater();
|
_persistThread->deleteLater();
|
||||||
_persistThread = NULL;
|
_persistThread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
storeSizeAndPosition();
|
storeSizeAndPosition();
|
||||||
saveScripts();
|
saveScripts();
|
||||||
_sharedVoxelSystem.changeTree(new VoxelTree);
|
_sharedVoxelSystem.changeTree(new VoxelTree);
|
||||||
|
|
||||||
VoxelTreeElement::removeDeleteHook(&_voxels); // we don't need to do this processing on shutdown
|
VoxelTreeElement::removeDeleteHook(&_voxels); // we don't need to do this processing on shutdown
|
||||||
Menu::getInstance()->deleteLater();
|
Menu::getInstance()->deleteLater();
|
||||||
|
|
||||||
_avatarManager.clear();
|
|
||||||
_myAvatar = NULL;
|
|
||||||
|
|
||||||
delete _logger;
|
|
||||||
delete _settings;
|
|
||||||
delete _glWidget;
|
delete _glWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4003,18 +3998,12 @@ void Application::setMenuShortcutsEnabled(bool enabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::updateWindowTitle(){
|
void Application::updateWindowTitle(){
|
||||||
QString title = "";
|
|
||||||
|
|
||||||
QString buildVersion = " (build " + applicationVersion() + ")";
|
|
||||||
|
|
||||||
QString username = _profile.getUsername();
|
|
||||||
if(!username.isEmpty()){
|
|
||||||
title += username;
|
|
||||||
title += " @ ";
|
|
||||||
}
|
|
||||||
|
|
||||||
title += NodeList::getInstance()->getDomainHostname();
|
QString buildVersion = " (build " + applicationVersion() + ")";
|
||||||
title += buildVersion;
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
|
QString title = QString() + _profile.getUsername() + " " + nodeList->getOwnerUUID().toString()
|
||||||
|
+ " @ " + nodeList->getDomainHostname() + buildVersion;
|
||||||
|
|
||||||
qDebug("Application title set to: %s", title.toStdString().c_str());
|
qDebug("Application title set to: %s", title.toStdString().c_str());
|
||||||
_window->setWindowTitle(title);
|
_window->setWindowTitle(title);
|
||||||
|
@ -4192,33 +4181,33 @@ void Application::packetSent(quint64 length) {
|
||||||
_bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length);
|
_bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::loadScripts(){
|
void Application::loadScripts() {
|
||||||
// loads all saved scripts
|
// loads all saved scripts
|
||||||
QSettings* settings = new QSettings(this);
|
QSettings* settings = new QSettings(this);
|
||||||
int size = settings->beginReadArray("Settings");
|
int size = settings->beginReadArray("Settings");
|
||||||
for(int i=0; i<size; ++i){
|
|
||||||
settings->setArrayIndex(i);
|
for (int i = 0; i < size; ++i){
|
||||||
QString string = settings->value("script").toString();
|
settings->setArrayIndex(i);
|
||||||
loadScript(string);
|
QString string = settings->value("script").toString();
|
||||||
}
|
loadScript(string);
|
||||||
settings->endArray();
|
}
|
||||||
|
|
||||||
|
settings->endArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::saveScripts(){
|
void Application::saveScripts() {
|
||||||
// saves all current running scripts
|
// saves all current running scripts
|
||||||
QSettings* settings = new QSettings(this);
|
QSettings* settings = new QSettings(this);
|
||||||
settings->beginWriteArray("Settings");
|
settings->beginWriteArray("Settings");
|
||||||
for(int i=0; i<_activeScripts.size(); ++i){
|
for (int i = 0; i < _activeScripts.size(); ++i){
|
||||||
settings->setArrayIndex(i);
|
settings->setArrayIndex(i);
|
||||||
settings->setValue("script", _activeScripts.at(i));
|
settings->setValue("script", _activeScripts.at(i));
|
||||||
}
|
}
|
||||||
settings->endArray();
|
|
||||||
|
settings->endArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::removeScriptName(const QString& fileNameString)
|
void Application::removeScriptName(const QString& fileNameString) {
|
||||||
{
|
|
||||||
_activeScripts.removeOne(fileNameString);
|
_activeScripts.removeOne(fileNameString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4250,7 +4239,8 @@ void Application::loadScript(const QString& fileNameString) {
|
||||||
// start the script on a new thread...
|
// start the script on a new thread...
|
||||||
bool wantMenuItems = true; // tells the ScriptEngine object to add menu items for itself
|
bool wantMenuItems = true; // tells the ScriptEngine object to add menu items for itself
|
||||||
|
|
||||||
ScriptEngine* scriptEngine = new ScriptEngine(script, wantMenuItems, fileName, Menu::getInstance(), &_controllerScriptingInterface);
|
ScriptEngine* scriptEngine = new ScriptEngine(script, wantMenuItems, fileName, Menu::getInstance(),
|
||||||
|
&_controllerScriptingInterface);
|
||||||
scriptEngine->setupMenuItems();
|
scriptEngine->setupMenuItems();
|
||||||
|
|
||||||
// setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so
|
// setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so
|
||||||
|
|
|
@ -18,7 +18,10 @@ const QString FILENAME_FORMAT = "hifi-log_%1_%2.txt";
|
||||||
const QString DATETIME_FORMAT = "yyyy-MM-dd_hh.mm.ss";
|
const QString DATETIME_FORMAT = "yyyy-MM-dd_hh.mm.ss";
|
||||||
const QString LOGS_DIRECTORY = "Logs";
|
const QString LOGS_DIRECTORY = "Logs";
|
||||||
|
|
||||||
FileLogger::FileLogger() : _logData(NULL) {
|
FileLogger::FileLogger(QObject* parent) :
|
||||||
|
AbstractLoggerInterface(parent),
|
||||||
|
_logData(NULL)
|
||||||
|
{
|
||||||
setExtraDebugging(false);
|
setExtraDebugging(false);
|
||||||
|
|
||||||
_fileName = FileUtils::standardPath(LOGS_DIRECTORY);
|
_fileName = FileUtils::standardPath(LOGS_DIRECTORY);
|
||||||
|
|
|
@ -16,7 +16,7 @@ class FileLogger : public AbstractLoggerInterface {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FileLogger();
|
FileLogger(QObject* parent = NULL);
|
||||||
|
|
||||||
virtual void addMessage(QString);
|
virtual void addMessage(QString);
|
||||||
virtual QStringList getLogData() { return _logData; };
|
virtual QStringList getLogData() { return _logData; };
|
||||||
|
|
|
@ -32,10 +32,11 @@ void ParticleTreeRenderer::init() {
|
||||||
|
|
||||||
void ParticleTreeRenderer::update() {
|
void ParticleTreeRenderer::update() {
|
||||||
if (_tree) {
|
if (_tree) {
|
||||||
ParticleTree* tree = (ParticleTree*)_tree;
|
ParticleTree* tree = static_cast<ParticleTree*>(_tree);
|
||||||
_tree->lockForWrite();
|
if (tree->tryLockForWrite()) {
|
||||||
tree->update();
|
tree->update();
|
||||||
_tree->unlock();
|
tree->unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,10 @@ void Profile::setUUID(const QUuid& uuid) {
|
||||||
|
|
||||||
// when the UUID is changed we need set it appropriately on the NodeList instance
|
// when the UUID is changed we need set it appropriately on the NodeList instance
|
||||||
NodeList::getInstance()->setOwnerUUID(uuid);
|
NodeList::getInstance()->setOwnerUUID(uuid);
|
||||||
}
|
|
||||||
|
// ask for a window title update so the new UUID is presented
|
||||||
|
Application::getInstance()->updateWindowTitle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Profile::setFaceModelURL(const QUrl& faceModelURL) {
|
void Profile::setFaceModelURL(const QUrl& faceModelURL) {
|
||||||
|
|
|
@ -240,9 +240,9 @@ public:
|
||||||
|
|
||||||
// Octree does not currently handle its own locking, caller must use these to lock/unlock
|
// Octree does not currently handle its own locking, caller must use these to lock/unlock
|
||||||
void lockForRead() { lock.lockForRead(); }
|
void lockForRead() { lock.lockForRead(); }
|
||||||
void tryLockForRead() { lock.tryLockForRead(); }
|
bool tryLockForRead() { return lock.tryLockForRead(); }
|
||||||
void lockForWrite() { lock.lockForWrite(); }
|
void lockForWrite() { lock.lockForWrite(); }
|
||||||
void tryLockForWrite() { lock.tryLockForWrite(); }
|
bool tryLockForWrite() { return lock.tryLockForWrite(); }
|
||||||
void unlock() { lock.unlock(); }
|
void unlock() { lock.unlock(); }
|
||||||
|
|
||||||
unsigned long getOctreeElementsCount();
|
unsigned long getOctreeElementsCount();
|
||||||
|
|
|
@ -60,8 +60,6 @@ void Particle::handleAddParticleResponse(const QByteArray& packet) {
|
||||||
memcpy(&particleID, dataAt, sizeof(particleID));
|
memcpy(&particleID, dataAt, sizeof(particleID));
|
||||||
dataAt += sizeof(particleID);
|
dataAt += sizeof(particleID);
|
||||||
|
|
||||||
//qDebug() << "handleAddParticleResponse()... particleID=" << particleID << " creatorTokenID=" << creatorTokenID;
|
|
||||||
|
|
||||||
// add our token to id mapping
|
// add our token to id mapping
|
||||||
_tokenIDsToIDs[creatorTokenID] = particleID;
|
_tokenIDsToIDs[creatorTokenID] = particleID;
|
||||||
}
|
}
|
||||||
|
@ -361,8 +359,6 @@ Particle Particle::fromEditPacket(const unsigned char* data, int length, int& pr
|
||||||
dataAt += sizeof(editID);
|
dataAt += sizeof(editID);
|
||||||
processedBytes += sizeof(editID);
|
processedBytes += sizeof(editID);
|
||||||
|
|
||||||
//qDebug() << "editID:" << editID;
|
|
||||||
|
|
||||||
bool isNewParticle = (editID == NEW_PARTICLE);
|
bool isNewParticle = (editID == NEW_PARTICLE);
|
||||||
|
|
||||||
// special case for handling "new" particles
|
// special case for handling "new" particles
|
||||||
|
@ -411,7 +407,6 @@ Particle Particle::fromEditPacket(const unsigned char* data, int length, int& pr
|
||||||
memcpy(&packetContainsBits, dataAt, sizeof(packetContainsBits));
|
memcpy(&packetContainsBits, dataAt, sizeof(packetContainsBits));
|
||||||
dataAt += sizeof(packetContainsBits);
|
dataAt += sizeof(packetContainsBits);
|
||||||
processedBytes += sizeof(packetContainsBits);
|
processedBytes += sizeof(packetContainsBits);
|
||||||
//qDebug() << "packetContainsBits:" << packetContainsBits;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -528,7 +523,6 @@ Particle Particle::fromEditPacket(const unsigned char* data, int length, int& pr
|
||||||
if (wantDebugging) {
|
if (wantDebugging) {
|
||||||
qDebug("Particle::fromEditPacket()...");
|
qDebug("Particle::fromEditPacket()...");
|
||||||
qDebug() << " Particle id in packet:" << editID;
|
qDebug() << " Particle id in packet:" << editID;
|
||||||
//qDebug() << " position: " << newParticle._position;
|
|
||||||
newParticle.debugDump();
|
newParticle.debugDump();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,8 +729,6 @@ bool Particle::encodeParticleEditMessageDetails(PacketType command, ParticleID i
|
||||||
// cleanup
|
// cleanup
|
||||||
delete[] octcode;
|
delete[] octcode;
|
||||||
|
|
||||||
//qDebug() << "encoding... sizeOut:" << sizeOut;
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,12 +816,8 @@ void Particle::update(const quint64& now) {
|
||||||
_lastUpdated = now;
|
_lastUpdated = now;
|
||||||
|
|
||||||
// calculate our default shouldDie state... then allow script to change it if it wants...
|
// calculate our default shouldDie state... then allow script to change it if it wants...
|
||||||
float speed = glm::length(_velocity);
|
|
||||||
bool isStopped = (speed < MIN_VALID_SPEED);
|
|
||||||
const quint64 REALLY_OLD = 30 * USECS_PER_SECOND; // 30 seconds
|
|
||||||
bool isReallyOld = ((now - _created) > REALLY_OLD);
|
|
||||||
bool isInHand = getInHand();
|
bool isInHand = getInHand();
|
||||||
bool shouldDie = (getAge() > getLifetime()) || getShouldDie() || (!isInHand && isStopped && isReallyOld);
|
bool shouldDie = (getAge() > getLifetime()) || getShouldDie();
|
||||||
setShouldDie(shouldDie);
|
setShouldDie(shouldDie);
|
||||||
|
|
||||||
executeUpdateScripts(); // allow the javascript to alter our state
|
executeUpdateScripts(); // allow the javascript to alter our state
|
||||||
|
@ -1068,7 +1056,7 @@ QScriptValue ParticleProperties::copyToScriptValue(QScriptEngine* engine) const
|
||||||
|
|
||||||
if (_idSet) {
|
if (_idSet) {
|
||||||
properties.setProperty("id", _id);
|
properties.setProperty("id", _id);
|
||||||
properties.setProperty("isKnownID", (_id == UNKNOWN_PARTICLE_ID));
|
properties.setProperty("isKnownID", (_id != UNKNOWN_PARTICLE_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
|
|
|
@ -56,9 +56,10 @@ bool ParticleCollisionSystem::updateOperation(OctreeElement* element, void* extr
|
||||||
|
|
||||||
void ParticleCollisionSystem::update() {
|
void ParticleCollisionSystem::update() {
|
||||||
// update all particles
|
// update all particles
|
||||||
_particles->lockForWrite();
|
if (_particles->tryLockForWrite()) {
|
||||||
_particles->recurseTreeWithOperation(updateOperation, this);
|
_particles->recurseTreeWithOperation(updateOperation, this);
|
||||||
_particles->unlock();
|
_particles->unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,12 +69,12 @@ void ParticleCollisionSystem::checkParticle(Particle* particle) {
|
||||||
updateCollisionWithAvatars(particle);
|
updateCollisionWithAvatars(particle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleCollisionSystem::emitGlobalParicleCollisionWithVoxel(Particle* particle, VoxelDetail* voxelDetails) {
|
void ParticleCollisionSystem::emitGlobalParticleCollisionWithVoxel(Particle* particle, VoxelDetail* voxelDetails) {
|
||||||
ParticleID particleID = particle->getParticleID();
|
ParticleID particleID = particle->getParticleID();
|
||||||
emit particleCollisionWithVoxel(particleID, *voxelDetails);
|
emit particleCollisionWithVoxel(particleID, *voxelDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleCollisionSystem::emitGlobalParicleCollisionWithParticle(Particle* particleA, Particle* particleB) {
|
void ParticleCollisionSystem::emitGlobalParticleCollisionWithParticle(Particle* particleA, Particle* particleB) {
|
||||||
ParticleID idA = particleA->getParticleID();
|
ParticleID idA = particleA->getParticleID();
|
||||||
ParticleID idB = particleB->getParticleID();
|
ParticleID idB = particleB->getParticleID();
|
||||||
emit particleCollisionWithParticle(idA, idB);
|
emit particleCollisionWithParticle(idA, idB);
|
||||||
|
@ -95,7 +96,7 @@ void ParticleCollisionSystem::updateCollisionWithVoxels(Particle* particle) {
|
||||||
particle->collisionWithVoxel(voxelDetails);
|
particle->collisionWithVoxel(voxelDetails);
|
||||||
|
|
||||||
// let the global script run their collision scripts for particles if they have them
|
// let the global script run their collision scripts for particles if they have them
|
||||||
emitGlobalParicleCollisionWithVoxel(particle, voxelDetails);
|
emitGlobalParticleCollisionWithVoxel(particle, voxelDetails);
|
||||||
|
|
||||||
updateCollisionSound(particle, collisionInfo._penetration, COLLISION_FREQUENCY);
|
updateCollisionSound(particle, collisionInfo._penetration, COLLISION_FREQUENCY);
|
||||||
collisionInfo._penetration /= (float)(TREE_SCALE);
|
collisionInfo._penetration /= (float)(TREE_SCALE);
|
||||||
|
@ -124,7 +125,7 @@ void ParticleCollisionSystem::updateCollisionWithParticles(Particle* particleA)
|
||||||
if (glm::dot(relativeVelocity, penetration) > 0.0f) {
|
if (glm::dot(relativeVelocity, penetration) > 0.0f) {
|
||||||
particleA->collisionWithParticle(particleB);
|
particleA->collisionWithParticle(particleB);
|
||||||
particleB->collisionWithParticle(particleA);
|
particleB->collisionWithParticle(particleA);
|
||||||
emitGlobalParicleCollisionWithParticle(particleA, particleB);
|
emitGlobalParticleCollisionWithParticle(particleA, particleB);
|
||||||
|
|
||||||
glm::vec3 axis = glm::normalize(penetration);
|
glm::vec3 axis = glm::normalize(penetration);
|
||||||
glm::vec3 axialVelocity = glm::dot(relativeVelocity, axis) * axis;
|
glm::vec3 axialVelocity = glm::dot(relativeVelocity, axis) * axis;
|
||||||
|
|
|
@ -58,8 +58,8 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool updateOperation(OctreeElement* element, void* extraData);
|
static bool updateOperation(OctreeElement* element, void* extraData);
|
||||||
void emitGlobalParicleCollisionWithVoxel(Particle* particle, VoxelDetail* voxelDetails);
|
void emitGlobalParticleCollisionWithVoxel(Particle* particle, VoxelDetail* voxelDetails);
|
||||||
void emitGlobalParicleCollisionWithParticle(Particle* particleA, Particle* particleB);
|
void emitGlobalParticleCollisionWithParticle(Particle* particleA, Particle* particleB);
|
||||||
|
|
||||||
ParticleEditPacketSender* _packetSender;
|
ParticleEditPacketSender* _packetSender;
|
||||||
ParticleTree* _particles;
|
ParticleTree* _particles;
|
||||||
|
|
|
@ -43,6 +43,7 @@ ParticleID ParticlesScriptingInterface::addParticle(const ParticleProperties& pr
|
||||||
|
|
||||||
ParticleID ParticlesScriptingInterface::identifyParticle(ParticleID particleID) {
|
ParticleID ParticlesScriptingInterface::identifyParticle(ParticleID particleID) {
|
||||||
uint32_t actualID = particleID.id;
|
uint32_t actualID = particleID.id;
|
||||||
|
|
||||||
if (!particleID.isKnownID) {
|
if (!particleID.isKnownID) {
|
||||||
actualID = Particle::getIDfromCreatorTokenID(particleID.creatorTokenID);
|
actualID = Particle::getIDfromCreatorTokenID(particleID.creatorTokenID);
|
||||||
if (actualID == UNKNOWN_PARTICLE_ID) {
|
if (actualID == UNKNOWN_PARTICLE_ID) {
|
||||||
|
@ -65,8 +66,12 @@ ParticleProperties ParticlesScriptingInterface::getParticleProperties(ParticleID
|
||||||
}
|
}
|
||||||
if (_particleTree) {
|
if (_particleTree) {
|
||||||
_particleTree->lockForRead();
|
_particleTree->lockForRead();
|
||||||
const Particle* particle = _particleTree->findParticleByID(identity.id);
|
const Particle* particle = _particleTree->findParticleByID(identity.id, true);
|
||||||
results.copyFromParticle(*particle);
|
if (particle) {
|
||||||
|
results.copyFromParticle(*particle);
|
||||||
|
} else {
|
||||||
|
results.setIsUnknownID();
|
||||||
|
}
|
||||||
_particleTree->unlock();
|
_particleTree->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,22 +118,19 @@ void ParticlesScriptingInterface::deleteParticle(ParticleID particleID) {
|
||||||
properties.setShouldDie(true);
|
properties.setShouldDie(true);
|
||||||
|
|
||||||
uint32_t actualID = particleID.id;
|
uint32_t actualID = particleID.id;
|
||||||
|
|
||||||
|
// if the particle is unknown, attempt to look it up
|
||||||
if (!particleID.isKnownID) {
|
if (!particleID.isKnownID) {
|
||||||
actualID = Particle::getIDfromCreatorTokenID(particleID.creatorTokenID);
|
actualID = Particle::getIDfromCreatorTokenID(particleID.creatorTokenID);
|
||||||
|
|
||||||
// hmmm... we kind of want to bail if someone attempts to edit an unknown
|
|
||||||
if (actualID == UNKNOWN_PARTICLE_ID) {
|
|
||||||
//qDebug() << "ParticlesScriptingInterface::deleteParticle(), bailing - unknown particle...";
|
|
||||||
return; // bailing early
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
particleID.id = actualID;
|
// if at this point, we know the id, send the update to the particle server
|
||||||
particleID.isKnownID = true;
|
if (actualID != UNKNOWN_PARTICLE_ID) {
|
||||||
|
particleID.id = actualID;
|
||||||
|
particleID.isKnownID = true;
|
||||||
|
queueParticleMessage(PacketTypeParticleAddOrEdit, particleID, properties);
|
||||||
|
}
|
||||||
|
|
||||||
//qDebug() << "ParticlesScriptingInterface::deleteParticle(), queueParticleMessage......";
|
|
||||||
queueParticleMessage(PacketTypeParticleAddOrEdit, particleID, properties);
|
|
||||||
|
|
||||||
// If we have a local particle tree set, then also update it.
|
// If we have a local particle tree set, then also update it.
|
||||||
if (_particleTree) {
|
if (_particleTree) {
|
||||||
_particleTree->lockForWrite();
|
_particleTree->lockForWrite();
|
||||||
|
|
|
@ -40,7 +40,8 @@ static QScriptValue soundConstructor(QScriptContext* context, QScriptEngine* eng
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ScriptEngine::ScriptEngine(const QString& scriptContents, bool wantMenuItems, const QString& fileNameString, AbstractMenuInterface* menu,
|
ScriptEngine::ScriptEngine(const QString& scriptContents, bool wantMenuItems, const QString& fileNameString,
|
||||||
|
AbstractMenuInterface* menu,
|
||||||
AbstractControllerScriptingInterface* controllerScriptingInterface) :
|
AbstractControllerScriptingInterface* controllerScriptingInterface) :
|
||||||
_isAvatar(false),
|
_isAvatar(false),
|
||||||
_dataServerScriptingInterface(),
|
_dataServerScriptingInterface(),
|
||||||
|
@ -133,7 +134,7 @@ void ScriptEngine::init() {
|
||||||
QScriptValue injectionOptionValue = _engine.scriptValueFromQMetaObject<AudioInjectorOptions>();
|
QScriptValue injectionOptionValue = _engine.scriptValueFromQMetaObject<AudioInjectorOptions>();
|
||||||
_engine.globalObject().setProperty("AudioInjectionOptions", injectionOptionValue);
|
_engine.globalObject().setProperty("AudioInjectionOptions", injectionOptionValue);
|
||||||
|
|
||||||
registerGlobalObject("Agent", this);
|
registerGlobalObject("Script", this);
|
||||||
registerGlobalObject("Audio", &_audioScriptingInterface);
|
registerGlobalObject("Audio", &_audioScriptingInterface);
|
||||||
registerGlobalObject("Controller", _controllerScriptingInterface);
|
registerGlobalObject("Controller", _controllerScriptingInterface);
|
||||||
registerGlobalObject("Data", &_dataServerScriptingInterface);
|
registerGlobalObject("Data", &_dataServerScriptingInterface);
|
||||||
|
@ -260,6 +261,27 @@ void ScriptEngine::run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit scriptEnding();
|
emit scriptEnding();
|
||||||
|
|
||||||
|
if (_voxelsScriptingInterface.getVoxelPacketSender()->serversExist()) {
|
||||||
|
// release the queue of edit voxel messages.
|
||||||
|
_voxelsScriptingInterface.getVoxelPacketSender()->releaseQueuedMessages();
|
||||||
|
|
||||||
|
// since we're in non-threaded mode, call process so that the packets are sent
|
||||||
|
if (!_voxelsScriptingInterface.getVoxelPacketSender()->isThreaded()) {
|
||||||
|
_voxelsScriptingInterface.getVoxelPacketSender()->process();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_particlesScriptingInterface.getParticlePacketSender()->serversExist()) {
|
||||||
|
// release the queue of edit voxel messages.
|
||||||
|
_particlesScriptingInterface.getParticlePacketSender()->releaseQueuedMessages();
|
||||||
|
|
||||||
|
// since we're in non-threaded mode, call process so that the packets are sent
|
||||||
|
if (!_particlesScriptingInterface.getParticlePacketSender()->isThreaded()) {
|
||||||
|
_particlesScriptingInterface.getParticlePacketSender()->process();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cleanMenuItems();
|
cleanMenuItems();
|
||||||
|
|
||||||
// If we were on a thread, then wait till it's done
|
// If we were on a thread, then wait till it's done
|
||||||
|
|
|
@ -31,12 +31,10 @@ const QString NO_SCRIPT("");
|
||||||
|
|
||||||
class ScriptEngine : public QObject {
|
class ScriptEngine : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(bool isAvatar READ isAvatar WRITE setIsAvatar)
|
|
||||||
public:
|
public:
|
||||||
ScriptEngine(const QString& scriptContents = NO_SCRIPT, bool wantMenuItems = false,
|
ScriptEngine(const QString& scriptContents = NO_SCRIPT, bool wantMenuItems = false,
|
||||||
const QString& scriptMenuName = QString(""), AbstractMenuInterface* menu = NULL,
|
const QString& scriptMenuName = QString(""), AbstractMenuInterface* menu = NULL,
|
||||||
AbstractControllerScriptingInterface* controllerScriptingInterface = NULL);
|
AbstractControllerScriptingInterface* controllerScriptingInterface = NULL);
|
||||||
|
|
||||||
~ScriptEngine();
|
~ScriptEngine();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue