mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 01:03:57 +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
|
||||
_scriptEngine.setAvatarData(&scriptedAvatar, "Avatar");
|
||||
|
||||
// register ourselves to the script engine
|
||||
_scriptEngine.registerGlobalObject("Agent", this);
|
||||
|
||||
_scriptEngine.setScriptContents(scriptContents);
|
||||
_scriptEngine.run();
|
||||
|
|
|
@ -21,9 +21,14 @@
|
|||
|
||||
class Agent : public ThreadedAssignment {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(bool isAvatar READ isAvatar WRITE setIsAvatar)
|
||||
public:
|
||||
Agent(const QByteArray& packet);
|
||||
|
||||
void setIsAvatar(bool isAvatar) { _scriptEngine.setIsAvatar(isAvatar); }
|
||||
bool isAvatar() const { return _scriptEngine.isAvatar(); }
|
||||
|
||||
public slots:
|
||||
void run();
|
||||
|
||||
|
|
|
@ -90,7 +90,8 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
|||
timer->start(ASSIGNMENT_REQUEST_INTERVAL_MSECS);
|
||||
|
||||
// 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() {
|
||||
|
|
|
@ -62,4 +62,4 @@ function maybePlaySound() {
|
|||
}
|
||||
|
||||
// Connect a call back that happens every frame
|
||||
Agent.willSendVisualDataCallback.connect(maybePlaySound);
|
||||
Script.willSendVisualDataCallback.connect(maybePlaySound);
|
|
@ -132,7 +132,7 @@ function draw() {
|
|||
print(scriptB);
|
||||
numberParticlesAdded++;
|
||||
} else {
|
||||
Agent.stop();
|
||||
Script.stop();
|
||||
}
|
||||
|
||||
print("Particles Stats: " + Particles.getLifetimeInSeconds() + " seconds," +
|
||||
|
@ -150,5 +150,5 @@ function draw() {
|
|||
// register the call back so it fires before each data send
|
||||
print("here...\n");
|
||||
Particles.setPacketsPerSecond(40000);
|
||||
Agent.willSendVisualDataCallback.connect(draw);
|
||||
Script.willSendVisualDataCallback.connect(draw);
|
||||
print("and here...\n");
|
||||
|
|
|
@ -82,7 +82,7 @@ function touchEndEvent(event) {
|
|||
}
|
||||
|
||||
// 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
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
|
@ -199,4 +199,4 @@ function scriptEnding() {
|
|||
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
|
||||
Agent.willSendVisualDataCallback.connect(displayCount);
|
||||
Script.willSendVisualDataCallback.connect(displayCount);
|
||||
|
||||
// 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
|
||||
Agent.willSendVisualDataCallback.connect(checkSticks);
|
||||
Script.willSendVisualDataCallback.connect(checkSticks);
|
|
@ -44,7 +44,6 @@ var particleID = Particles.addParticle(originalProperties);
|
|||
|
||||
function moveParticle() {
|
||||
if (count >= moveUntil) {
|
||||
//Agent.stop();
|
||||
|
||||
// delete it...
|
||||
if (count == moveUntil) {
|
||||
|
@ -54,8 +53,8 @@ function moveParticle() {
|
|||
|
||||
// stop it...
|
||||
if (count >= stopAfter) {
|
||||
print("calling Agent.stop()");
|
||||
Agent.stop();
|
||||
print("calling Script.stop()");
|
||||
Script.stop();
|
||||
}
|
||||
|
||||
count++;
|
||||
|
@ -86,5 +85,5 @@ function moveParticle() {
|
|||
|
||||
|
||||
// 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
|
||||
// stop it...
|
||||
if (iteration >= 100) {
|
||||
print("calling Agent.stop()");
|
||||
Agent.stop();
|
||||
print("calling Script.stop()");
|
||||
Script.stop();
|
||||
}
|
||||
|
||||
print("--------------------------");
|
||||
|
@ -122,7 +122,7 @@ function findParticles() {
|
|||
|
||||
|
||||
// register the call back so it fires before each data send
|
||||
Agent.willSendVisualDataCallback.connect(findParticles);
|
||||
Script.willSendVisualDataCallback.connect(findParticles);
|
||||
|
||||
// register our scriptEnding callback
|
||||
Agent.scriptEnding.connect(scriptEnding);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
|
|
@ -60,8 +60,8 @@ function makeFountain() {
|
|||
totalParticles++;
|
||||
}
|
||||
if (totalParticles > 100) {
|
||||
Agent.stop();
|
||||
Script.stop();
|
||||
}
|
||||
}
|
||||
// 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");
|
||||
Agent.willSendVisualDataCallback.connect(step);
|
||||
Script.willSendVisualDataCallback.connect(step);
|
||||
Voxels.setPacketsPerSecond(200);
|
||||
print("now here");
|
||||
|
|
|
@ -99,4 +99,4 @@ function checkController() {
|
|||
|
||||
|
||||
// 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;
|
||||
|
||||
// would be nice to change to update
|
||||
Agent.willSendVisualDataCallback.connect(update);
|
||||
Agent.scriptEnding.connect(scriptEnding);
|
||||
Script.willSendVisualDataCallback.connect(update);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
|
|
@ -41,4 +41,4 @@ function moveVoxel() {
|
|||
|
||||
Voxels.setPacketsPerSecond(300);
|
||||
// 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
|
||||
Agent.willSendVisualDataCallback.connect(checkController);
|
||||
Script.willSendVisualDataCallback.connect(checkController);
|
||||
|
|
|
@ -95,7 +95,7 @@ function moveBird() {
|
|||
var nowTimeInSeconds = new Date().getTime() / 1000;
|
||||
if ((nowTimeInSeconds - startTimeInSeconds) >= birdLifetime) {
|
||||
print("our bird is dying, stop our script");
|
||||
Agent.stop();
|
||||
Script.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -171,4 +171,4 @@ function moveBird() {
|
|||
}
|
||||
}
|
||||
// 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() {
|
||||
// stop it...
|
||||
if (count >= stopAfter) {
|
||||
print("calling Agent.stop()");
|
||||
Agent.stop();
|
||||
print("calling Script.stop()");
|
||||
Script.stop();
|
||||
}
|
||||
|
||||
print("count =" + count);
|
||||
|
@ -47,5 +47,5 @@ function endAfterAWhile() {
|
|||
|
||||
|
||||
// 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
|
||||
Agent.willSendVisualDataCallback.connect(maybePlaySound);
|
||||
Script.willSendVisualDataCallback.connect(maybePlaySound);
|
|
@ -37,7 +37,7 @@ function rideWithParticle() {
|
|||
y: propertiesA.position.y + 2,
|
||||
z: propertiesA.position.z };
|
||||
} else {
|
||||
Agent.stop();
|
||||
Script.stop();
|
||||
}
|
||||
|
||||
iteration++;
|
||||
|
@ -46,5 +46,5 @@ function rideWithParticle() {
|
|||
|
||||
|
||||
// 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
|
||||
Agent.willSendVisualDataCallback.connect(checkController);
|
||||
Script.willSendVisualDataCallback.connect(checkController);
|
||||
|
|
|
@ -130,4 +130,4 @@ function moveBird() {
|
|||
|
||||
Voxels.setPacketsPerSecond(10000);
|
||||
// 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
|
||||
|
||||
public:
|
||||
AbstractLoggerInterface(QObject* parent = NULL) : QObject(parent) {};
|
||||
inline bool extraDebugging() { return _extraDebugging; };
|
||||
inline void setExtraDebugging(bool debugging) { _extraDebugging = debugging; };
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
_resetRecentMaxPacketsSoon(true),
|
||||
_swatch(NULL),
|
||||
_pasteMode(false),
|
||||
_logger(new FileLogger()),
|
||||
_logger(new FileLogger(this)),
|
||||
_persistThread(NULL)
|
||||
{
|
||||
_myAvatar = _avatarManager.getMyAvatar();
|
||||
|
@ -321,19 +321,14 @@ Application::~Application() {
|
|||
_persistThread->deleteLater();
|
||||
_persistThread = NULL;
|
||||
}
|
||||
|
||||
|
||||
storeSizeAndPosition();
|
||||
saveScripts();
|
||||
_sharedVoxelSystem.changeTree(new VoxelTree);
|
||||
|
||||
VoxelTreeElement::removeDeleteHook(&_voxels); // we don't need to do this processing on shutdown
|
||||
Menu::getInstance()->deleteLater();
|
||||
|
||||
_avatarManager.clear();
|
||||
_myAvatar = NULL;
|
||||
|
||||
delete _logger;
|
||||
delete _settings;
|
||||
|
||||
delete _glWidget;
|
||||
}
|
||||
|
||||
|
@ -4003,18 +3998,12 @@ void Application::setMenuShortcutsEnabled(bool enabled) {
|
|||
}
|
||||
|
||||
void Application::updateWindowTitle(){
|
||||
QString title = "";
|
||||
|
||||
QString buildVersion = " (build " + applicationVersion() + ")";
|
||||
|
||||
QString username = _profile.getUsername();
|
||||
if(!username.isEmpty()){
|
||||
title += username;
|
||||
title += " @ ";
|
||||
}
|
||||
|
||||
title += NodeList::getInstance()->getDomainHostname();
|
||||
title += buildVersion;
|
||||
QString buildVersion = " (build " + applicationVersion() + ")";
|
||||
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());
|
||||
_window->setWindowTitle(title);
|
||||
|
@ -4192,33 +4181,33 @@ void Application::packetSent(quint64 length) {
|
|||
_bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length);
|
||||
}
|
||||
|
||||
void Application::loadScripts(){
|
||||
// loads all saved scripts
|
||||
QSettings* settings = new QSettings(this);
|
||||
int size = settings->beginReadArray("Settings");
|
||||
for(int i=0; i<size; ++i){
|
||||
settings->setArrayIndex(i);
|
||||
QString string = settings->value("script").toString();
|
||||
loadScript(string);
|
||||
}
|
||||
settings->endArray();
|
||||
|
||||
void Application::loadScripts() {
|
||||
// loads all saved scripts
|
||||
QSettings* settings = new QSettings(this);
|
||||
int size = settings->beginReadArray("Settings");
|
||||
|
||||
for (int i = 0; i < size; ++i){
|
||||
settings->setArrayIndex(i);
|
||||
QString string = settings->value("script").toString();
|
||||
loadScript(string);
|
||||
}
|
||||
|
||||
settings->endArray();
|
||||
}
|
||||
|
||||
void Application::saveScripts(){
|
||||
// saves all current running scripts
|
||||
QSettings* settings = new QSettings(this);
|
||||
settings->beginWriteArray("Settings");
|
||||
for(int i=0; i<_activeScripts.size(); ++i){
|
||||
settings->setArrayIndex(i);
|
||||
settings->setValue("script", _activeScripts.at(i));
|
||||
}
|
||||
settings->endArray();
|
||||
|
||||
void Application::saveScripts() {
|
||||
// saves all current running scripts
|
||||
QSettings* settings = new QSettings(this);
|
||||
settings->beginWriteArray("Settings");
|
||||
for (int i = 0; i < _activeScripts.size(); ++i){
|
||||
settings->setArrayIndex(i);
|
||||
settings->setValue("script", _activeScripts.at(i));
|
||||
}
|
||||
|
||||
settings->endArray();
|
||||
}
|
||||
|
||||
void Application::removeScriptName(const QString& fileNameString)
|
||||
{
|
||||
void Application::removeScriptName(const QString& fileNameString) {
|
||||
_activeScripts.removeOne(fileNameString);
|
||||
}
|
||||
|
||||
|
@ -4250,7 +4239,8 @@ void Application::loadScript(const QString& fileNameString) {
|
|||
// start the script on a new thread...
|
||||
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();
|
||||
|
||||
// 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 LOGS_DIRECTORY = "Logs";
|
||||
|
||||
FileLogger::FileLogger() : _logData(NULL) {
|
||||
FileLogger::FileLogger(QObject* parent) :
|
||||
AbstractLoggerInterface(parent),
|
||||
_logData(NULL)
|
||||
{
|
||||
setExtraDebugging(false);
|
||||
|
||||
_fileName = FileUtils::standardPath(LOGS_DIRECTORY);
|
||||
|
|
|
@ -16,7 +16,7 @@ class FileLogger : public AbstractLoggerInterface {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FileLogger();
|
||||
FileLogger(QObject* parent = NULL);
|
||||
|
||||
virtual void addMessage(QString);
|
||||
virtual QStringList getLogData() { return _logData; };
|
||||
|
|
|
@ -32,10 +32,11 @@ void ParticleTreeRenderer::init() {
|
|||
|
||||
void ParticleTreeRenderer::update() {
|
||||
if (_tree) {
|
||||
ParticleTree* tree = (ParticleTree*)_tree;
|
||||
_tree->lockForWrite();
|
||||
tree->update();
|
||||
_tree->unlock();
|
||||
ParticleTree* tree = static_cast<ParticleTree*>(_tree);
|
||||
if (tree->tryLockForWrite()) {
|
||||
tree->update();
|
||||
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
|
||||
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) {
|
||||
|
|
|
@ -240,9 +240,9 @@ public:
|
|||
|
||||
// Octree does not currently handle its own locking, caller must use these to lock/unlock
|
||||
void lockForRead() { lock.lockForRead(); }
|
||||
void tryLockForRead() { lock.tryLockForRead(); }
|
||||
bool tryLockForRead() { return lock.tryLockForRead(); }
|
||||
void lockForWrite() { lock.lockForWrite(); }
|
||||
void tryLockForWrite() { lock.tryLockForWrite(); }
|
||||
bool tryLockForWrite() { return lock.tryLockForWrite(); }
|
||||
void unlock() { lock.unlock(); }
|
||||
|
||||
unsigned long getOctreeElementsCount();
|
||||
|
|
|
@ -60,8 +60,6 @@ void Particle::handleAddParticleResponse(const QByteArray& packet) {
|
|||
memcpy(&particleID, dataAt, sizeof(particleID));
|
||||
dataAt += sizeof(particleID);
|
||||
|
||||
//qDebug() << "handleAddParticleResponse()... particleID=" << particleID << " creatorTokenID=" << creatorTokenID;
|
||||
|
||||
// add our token to id mapping
|
||||
_tokenIDsToIDs[creatorTokenID] = particleID;
|
||||
}
|
||||
|
@ -361,8 +359,6 @@ Particle Particle::fromEditPacket(const unsigned char* data, int length, int& pr
|
|||
dataAt += sizeof(editID);
|
||||
processedBytes += sizeof(editID);
|
||||
|
||||
//qDebug() << "editID:" << editID;
|
||||
|
||||
bool isNewParticle = (editID == NEW_PARTICLE);
|
||||
|
||||
// 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));
|
||||
dataAt += 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) {
|
||||
qDebug("Particle::fromEditPacket()...");
|
||||
qDebug() << " Particle id in packet:" << editID;
|
||||
//qDebug() << " position: " << newParticle._position;
|
||||
newParticle.debugDump();
|
||||
}
|
||||
|
||||
|
@ -735,8 +729,6 @@ bool Particle::encodeParticleEditMessageDetails(PacketType command, ParticleID i
|
|||
// cleanup
|
||||
delete[] octcode;
|
||||
|
||||
//qDebug() << "encoding... sizeOut:" << sizeOut;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
@ -824,12 +816,8 @@ void Particle::update(const quint64& now) {
|
|||
_lastUpdated = now;
|
||||
|
||||
// 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 shouldDie = (getAge() > getLifetime()) || getShouldDie() || (!isInHand && isStopped && isReallyOld);
|
||||
bool shouldDie = (getAge() > getLifetime()) || getShouldDie();
|
||||
setShouldDie(shouldDie);
|
||||
|
||||
executeUpdateScripts(); // allow the javascript to alter our state
|
||||
|
@ -1068,7 +1056,7 @@ QScriptValue ParticleProperties::copyToScriptValue(QScriptEngine* engine) const
|
|||
|
||||
if (_idSet) {
|
||||
properties.setProperty("id", _id);
|
||||
properties.setProperty("isKnownID", (_id == UNKNOWN_PARTICLE_ID));
|
||||
properties.setProperty("isKnownID", (_id != UNKNOWN_PARTICLE_ID));
|
||||
}
|
||||
|
||||
return properties;
|
||||
|
|
|
@ -56,9 +56,10 @@ bool ParticleCollisionSystem::updateOperation(OctreeElement* element, void* extr
|
|||
|
||||
void ParticleCollisionSystem::update() {
|
||||
// update all particles
|
||||
_particles->lockForWrite();
|
||||
_particles->recurseTreeWithOperation(updateOperation, this);
|
||||
_particles->unlock();
|
||||
if (_particles->tryLockForWrite()) {
|
||||
_particles->recurseTreeWithOperation(updateOperation, this);
|
||||
_particles->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,12 +69,12 @@ void ParticleCollisionSystem::checkParticle(Particle* particle) {
|
|||
updateCollisionWithAvatars(particle);
|
||||
}
|
||||
|
||||
void ParticleCollisionSystem::emitGlobalParicleCollisionWithVoxel(Particle* particle, VoxelDetail* voxelDetails) {
|
||||
void ParticleCollisionSystem::emitGlobalParticleCollisionWithVoxel(Particle* particle, VoxelDetail* voxelDetails) {
|
||||
ParticleID particleID = particle->getParticleID();
|
||||
emit particleCollisionWithVoxel(particleID, *voxelDetails);
|
||||
}
|
||||
|
||||
void ParticleCollisionSystem::emitGlobalParicleCollisionWithParticle(Particle* particleA, Particle* particleB) {
|
||||
void ParticleCollisionSystem::emitGlobalParticleCollisionWithParticle(Particle* particleA, Particle* particleB) {
|
||||
ParticleID idA = particleA->getParticleID();
|
||||
ParticleID idB = particleB->getParticleID();
|
||||
emit particleCollisionWithParticle(idA, idB);
|
||||
|
@ -95,7 +96,7 @@ void ParticleCollisionSystem::updateCollisionWithVoxels(Particle* particle) {
|
|||
particle->collisionWithVoxel(voxelDetails);
|
||||
|
||||
// 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);
|
||||
collisionInfo._penetration /= (float)(TREE_SCALE);
|
||||
|
@ -124,7 +125,7 @@ void ParticleCollisionSystem::updateCollisionWithParticles(Particle* particleA)
|
|||
if (glm::dot(relativeVelocity, penetration) > 0.0f) {
|
||||
particleA->collisionWithParticle(particleB);
|
||||
particleB->collisionWithParticle(particleA);
|
||||
emitGlobalParicleCollisionWithParticle(particleA, particleB);
|
||||
emitGlobalParticleCollisionWithParticle(particleA, particleB);
|
||||
|
||||
glm::vec3 axis = glm::normalize(penetration);
|
||||
glm::vec3 axialVelocity = glm::dot(relativeVelocity, axis) * axis;
|
||||
|
|
|
@ -58,8 +58,8 @@ signals:
|
|||
|
||||
private:
|
||||
static bool updateOperation(OctreeElement* element, void* extraData);
|
||||
void emitGlobalParicleCollisionWithVoxel(Particle* particle, VoxelDetail* voxelDetails);
|
||||
void emitGlobalParicleCollisionWithParticle(Particle* particleA, Particle* particleB);
|
||||
void emitGlobalParticleCollisionWithVoxel(Particle* particle, VoxelDetail* voxelDetails);
|
||||
void emitGlobalParticleCollisionWithParticle(Particle* particleA, Particle* particleB);
|
||||
|
||||
ParticleEditPacketSender* _packetSender;
|
||||
ParticleTree* _particles;
|
||||
|
|
|
@ -43,6 +43,7 @@ ParticleID ParticlesScriptingInterface::addParticle(const ParticleProperties& pr
|
|||
|
||||
ParticleID ParticlesScriptingInterface::identifyParticle(ParticleID particleID) {
|
||||
uint32_t actualID = particleID.id;
|
||||
|
||||
if (!particleID.isKnownID) {
|
||||
actualID = Particle::getIDfromCreatorTokenID(particleID.creatorTokenID);
|
||||
if (actualID == UNKNOWN_PARTICLE_ID) {
|
||||
|
@ -65,8 +66,12 @@ ParticleProperties ParticlesScriptingInterface::getParticleProperties(ParticleID
|
|||
}
|
||||
if (_particleTree) {
|
||||
_particleTree->lockForRead();
|
||||
const Particle* particle = _particleTree->findParticleByID(identity.id);
|
||||
results.copyFromParticle(*particle);
|
||||
const Particle* particle = _particleTree->findParticleByID(identity.id, true);
|
||||
if (particle) {
|
||||
results.copyFromParticle(*particle);
|
||||
} else {
|
||||
results.setIsUnknownID();
|
||||
}
|
||||
_particleTree->unlock();
|
||||
}
|
||||
|
||||
|
@ -113,22 +118,19 @@ void ParticlesScriptingInterface::deleteParticle(ParticleID particleID) {
|
|||
properties.setShouldDie(true);
|
||||
|
||||
uint32_t actualID = particleID.id;
|
||||
|
||||
// if the particle is unknown, attempt to look it up
|
||||
if (!particleID.isKnownID) {
|
||||
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;
|
||||
particleID.isKnownID = true;
|
||||
// if at this point, we know the id, send the update to the particle server
|
||||
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 (_particleTree) {
|
||||
_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) :
|
||||
_isAvatar(false),
|
||||
_dataServerScriptingInterface(),
|
||||
|
@ -133,7 +134,7 @@ void ScriptEngine::init() {
|
|||
QScriptValue injectionOptionValue = _engine.scriptValueFromQMetaObject<AudioInjectorOptions>();
|
||||
_engine.globalObject().setProperty("AudioInjectionOptions", injectionOptionValue);
|
||||
|
||||
registerGlobalObject("Agent", this);
|
||||
registerGlobalObject("Script", this);
|
||||
registerGlobalObject("Audio", &_audioScriptingInterface);
|
||||
registerGlobalObject("Controller", _controllerScriptingInterface);
|
||||
registerGlobalObject("Data", &_dataServerScriptingInterface);
|
||||
|
@ -260,6 +261,27 @@ void ScriptEngine::run() {
|
|||
}
|
||||
}
|
||||
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();
|
||||
|
||||
// If we were on a thread, then wait till it's done
|
||||
|
|
|
@ -31,12 +31,10 @@ const QString NO_SCRIPT("");
|
|||
|
||||
class ScriptEngine : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(bool isAvatar READ isAvatar WRITE setIsAvatar)
|
||||
public:
|
||||
ScriptEngine(const QString& scriptContents = NO_SCRIPT, bool wantMenuItems = false,
|
||||
const QString& scriptMenuName = QString(""), AbstractMenuInterface* menu = NULL,
|
||||
AbstractControllerScriptingInterface* controllerScriptingInterface = NULL);
|
||||
const QString& scriptMenuName = QString(""), AbstractMenuInterface* menu = NULL,
|
||||
AbstractControllerScriptingInterface* controllerScriptingInterface = NULL);
|
||||
|
||||
~ScriptEngine();
|
||||
|
||||
|
|
Loading…
Reference in a new issue