mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 14:09:01 +02:00
Merge pull request #10223 from kunalgosar/blendshapesbug
Make setBlendshape changes persist
This commit is contained in:
commit
3f9f16cc98
4 changed files with 30 additions and 2 deletions
|
@ -242,7 +242,7 @@ void SkeletonModel::updateAttitude() {
|
||||||
void SkeletonModel::simulate(float deltaTime, bool fullUpdate) {
|
void SkeletonModel::simulate(float deltaTime, bool fullUpdate) {
|
||||||
updateAttitude();
|
updateAttitude();
|
||||||
if (fullUpdate) {
|
if (fullUpdate) {
|
||||||
setBlendshapeCoefficients(_owningAvatar->getHead()->getBlendshapeCoefficients());
|
setBlendshapeCoefficients(_owningAvatar->getHead()->getSummedBlendshapeCoefficients());
|
||||||
|
|
||||||
Model::simulate(deltaTime, fullUpdate);
|
Model::simulate(deltaTime, fullUpdate);
|
||||||
|
|
||||||
|
|
|
@ -967,6 +967,7 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
const int coefficientsSize = sizeof(float) * numCoefficients;
|
const int coefficientsSize = sizeof(float) * numCoefficients;
|
||||||
PACKET_READ_CHECK(FaceTrackerCoefficients, coefficientsSize);
|
PACKET_READ_CHECK(FaceTrackerCoefficients, coefficientsSize);
|
||||||
_headData->_blendshapeCoefficients.resize(numCoefficients); // make sure there's room for the copy!
|
_headData->_blendshapeCoefficients.resize(numCoefficients); // make sure there's room for the copy!
|
||||||
|
_headData->_baseBlendshapeCoefficients.resize(numCoefficients);
|
||||||
memcpy(_headData->_blendshapeCoefficients.data(), sourceBuffer, coefficientsSize);
|
memcpy(_headData->_blendshapeCoefficients.data(), sourceBuffer, coefficientsSize);
|
||||||
sourceBuffer += coefficientsSize;
|
sourceBuffer += coefficientsSize;
|
||||||
int numBytesRead = sourceBuffer - startSection;
|
int numBytesRead = sourceBuffer - startSection;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include <QtCore/QJsonObject>
|
#include <QtCore/QJsonObject>
|
||||||
#include <QtCore/QJsonArray>
|
#include <QtCore/QJsonArray>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
#include <FaceshiftConstants.h>
|
#include <FaceshiftConstants.h>
|
||||||
#include <GLMHelpers.h>
|
#include <GLMHelpers.h>
|
||||||
|
@ -38,6 +39,8 @@ HeadData::HeadData(AvatarData* owningAvatar) :
|
||||||
_rightEyeBlink(0.0f),
|
_rightEyeBlink(0.0f),
|
||||||
_averageLoudness(0.0f),
|
_averageLoudness(0.0f),
|
||||||
_browAudioLift(0.0f),
|
_browAudioLift(0.0f),
|
||||||
|
_baseBlendshapeCoefficients(QVector<float>(0, 0.0f)),
|
||||||
|
_currBlendShapeCoefficients(QVector<float>(0, 0.0f)),
|
||||||
_owningAvatar(owningAvatar)
|
_owningAvatar(owningAvatar)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -86,6 +89,24 @@ static const QMap<QString, int>& getBlendshapesLookupMap() {
|
||||||
return blendshapeLookupMap;
|
return blendshapeLookupMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QVector<float>& HeadData::getSummedBlendshapeCoefficients() {
|
||||||
|
int maxSize = std::max(_baseBlendshapeCoefficients.size(), _blendshapeCoefficients.size());
|
||||||
|
if (_currBlendShapeCoefficients.size() != maxSize) {
|
||||||
|
_currBlendShapeCoefficients.resize(maxSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < maxSize; i++) {
|
||||||
|
if (i >= _baseBlendshapeCoefficients.size()) {
|
||||||
|
_currBlendShapeCoefficients[i] = _blendshapeCoefficients[i];
|
||||||
|
} else if (i >= _blendshapeCoefficients.size()) {
|
||||||
|
_currBlendShapeCoefficients[i] = _baseBlendshapeCoefficients[i];
|
||||||
|
} else {
|
||||||
|
_currBlendShapeCoefficients[i] = _baseBlendshapeCoefficients[i] + _blendshapeCoefficients[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _currBlendShapeCoefficients;
|
||||||
|
}
|
||||||
|
|
||||||
void HeadData::setBlendshape(QString name, float val) {
|
void HeadData::setBlendshape(QString name, float val) {
|
||||||
const auto& blendshapeLookupMap = getBlendshapesLookupMap();
|
const auto& blendshapeLookupMap = getBlendshapesLookupMap();
|
||||||
|
@ -96,7 +117,10 @@ void HeadData::setBlendshape(QString name, float val) {
|
||||||
if (_blendshapeCoefficients.size() <= it.value()) {
|
if (_blendshapeCoefficients.size() <= it.value()) {
|
||||||
_blendshapeCoefficients.resize(it.value() + 1);
|
_blendshapeCoefficients.resize(it.value() + 1);
|
||||||
}
|
}
|
||||||
_blendshapeCoefficients[it.value()] = val;
|
if (_baseBlendshapeCoefficients.size() <= it.value()) {
|
||||||
|
_baseBlendshapeCoefficients.resize(it.value() + 1);
|
||||||
|
}
|
||||||
|
_baseBlendshapeCoefficients[it.value()] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
|
|
||||||
void setBlendshape(QString name, float val);
|
void setBlendshape(QString name, float val);
|
||||||
const QVector<float>& getBlendshapeCoefficients() const { return _blendshapeCoefficients; }
|
const QVector<float>& getBlendshapeCoefficients() const { return _blendshapeCoefficients; }
|
||||||
|
const QVector<float>& getSummedBlendshapeCoefficients();
|
||||||
void setBlendshapeCoefficients(const QVector<float>& blendshapeCoefficients) { _blendshapeCoefficients = blendshapeCoefficients; }
|
void setBlendshapeCoefficients(const QVector<float>& blendshapeCoefficients) { _blendshapeCoefficients = blendshapeCoefficients; }
|
||||||
|
|
||||||
const glm::vec3& getLookAtPosition() const { return _lookAtPosition; }
|
const glm::vec3& getLookAtPosition() const { return _lookAtPosition; }
|
||||||
|
@ -92,6 +93,8 @@ protected:
|
||||||
float _browAudioLift;
|
float _browAudioLift;
|
||||||
|
|
||||||
QVector<float> _blendshapeCoefficients;
|
QVector<float> _blendshapeCoefficients;
|
||||||
|
QVector<float> _baseBlendshapeCoefficients;
|
||||||
|
QVector<float> _currBlendShapeCoefficients;
|
||||||
AvatarData* _owningAvatar;
|
AvatarData* _owningAvatar;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue