mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 18:26:26 +02:00
Revert "Trying a different method of updating the normals."
This reverts commit 8e2be380f6
.
This commit is contained in:
parent
8e2be380f6
commit
1893fdba29
1 changed files with 5 additions and 17 deletions
|
@ -6,8 +6,6 @@
|
||||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <numeric>
|
|
||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
@ -52,35 +50,25 @@ bool BlendFace::render(float alpha) {
|
||||||
|
|
||||||
// start with the base
|
// start with the base
|
||||||
int vertexCount = _geometry.vertices.size();
|
int vertexCount = _geometry.vertices.size();
|
||||||
_blendedVertices.resize(vertexCount);
|
|
||||||
memcpy(_blendedVertices.data(), _geometry.vertices.constData(), vertexCount * sizeof(glm::vec3));
|
|
||||||
|
|
||||||
// find the coefficient total
|
|
||||||
const vector<float>& coefficients = _owningHead->getBlendshapeCoefficients();
|
|
||||||
float coefficientTotal = accumulate(coefficients.begin(), coefficients.end(), 0.0f);
|
|
||||||
|
|
||||||
// for the normals, only use the base if we have nothing else
|
|
||||||
int normalCount = _geometry.normals.size();
|
int normalCount = _geometry.normals.size();
|
||||||
|
_blendedVertices.resize(vertexCount);
|
||||||
_blendedNormals.resize(normalCount);
|
_blendedNormals.resize(normalCount);
|
||||||
if (coefficientTotal == 0.0f) {
|
memcpy(_blendedVertices.data(), _geometry.vertices.constData(), vertexCount * sizeof(glm::vec3));
|
||||||
memcpy(_blendedNormals.data(), _geometry.normals.constData(), normalCount * sizeof(glm::vec3));
|
memcpy(_blendedNormals.data(), _geometry.normals.constData(), normalCount * sizeof(glm::vec3));
|
||||||
} else {
|
|
||||||
memset(_blendedNormals.data(), 0, normalCount * sizeof(glm::vec3));
|
|
||||||
}
|
|
||||||
|
|
||||||
// blend in each coefficient
|
// blend in each coefficient
|
||||||
|
const vector<float>& coefficients = _owningHead->getBlendshapeCoefficients();
|
||||||
for (int i = 0; i < coefficients.size(); i++) {
|
for (int i = 0; i < coefficients.size(); i++) {
|
||||||
float coefficient = coefficients[i];
|
float coefficient = coefficients[i];
|
||||||
if (coefficient == 0.0f || i >= _geometry.blendshapes.size() || _geometry.blendshapes[i].vertices.isEmpty()) {
|
if (coefficient == 0.0f || i >= _geometry.blendshapes.size() || _geometry.blendshapes[i].vertices.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
float normalCoefficient = coefficient / coefficientTotal;
|
|
||||||
const glm::vec3* vertex = _geometry.blendshapes[i].vertices.constData();
|
const glm::vec3* vertex = _geometry.blendshapes[i].vertices.constData();
|
||||||
const glm::vec3* normal = _geometry.blendshapes[i].normals.constData();
|
const glm::vec3* normal = _geometry.blendshapes[i].normals.constData();
|
||||||
for (const int* index = _geometry.blendshapes[i].indices.constData(),
|
for (const int* index = _geometry.blendshapes[i].indices.constData(),
|
||||||
*end = index + _geometry.blendshapes[i].indices.size(); index != end; index++, vertex++, normal++) {
|
*end = index + _geometry.blendshapes[i].indices.size(); index != end; index++, vertex++, normal++) {
|
||||||
_blendedVertices[*index] += *vertex * coefficient;
|
_blendedVertices[*index] += *vertex * coefficient;
|
||||||
_blendedNormals[*index] += *normal * normalCoefficient;
|
_blendedNormals[*index] += *normal * coefficient;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue