mirror of
https://github.com/lubosz/overte.git
synced 2025-04-10 08:57:12 +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) {
|
||||
updateAttitude();
|
||||
if (fullUpdate) {
|
||||
setBlendshapeCoefficients(_owningAvatar->getHead()->getBlendshapeCoefficients());
|
||||
setBlendshapeCoefficients(_owningAvatar->getHead()->getSummedBlendshapeCoefficients());
|
||||
|
||||
Model::simulate(deltaTime, fullUpdate);
|
||||
|
||||
|
|
|
@ -967,6 +967,7 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
|||
const int coefficientsSize = sizeof(float) * numCoefficients;
|
||||
PACKET_READ_CHECK(FaceTrackerCoefficients, coefficientsSize);
|
||||
_headData->_blendshapeCoefficients.resize(numCoefficients); // make sure there's room for the copy!
|
||||
_headData->_baseBlendshapeCoefficients.resize(numCoefficients);
|
||||
memcpy(_headData->_blendshapeCoefficients.data(), sourceBuffer, coefficientsSize);
|
||||
sourceBuffer += coefficientsSize;
|
||||
int numBytesRead = sourceBuffer - startSection;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QJsonArray>
|
||||
#include <QVector>
|
||||
|
||||
#include <FaceshiftConstants.h>
|
||||
#include <GLMHelpers.h>
|
||||
|
@ -38,6 +39,8 @@ HeadData::HeadData(AvatarData* owningAvatar) :
|
|||
_rightEyeBlink(0.0f),
|
||||
_averageLoudness(0.0f),
|
||||
_browAudioLift(0.0f),
|
||||
_baseBlendshapeCoefficients(QVector<float>(0, 0.0f)),
|
||||
_currBlendShapeCoefficients(QVector<float>(0, 0.0f)),
|
||||
_owningAvatar(owningAvatar)
|
||||
{
|
||||
|
||||
|
@ -86,6 +89,24 @@ static const QMap<QString, int>& getBlendshapesLookupMap() {
|
|||
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) {
|
||||
const auto& blendshapeLookupMap = getBlendshapesLookupMap();
|
||||
|
@ -96,7 +117,10 @@ void HeadData::setBlendshape(QString name, float val) {
|
|||
if (_blendshapeCoefficients.size() <= it.value()) {
|
||||
_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);
|
||||
const QVector<float>& getBlendshapeCoefficients() const { return _blendshapeCoefficients; }
|
||||
const QVector<float>& getSummedBlendshapeCoefficients();
|
||||
void setBlendshapeCoefficients(const QVector<float>& blendshapeCoefficients) { _blendshapeCoefficients = blendshapeCoefficients; }
|
||||
|
||||
const glm::vec3& getLookAtPosition() const { return _lookAtPosition; }
|
||||
|
@ -92,6 +93,8 @@ protected:
|
|||
float _browAudioLift;
|
||||
|
||||
QVector<float> _blendshapeCoefficients;
|
||||
QVector<float> _baseBlendshapeCoefficients;
|
||||
QVector<float> _currBlendShapeCoefficients;
|
||||
AvatarData* _owningAvatar;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue