mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 10:09:05 +02:00
When computing average model color, skip eyes and weight rest by number of
vertices.
This commit is contained in:
parent
43e01ee105
commit
6e012ea6d2
1 changed files with 8 additions and 6 deletions
|
@ -289,18 +289,20 @@ NetworkGeometry::~NetworkGeometry() {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec4 NetworkGeometry::computeAverageColor() const {
|
glm::vec4 NetworkGeometry::computeAverageColor() const {
|
||||||
if (_meshes.isEmpty()) {
|
glm::vec4 totalColor;
|
||||||
return glm::vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
int totalVertices = 0;
|
||||||
}
|
|
||||||
glm::vec4 total;
|
|
||||||
for (int i = 0; i < _meshes.size(); i++) {
|
for (int i = 0; i < _meshes.size(); i++) {
|
||||||
|
if (_geometry.meshes.at(i).isEye) {
|
||||||
|
continue; // skip eyes
|
||||||
|
}
|
||||||
glm::vec4 color = glm::vec4(_geometry.meshes.at(i).diffuseColor, 1.0f);
|
glm::vec4 color = glm::vec4(_geometry.meshes.at(i).diffuseColor, 1.0f);
|
||||||
if (_meshes.at(i).diffuseTexture) {
|
if (_meshes.at(i).diffuseTexture) {
|
||||||
color *= _meshes.at(i).diffuseTexture->getAverageColor();
|
color *= _meshes.at(i).diffuseTexture->getAverageColor();
|
||||||
}
|
}
|
||||||
total += color;
|
totalColor += color * _geometry.meshes.at(i).vertices.size();
|
||||||
|
totalVertices += _geometry.meshes.at(i).vertices.size();
|
||||||
}
|
}
|
||||||
return total / _meshes.size();
|
return (totalVertices == 0) ? glm::vec4(1.0f, 1.0f, 1.0f, 1.0f) : totalColor / totalVertices;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkGeometry::handleModelReplyError() {
|
void NetworkGeometry::handleModelReplyError() {
|
||||||
|
|
Loading…
Reference in a new issue