merge upstream/master into andrew/bispinor

This commit is contained in:
Andrew Meadows 2015-01-10 07:47:52 -08:00
commit ecd352fd4d
8 changed files with 28 additions and 41 deletions

View file

@ -54,7 +54,6 @@ Head::Head(Avatar* owningAvatar) :
_deltaRoll(0.0f), _deltaRoll(0.0f),
_deltaLeanSideways(0.0f), _deltaLeanSideways(0.0f),
_deltaLeanForward(0.0f), _deltaLeanForward(0.0f),
_torsoTwist(0.0f),
_isCameraMoving(false), _isCameraMoving(false),
_isLookingAtMe(false), _isLookingAtMe(false),
_faceModel(this), _faceModel(this),

View file

@ -76,9 +76,6 @@ public:
float getFinalLeanSideways() const { return _leanSideways + _deltaLeanSideways; } float getFinalLeanSideways() const { return _leanSideways + _deltaLeanSideways; }
float getFinalLeanForward() const { return _leanForward + _deltaLeanForward; } float getFinalLeanForward() const { return _leanForward + _deltaLeanForward; }
float getTorsoTwist() const { return _torsoTwist; }
void setTorsoTwist(float torsoTwist) { _torsoTwist = torsoTwist; }
glm::quat getEyeRotation(const glm::vec3& eyePosition) const; glm::quat getEyeRotation(const glm::vec3& eyePosition) const;
const glm::vec3& getRightEyePosition() const { return _rightEyePosition; } const glm::vec3& getRightEyePosition() const { return _rightEyePosition; }
@ -151,8 +148,6 @@ private:
// delta lean angles for lean perturbations (driven by collisions) // delta lean angles for lean perturbations (driven by collisions)
float _deltaLeanSideways; float _deltaLeanSideways;
float _deltaLeanForward; float _deltaLeanForward;
float _torsoTwist;
bool _isCameraMoving; bool _isCameraMoving;
bool _isLookingAtMe; bool _isLookingAtMe;

View file

@ -158,15 +158,18 @@ QByteArray AvatarData::toByteArray() {
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _targetScale); destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _targetScale);
// Head rotation (NOTE: This needs to become a quaternion to save two bytes) // Head rotation (NOTE: This needs to become a quaternion to save two bytes)
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalYaw()); glm::vec3 pitchYawRoll = glm::vec3(_headData->getFinalPitch(),
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalPitch()); _headData->getFinalYaw(),
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalRoll()); _headData->getFinalRoll());
if (this->isMyAvatar()) {
// Head lean X,Z (head lateral and fwd/back motion relative to torso) glm::vec3 lean = glm::vec3(_headData->getFinalLeanForward(),
memcpy(destinationBuffer, &_headData->_leanSideways, sizeof(_headData->_leanSideways)); _headData->getTorsoTwist(),
destinationBuffer += sizeof(_headData->_leanSideways); _headData->getFinalLeanSideways());
memcpy(destinationBuffer, &_headData->_leanForward, sizeof(_headData->_leanForward)); pitchYawRoll -= lean;
destinationBuffer += sizeof(_headData->_leanForward); }
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.x);
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.y);
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.z);
// Lookat Position // Lookat Position
memcpy(destinationBuffer, &_headData->_lookAtPosition, sizeof(_headData->_lookAtPosition)); memcpy(destinationBuffer, &_headData->_lookAtPosition, sizeof(_headData->_lookAtPosition));
@ -287,18 +290,16 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
// bodyPitch = 2 (compressed float) // bodyPitch = 2 (compressed float)
// bodyRoll = 2 (compressed float) // bodyRoll = 2 (compressed float)
// targetScale = 2 (compressed float) // targetScale = 2 (compressed float)
// headYaw = 2 (compressed float)
// headPitch = 2 (compressed float) // headPitch = 2 (compressed float)
// headYaw = 2 (compressed float)
// headRoll = 2 (compressed float) // headRoll = 2 (compressed float)
// leanSideways = 4
// leanForward = 4
// lookAt = 12 // lookAt = 12
// audioLoudness = 4 // audioLoudness = 4
// } // }
// + 1 byte for pupilSize // + 1 byte for pupilSize
// + 1 byte for numJoints (0) // + 1 byte for numJoints (0)
// = 53 bytes // = 45 bytes
int minPossibleSize = 52; int minPossibleSize = 45;
int maxAvailableSize = packet.size() - offset; int maxAvailableSize = packet.size() - offset;
if (minPossibleSize > maxAvailableSize) { if (minPossibleSize > maxAvailableSize) {
@ -356,8 +357,8 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
{ // Head rotation { // Head rotation
//(NOTE: This needs to become a quaternion to save two bytes) //(NOTE: This needs to become a quaternion to save two bytes)
float headYaw, headPitch, headRoll; float headYaw, headPitch, headRoll;
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw);
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headPitch); sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headPitch);
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw);
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headRoll); sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headRoll);
if (glm::isnan(headYaw) || glm::isnan(headPitch) || glm::isnan(headRoll)) { if (glm::isnan(headYaw) || glm::isnan(headPitch) || glm::isnan(headRoll)) {
if (shouldLogError(now)) { if (shouldLogError(now)) {
@ -365,27 +366,10 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
} }
return maxAvailableSize; return maxAvailableSize;
} }
_headData->setBaseYaw(headYaw);
_headData->setBasePitch(headPitch); _headData->setBasePitch(headPitch);
_headData->setBaseYaw(headYaw);
_headData->setBaseRoll(headRoll); _headData->setBaseRoll(headRoll);
} // 6 bytes } // 6 bytes
// Head lean (relative to pelvis)
{
float leanSideways, leanForward;
memcpy(&leanSideways, sourceBuffer, sizeof(float));
sourceBuffer += sizeof(float);
memcpy(&leanForward, sourceBuffer, sizeof(float));
sourceBuffer += sizeof(float);
if (glm::isnan(leanSideways) || glm::isnan(leanForward)) {
if (shouldLogError(now)) {
qDebug() << "Discard nan AvatarData::leanSideways,leanForward; displayName = '" << _displayName << "'";
}
return maxAvailableSize;
}
_headData->_leanSideways = leanSideways;
_headData->_leanForward = leanForward;
} // 8 bytes
{ // Lookat Position { // Lookat Position
glm::vec3 lookAt; glm::vec3 lookAt;

View file

@ -152,6 +152,8 @@ class AvatarData : public QObject {
public: public:
AvatarData(); AvatarData();
virtual ~AvatarData(); virtual ~AvatarData();
virtual bool isMyAvatar() { return false; }
const QUuid& getSessionUUID() const { return _sessionUUID; } const QUuid& getSessionUUID() const { return _sessionUUID; }

View file

@ -24,6 +24,7 @@ HeadData::HeadData(AvatarData* owningAvatar) :
_baseRoll(0.0f), _baseRoll(0.0f),
_leanSideways(0.0f), _leanSideways(0.0f),
_leanForward(0.0f), _leanForward(0.0f),
_torsoTwist(0.0f),
_lookAtPosition(0.0f, 0.0f, 0.0f), _lookAtPosition(0.0f, 0.0f, 0.0f),
_audioLoudness(0.0f), _audioLoudness(0.0f),
_isFaceshiftConnected(false), _isFaceshiftConnected(false),

View file

@ -71,11 +71,13 @@ public:
float getLeanSideways() const { return _leanSideways; } float getLeanSideways() const { return _leanSideways; }
float getLeanForward() const { return _leanForward; } float getLeanForward() const { return _leanForward; }
float getTorsoTwist() const { return _torsoTwist; }
virtual float getFinalLeanSideways() const { return _leanSideways; } virtual float getFinalLeanSideways() const { return _leanSideways; }
virtual float getFinalLeanForward() const { return _leanForward; } virtual float getFinalLeanForward() const { return _leanForward; }
void setLeanSideways(float leanSideways) { _leanSideways = leanSideways; } void setLeanSideways(float leanSideways) { _leanSideways = leanSideways; }
void setLeanForward(float leanForward) { _leanForward = leanForward; } void setLeanForward(float leanForward) { _leanForward = leanForward; }
void setTorsoTwist(float torsoTwist) { _torsoTwist = torsoTwist; }
friend class AvatarData; friend class AvatarData;
@ -86,6 +88,7 @@ protected:
float _baseRoll; float _baseRoll;
float _leanSideways; float _leanSideways;
float _leanForward; float _leanForward;
float _torsoTwist;
glm::vec3 _lookAtPosition; glm::vec3 _lookAtPosition;
float _audioLoudness; float _audioLoudness;

View file

@ -57,7 +57,7 @@ PacketVersion versionForPacketType(PacketType type) {
case PacketTypeInjectAudio: case PacketTypeInjectAudio:
return 1; return 1;
case PacketTypeAvatarData: case PacketTypeAvatarData:
return 4; return 5;
case PacketTypeAvatarIdentity: case PacketTypeAvatarIdentity:
return 1; return 1;
case PacketTypeEnvironmentData: case PacketTypeEnvironmentData:

View file

@ -13,6 +13,7 @@
#define hifi_DependencyManager_h #define hifi_DependencyManager_h
#include <QSharedPointer> #include <QSharedPointer>
#include <QDebug>
#include <typeinfo> #include <typeinfo>
@ -22,10 +23,12 @@ public:\
private:\ private:\
void customDeleter() {\ void customDeleter() {\
QObject* thisObject = dynamic_cast<QObject*>(this);\ QObject* thisObject = dynamic_cast<QObject*>(this);\
if (thisObject) {\ if (thisObject && thisObject->parent()) {\
thisObject->deleteLater();\ thisObject->deleteLater();\
qDebug() << "Delete later:" << #T;\
} else {\ } else {\
delete this;\ delete this;\
qDebug() << "Deleted:" << #T;\
}\ }\
}\ }\
friend class DependencyManager; friend class DependencyManager;