fixed indent, added some damping debugging

This commit is contained in:
ZappoMan 2013-12-12 10:59:28 -08:00
parent 5ec8de1bf3
commit e1b3b9d967
3 changed files with 85 additions and 79 deletions

View file

@ -22,7 +22,7 @@ using namespace std;
const float FINGERTIP_VOXEL_SIZE = 0.05; const float FINGERTIP_VOXEL_SIZE = 0.05;
const int TOY_BALL_HAND = 1; const int TOY_BALL_HAND = 1;
const float TOY_BALL_RADIUS = 0.05f; const float TOY_BALL_RADIUS = 0.05f;
const float TOY_BALL_DAMPING = 0.f; const float TOY_BALL_DAMPING = 0.99f;
const glm::vec3 TOY_BALL_GRAVITY = glm::vec3(0,-1,0); const glm::vec3 TOY_BALL_GRAVITY = glm::vec3(0,-1,0);
const QString TOY_BALL_UPDATE_SCRIPT(""); const QString TOY_BALL_UPDATE_SCRIPT("");
const float PALM_COLLISION_RADIUS = 0.03f; const float PALM_COLLISION_RADIUS = 0.03f;
@ -39,6 +39,7 @@ Hand::Hand(Avatar* owningAvatar) :
_toyBallPosition(0), _toyBallPosition(0),
_toyBallVelocity(0), _toyBallVelocity(0),
_toyBallInHand(false), _toyBallInHand(false),
_hasToyBall(false),
_ballParticleEditHandle(NULL), _ballParticleEditHandle(NULL),
_pitchUpdate(0) _pitchUpdate(0)
{ {
@ -58,7 +59,6 @@ void Hand::reset() {
} }
void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, float deltaTime) { void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, float deltaTime) {
// Is the controller button being held down.... // Is the controller button being held down....
if (palm.getControllerButtons() & BUTTON_FWD) { if (palm.getControllerButtons() & BUTTON_FWD) {
// If grabbing toy ball, add forces to it. // If grabbing toy ball, add forces to it.
@ -72,6 +72,7 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f
bool isCaught = true; bool isCaught = true;
if (isCaught) { if (isCaught) {
_toyBallInHand = true; _toyBallInHand = true;
_hasToyBall = true;
// create the ball, call MakeParticle, and use the resulting ParticleEditHandle to // create the ball, call MakeParticle, and use the resulting ParticleEditHandle to
// manage the newly created particle. // manage the newly created particle.
@ -139,8 +140,11 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f
_toyBallPosition.y = 0.f; _toyBallPosition.y = 0.f;
_toyBallVelocity.y *= -1.f; _toyBallVelocity.y *= -1.f;
} }
_toyBallVelocity -= (_toyBallVelocity * TOY_BALL_DAMPING) * deltaTime;
if (_hasToyBall) {
_toyBallVelocity -= (_toyBallVelocity * TOY_BALL_DAMPING) * deltaTime;
//printf("applying damping to TOY_BALL deltaTime=%f\n",deltaTime);
}
} }
void Hand::simulate(float deltaTime, bool isMine) { void Hand::simulate(float deltaTime, bool isMine) {

View file

@ -99,6 +99,7 @@ private:
glm::vec3 _toyBallPosition; glm::vec3 _toyBallPosition;
glm::vec3 _toyBallVelocity; glm::vec3 _toyBallVelocity;
bool _toyBallInHand; bool _toyBallInHand;
bool _hasToyBall;
ParticleEditHandle* _ballParticleEditHandle; ParticleEditHandle* _ballParticleEditHandle;
float _pitchUpdate; float _pitchUpdate;

View file

@ -375,6 +375,7 @@ void Particle::update() {
// handle damping // handle damping
glm::vec3 dampingResistance = _velocity * _damping; glm::vec3 dampingResistance = _velocity * _damping;
_velocity -= dampingResistance * timeElapsed; _velocity -= dampingResistance * timeElapsed;
//printf("applying damping to Particle timeElapsed=%f\n",timeElapsed);
_lastUpdated = now; _lastUpdated = now;
} }