From 939a9bf5c415543055f8a675a38fa4a1a533ad12 Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Thu, 12 Dec 2013 12:59:34 -0800 Subject: [PATCH 1/3] We can let qt find things on its own, which will let us add frameworks/plugins inside the bundle --- interface/src/main.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 31468f1320..07788fefe0 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -24,11 +24,6 @@ int main(int argc, const char * argv[]) { timeval startup_time; gettimeofday(&startup_time, NULL); - #if defined(Q_OS_MAC) - const QString QT_RELEASE_PLUGIN_PATH = "/usr/local/lib/qt5/plugins"; - QCoreApplication::addLibraryPath(QT_RELEASE_PLUGIN_PATH); - #endif - int exitCode; { Application app(argc, const_cast(argv), startup_time); From d3197ef8f9c9baa86d87aa6bdd4f3e7457f72a11 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 12 Dec 2013 13:54:36 -0800 Subject: [PATCH 2/3] fix crash, and remove gravity while in hand --- interface/src/Application.cpp | 5 ++++- interface/src/avatar/Hand.cpp | 6 ++++-- libraries/particles/src/Particle.cpp | 3 +++ libraries/particles/src/ParticleTreeElement.cpp | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1ab9dea1f3..c84165456e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2815,8 +2815,11 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node int packetLength = endOfVoxelQueryPacket - voxelQueryPacket; - nodeList->getNodeSocket().writeDatagram((char*) voxelQueryPacket, packetLength, + // make sure we still have an active socket + if (node->getActiveSocket()) { + nodeList->getNodeSocket().writeDatagram((char*) voxelQueryPacket, packetLength, node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort()); + } // Feed number of bytes to corresponding channel of the bandwidth meter _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength); diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 32a9c26d36..7530096e9d 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -23,6 +23,7 @@ const float FINGERTIP_VOXEL_SIZE = 0.05; const int TOY_BALL_HAND = 1; const float TOY_BALL_RADIUS = 0.05f; const float TOY_BALL_DAMPING = 0.99f; +const glm::vec3 NO_GRAVITY = glm::vec3(0,0,0); const glm::vec3 TOY_BALL_GRAVITY = glm::vec3(0,-1,0); const QString TOY_BALL_UPDATE_SCRIPT(""); const QString TOY_BALL_DONT_DIE_SCRIPT("Particle.setShouldDie(false);"); @@ -101,7 +102,7 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f TOY_BALL_RADIUS / (float) TREE_SCALE, TOY_BALL_ON_SERVER_COLOR, _toyBallVelocity / (float)TREE_SCALE, - TOY_BALL_GRAVITY / (float) TREE_SCALE, + NO_GRAVITY / (float) TREE_SCALE, TOY_BALL_DAMPING, TOY_BALL_DONT_DIE_SCRIPT); } @@ -115,7 +116,7 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f TOY_BALL_RADIUS / (float) TREE_SCALE, TOY_BALL_ON_SERVER_COLOR, _toyBallVelocity / (float)TREE_SCALE, - TOY_BALL_GRAVITY / (float) TREE_SCALE, + NO_GRAVITY / (float) TREE_SCALE, TOY_BALL_DAMPING, TOY_BALL_DONT_DIE_SCRIPT); } @@ -130,6 +131,7 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f //printVector(avatarRotation * handVelocity); _toyBallVelocity += avatarRotation * fingerTipVelocity; + // ball is no longer in hand... _ballParticleEditHandle->updateParticle(fingerTipPosition / (float)TREE_SCALE, TOY_BALL_RADIUS / (float) TREE_SCALE, TOY_BALL_ON_SERVER_COLOR, diff --git a/libraries/particles/src/Particle.cpp b/libraries/particles/src/Particle.cpp index e0b24ad4dc..9f945999b6 100644 --- a/libraries/particles/src/Particle.cpp +++ b/libraries/particles/src/Particle.cpp @@ -249,6 +249,9 @@ Particle Particle::fromEditPacket(unsigned char* data, int length, int& processe void Particle::debugDump() const { printf("Particle id :%u\n", _id); printf(" last updated:%llu\n", _lastUpdated); + printf(" position:%f,%f,%f\n", _position.x, _position.y, _position.z); + printf(" velocity:%f,%f,%f\n", _velocity.x, _velocity.y, _velocity.z); + printf(" gravity:%f,%f,%f\n", _gravity.x, _gravity.y, _gravity.z); } bool Particle::encodeParticleEditMessageDetails(PACKET_TYPE command, int count, const ParticleDetail* details, diff --git a/libraries/particles/src/ParticleTreeElement.cpp b/libraries/particles/src/ParticleTreeElement.cpp index a997dd1480..d98e0d2e0a 100644 --- a/libraries/particles/src/ParticleTreeElement.cpp +++ b/libraries/particles/src/ParticleTreeElement.cpp @@ -65,6 +65,7 @@ void ParticleTreeElement::update(ParticleTreeUpdateArgs& args) { // update our contained particles uint16_t numberOfParticles = _particles.size(); + for (uint16_t i = 0; i < numberOfParticles; i++) { _particles[i].update(); From 18cbb2d00f254593b1db520290fc598b6b60a52b Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 12 Dec 2013 15:09:30 -0800 Subject: [PATCH 3/3] particle tree pruning on update --- .../octree-server/src/OctreePersistThread.cpp | 2 ++ libraries/octree/src/Octree.cpp | 25 +++++++++++-------- libraries/octree/src/OctreeElement.cpp | 6 +++-- libraries/particles/src/ParticleTree.cpp | 14 +++++++++++ libraries/particles/src/ParticleTree.h | 1 + libraries/particles/src/ParticleTreeElement.h | 3 ++- 6 files changed, 37 insertions(+), 14 deletions(-) diff --git a/libraries/octree-server/src/OctreePersistThread.cpp b/libraries/octree-server/src/OctreePersistThread.cpp index aba683e110..4361ae1044 100644 --- a/libraries/octree-server/src/OctreePersistThread.cpp +++ b/libraries/octree-server/src/OctreePersistThread.cpp @@ -68,7 +68,9 @@ bool OctreePersistThread::process() { usleep(USECS_TO_SLEEP); // do our updates then check to save... + _tree->lockForWrite(); _tree->update(); + _tree->unlock(); uint64_t now = usecTimestampNow(); uint64_t sinceLastSave = now - _lastCheck; diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index 724a52808d..d10248d9e3 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -1083,19 +1083,22 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* node, for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { if (oneAtBit(childrenColoredBits, i)) { OctreeElement* childNode = node->getChildAtIndex(i); - continueThisLevel = childNode->appendElementData(packetData); - - if (!continueThisLevel) { - break; // no point in continuing - } - - bytesAtThisLevel += BYTES_PER_COLOR; // keep track of byte count for color + if (childNode) { + int bytesBeforeChild = packetData->getUncompressedSize(); + continueThisLevel = childNode->appendElementData(packetData); + int bytesAfterChild = packetData->getUncompressedSize(); + + if (!continueThisLevel) { + break; // no point in continuing + } + + bytesAtThisLevel += (bytesAfterChild - bytesBeforeChild); // keep track of byte count for this child - // don't need to check childNode here, because we can't get here with no childNode - if (params.stats) { - params.stats->colorSent(childNode); + // don't need to check childNode here, because we can't get here with no childNode + if (params.stats) { + params.stats->colorSent(childNode); + } } - } } } diff --git a/libraries/octree/src/OctreeElement.cpp b/libraries/octree/src/OctreeElement.cpp index 5a11e0ec5c..b7a791991b 100644 --- a/libraries/octree/src/OctreeElement.cpp +++ b/libraries/octree/src/OctreeElement.cpp @@ -196,7 +196,7 @@ void OctreeElement::calculateAABox() { void OctreeElement::deleteChildAtIndex(int childIndex) { OctreeElement* childAt = getChildAtIndex(childIndex); if (childAt) { -printf("deleteChildAtIndex()... about to call delete childAt=%p\n",childAt); + //printf("deleteChildAtIndex()... about to call delete childAt=%p\n",childAt); delete childAt; setChildAtIndex(childIndex, NULL); _isDirty = true; @@ -1292,7 +1292,9 @@ OctreeElement* OctreeElement::getOrCreateChildElementAt(float x, float y, float float ourScale = getScale(); float halfOurScale = ourScale / 2.0f; - assert(s <= ourScale); // This should never happen + if(s > ourScale) { + printf("UNEXPECTED -- OctreeElement::getOrCreateChildElementAt() s=[%f] > ourScale=[%f] \n", s, ourScale); + } if (s > halfOurScale) { return this; diff --git a/libraries/particles/src/ParticleTree.cpp b/libraries/particles/src/ParticleTree.cpp index 152f1dec69..c1fd6d8bbb 100644 --- a/libraries/particles/src/ParticleTree.cpp +++ b/libraries/particles/src/ParticleTree.cpp @@ -169,6 +169,17 @@ bool ParticleTree::updateOperation(OctreeElement* element, void* extraData) { return true; } +bool ParticleTree::pruneOperation(OctreeElement* element, void* extraData) { + ParticleTreeElement* particleTreeElement = static_cast(element); + for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { + ParticleTreeElement* childAt = particleTreeElement->getChildAtIndex(i); + if (childAt && childAt->isLeaf() && !childAt->hasParticles()) { + particleTreeElement->deleteChildAtIndex(i); + } + } + return true; +} + void ParticleTree::update() { _isDirty = true; @@ -187,6 +198,9 @@ void ParticleTree::update() { storeParticle(args._movingParticles[i]); } } + + // prune the tree... + recurseTreeWithOperation(pruneOperation, NULL); } diff --git a/libraries/particles/src/ParticleTree.h b/libraries/particles/src/ParticleTree.h index 2491934252..9d7d4a98f8 100644 --- a/libraries/particles/src/ParticleTree.h +++ b/libraries/particles/src/ParticleTree.h @@ -53,6 +53,7 @@ private: static bool updateOperation(OctreeElement* element, void* extraData); static bool findAndUpdateOperation(OctreeElement* element, void* extraData); static bool findNearPointOperation(OctreeElement* element, void* extraData); + static bool pruneOperation(OctreeElement* element, void* extraData); void notifyNewlyCreatedParticle(const Particle& newParticle, Node* senderNode); diff --git a/libraries/particles/src/ParticleTreeElement.h b/libraries/particles/src/ParticleTreeElement.h index 292e0fe745..b513a4a860 100644 --- a/libraries/particles/src/ParticleTreeElement.h +++ b/libraries/particles/src/ParticleTreeElement.h @@ -71,9 +71,10 @@ public: /// shouldRender() state, the tree will remark elements as changed even in cases there the elements have not changed. virtual bool isRendered() const { return getShouldRender(); } - virtual bool deleteApproved() const { return (_particles.size() == 0); } + virtual bool deleteApproved() const { return !hasParticles(); } const std::vector& getParticles() const { return _particles; } + bool hasParticles() const { return _particles.size() > 0; } void update(ParticleTreeUpdateArgs& args); void setTree(ParticleTree* tree) { _myTree = tree; }