fixes per review, clap animation requires double-tap to start

This commit is contained in:
Philip Rosedale 2014-07-13 23:33:02 -07:00
parent b0e44be1c0
commit 2d4194cae5
3 changed files with 9 additions and 14 deletions

View file

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

View file

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

View file

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