fix crash, and remove gravity while in hand

This commit is contained in:
ZappoMan 2013-12-12 13:54:36 -08:00
parent 50b93d1e2b
commit d3197ef8f9
4 changed files with 12 additions and 3 deletions

View file

@ -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);

View file

@ -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,

View file

@ -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,

View file

@ -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();