From 44699fc661e397ebe40ed68c2cefc08871c38e69 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 10 Jan 2017 16:21:13 -0800 Subject: [PATCH 01/10] modelToWorld rotation not in cluster matrices --- .../render-utils/src/MeshPartPayload.cpp | 26 +++++++------------ libraries/render-utils/src/MeshPartPayload.h | 7 +++-- libraries/render-utils/src/Model.cpp | 10 +++---- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/libraries/render-utils/src/MeshPartPayload.cpp b/libraries/render-utils/src/MeshPartPayload.cpp index 037d58a67b..66f4f577b7 100644 --- a/libraries/render-utils/src/MeshPartPayload.cpp +++ b/libraries/render-utils/src/MeshPartPayload.cpp @@ -63,8 +63,7 @@ void MeshPartPayload::updateMeshPart(const std::shared_ptr& d void MeshPartPayload::updateTransform(const Transform& transform, const Transform& offsetTransform) { _transform = transform; - _offsetTransform = offsetTransform; - Transform::mult(_drawTransform, _transform, _offsetTransform); + Transform::mult(_drawTransform, _transform, offsetTransform); _worldBound = _localBound; _worldBound.transform(_drawTransform); } @@ -360,8 +359,8 @@ void ModelMeshPartPayload::notifyLocationChanged() { } -void ModelMeshPartPayload::updateTransformForSkinnedMesh(const Transform& transform, const Transform& offsetTransform, const QVector& clusterMatrices) { - ModelMeshPartPayload::updateTransform(transform, offsetTransform); +void ModelMeshPartPayload::updateTransformForSkinnedMesh(const Transform& transform, const QVector& clusterMatrices) { + _transform = transform; if (clusterMatrices.size() > 0) { _worldBound = AABox(); @@ -371,8 +370,10 @@ void ModelMeshPartPayload::updateTransformForSkinnedMesh(const Transform& transf _worldBound += clusterBound; } - // clusterMatrix has world rotation but not world translation. - _worldBound.translate(transform.getTranslation()); + _worldBound.transform(transform); + if (clusterMatrices.size() == 1) { + _transform.worldTransform(Transform(clusterMatrices[0])); + } } } @@ -520,23 +521,15 @@ void ModelMeshPartPayload::bindTransform(gpu::Batch& batch, const ShapePipeline: // Still relying on the raw data from the model const Model::MeshState& state = _model->_meshStates.at(_meshIndex); - Transform transform; if (state.clusterBuffer) { if (canCauterize && _model->getCauterizeBones()) { batch.setUniformBuffer(ShapePipeline::Slot::BUFFER::SKINNING, state.cauterizedClusterBuffer); } else { batch.setUniformBuffer(ShapePipeline::Slot::BUFFER::SKINNING, state.clusterBuffer); } - } else { - if (canCauterize && _model->getCauterizeBones()) { - transform = Transform(state.cauterizedClusterMatrices[0]); - } else { - transform = Transform(state.clusterMatrices[0]); - } } - transform.preTranslate(_transform.getTranslation()); - batch.setModelTransform(transform); + batch.setModelTransform(_transform); } void ModelMeshPartPayload::startFade() { @@ -570,7 +563,7 @@ void ModelMeshPartPayload::render(RenderArgs* args) const { } - // When an individual mesh parts like this finishes its fade, we will mark the Model as + // When an individual mesh parts like this finishes its fade, we will mark the Model as // having render items that need updating bool nextIsFading = _isFading ? isStillFading() : false; bool startFading = !_isFading && !_hasFinishedFade && _hasStartedFade; @@ -592,6 +585,7 @@ void ModelMeshPartPayload::render(RenderArgs* args) const { // Bind the model transform and the skinCLusterMatrices if needed bool canCauterize = args->_renderMode != RenderArgs::SHADOW_RENDER_MODE; + // TODO: maybe get rid of this call? _model->updateClusterMatrices(_transform.getTranslation(), _transform.getRotation()); bindTransform(batch, locations, canCauterize); diff --git a/libraries/render-utils/src/MeshPartPayload.h b/libraries/render-utils/src/MeshPartPayload.h index 3b882a9bb9..a09bb8626d 100644 --- a/libraries/render-utils/src/MeshPartPayload.h +++ b/libraries/render-utils/src/MeshPartPayload.h @@ -56,13 +56,12 @@ public: model::Mesh::Part _drawPart; std::shared_ptr _drawMaterial; - + model::Box _localBound; Transform _drawTransform; Transform _transform; - Transform _offsetTransform; mutable model::Box _worldBound; - + bool _hasColorAttrib = false; size_t getVerticesCount() const { return _drawMesh ? _drawMesh->getNumVertices() : 0; } @@ -86,7 +85,7 @@ public: typedef Payload::DataPointer Pointer; void notifyLocationChanged() override; - void updateTransformForSkinnedMesh(const Transform& transform, const Transform& offsetTransform, const QVector& clusterMatrices); + void updateTransformForSkinnedMesh(const Transform& transform, const QVector& clusterMatrices); // Entity fade in void startFade(); diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index ffbe1fb34c..bc74a073ab 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -245,7 +245,7 @@ void Model::updateRenderItems() { // update the model transform and bounding box for this render item. const Model::MeshState& state = data._model->_meshStates.at(data._meshIndex); - data.updateTransformForSkinnedMesh(modelTransform, modelMeshOffset, state.clusterMatrices); + data.updateTransformForSkinnedMesh(modelTransform, state.clusterMatrices); } } }); @@ -1167,7 +1167,6 @@ void Model::updateClusterMatrices(glm::vec3 modelPosition, glm::quat modelOrient glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); auto cauterizeMatrix = _rig->getJointTransform(geometry.neckJointIndex) * zeroScale; - glm::mat4 modelToWorld = glm::mat4_cast(modelOrientation); for (int i = 0; i < _meshStates.size(); i++) { MeshState& state = _meshStates[i]; const FBXMesh& mesh = geometry.meshes.at(i); @@ -1176,11 +1175,10 @@ void Model::updateClusterMatrices(glm::vec3 modelPosition, glm::quat modelOrient auto jointMatrix = _rig->getJointTransform(cluster.jointIndex); #if GLM_ARCH & GLM_ARCH_SSE2 glm::mat4 temp, out, inverseBindMatrix = cluster.inverseBindMatrix; - glm_mat4_mul((glm_vec4*)&modelToWorld, (glm_vec4*)&jointMatrix, (glm_vec4*)&temp); glm_mat4_mul((glm_vec4*)&temp, (glm_vec4*)&inverseBindMatrix, (glm_vec4*)&out); state.clusterMatrices[j] = out; -#else - state.clusterMatrices[j] = modelToWorld * jointMatrix * cluster.inverseBindMatrix; +#else + state.clusterMatrices[j] = jointMatrix * cluster.inverseBindMatrix; #endif // as an optimization, don't build cautrizedClusterMatrices if the boneSet is empty. @@ -1188,7 +1186,7 @@ void Model::updateClusterMatrices(glm::vec3 modelPosition, glm::quat modelOrient if (_cauterizeBoneSet.find(cluster.jointIndex) != _cauterizeBoneSet.end()) { jointMatrix = cauterizeMatrix; } - state.cauterizedClusterMatrices[j] = modelToWorld * jointMatrix * cluster.inverseBindMatrix; + state.cauterizedClusterMatrices[j] = jointMatrix * cluster.inverseBindMatrix; } } From 7a01b856f7dd62430c044a0253d0b7b17a746ceb Mon Sep 17 00:00:00 2001 From: sam Date: Wed, 11 Jan 2017 02:33:56 -0800 Subject: [PATCH 02/10] Factorization of the modelTransform out of the cluster matrices --- libraries/render-utils/src/MeshPartPayload.cpp | 4 ++-- libraries/render-utils/src/Model.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/render-utils/src/MeshPartPayload.cpp b/libraries/render-utils/src/MeshPartPayload.cpp index 66f4f577b7..bba658c75c 100644 --- a/libraries/render-utils/src/MeshPartPayload.cpp +++ b/libraries/render-utils/src/MeshPartPayload.cpp @@ -372,7 +372,7 @@ void ModelMeshPartPayload::updateTransformForSkinnedMesh(const Transform& transf _worldBound.transform(transform); if (clusterMatrices.size() == 1) { - _transform.worldTransform(Transform(clusterMatrices[0])); + _transform = _transform.worldTransform(Transform(clusterMatrices[0])); } } } @@ -586,7 +586,7 @@ void ModelMeshPartPayload::render(RenderArgs* args) const { // Bind the model transform and the skinCLusterMatrices if needed bool canCauterize = args->_renderMode != RenderArgs::SHADOW_RENDER_MODE; // TODO: maybe get rid of this call? - _model->updateClusterMatrices(_transform.getTranslation(), _transform.getRotation()); + // _model->updateClusterMatrices(_transform.getTranslation(), _transform.getRotation()); bindTransform(batch, locations, canCauterize); //Bind the index buffer and vertex buffer and Blend shapes if needed diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index bc74a073ab..b7e0492413 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -1174,8 +1174,8 @@ void Model::updateClusterMatrices(glm::vec3 modelPosition, glm::quat modelOrient const FBXCluster& cluster = mesh.clusters.at(j); auto jointMatrix = _rig->getJointTransform(cluster.jointIndex); #if GLM_ARCH & GLM_ARCH_SSE2 - glm::mat4 temp, out, inverseBindMatrix = cluster.inverseBindMatrix; - glm_mat4_mul((glm_vec4*)&temp, (glm_vec4*)&inverseBindMatrix, (glm_vec4*)&out); + glm::mat4 out, inverseBindMatrix = cluster.inverseBindMatrix; + glm_mat4_mul((glm_vec4*)&jointMatrix, (glm_vec4*)&inverseBindMatrix, (glm_vec4*)&out); state.clusterMatrices[j] = out; #else state.clusterMatrices[j] = jointMatrix * cluster.inverseBindMatrix; From e88f02d7b6c7931700b0400e7be7fcbbf3838253 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 11 Jan 2017 06:55:13 -0800 Subject: [PATCH 03/10] remove cruft --- libraries/render-utils/src/MeshPartPayload.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/libraries/render-utils/src/MeshPartPayload.cpp b/libraries/render-utils/src/MeshPartPayload.cpp index bba658c75c..650b8934ee 100644 --- a/libraries/render-utils/src/MeshPartPayload.cpp +++ b/libraries/render-utils/src/MeshPartPayload.cpp @@ -562,7 +562,6 @@ void ModelMeshPartPayload::render(RenderArgs* args) const { return; } - // When an individual mesh parts like this finishes its fade, we will mark the Model as // having render items that need updating bool nextIsFading = _isFading ? isStillFading() : false; @@ -585,8 +584,6 @@ void ModelMeshPartPayload::render(RenderArgs* args) const { // Bind the model transform and the skinCLusterMatrices if needed bool canCauterize = args->_renderMode != RenderArgs::SHADOW_RENDER_MODE; - // TODO: maybe get rid of this call? - // _model->updateClusterMatrices(_transform.getTranslation(), _transform.getRotation()); bindTransform(batch, locations, canCauterize); //Bind the index buffer and vertex buffer and Blend shapes if needed From 5d880487a031c56788a318e6285b60b9376669a7 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 11 Jan 2017 06:56:07 -0800 Subject: [PATCH 04/10] cleanup class method declarations --- libraries/render-utils/src/MeshPartPayload.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/render-utils/src/MeshPartPayload.h b/libraries/render-utils/src/MeshPartPayload.h index a09bb8626d..b048dc903f 100644 --- a/libraries/render-utils/src/MeshPartPayload.h +++ b/libraries/render-utils/src/MeshPartPayload.h @@ -34,7 +34,7 @@ public: virtual void updateMeshPart(const std::shared_ptr& drawMesh, int partIndex); virtual void notifyLocationChanged() {} - virtual void updateTransform(const Transform& transform, const Transform& offsetTransform); + void updateTransform(const Transform& transform, const Transform& offsetTransform); virtual void updateMaterial(model::MaterialPointer drawMaterial); @@ -100,7 +100,7 @@ public: // ModelMeshPartPayload functions to perform render void bindMesh(gpu::Batch& batch) const override; - void bindTransform(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations, bool canCauterize) const override; + void bindTransform(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations, bool canCauterize = true) const override; void initCache(); From 1804f33b98f4d52e14882b245c4aae51f0a6b71f Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 11 Jan 2017 06:56:35 -0800 Subject: [PATCH 05/10] add assert and TODO comment --- libraries/render-utils/src/Model.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index b7e0492413..b7848bc717 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -295,6 +295,7 @@ bool Model::updateGeometry() { if (_rig->jointStatesEmpty() && getFBXGeometry().joints.size() > 0) { initJointStates(); + assert(_meshStates.empty()); const FBXGeometry& fbxGeometry = getFBXGeometry(); foreach (const FBXMesh& mesh, fbxGeometry.meshes) { @@ -304,6 +305,9 @@ bool Model::updateGeometry() { _meshStates.append(state); + // Note: we add empty buffers for meshes that lack blendshapes so we can access the buffers by index + // later in ModelMeshPayload, however the vast majority of meshes will not have them. + // TODO? make _blendedVertexBuffers a map instead of vector and only add for meshes with blendshapes? auto buffer = std::make_shared(); if (!mesh.blendshapes.isEmpty()) { buffer->resize((mesh.vertices.size() + mesh.normals.size()) * sizeof(glm::vec3)); From bd16824d55a574bd2182db913964e07d24168b8f Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 11 Jan 2017 06:57:05 -0800 Subject: [PATCH 06/10] remove cruft: Model::_pupilDilation --- libraries/render-utils/src/Model.cpp | 1 - libraries/render-utils/src/Model.h | 4 ---- 2 files changed, 5 deletions(-) diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index b7848bc717..e0a378176f 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -92,7 +92,6 @@ Model::Model(RigPointer rig, QObject* parent) : _snapModelToRegistrationPoint(false), _snappedToRegistrationPoint(false), _cauterizeBones(false), - _pupilDilation(0.0f), _url(HTTP_INVALID_COM), _isVisible(true), _blendNumber(0), diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index d4387a6a9a..92b718d487 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -251,9 +251,6 @@ signals: protected: bool addedToScene() const { return _addedToScene; } - void setPupilDilation(float dilation) { _pupilDilation = dilation; } - float getPupilDilation() const { return _pupilDilation; } - void setBlendshapeCoefficients(const QVector& coefficients) { _blendshapeCoefficients = coefficients; } const QVector& getBlendshapeCoefficients() const { return _blendshapeCoefficients; } @@ -347,7 +344,6 @@ protected: void deleteGeometry(); void initJointTransforms(); - float _pupilDilation; QVector _blendshapeCoefficients; QUrl _url; From 87bdaae05acc2aa9fe82e71d80d1a183cbaa9846 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 11 Jan 2017 12:38:47 -0800 Subject: [PATCH 07/10] remove scale from ModelMeshPartPayload's transform --- libraries/render-utils/src/Model.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index e0a378176f..6292abea3b 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -216,10 +216,12 @@ void Model::updateRenderItems() { render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene(); Transform modelTransform; - modelTransform.setScale(scale); modelTransform.setTranslation(self->_translation); modelTransform.setRotation(self->_rotation); + Transform scaledModelTransform(modelTransform); + scaledModelTransform.setScale(scale); + Transform modelMeshOffset; if (self->isLoaded()) { // includes model offset and unitScale. @@ -254,9 +256,9 @@ void Model::updateRenderItems() { Transform collisionMeshOffset; collisionMeshOffset.setIdentity(); foreach (auto itemID, self->_collisionRenderItems.keys()) { - pendingChanges.updateItem(itemID, [modelTransform, collisionMeshOffset](MeshPartPayload& data) { + pendingChanges.updateItem(itemID, [scaledModelTransform, collisionMeshOffset](MeshPartPayload& data) { // update the model transform for this render item. - data.updateTransform(modelTransform, collisionMeshOffset); + data.updateTransform(scaledModelTransform, collisionMeshOffset); }); } From b3e336de3dd0d2e696eff0b7aa63b30fd4d3e4d4 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 11 Jan 2017 15:02:18 -0800 Subject: [PATCH 08/10] remove cruft: unused function arguments --- interface/src/avatar/SoftAttachmentModel.cpp | 13 +++++++++---- interface/src/avatar/SoftAttachmentModel.h | 2 +- libraries/render-utils/src/Model.cpp | 14 +++----------- libraries/render-utils/src/Model.h | 2 +- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/interface/src/avatar/SoftAttachmentModel.cpp b/interface/src/avatar/SoftAttachmentModel.cpp index c2e8dab2a1..6351495598 100644 --- a/interface/src/avatar/SoftAttachmentModel.cpp +++ b/interface/src/avatar/SoftAttachmentModel.cpp @@ -37,7 +37,7 @@ int SoftAttachmentModel::getJointIndexOverride(int i) const { // virtual // use the _rigOverride matrices instead of the Model::_rig -void SoftAttachmentModel::updateClusterMatrices(glm::vec3 modelPosition, glm::quat modelOrientation) { +void SoftAttachmentModel::updateClusterMatrices() { if (!_needsUpdateClusterMatrices) { return; } @@ -45,7 +45,6 @@ void SoftAttachmentModel::updateClusterMatrices(glm::vec3 modelPosition, glm::qu const FBXGeometry& geometry = getFBXGeometry(); - glm::mat4 modelToWorld = glm::mat4_cast(modelOrientation); for (int i = 0; i < _meshStates.size(); i++) { MeshState& state = _meshStates[i]; const FBXMesh& mesh = geometry.meshes.at(i); @@ -53,7 +52,7 @@ void SoftAttachmentModel::updateClusterMatrices(glm::vec3 modelPosition, glm::qu for (int j = 0; j < mesh.clusters.size(); j++) { const FBXCluster& cluster = mesh.clusters.at(j); - // TODO: cache these look ups as an optimization + // TODO: cache these look-ups as an optimization int jointIndexOverride = getJointIndexOverride(cluster.jointIndex); glm::mat4 jointMatrix; if (jointIndexOverride >= 0 && jointIndexOverride < _rigOverride->getJointStateCount()) { @@ -61,7 +60,13 @@ void SoftAttachmentModel::updateClusterMatrices(glm::vec3 modelPosition, glm::qu } else { jointMatrix = _rig->getJointTransform(cluster.jointIndex); } - state.clusterMatrices[j] = modelToWorld * jointMatrix * cluster.inverseBindMatrix; +#if GLM_ARCH & GLM_ARCH_SSE2 + glm::mat4 out, inverseBindMatrix = cluster.inverseBindMatrix; + glm_mat4_mul((glm_vec4*)&jointMatrix, (glm_vec4*)&inverseBindMatrix, (glm_vec4*)&out); + state.clusterMatrices[j] = out; +#else + state.clusterMatrices[j] = jointMatrix * cluster.inverseBindMatrix; +#endif } // Once computed the cluster matrices, update the buffer(s) diff --git a/interface/src/avatar/SoftAttachmentModel.h b/interface/src/avatar/SoftAttachmentModel.h index 84a8b4cc66..cdf957514c 100644 --- a/interface/src/avatar/SoftAttachmentModel.h +++ b/interface/src/avatar/SoftAttachmentModel.h @@ -31,7 +31,7 @@ public: ~SoftAttachmentModel(); virtual void updateRig(float deltaTime, glm::mat4 parentTransform) override; - virtual void updateClusterMatrices(glm::vec3 modelPosition, glm::quat modelOrientation) override; + virtual void updateClusterMatrices() override; protected: int getJointIndexOverride(int i) const; diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 6292abea3b..ccfea99066 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -222,19 +222,11 @@ void Model::updateRenderItems() { Transform scaledModelTransform(modelTransform); scaledModelTransform.setScale(scale); - Transform modelMeshOffset; - if (self->isLoaded()) { - // includes model offset and unitScale. - modelMeshOffset = Transform(self->_rig->getGeometryToRigTransform()); - } else { - modelMeshOffset.postTranslate(self->_offset); - } - uint32_t deleteGeometryCounter = self->_deleteGeometryCounter; render::PendingChanges pendingChanges; foreach (auto itemID, self->_modelMeshRenderItems.keys()) { - pendingChanges.updateItem(itemID, [modelTransform, modelMeshOffset, deleteGeometryCounter](ModelMeshPartPayload& data) { + pendingChanges.updateItem(itemID, [modelTransform, deleteGeometryCounter](ModelMeshPartPayload& data) { if (data._model && data._model->isLoaded()) { if (!data.hasStartedFade() && data._model->getGeometry()->areTexturesLoaded()) { data.startFade(); @@ -242,7 +234,7 @@ void Model::updateRenderItems() { // Ensure the model geometry was not reset between frames if (deleteGeometryCounter == data._model->_deleteGeometryCounter) { // lazy update of cluster matrices used for rendering. We need to update them here, so we can correctly update the bounding box. - data._model->updateClusterMatrices(modelTransform.getTranslation(), modelTransform.getRotation()); + data._model->updateClusterMatrices(); // update the model transform and bounding box for this render item. const Model::MeshState& state = data._model->_meshStates.at(data._meshIndex); @@ -1157,7 +1149,7 @@ void Model::simulateInternal(float deltaTime) { } // virtual -void Model::updateClusterMatrices(glm::vec3 modelPosition, glm::quat modelOrientation) { +void Model::updateClusterMatrices() { PerformanceTimer perfTimer("Model::updateClusterMatrices"); if (!_needsUpdateClusterMatrices || !isLoaded()) { diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index 92b718d487..55806b27e1 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -126,7 +126,7 @@ public: bool getSnapModelToRegistrationPoint() { return _snapModelToRegistrationPoint; } virtual void simulate(float deltaTime, bool fullUpdate = true); - virtual void updateClusterMatrices(glm::vec3 modelPosition, glm::quat modelOrientation); + virtual void updateClusterMatrices(); /// Returns a reference to the shared geometry. const Geometry::Pointer& getGeometry() const { return _renderGeometry; } From e2130d33d9e70eb7f892715db0e4bc07fe0cf72f Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 11 Jan 2017 15:10:44 -0800 Subject: [PATCH 09/10] speedup cauterizedClusterMatrices math --- libraries/render-utils/src/Model.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index ccfea99066..55c8d92333 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -1183,7 +1183,13 @@ void Model::updateClusterMatrices() { if (_cauterizeBoneSet.find(cluster.jointIndex) != _cauterizeBoneSet.end()) { jointMatrix = cauterizeMatrix; } +#if GLM_ARCH & GLM_ARCH_SSE2 + glm::mat4 out, inverseBindMatrix = cluster.inverseBindMatrix; + glm_mat4_mul((glm_vec4*)&jointMatrix, (glm_vec4*)&inverseBindMatrix, (glm_vec4*)&out); + state.cauterizedClusterMatrices[j] = out; +#else state.cauterizedClusterMatrices[j] = jointMatrix * cluster.inverseBindMatrix; +#endif } } From c060fd6a68b3d669cca61d050d2bfd1a07f0998a Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 11 Jan 2017 17:33:30 -0800 Subject: [PATCH 10/10] restore updateClusterMatrices() in render() --- libraries/render-utils/src/MeshPartPayload.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/render-utils/src/MeshPartPayload.cpp b/libraries/render-utils/src/MeshPartPayload.cpp index 650b8934ee..5c4c0890a7 100644 --- a/libraries/render-utils/src/MeshPartPayload.cpp +++ b/libraries/render-utils/src/MeshPartPayload.cpp @@ -584,6 +584,7 @@ void ModelMeshPartPayload::render(RenderArgs* args) const { // Bind the model transform and the skinCLusterMatrices if needed bool canCauterize = args->_renderMode != RenderArgs::SHADOW_RENDER_MODE; + _model->updateClusterMatrices(); bindTransform(batch, locations, canCauterize); //Bind the index buffer and vertex buffer and Blend shapes if needed