mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 06:24:41 +02:00
Various tweaks and code cleanup
This commit is contained in:
parent
acb55ce65e
commit
52640c8482
9 changed files with 53 additions and 25 deletions
|
@ -1047,6 +1047,8 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
break;
|
||||
case Qt::Key_R:
|
||||
if (isShifted) {
|
||||
Menu::getInstance()->triggerOption(MenuOption::FrustumRenderMode);
|
||||
} else if (isMeta) {
|
||||
if (_myAvatar->isRecording()) {
|
||||
_myAvatar->stopRecording();
|
||||
} else {
|
||||
|
|
|
@ -75,6 +75,7 @@ Recorder::Recorder(AvatarData* avatar) :
|
|||
_recording(new Recording()),
|
||||
_avatar(avatar)
|
||||
{
|
||||
_timer.invalidate();
|
||||
}
|
||||
|
||||
bool Recorder::isRecording() const {
|
||||
|
@ -124,7 +125,7 @@ void Recorder::saveToFile(QString file) {
|
|||
qDebug() << "Cannot save recording to file, recording is empty.";
|
||||
}
|
||||
|
||||
writeRecordingToFile(*_recording, file);
|
||||
writeRecordingToFile(_recording, file);
|
||||
}
|
||||
|
||||
void Recorder::record() {
|
||||
|
@ -161,6 +162,7 @@ Player::Player(AvatarData* avatar) :
|
|||
_avatar(avatar),
|
||||
_audioThread(NULL)
|
||||
{
|
||||
_timer.invalidate();
|
||||
_options.setLoop(false);
|
||||
_options.setVolume(1.0f);
|
||||
}
|
||||
|
@ -318,8 +320,16 @@ void Player::startPlaying() {
|
|||
}
|
||||
|
||||
void Player::stopPlaying() {
|
||||
if (!isPlaying()) {
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Recorder::stopPlaying()";
|
||||
_timer.invalidate();
|
||||
|
||||
_avatar->clearJointsData();
|
||||
|
||||
// Cleanup audio thread
|
||||
_injector->stop();
|
||||
_injector.clear();
|
||||
_audioThread->exit();
|
||||
|
@ -332,7 +342,7 @@ void Player::loadFromFile(QString file) {
|
|||
} else {
|
||||
_recording = RecordingPointer(new Recording());
|
||||
}
|
||||
readRecordingFromFile(*_recording, file);
|
||||
readRecordingFromFile(_recording, file);
|
||||
}
|
||||
|
||||
void Player::loadRecording(RecordingPointer recording) {
|
||||
|
@ -368,17 +378,6 @@ void Player::play() {
|
|||
}
|
||||
}
|
||||
|
||||
void Player::playAudio() {
|
||||
_options.setPosition(_avatar->getPosition());
|
||||
_options.setOrientation(_avatar->getOrientation());
|
||||
|
||||
qDebug() << "Play";
|
||||
if (_injector) {
|
||||
_injector->injectAudio();
|
||||
}
|
||||
qDebug() << "Played";
|
||||
}
|
||||
|
||||
void Player::computeCurrentFrame() {
|
||||
if (!isPlaying()) {
|
||||
qDebug() << "Not Playing";
|
||||
|
@ -396,12 +395,12 @@ void Player::computeCurrentFrame() {
|
|||
}
|
||||
}
|
||||
|
||||
void writeRecordingToFile(Recording& recording, QString file) {
|
||||
void writeRecordingToFile(RecordingPointer recording, QString file) {
|
||||
// TODO
|
||||
qDebug() << "Writing recording to " << file;
|
||||
}
|
||||
|
||||
Recording& readRecordingFromFile(Recording& recording, QString file) {
|
||||
RecordingPointer readRecordingFromFile(RecordingPointer recording, QString file) {
|
||||
// TODO
|
||||
qDebug() << "Reading recording from " << file;
|
||||
return recording;
|
||||
|
|
|
@ -70,8 +70,8 @@ private:
|
|||
float _leanForward;
|
||||
|
||||
friend class Recorder;
|
||||
friend void writeRecordingToFile(Recording& recording, QString file);
|
||||
friend RecordingPointer readRecordingFromFile(QString file);
|
||||
friend void writeRecordingToFile(RecordingPointer recording, QString file);
|
||||
friend RecordingPointer readRecordingFromFile(RecordingPointer recording, QString file);
|
||||
};
|
||||
|
||||
/// Stores a recording
|
||||
|
@ -101,8 +101,8 @@ private:
|
|||
|
||||
friend class Recorder;
|
||||
friend class Player;
|
||||
friend void writeRecordingToFile(Recording& recording, QString file);
|
||||
friend RecordingPointer readRecordingFromFile(QString file);
|
||||
friend void writeRecordingToFile(RecordingPointer recording, QString file);
|
||||
friend RecordingPointer readRecordingFromFile(RecordingPointer recording, QString file);
|
||||
};
|
||||
|
||||
/// Records a recording
|
||||
|
@ -154,7 +154,6 @@ public slots:
|
|||
void loadFromFile(QString file);
|
||||
void loadRecording(RecordingPointer recording);
|
||||
void play();
|
||||
void playAudio();
|
||||
|
||||
private:
|
||||
void computeCurrentFrame();
|
||||
|
@ -170,7 +169,7 @@ private:
|
|||
QThread* _audioThread;
|
||||
};
|
||||
|
||||
void writeRecordingToFile(Recording& recording, QString file);
|
||||
Recording& readRecordingFromFile(Recording& recording, QString file);
|
||||
void writeRecordingToFile(RecordingPointer recording, QString file);
|
||||
RecordingPointer readRecordingFromFile(RecordingPointer recording, QString file);
|
||||
|
||||
#endif // hifi_Recorder_h
|
|
@ -922,8 +922,7 @@ const float JOINT_PRIORITY = 2.0f;
|
|||
void MyAvatar::setJointRotations(QVector<glm::quat> jointRotations) {
|
||||
for (int i = 0; i < jointRotations.size(); ++i) {
|
||||
if (i < _jointData.size()) {
|
||||
// TODO change animation priority to proper value
|
||||
_skeletonModel.setJointState(i, true, jointRotations[i], 100.0f);
|
||||
_skeletonModel.setJointState(i, true, jointRotations[i], JOINT_PRIORITY + 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -942,6 +941,15 @@ void MyAvatar::clearJointData(int index) {
|
|||
}
|
||||
}
|
||||
|
||||
void MyAvatar::clearJointsData() {
|
||||
for (int i = 0; i < _jointData.size(); ++i) {
|
||||
Avatar::clearJointData(i);
|
||||
if (QThread::currentThread() == thread()) {
|
||||
_skeletonModel.clearJointState(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::setFaceModelURL(const QUrl& faceModelURL) {
|
||||
Avatar::setFaceModelURL(faceModelURL);
|
||||
_billboardValid = false;
|
||||
|
|
|
@ -115,6 +115,7 @@ public:
|
|||
virtual void setJointRotations(QVector<glm::quat> jointRotations);
|
||||
virtual void setJointData(int index, const glm::quat& rotation);
|
||||
virtual void clearJointData(int index);
|
||||
virtual void clearJointsData();
|
||||
virtual void setFaceModelURL(const QUrl& faceModelURL);
|
||||
virtual void setSkeletonModelURL(const QUrl& skeletonModelURL);
|
||||
virtual void setAttachmentData(const QVector<AttachmentData>& attachmentData);
|
||||
|
|
|
@ -692,6 +692,14 @@ bool Model::getVisibleJointState(int index, glm::quat& rotation) const {
|
|||
return !state.rotationIsDefault(rotation);
|
||||
}
|
||||
|
||||
void Model::clearJointState(int index) {
|
||||
if (index != -1 && index < _jointStates.size()) {
|
||||
JointState& state = _jointStates[index];
|
||||
state.setRotationInConstrainedFrame(glm::quat());
|
||||
state._animationPriority = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void Model::setJointState(int index, bool valid, const glm::quat& rotation, float priority) {
|
||||
if (index != -1 && index < _jointStates.size()) {
|
||||
JointState& state = _jointStates[index];
|
||||
|
|
|
@ -118,6 +118,9 @@ public:
|
|||
/// \return whether or not the joint state is "valid" (that is, non-default)
|
||||
bool getVisibleJointState(int index, glm::quat& rotation) const;
|
||||
|
||||
/// Clear the joint states
|
||||
void clearJointState(int index);
|
||||
|
||||
/// Sets the joint state at the specified index.
|
||||
void setJointState(int index, bool valid, const glm::quat& rotation = glm::quat(), float priority = 1.0f);
|
||||
|
||||
|
|
|
@ -712,6 +712,12 @@ void AvatarData::setJointRotations(QVector<glm::quat> jointRotations) {
|
|||
}
|
||||
}
|
||||
|
||||
void AvatarData::clearJointsData() {
|
||||
for (int i = 0; i < _jointData.size(); ++i) {
|
||||
clearJointData(i);
|
||||
}
|
||||
}
|
||||
|
||||
bool AvatarData::hasIdentityChangedAfterParsing(const QByteArray &packet) {
|
||||
QDataStream packetStream(packet);
|
||||
packetStream.skipRawData(numBytesForPacketHeader(packet));
|
||||
|
|
|
@ -213,7 +213,9 @@ public:
|
|||
|
||||
Q_INVOKABLE virtual QVector<glm::quat> getJointRotations() const;
|
||||
Q_INVOKABLE virtual void setJointRotations(QVector<glm::quat> jointRotations);
|
||||
|
||||
|
||||
Q_INVOKABLE virtual void clearJointsData();
|
||||
|
||||
/// Returns the index of the joint with the specified name, or -1 if not found/unknown.
|
||||
Q_INVOKABLE virtual int getJointIndex(const QString& name) const { return _jointIndices.value(name) - 1; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue