From d3197ef8f9c9baa86d87aa6bdd4f3e7457f72a11 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 12 Dec 2013 13:54:36 -0800 Subject: [PATCH] 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();