setBlendshapes will presist

This commit is contained in:
kunalgosar 2017-04-14 13:56:13 -07:00
parent 7505b82189
commit 0a295fc258
6 changed files with 21 additions and 4 deletions

View file

@ -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);

View file

@ -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;

View file

@ -438,6 +438,12 @@ public:
_headData->setBlendshapeCoefficients(blendshapeCoefficients);
}
}
void setSummedBlendshapeCoefficients(QVector<float>& blendshapeCoefficients) {
if (_headData) {
_headData->setSummedBlendshapeCoefficients(blendshapeCoefficients);
}
}
// access to Head().set/getMousePitch (degrees)
float getHeadPitch() const { return _headData->getBasePitch(); }

View file

@ -38,7 +38,8 @@ HeadData::HeadData(AvatarData* owningAvatar) :
_rightEyeBlink(0.0f),
_averageLoudness(0.0f),
_browAudioLift(0.0f),
_owningAvatar(owningAvatar)
_owningAvatar(owningAvatar),
_baseBlendshapeCoefficients(0, 0),
{
}
@ -86,17 +87,23 @@ static const QMap<QString, int>& getBlendshapesLookupMap() {
return blendshapeLookupMap;
}
const QVector<float>& HeadData::getSummedBlendshapeCoefficients() {
for (int i = 0; i < _baseBlendshapeCoefficients.size(); i++) {
_blendshapeCoefficients[i] += _baseBlendshapeCoefficients[i];
}
return _blendshapeCoefficients;
}
void HeadData::setBlendshape(QString name, float val) {
const auto& blendshapeLookupMap = getBlendshapesLookupMap();
//Check to see if the named blendshape exists, and then set its value if it does
auto it = blendshapeLookupMap.find(name);
if (it != blendshapeLookupMap.end()) {
if (_blendshapeCoefficients.size() <= it.value()) {
_blendshapeCoefficients.resize(it.value() + 1);
_baseBlendshapeCoefficients.resize(it.value() + 1);
}
_blendshapeCoefficients[it.value()] = val;
_baseBlendshapeCoefficients[it.value()] = val;
}
}

View file

@ -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,7 @@ protected:
float _browAudioLift;
QVector<float> _blendshapeCoefficients;
QVector<float> _baseBlendshapeCoefficients;
AvatarData* _owningAvatar;
private:

View file

@ -901,6 +901,7 @@ Blender::Blender(ModelPointer model, int blendNumber, const Geometry::WeakPointe
}
void Blender::run() {
qDebug() << "!!!!!!!!!!!!!!" << _blendshapeCoefficients;
PROFILE_RANGE_EX(simulation_animation, __FUNCTION__, 0xFFFF0000, 0, { { "url", _model->getURL().toString() } });
QVector<glm::vec3> vertices, normals;
if (_model) {