Merge branch 'master' of github.com:Atlante45/hifi

This commit is contained in:
Atlante45 2014-08-25 12:47:01 -07:00
commit 88c8e5124e
7 changed files with 108 additions and 92 deletions

View file

@ -105,7 +105,6 @@ public:
float getAudioOutputAverageMsecsUnplayed() const { return (float)_audioOutputMsecsUnplayedStats.getWindowAverage(); }
void setRecorder(RecorderPointer recorder) { _recorder = recorder; }
void setPlayer(PlayerPointer player) { _player = player; }
public slots:
void start();
@ -314,7 +313,6 @@ private:
AudioOutputIODevice _audioOutputIODevice;
WeakRecorderPointer _recorder;
WeakPlayerPointer _player;
};

View file

@ -575,58 +575,6 @@ void MyAvatar::saveRecording(QString filename) {
}
}
bool MyAvatar::isPlaying() {
if (!_player) {
return false;
}
if (QThread::currentThread() != thread()) {
bool result;
QMetaObject::invokeMethod(this, "isPlaying", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, result));
return result;
}
return _player && _player->isPlaying();
}
qint64 MyAvatar::playerElapsed() {
if (!_player) {
return 0;
}
if (QThread::currentThread() != thread()) {
qint64 result;
QMetaObject::invokeMethod(this, "playerElapsed", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(qint64, result));
return result;
}
return _player->elapsed();
}
qint64 MyAvatar::playerLength() {
if (!_player) {
return 0;
}
if (QThread::currentThread() != thread()) {
qint64 result;
QMetaObject::invokeMethod(this, "playerLength", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(qint64, result));
return result;
}
return _player->getRecording()->getLength();
}
void MyAvatar::loadRecording(QString filename) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "loadRecording", Qt::BlockingQueuedConnection,
Q_ARG(QString, filename));
return;
}
if (!_player) {
_player = PlayerPointer(new Player(this));
}
_player->loadFromFile(filename);
}
void MyAvatar::loadLastRecording() {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "loadLastRecording", Qt::BlockingQueuedConnection);
@ -643,32 +591,6 @@ void MyAvatar::loadLastRecording() {
_player->loadRecording(_recorder->getRecording());
}
void MyAvatar::startPlaying() {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "startPlaying", Qt::BlockingQueuedConnection);
return;
}
if (!_player) {
_player = PlayerPointer(new Player(this));
}
Application::getInstance()->getAudio()->setPlayer(_player);
_player->startPlaying();
}
void MyAvatar::stopPlaying() {
if (!_player) {
return;
}
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "stopPlaying", Qt::BlockingQueuedConnection);
return;
}
if (_player) {
_player->stopPlaying();
}
}
void MyAvatar::setLocalGravity(glm::vec3 gravity) {
_motionBehaviors |= AVATAR_MOTION_OBEY_LOCAL_GRAVITY;
// Environmental and Local gravities are incompatible. Since Local is being set here

View file

@ -176,15 +176,7 @@ public slots:
void startRecording();
void stopRecording();
void saveRecording(QString filename);
bool isPlaying();
qint64 playerElapsed();
qint64 playerLength();
void loadRecording(QString filename);
void loadLastRecording();
void startPlaying();
void stopPlaying();
signals:
void transformChanged();
@ -224,7 +216,6 @@ private:
PhysicsSimulation _physicsSimulation;
RecorderPointer _recorder;
PlayerPointer _player;
// private methods
float computeDistanceToFloor(const glm::vec3& startPoint);

View file

@ -585,6 +585,94 @@ bool AvatarData::hasReferential() {
return _referential != NULL;
}
bool AvatarData::isPlaying() {
if (!_player) {
return false;
}
if (QThread::currentThread() != thread()) {
bool result;
QMetaObject::invokeMethod(this, "isPlaying", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, result));
return result;
}
return _player && _player->isPlaying();
}
qint64 AvatarData::playerElapsed() {
if (!_player) {
return 0;
}
if (QThread::currentThread() != thread()) {
qint64 result;
QMetaObject::invokeMethod(this, "playerElapsed", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(qint64, result));
return result;
}
return _player->elapsed();
}
qint64 AvatarData::playerLength() {
if (!_player) {
return 0;
}
if (QThread::currentThread() != thread()) {
qint64 result;
QMetaObject::invokeMethod(this, "playerLength", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(qint64, result));
return result;
}
return _player->getRecording()->getLength();
}
void AvatarData::loadRecording(QString filename) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "loadRecording", Qt::BlockingQueuedConnection,
Q_ARG(QString, filename));
return;
}
if (!_player) {
_player = PlayerPointer(new Player(this));
}
_player->loadFromFile(filename);
}
void AvatarData::startPlaying() {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "startPlaying", Qt::BlockingQueuedConnection);
return;
}
if (!_player) {
_player = PlayerPointer(new Player(this));
}
_player->startPlaying();
}
void AvatarData::play() {
if (isPlaying()) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "play", Qt::BlockingQueuedConnection);
return;
}
_player->play();
}
}
void AvatarData::stopPlaying() {
if (!_player) {
return;
}
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "stopPlaying", Qt::BlockingQueuedConnection);
return;
}
if (_player) {
_player->stopPlaying();
}
}
void AvatarData::changeReferential(Referential *ref) {
delete _referential;
_referential = ref;

View file

@ -49,6 +49,7 @@ typedef unsigned long long quint64;
#include <Node.h>
#include "Recorder.h"
#include "Referential.h"
#include "HeadData.h"
#include "HandData.h"
@ -298,6 +299,14 @@ public slots:
void setSessionUUID(const QUuid& sessionUUID) { _sessionUUID = sessionUUID; }
bool hasReferential();
bool isPlaying();
qint64 playerElapsed();
qint64 playerLength();
void loadRecording(QString filename);
void startPlaying();
void play();
void stopPlaying();
protected:
QUuid _sessionUUID;
glm::vec3 _position;
@ -351,6 +360,8 @@ protected:
QWeakPointer<Node> _owningAvatarMixer;
QElapsedTimer _lastUpdateTimer;
PlayerPointer _player;
/// Loads the joint indices, names from the FST file (if any)
virtual void updateJointMappings();
void changeReferential(Referential* ref);

View file

@ -15,6 +15,7 @@
#include <QMetaObject>
#include <QObject>
#include "AvatarData.h"
#include "Recorder.h"
void RecordingFrame::setBlendshapeCoefficients(QVector<float> blendshapeCoefficients) {
@ -281,7 +282,9 @@ void Player::play() {
_avatar->setTargetScale(_recording->getFrame(_currentFrame).getScale());
_avatar->setJointRotations(_recording->getFrame(_currentFrame).getJointRotations());
HeadData* head = const_cast<HeadData*>(_avatar->getHeadData());
head->setBlendshapeCoefficients(_recording->getFrame(_currentFrame).getBlendshapeCoefficients());
if (head) {
head->setBlendshapeCoefficients(_recording->getFrame(_currentFrame).getBlendshapeCoefficients());
}
} else {
_avatar->setPosition(_recording->getFrame(0).getTranslation() +
_recording->getFrame(_currentFrame).getTranslation());
@ -291,7 +294,10 @@ void Player::play() {
_recording->getFrame(_currentFrame).getScale());
_avatar->setJointRotations(_recording->getFrame(_currentFrame).getJointRotations());
HeadData* head = const_cast<HeadData*>(_avatar->getHeadData());
head->setBlendshapeCoefficients(_recording->getFrame(_currentFrame).getBlendshapeCoefficients());
if (head) {
head->setBlendshapeCoefficients(_recording->getFrame(_currentFrame).getBlendshapeCoefficients());
}
}
_options.setPosition(_avatar->getPosition());

View file

@ -23,10 +23,10 @@
#include <glm/gtx/quaternion.hpp>
#include <AudioInjector.h>
#include <AvatarData.h>
#include <SharedUtil.h>
#include <Sound.h>
class AvatarData;
class Recorder;
class Recording;
class Player;