Merge pull request #496 from ey6es/master

Apply the head rotation to the head bones, show balls when no avatar voxel URL is set.
This commit is contained in:
birarda 2013-06-06 13:51:54 -07:00
commit b40af0f02b
5 changed files with 16 additions and 11 deletions

View file

@ -40,4 +40,4 @@ int InjectedAudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes
currentBuffer += parseAudioSamples(currentBuffer, numBytes - (currentBuffer - sourceBuffer));
return currentBuffer - sourceBuffer;
}
}

View file

@ -65,4 +65,4 @@ bool PositionalAudioRingBuffer::shouldBeAddedToMix(int numJitterBufferSamples) {
}
return false;
}
}

View file

@ -806,13 +806,12 @@ void Avatar::applyCollisionWithScene(const glm::vec3& penetration) {
static float STATIC_FRICTION_VELOCITY = 0.15f;
static float STATIC_FRICTION_DAMPING = 0.0f;
static float KINETIC_FRICTION_DAMPING = 0.95f;
const float BOUNCE = 0.3f;
// reflect the velocity component in the direction of penetration
// cancel out the velocity component in the direction of penetration
float penetrationLength = glm::length(penetration);
if (penetrationLength > EPSILON) {
glm::vec3 direction = penetration / penetrationLength;
_velocity -= 2.0f * glm::dot(_velocity, direction) * direction * BOUNCE;
_velocity -= glm::dot(_velocity, direction) * direction;
_velocity *= KINETIC_FRICTION_DAMPING;
// If velocity is quite low, apply static friction that takes away energy
if (glm::length(_velocity) < STATIC_FRICTION_VELOCITY) {
@ -1008,7 +1007,6 @@ void Avatar::updateBodyBalls(float deltaTime) {
resetBodyBalls();
}
glm::quat orientation = getOrientation();
glm::vec3 jointDirection = orientation * JOINT_DIRECTION;
for (int b = 0; b < NUM_AVATAR_BODY_BALLS; b++) {
glm::vec3 springVector;
@ -1068,11 +1066,18 @@ void Avatar::updateBodyBalls(float deltaTime) {
if (_skeleton.joint[b].parent == AVATAR_JOINT_NULL || length < SMALL_SPRING_LENGTH) {
_bodyBall[b].rotation = orientation * _skeleton.joint[_bodyBall[b].parentJoint].absoluteBindPoseRotation;
} else {
glm::vec3 parentDirection = _bodyBall[ _skeleton.joint[b].parent ].rotation * JOINT_DIRECTION;
glm::vec3 parentDirection = _bodyBall[ _bodyBall[b].parentBall ].rotation * JOINT_DIRECTION;
_bodyBall[b].rotation = rotationBetween(parentDirection, springVector) *
_bodyBall[ _skeleton.joint[b].parent ].rotation;
_bodyBall[ _bodyBall[b].parentBall ].rotation;
}
}
// copy the head's rotation
_bodyBall[BODY_BALL_HEAD_BASE].rotation = _bodyBall[BODY_BALL_HEAD_TOP].rotation = _head.getOrientation();
_bodyBall[BODY_BALL_HEAD_BASE].position = _bodyBall[BODY_BALL_NECK_BASE].position +
_bodyBall[BODY_BALL_HEAD_BASE].rotation * _skeleton.joint[BODY_BALL_HEAD_BASE].bindPosePosition;
_bodyBall[BODY_BALL_HEAD_TOP].position = _bodyBall[BODY_BALL_HEAD_BASE].position +
_bodyBall[BODY_BALL_HEAD_TOP].rotation * _skeleton.joint[BODY_BALL_HEAD_TOP].bindPosePosition;
}
void Avatar::updateArmIKAndConstraints(float deltaTime) {
@ -1133,7 +1138,7 @@ void Avatar::renderBody(bool lookingInMirror, bool renderAvatarBalls) {
const float RENDER_TRANSLUCENT_BEYOND = 0.5f;
// Render the body as balls and cones
if (renderAvatarBalls) {
if (renderAvatarBalls || !_voxels.getVoxelURL().isValid()) {
for (int b = 0; b < NUM_AVATAR_BODY_BALLS; b++) {
float distanceToCamera = glm::length(_cameraPosition - _bodyBall[b].position);

View file

@ -56,6 +56,7 @@ void Skeleton::initialize() {
joint[ AVATAR_JOINT_CHEST ].bindPosePosition = glm::vec3( 0.0, 0.09, -0.01 );
joint[ AVATAR_JOINT_NECK_BASE ].bindPosePosition = glm::vec3( 0.0, 0.14, 0.01 );
joint[ AVATAR_JOINT_HEAD_BASE ].bindPosePosition = glm::vec3( 0.0, 0.04, 0.00 );
joint[ AVATAR_JOINT_HEAD_TOP ].bindPosePosition = glm::vec3( 0.0, 0.04, 0.00 );
joint[ AVATAR_JOINT_LEFT_COLLAR ].bindPosePosition = glm::vec3( -0.06, 0.04, 0.01 );
joint[ AVATAR_JOINT_LEFT_SHOULDER ].bindPosePosition = glm::vec3( -0.05, 0.0, 0.01 );
@ -85,6 +86,7 @@ void Skeleton::initialize() {
joint[ AVATAR_JOINT_CHEST ].defaultPosePosition = glm::vec3( 0.0, 0.09, -0.01 );
joint[ AVATAR_JOINT_NECK_BASE ].defaultPosePosition = glm::vec3( 0.0, 0.14, 0.01 );
joint[ AVATAR_JOINT_HEAD_BASE ].defaultPosePosition = glm::vec3( 0.0, 0.04, 0.00 );
joint[ AVATAR_JOINT_HEAD_TOP ].defaultPosePosition = glm::vec3( 0.0, 0.04, 0.00 );
joint[ AVATAR_JOINT_LEFT_COLLAR ].defaultPosePosition = glm::vec3( -0.06, 0.04, 0.01 );
joint[ AVATAR_JOINT_LEFT_SHOULDER ].defaultPosePosition = glm::vec3( -0.05, 0.0, 0.01 );

View file

@ -256,7 +256,6 @@ void VoxelSystem::copyWrittenDataToReadArraysFullVBOs() {
void VoxelSystem::copyWrittenDataToReadArraysPartialVBOs() {
glBufferIndex segmentStart = 0;
glBufferIndex segmentEnd = 0;
bool inSegment = false;
for (glBufferIndex i = 0; i < _voxelsInWriteArrays; i++) {
bool thisVoxelDirty = _writeVoxelDirtyArray[i];
@ -560,7 +559,6 @@ void VoxelSystem::updateFullVBOs() {
void VoxelSystem::updatePartialVBOs() {
glBufferIndex segmentStart = 0;
glBufferIndex segmentEnd = 0;
bool inSegment = false;
for (glBufferIndex i = 0; i < _voxelsInReadArrays; i++) {
bool thisVoxelDirty = _readVoxelDirtyArray[i];