Merge pull request #972 from ey6es/blendface

Cache face models, don't render neck/neck base when face model is displayed.
This commit is contained in:
Philip Rosedale 2013-09-20 18:02:20 -07:00
commit 8bf9c37457
6 changed files with 28 additions and 5 deletions

View file

@ -35,6 +35,7 @@
#include <QMenuBar>
#include <QMouseEvent>
#include <QNetworkAccessManager>
#include <QNetworkDiskCache>
#include <QOpenGLFramebufferObject>
#include <QWheelEvent>
#include <QSettings>
@ -208,6 +209,9 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
_window->setMenuBar(Menu::getInstance());
_networkAccessManager = new QNetworkAccessManager(this);
QNetworkDiskCache* cache = new QNetworkDiskCache(_networkAccessManager);
cache->setCacheDirectory("interfaceCache");
_networkAccessManager->setCache(cache);
QRect available = desktop()->availableGeometry();
_window->resize(available.size());

View file

@ -699,6 +699,10 @@ void Avatar::renderBody(bool lookingInMirror, bool renderAvatarBalls) {
SKIN_COLOR[1] - _bodyBall[b].touchForce * 0.2f,
SKIN_COLOR[2] - _bodyBall[b].touchForce * 0.1f);
if (b == BODY_BALL_NECK_BASE && _head.getBlendFace().isActive()) {
continue; // don't render the neck if we have a face model
}
if ((b != BODY_BALL_HEAD_TOP )
&& (b != BODY_BALL_HEAD_BASE )) {
glPushMatrix();

View file

@ -118,7 +118,9 @@ void BlendFace::setModelURL(const QUrl& url) {
if (!url.isValid()) {
return;
}
_modelReply = Application::getInstance()->getNetworkAccessManager()->get(QNetworkRequest(url));
QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
_modelReply = Application::getInstance()->getNetworkAccessManager()->get(request);
connect(_modelReply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(handleModelDownloadProgress(qint64,qint64)));
connect(_modelReply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleModelReplyError()));
}
@ -163,7 +165,7 @@ void BlendFace::setRig(const fsMsgRig& rig) {
}
void BlendFace::handleModelDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
if (bytesReceived < bytesTotal) {
if (bytesReceived < bytesTotal && !_modelReply->isFinished()) {
return;
}

View file

@ -30,6 +30,8 @@ public:
BlendFace(Head* owningHead);
~BlendFace();
bool isActive() const { return _iboID != 0; }
bool render(float alpha);
Q_INVOKABLE void setModelURL(const QUrl& url);

View file

@ -567,6 +567,10 @@ void MyAvatar::renderBody(bool lookingInMirror, bool renderAvatarBalls) {
alpha);
}
if (b == BODY_BALL_NECK_BASE && _head.getBlendFace().isActive()) {
continue; // don't render the neck if we have a face model
}
if ((b != BODY_BALL_HEAD_TOP )
&& (b != BODY_BALL_HEAD_BASE )) {
glPushMatrix();

View file

@ -272,7 +272,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node) {
if (object.properties.at(2) == "Mesh") {
FBXGeometry mesh;
QVector<glm::vec3> vertices;
QVector<glm::vec3> normals;
QVector<int> polygonIndices;
foreach (const FBXNode& data, object.children) {
if (data.name == "Vertices") {
@ -284,12 +284,19 @@ FBXGeometry extractFBXGeometry(const FBXNode& node) {
} else if (data.name == "LayerElementNormal") {
foreach (const FBXNode& subdata, data.children) {
if (subdata.name == "Normals") {
mesh.normals = createVec3Vector(
subdata.properties.at(0).value<QVector<double> >());
normals = createVec3Vector(subdata.properties.at(0).value<QVector<double> >());
}
}
}
}
// the (base) normals correspond to the polygon indices, for some reason
mesh.normals.resize(mesh.vertices.size());
for (int i = 0, n = polygonIndices.size(); i < n; i++) {
int index = polygonIndices.at(i);
mesh.normals[index < 0 ? (-index - 1) : index] = normals[i];
}
// convert the polygons to quads and triangles
for (const int* beginIndex = polygonIndices.constData(), *end = beginIndex + polygonIndices.size();
beginIndex != end; ) {