From 2d4194cae501d3dfba678e17856b161185d76bc4 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Sun, 13 Jul 2014 23:33:02 -0700 Subject: [PATCH] fixes per review, clap animation requires double-tap to start --- examples/clap.js | 12 +++++------- interface/src/Hair.cpp | 10 ++++------ interface/src/avatar/Avatar.cpp | 1 - 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/examples/clap.js b/examples/clap.js index 28835c1f00..6e70979c2e 100644 --- a/examples/clap.js +++ b/examples/clap.js @@ -94,23 +94,21 @@ function playClap(volume, position) { Audio.playSound(claps[clip], options); } -var FASTEST_CLAP_INTERVAL = 100.0; -var SLOWEST_CLAP_INTERVAL = 2000.0; +var FASTEST_CLAP_INTERVAL = 150.0; +var SLOWEST_CLAP_INTERVAL = 750.0; Controller.keyPressEvent.connect(function(event) { if(event.text == "SHIFT") { if (!clickClappingNow) { clickClappingNow = true; clickStartTime = new Date(); - playClap(1.0, Camera.getPosition()); lastClapFrame = 0; - MyAvatar.startAnimation(clapAnimation, clapRate, 1.0, true, false); } else { - // Adjust animation speed for measured clicking interval + // start or adjust clapping speed based on the duration between clicks clickEndTime = new Date(); - var milliseconds = clickEndTime - clickStartTime; + var milliseconds = Math.max(clickEndTime - clickStartTime, FASTEST_CLAP_INTERVAL); clickStartTime = new Date(); - if ((milliseconds < SLOWEST_CLAP_INTERVAL) && (milliseconds > FASTEST_CLAP_INTERVAL)) { + if (milliseconds < SLOWEST_CLAP_INTERVAL) { clapRate = ANIMATION_FRAMES_PER_CLAP * (1000.0 / milliseconds); playClap(1.0, Camera.getPosition()); MyAvatar.stopAnimation(clapAnimation); diff --git a/interface/src/Hair.cpp b/interface/src/Hair.cpp index 824e273049..4dc9b9cf98 100644 --- a/interface/src/Hair.cpp +++ b/interface/src/Hair.cpp @@ -20,7 +20,7 @@ const float CONSTRAINT_RELAXATION = 10.0f; const float HAIR_ACCELERATION_COUPLING = 0.025f; const float HAIR_ANGULAR_VELOCITY_COUPLING = 0.10f; const float HAIR_MAX_LINEAR_ACCELERATION = 4.0f; -const float HAIR_STIFFNESS = 0.0003f; +const float HAIR_STIFFNESS = 0.005f; const glm::vec3 HAIR_COLOR1(0.98f, 0.92f, 0.843f); const glm::vec3 HAIR_COLOR2(0.545f, 0.533f, 0.47f); @@ -72,12 +72,10 @@ Hair::Hair(int strands, _hairConstraints[vertexIndex * HAIR_CONSTRAINTS + 1] = vertexIndex + 1; } } - _hairPosition[vertexIndex] = thisVertex; - _hairLastPosition[vertexIndex] = _hairPosition[vertexIndex]; - _hairOriginalPosition[vertexIndex] = _hairPosition[vertexIndex]; + _hairOriginalPosition[vertexIndex] = _hairLastPosition[vertexIndex] = _hairPosition[vertexIndex] = thisVertex; _hairQuadDelta[vertexIndex] = glm::vec3(cos(strandAngle) * _hairThickness, 0.f, sin(strandAngle) * _hairThickness); - _hairQuadDelta[vertexIndex] *= 1.f - (link / _links); + _hairQuadDelta[vertexIndex] *= 1.f - ((float)link / _links); _hairNormals[vertexIndex] = glm::normalize(randVector()); if (randFloat() < elevation / PI_OVER_TWO) { _hairColors[vertexIndex] = HAIR_COLOR1 * ((float)(link + 1) / (float)_links); @@ -123,7 +121,7 @@ void Hair::simulate(float deltaTime) { // Add stiffness to return to original position _hairPosition[vertexIndex] += (_hairOriginalPosition[vertexIndex] - _hairPosition[vertexIndex]) - * powf(1.f - link / _links, 2.f) * HAIR_STIFFNESS; + * powf(1.f - (float)link / _links, 2.f) * HAIR_STIFFNESS; // Add angular acceleration const float ANGULAR_VELOCITY_MIN = 0.001f; diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index ff49d7394b..fd8f2d836b 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -46,7 +46,6 @@ const float DISPLAYNAME_BACKGROUND_ALPHA = 0.4f; Avatar::Avatar() : AvatarData(), - _hair(), _skeletonModel(this), _bodyYawDelta(0.0f), _velocity(0.0f, 0.0f, 0.0f),