mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 14:03:55 +02:00
Avatar transmission fixes, moved JointData into shared
* Moved JointData into shared library * added methods to the rig to copy into and out of JointData * JointData translations must be in meters this is so the fixed point compression wont overflow, also, it's a consistent wire format.
This commit is contained in:
parent
27685e0425
commit
ad4b8e0001
6 changed files with 43 additions and 21 deletions
|
@ -202,12 +202,7 @@ void Avatar::simulate(float deltaTime) {
|
|||
if (!_shouldRenderBillboard && inViewFrustum) {
|
||||
{
|
||||
PerformanceTimer perfTimer("skeleton");
|
||||
for (int i = 0; i < _jointData.size(); i++) {
|
||||
const JointData& data = _jointData.at(i);
|
||||
_skeletonModel.setJointRotation(i, data.rotationSet, data.rotation, 1.0f);
|
||||
_skeletonModel.setJointTranslation(i, data.translationSet, data.translation, 1.0f);
|
||||
}
|
||||
|
||||
_skeletonModel.getRig()->copyJointsFromJointData(_jointData);
|
||||
_skeletonModel.simulate(deltaTime, _hasNewJointRotations || _hasNewJointTranslations);
|
||||
simulateAttachments(deltaTime);
|
||||
_hasNewJointRotations = false;
|
||||
|
|
|
@ -269,12 +269,7 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
PerformanceTimer perfTimer("joints");
|
||||
// copy out the skeleton joints from the model
|
||||
_jointData.resize(_rig->getJointStateCount());
|
||||
|
||||
for (int i = 0; i < _jointData.size(); i++) {
|
||||
JointData& data = _jointData[i];
|
||||
data.rotationSet |= _rig->getJointStateRotation(i, data.rotation);
|
||||
data.translationSet |= _rig->getJointStateTranslation(i, data.translation);
|
||||
}
|
||||
_rig->copyJointsIntoJointData(_jointData);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -1380,3 +1380,22 @@ glm::mat4 Rig::getJointTransform(int jointIndex) const {
|
|||
}
|
||||
}
|
||||
|
||||
void Rig::copyJointsIntoJointData(QVector<JointData>& jointDataVec) const {
|
||||
for (int i = 0; i < jointDataVec.size(); i++) {
|
||||
JointData& data = jointDataVec[i];
|
||||
data.rotationSet |= getJointStateRotation(i, data.rotation);
|
||||
// geometry offset is used here so that translations are in meters.
|
||||
// this is what the avatar mixer expects
|
||||
data.translationSet |= getJointStateTranslation(i, _geometryOffset * data.translation);
|
||||
}
|
||||
}
|
||||
|
||||
void Rig::copyJointsFromJointData(const QVector<JointData>& jointDataVec) {
|
||||
AnimPose invGeometryOffset = _geometryOffset.inverse();
|
||||
for (int i = 0; i < jointDataVec.size(); i++) {
|
||||
const JointData& data = jointDataVec.at(i);
|
||||
setJointRotation(i, data.rotationSet, data.rotation, 1.0f);
|
||||
// geometry offset is used here to undo the fact that avatar mixer translations are in meters.
|
||||
setJointTranslation(i, data.translationSet, invGeometryOffset * data.translation, 1.0f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <QMutex>
|
||||
#include <QScriptValue>
|
||||
#include <vector>
|
||||
#include <JointData.h>
|
||||
|
||||
#include "JointState.h" // We might want to change this (later) to something that doesn't depend on gpu, fbx and model. -HRS
|
||||
|
||||
|
@ -162,6 +163,8 @@ public:
|
|||
|
||||
const glm::vec3& getEyesInRootFrame() const { return _eyesInRootFrame; }
|
||||
|
||||
void copyJointsIntoJointData(QVector<JointData>& jointDataVec) const;
|
||||
void copyJointsFromJointData(const QVector<JointData>& jointDataVec);
|
||||
|
||||
protected:
|
||||
void updateAnimationStateHandlers();
|
||||
|
|
|
@ -46,6 +46,7 @@ typedef unsigned long long quint64;
|
|||
#include <QtScript/QScriptable>
|
||||
#include <QReadWriteLock>
|
||||
|
||||
#include <JointData.h>
|
||||
#include <NLPacket.h>
|
||||
#include <Node.h>
|
||||
#include <RegisteredMetaTypes.h>
|
||||
|
@ -131,7 +132,6 @@ enum KeyState {
|
|||
class QDataStream;
|
||||
|
||||
class AttachmentData;
|
||||
class JointData;
|
||||
class Transform;
|
||||
using TransformPointer = std::shared_ptr<Transform>;
|
||||
|
||||
|
@ -432,14 +432,6 @@ private:
|
|||
};
|
||||
Q_DECLARE_METATYPE(AvatarData*)
|
||||
|
||||
class JointData {
|
||||
public:
|
||||
glm::quat rotation;
|
||||
bool rotationSet = false;
|
||||
glm::vec3 translation;
|
||||
bool translationSet = false;
|
||||
};
|
||||
|
||||
QJsonValue toJsonValue(const JointData& joint);
|
||||
JointData jointDataFromJsonValue(const QJsonValue& q);
|
||||
|
||||
|
|
18
libraries/shared/src/JointData.h
Normal file
18
libraries/shared/src/JointData.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
|
||||
#ifndef hifi_JointData_h
|
||||
#define hifi_JointData_h
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
// Used by the avatar mixer to describe a single joint
|
||||
// These are relative to their parent and translations are in meters
|
||||
class JointData {
|
||||
public:
|
||||
glm::quat rotation;
|
||||
bool rotationSet = false;
|
||||
glm::vec3 translation; // meters
|
||||
bool translationSet = false;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue