Merge pull request #3407 from ey6es/master

Only allow one "blender" to run at a time for each model.
This commit is contained in:
Brad Hefta-Gaub 2014-09-12 15:34:39 -07:00
commit 66ce6b7c3c
2 changed files with 26 additions and 4 deletions

View file

@ -61,7 +61,10 @@ Model::Model(QObject* parent) :
_showTrueJointTransforms(true),
_lodDistance(0.0f),
_pupilDilation(0.0f),
_url("http://invalid.com") {
_url("http://invalid.com"),
_blenderPending(false),
_blendRequired(false) {
// we may have been created in the network thread, but we live in the main thread
moveToThread(Application::getInstance()->thread());
}
@ -998,9 +1001,15 @@ void Model::simulateInternal(float deltaTime) {
}
}
// post the blender
// post the blender if we're not currently waiting for one to finish
if (geometry.hasBlendedMeshes()) {
QThreadPool::globalInstance()->start(new Blender(this, _geometry, geometry.meshes, _blendshapeCoefficients));
if (_blenderPending) {
_blendRequired = true;
} else {
_blendRequired = false;
_blenderPending = true;
QThreadPool::globalInstance()->start(new Blender(this, _geometry, geometry.meshes, _blendshapeCoefficients));
}
}
}
@ -1264,10 +1273,20 @@ void Model::renderJointCollisionShapes(float alpha) {
}
void Model::setBlendedVertices(const QVector<glm::vec3>& vertices, const QVector<glm::vec3>& normals) {
_blenderPending = false;
// start the next blender if required
const FBXGeometry& geometry = _geometry->getFBXGeometry();
if (_blendRequired) {
_blendRequired = false;
if (geometry.hasBlendedMeshes()) {
_blenderPending = true;
QThreadPool::globalInstance()->start(new Blender(this, _geometry, geometry.meshes, _blendshapeCoefficients));
}
}
if (_blendedVertexBuffers.isEmpty()) {
return;
}
const FBXGeometry& geometry = _geometry->getFBXGeometry();
int index = 0;
for (int i = 0; i < geometry.meshes.size(); i++) {
const FBXMesh& mesh = geometry.meshes.at(i);

View file

@ -284,6 +284,9 @@ private:
glm::vec4 _localLightColors[MAX_LOCAL_LIGHTS];
glm::vec4 _localLightDirections[MAX_LOCAL_LIGHTS];
bool _blenderPending;
bool _blendRequired;
static ProgramObject _program;
static ProgramObject _normalMapProgram;
static ProgramObject _specularMapProgram;