Showing the changes to libraries/render-utils/src/Model.cpp (1 of 14 files). Show all
Unified · Split
| @@ -30,7 +30,7 @@ · 29 unmodified lines | ||
| 30 | 30 | using namespace std; |
| 31 | 31 | |
| 32 | 32 | static int nakedModelPointerTypeId = qRegisterMetaType<ModelPointer>(); |
| 33 | −static int weakNetworkGeometryPointerTypeId = qRegisterMetaType<QWeakPointer<NetworkGeometry> >(); | |
| 33 | +static int weakNetworkGeometryPointerTypeId = qRegisterMetaType<std::weak_ptr<NetworkGeometry> >(); | |
| 34 | 34 | static int vec3VectorTypeId = qRegisterMetaType<QVector<glm::vec3> >(); |
| 35 | 35 | float Model::FAKE_DIMENSION_PLACEHOLDER = -1.0f; |
| 36 | 36 | #define HTTP_INVALID_COM "http://invalid.com" |
| @@ -74,12 +74,12 @@ Model::~Model() { · 37 unmodified lines | ||
| 74 | 74 | |
| 75 | 75 | AbstractViewStateInterface* Model::_viewState = NULL; |
| 76 | 76 | |
| 77 | −bool Model::needsFixupInScene() { | |
| 77 | +bool Model::needsFixupInScene() const { | |
| 78 | 78 | if (readyToAddToScene()) { |
| 79 | 79 | // Once textures are loaded, fixup if they are now transparent |
| 80 | − if (!_needsReload && _needsUpdateTransparentTextures && _geometry->isLoadedWithTextures()) { | |
| 80 | + if (_needsUpdateTransparentTextures && _geometry->getGeometry()->areTexturesLoaded()) { | |
| 81 | 81 | _needsUpdateTransparentTextures = false; |
| 82 | − if (_hasTransparentTextures != _geometry->hasTransparentTextures()) { | |
| 82 | + if (_hasTransparentTextures != _geometry->getGeometry()->hasTransparentTextures()) { | |
| 83 | 83 | return true; |
| 84 | 84 | } |
| 85 | 85 | } |
| @@ -150,19 +150,18 @@ void Model::enqueueLocationChange() { · 64 unmodified lines | ||
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | void Model::initJointTransforms() { |
| 153 | − if (!_geometry || !_geometry->isLoaded()) { | |
| 154 | − return; | |
| 153 | + if (isLoaded()) { | |
| 154 | + glm::mat4 modelOffset = glm::scale(_scale) * glm::translate(_offset); | |
| 155 | + _rig->setModelOffset(modelOffset); | |
| 155 | 156 | } |
| 156 | − glm::mat4 modelOffset = glm::scale(_scale) * glm::translate(_offset); | |
| 157 | − _rig->setModelOffset(modelOffset); | |
| 158 | 157 | } |
| 159 | 158 | |
| 160 | 159 | void Model::init() { |
| 161 | 160 | } |
| 162 | 161 | |
| 163 | 162 | void Model::reset() { |
| 164 | − if (_geometry && _geometry->isLoaded()) { | |
| 165 | − const FBXGeometry& geometry = _geometry->getFBXGeometry(); | |
| 163 | + if (isLoaded()) { | |
| 164 | + const FBXGeometry& geometry = getFBXGeometry(); | |
| 166 | 165 | _rig->reset(geometry); |
| 167 | 166 | } |
| 168 | 167 | } |
| @@ -171,17 +170,16 @@ bool Model::updateGeometry() { · 2 unmodified lines | ||
| 171 | 170 | PROFILE_RANGE(__FUNCTION__); |
| 172 | 171 | bool needFullUpdate = false; |
| 173 | 172 | |
| 174 | − if (!_geometry || !_geometry->isLoaded()) { | |
| 175 | − // geometry is not ready | |
| 173 | + if (!isLoaded()) { | |
| 176 | 174 | return false; |
| 177 | 175 | } |
| 178 | 176 | |
| 179 | 177 | _needsReload = false; |
| 180 | 178 | |
| 181 | − if (_rig->jointStatesEmpty() && _geometry->getFBXGeometry().joints.size() > 0) { | |
| 179 | + if (_rig->jointStatesEmpty() && getFBXGeometry().joints.size() > 0) { | |
| 182 | 180 | initJointStates(); |
| 183 | 181 | |
| 184 | − const FBXGeometry& fbxGeometry = _geometry->getFBXGeometry(); | |
| 182 | + const FBXGeometry& fbxGeometry = getFBXGeometry(); | |
| 185 | 183 | foreach (const FBXMesh& mesh, fbxGeometry.meshes) { |
| 186 | 184 | MeshState state; |
| 187 | 185 | state.clusterMatrices.resize(mesh.clusters.size()); |
| @@ -205,7 +203,7 @@ bool Model::updateGeometry() { · 17 unmodified lines | ||
| 205 | 203 | |
| 206 | 204 | // virtual |
| 207 | 205 | void Model::initJointStates() { |
| 208 | − const FBXGeometry& geometry = _geometry->getFBXGeometry(); | |
| 206 | + const FBXGeometry& geometry = getFBXGeometry(); | |
| 209 | 207 | glm::mat4 modelOffset = glm::scale(_scale) * glm::translate(_offset); |
| 210 | 208 | |
| 211 | 209 | _rig->initJointStates(geometry, modelOffset); |
| @@ -248,7 +246,7 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g · 36 unmodified lines | ||
| 248 | 246 | glm::vec3 subMeshSurfaceNormal; |
| 249 | 247 | int subMeshIndex = 0; |
| 250 | 248 | |
| 251 | − const FBXGeometry& geometry = _geometry->getFBXGeometry(); | |
| 249 | + const FBXGeometry& geometry = getFBXGeometry(); | |
| 252 | 250 | |
| 253 | 251 | // If we hit the models box, then consider the submeshes... |
| 254 | 252 | _mutex.lock(); |
| @@ -367,7 +365,7 @@ void Model::recalculateMeshBoxes(bool pickAgainstTriangles) { · 112 unmodified lines | ||
| 367 | 365 | bool calculatedMeshTrianglesNeeded = pickAgainstTriangles && !_calculatedMeshTrianglesValid; |
| 368 | 366 | |
| 369 | 367 | if (!_calculatedMeshBoxesValid || calculatedMeshTrianglesNeeded || (!_calculatedMeshPartBoxesValid && pickAgainstTriangles) ) { |
| 370 | − const FBXGeometry& geometry = _geometry->getFBXGeometry(); | |
| 368 | + const FBXGeometry& geometry = getFBXGeometry(); | |
| 371 | 369 | int numberOfMeshes = geometry.meshes.size(); |
| 372 | 370 | _calculatedMeshBoxes.resize(numberOfMeshes); |
| 373 | 371 | _calculatedMeshTriangles.clear(); |
| @@ -478,7 +476,7 @@ void Model::recalculateMeshBoxes(bool pickAgainstTriangles) { · 104 unmodified lines | ||
| 478 | 476 | |
| 479 | 477 | void Model::renderSetup(RenderArgs* args) { |
| 480 | 478 | // set up dilated textures on first render after load/simulate |
| 481 | − const FBXGeometry& geometry = _geometry->getFBXGeometry(); | |
| 479 | + const FBXGeometry& geometry = getFBXGeometry(); | |
| 482 | 480 | if (_dilatedTextures.isEmpty()) { |
| 483 | 481 | foreach (const FBXMesh& mesh, geometry.meshes) { |
| 484 | 482 | QVector<QSharedPointer<Texture> > dilated; |
| @@ -627,7 +625,7 @@ Extents Model::getBindExtents() const { · 142 unmodified lines | ||
| 627 | 625 | if (!isActive()) { |
| 628 | 626 | return Extents(); |
| 629 | 627 | } |
| 630 | − const Extents& bindExtents = _geometry->getFBXGeometry().bindExtents; | |
| 628 | + const Extents& bindExtents = getFBXGeometry().bindExtents; | |
| 631 | 629 | Extents scaledExtents = { bindExtents.minimum * _scale, bindExtents.maximum * _scale }; |
| 632 | 630 | return scaledExtents; |
| 633 | 631 | } |
| @@ -636,12 +634,12 @@ Extents Model::getMeshExtents() const { · 2 unmodified lines | ||
| 636 | 634 | if (!isActive()) { |
| 637 | 635 | return Extents(); |
| 638 | 636 | } |
| 639 | − const Extents& extents = _geometry->getFBXGeometry().meshExtents; | |
| 637 | + const Extents& extents = getFBXGeometry().meshExtents; | |
| 640 | 638 | |
| 641 | 639 | // even though our caller asked for "unscaled" we need to include any fst scaling, translation, and rotation, which |
| 642 | 640 | // is captured in the offset matrix |
| 643 | − glm::vec3 minimum = glm::vec3(_geometry->getFBXGeometry().offset * glm::vec4(extents.minimum, 1.0f)); | |
| 644 | − glm::vec3 maximum = glm::vec3(_geometry->getFBXGeometry().offset * glm::vec4(extents.maximum, 1.0f)); | |
| 641 | + glm::vec3 minimum = glm::vec3(getFBXGeometry().offset * glm::vec4(extents.minimum, 1.0f)); | |
| 642 | + glm::vec3 maximum = glm::vec3(getFBXGeometry().offset * glm::vec4(extents.maximum, 1.0f)); | |
| 645 | 643 | Extents scaledExtents = { minimum * _scale, maximum * _scale }; |
| 646 | 644 | return scaledExtents; |
| 647 | 645 | } |
| @@ -651,12 +649,12 @@ Extents Model::getUnscaledMeshExtents() const { · 3 unmodified lines | ||
| 651 | 649 | return Extents(); |
| 652 | 650 | } |
| 653 | 651 | |
| 654 | − const Extents& extents = _geometry->getFBXGeometry().meshExtents; | |
| 652 | + const Extents& extents = getFBXGeometry().meshExtents; | |
| 655 | 653 | |
| 656 | 654 | // even though our caller asked for "unscaled" we need to include any fst scaling, translation, and rotation, which |
| 657 | 655 | // is captured in the offset matrix |
| 658 | − glm::vec3 minimum = glm::vec3(_geometry->getFBXGeometry().offset * glm::vec4(extents.minimum, 1.0f)); | |
| 659 | − glm::vec3 maximum = glm::vec3(_geometry->getFBXGeometry().offset * glm::vec4(extents.maximum, 1.0f)); | |
| 656 | + glm::vec3 minimum = glm::vec3(getFBXGeometry().offset * glm::vec4(extents.minimum, 1.0f)); | |
| 657 | + glm::vec3 maximum = glm::vec3(getFBXGeometry().offset * glm::vec4(extents.maximum, 1.0f)); | |
| 660 | 658 | Extents scaledExtents = { minimum, maximum }; |
| 661 | 659 | |
| 662 | 660 | return scaledExtents; |
| @@ -665,8 +663,8 @@ Extents Model::getUnscaledMeshExtents() const { · 2 unmodified lines | ||
| 665 | 663 | Extents Model::calculateScaledOffsetExtents(const Extents& extents, |
| 666 | 664 | glm::vec3 modelPosition, glm::quat modelOrientation) const { |
| 667 | 665 | // we need to include any fst scaling, translation, and rotation, which is captured in the offset matrix |
| 668 | − glm::vec3 minimum = glm::vec3(_geometry->getFBXGeometry().offset * glm::vec4(extents.minimum, 1.0f)); | |
| 669 | − glm::vec3 maximum = glm::vec3(_geometry->getFBXGeometry().offset * glm::vec4(extents.maximum, 1.0f)); | |
| 666 | + glm::vec3 minimum = glm::vec3(getFBXGeometry().offset * glm::vec4(extents.minimum, 1.0f)); | |
| 667 | + glm::vec3 maximum = glm::vec3(getFBXGeometry().offset * glm::vec4(extents.maximum, 1.0f)); | |
| 670 | 668 | |
| 671 | 669 | Extents scaledOffsetExtents = { ((minimum + _offset) * _scale), |
| 672 | 670 | ((maximum + _offset) * _scale) }; |
| @@ -686,7 +684,7 @@ AABox Model::calculateScaledOffsetAABox(const AABox& box, glm::vec3 modelPositio · 13 unmodified lines | ||
| 686 | 684 | |
| 687 | 685 | glm::vec3 Model::calculateScaledOffsetPoint(const glm::vec3& point) const { |
| 688 | 686 | // we need to include any fst scaling, translation, and rotation, which is captured in the offset matrix |
| 689 | − glm::vec3 offsetPoint = glm::vec3(_geometry->getFBXGeometry().offset * glm::vec4(point, 1.0f)); | |
| 687 | + glm::vec3 offsetPoint = glm::vec3(getFBXGeometry().offset * glm::vec4(point, 1.0f)); | |
| 690 | 688 | glm::vec3 scaledPoint = ((offsetPoint + _offset) * _scale); |
| 691 | 689 | glm::vec3 rotatedPoint = _rotation * scaledPoint; |
| 692 | 690 | glm::vec3 translatedPoint = rotatedPoint + _translation; |
| @@ -714,11 +712,11 @@ void Model::setJointTranslation(int index, bool valid, const glm::vec3& translat · 21 unmodified lines | ||
| 714 | 712 | } |
| 715 | 713 | |
| 716 | 714 | int Model::getParentJointIndex(int jointIndex) const { |
| 717 | − return (isActive() && jointIndex != -1) ? _geometry->getFBXGeometry().joints.at(jointIndex).parentIndex : -1; | |
| 715 | + return (isActive() && jointIndex != -1) ? getFBXGeometry().joints.at(jointIndex).parentIndex : -1; | |
| 718 | 716 | } |
| 719 | 717 | |
| 720 | 718 | int Model::getLastFreeJointIndex(int jointIndex) const { |
| 721 | − return (isActive() && jointIndex != -1) ? _geometry->getFBXGeometry().joints.at(jointIndex).freeLineage.last() : -1; | |
| 719 | + return (isActive() && jointIndex != -1) ? getFBXGeometry().joints.at(jointIndex).freeLineage.last() : -1; | |
| 722 | 720 | } |
| 723 | 721 | |
| 724 | 722 | void Model::setURL(const QUrl& url) { |
| @@ -743,29 +741,16 @@ void Model::setURL(const QUrl& url) { · 18 unmodified lines | ||
| 743 | 741 | invalidCalculatedMeshBoxes(); |
| 744 | 742 | deleteGeometry(); |
| 745 | 743 | |
| 746 | − _geometry.reset(new NetworkGeometry(url, false, QVariantHash())); | |
| 744 | + _geometry = DependencyManager::get<ModelCache>()->getGeometry(url); | |
| 747 | 745 | onInvalidate(); |
| 748 | 746 | } |
| 749 | 747 | |
| 750 | −const QSharedPointer<NetworkGeometry> Model::getCollisionGeometry(bool delayLoad) | |
| 751 | −{ | |
| 752 | − if (_collisionGeometry.isNull() && !_collisionUrl.isEmpty()) { | |
| 753 | − _collisionGeometry.reset(new NetworkGeometry(_collisionUrl, delayLoad, QVariantHash())); | |
| 754 | − } | |
| 755 | − | |
| 756 | − if (_collisionGeometry && _collisionGeometry->isLoaded()) { | |
| 757 | − return _collisionGeometry; | |
| 758 | − } | |
| 759 | − | |
| 760 | − return QSharedPointer<NetworkGeometry>(); | |
| 761 | −} | |
| 762 | − | |
| 763 | 748 | void Model::setCollisionModelURL(const QUrl& url) { |
| 764 | 749 | if (_collisionUrl == url) { |
| 765 | 750 | return; |
| 766 | 751 | } |
| 767 | 752 | _collisionUrl = url; |
| 768 | − _collisionGeometry.reset(new NetworkGeometry(url, false, QVariantHash())); | |
| 753 | + _collisionGeometry = DependencyManager::get<ModelCache>()->getGeometry(url); | |
| 769 | 754 | } |
| 770 | 755 | |
| 771 | 756 | bool Model::getJointPositionInWorldFrame(int jointIndex, glm::vec3& position) const { |
| @@ -815,13 +800,13 @@ QStringList Model::getJointNames() const { · 43 unmodified lines | ||
| 815 | 800 | Q_RETURN_ARG(QStringList, result)); |
| 816 | 801 | return result; |
| 817 | 802 | } |
| 818 | − return isActive() ? _geometry->getFBXGeometry().getJointNames() : QStringList(); | |
| 803 | + return isActive() ? getFBXGeometry().getJointNames() : QStringList(); | |
| 819 | 804 | } |
| 820 | 805 | |
| 821 | 806 | class Blender : public QRunnable { |
| 822 | 807 | public: |
| 823 | 808 | |
| 824 | − Blender(ModelPointer model, int blendNumber, const QWeakPointer<NetworkGeometry>& geometry, | |
| 809 | + Blender(ModelPointer model, int blendNumber, const std::weak_ptr<NetworkGeometry>& geometry, | |
| 825 | 810 | const QVector<FBXMesh>& meshes, const QVector<float>& blendshapeCoefficients); |
| 826 | 811 | |
| 827 | 812 | virtual void run(); |
| @@ -830,12 +815,12 @@ private: · 2 unmodified lines | ||
| 830 | 815 | |
| 831 | 816 | ModelPointer _model; |
| 832 | 817 | int _blendNumber; |
| 833 | − QWeakPointer<NetworkGeometry> _geometry; | |
| 818 | + std::weak_ptr<NetworkGeometry> _geometry; | |
| 834 | 819 | QVector<FBXMesh> _meshes; |
| 835 | 820 | QVector<float> _blendshapeCoefficients; |
| 836 | 821 | }; |
| 837 | 822 | |
| 838 | −Blender::Blender(ModelPointer model, int blendNumber, const QWeakPointer<NetworkGeometry>& geometry, | |
| 823 | +Blender::Blender(ModelPointer model, int blendNumber, const std::weak_ptr<NetworkGeometry>& geometry, | |
| 839 | 824 | const QVector<FBXMesh>& meshes, const QVector<float>& blendshapeCoefficients) : |
| 840 | 825 | _model(model), |
| 841 | 826 | _blendNumber(blendNumber), |
| @@ -878,7 +863,7 @@ void Blender::run() { · 36 unmodified lines | ||
| 878 | 863 | // post the result to the geometry cache, which will dispatch to the model if still alive |
| 879 | 864 | QMetaObject::invokeMethod(DependencyManager::get<ModelBlender>().data(), "setBlendedVertices", |
| 880 | 865 | Q_ARG(ModelPointer, _model), Q_ARG(int, _blendNumber), |
| 881 | − Q_ARG(const QWeakPointer<NetworkGeometry>&, _geometry), Q_ARG(const QVector<glm::vec3>&, vertices), | |
| 866 | + Q_ARG(const std::weak_ptr<NetworkGeometry>&, _geometry), Q_ARG(const QVector<glm::vec3>&, vertices), | |
| 882 | 867 | Q_ARG(const QVector<glm::vec3>&, normals)); |
| 883 | 868 | } |
| 884 | 869 | |
| @@ -1010,7 +995,7 @@ void Model::updateClusterMatrices(glm::vec3 modelPosition, glm::quat modelOrient · 125 unmodified lines | ||
| 1010 | 995 | return; |
| 1011 | 996 | } |
| 1012 | 997 | _needsUpdateClusterMatrices = false; |
| 1013 | − const FBXGeometry& geometry = _geometry->getFBXGeometry(); | |
| 998 | + const FBXGeometry& geometry = getFBXGeometry(); | |
| 1014 | 999 | glm::mat4 zeroScale(glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), |
| 1015 | 1000 | glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), |
| 1016 | 1001 | glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), |
| @@ -1067,26 +1052,26 @@ void Model::updateClusterMatrices(glm::vec3 modelPosition, glm::quat modelOrient · 50 unmodified lines | ||
| 1067 | 1052 | } |
| 1068 | 1053 | |
| 1069 | 1054 | void Model::inverseKinematics(int endIndex, glm::vec3 targetPosition, const glm::quat& targetRotation, float priority) { |
| 1070 | − const FBXGeometry& geometry = _geometry->getFBXGeometry(); | |
| 1055 | + const FBXGeometry& geometry = getFBXGeometry(); | |
| 1071 | 1056 | const QVector<int>& freeLineage = geometry.joints.at(endIndex).freeLineage; |
| 1072 | 1057 | glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset); |
| 1073 | 1058 | _rig->inverseKinematics(endIndex, targetPosition, targetRotation, priority, freeLineage, parentTransform); |
| 1074 | 1059 | } |
| 1075 | 1060 | |
| 1076 | 1061 | bool Model::restoreJointPosition(int jointIndex, float fraction, float priority) { |
| 1077 | − const FBXGeometry& geometry = _geometry->getFBXGeometry(); | |
| 1062 | + const FBXGeometry& geometry = getFBXGeometry(); | |
| 1078 | 1063 | const QVector<int>& freeLineage = geometry.joints.at(jointIndex).freeLineage; |
| 1079 | 1064 | return _rig->restoreJointPosition(jointIndex, fraction, priority, freeLineage); |
| 1080 | 1065 | } |
| 1081 | 1066 | |
| 1082 | 1067 | float Model::getLimbLength(int jointIndex) const { |
| 1083 | − const FBXGeometry& geometry = _geometry->getFBXGeometry(); | |
| 1068 | + const FBXGeometry& geometry = getFBXGeometry(); | |
| 1084 | 1069 | const QVector<int>& freeLineage = geometry.joints.at(jointIndex).freeLineage; |
| 1085 | 1070 | return _rig->getLimbLength(jointIndex, freeLineage, _scale, geometry.joints); |
| 1086 | 1071 | } |
| 1087 | 1072 | |
| 1088 | 1073 | bool Model::maybeStartBlender() { |
| 1089 | − const FBXGeometry& fbxGeometry = _geometry->getFBXGeometry(); | |
| 1074 | + const FBXGeometry& fbxGeometry = getFBXGeometry(); | |
| 1090 | 1075 | if (fbxGeometry.hasBlendedMeshes()) { |
| 1091 | 1076 | QThreadPool::globalInstance()->start(new Blender(getThisPointer(), ++_blendNumber, _geometry, |
| 1092 | 1077 | fbxGeometry.meshes, _blendshapeCoefficients)); |
| @@ -1095,13 +1080,13 @@ bool Model::maybeStartBlender() { · 2 unmodified lines | ||
| 1095 | 1080 | return false; |
| 1096 | 1081 | } |
| 1097 | 1082 | |
| 1098 | −void Model::setBlendedVertices(int blendNumber, const QWeakPointer<NetworkGeometry>& geometry, | |
| 1083 | +void Model::setBlendedVertices(int blendNumber, const std::weak_ptr<NetworkGeometry>& geometry, | |
| 1099 | 1084 | const QVector<glm::vec3>& vertices, const QVector<glm::vec3>& normals) { |
| 1100 | − if (_geometry != geometry || _blendedVertexBuffers.empty() || blendNumber < _appliedBlendNumber) { | |
| 1085 | + if (_geometry != geometry.lock() || _blendedVertexBuffers.empty() || blendNumber < _appliedBlendNumber) { | |
| 1101 | 1086 | return; |
| 1102 | 1087 | } |
| 1103 | 1088 | _appliedBlendNumber = blendNumber; |
| 1104 | − const FBXGeometry& fbxGeometry = _geometry->getFBXGeometry(); | |
| 1089 | + const FBXGeometry& fbxGeometry = getFBXGeometry(); | |
| 1105 | 1090 | int index = 0; |
| 1106 | 1091 | for (int i = 0; i < fbxGeometry.meshes.size(); i++) { |
| 1107 | 1092 | const FBXMesh& mesh = fbxGeometry.meshes.at(i); |
| @@ -1118,13 +1103,6 @@ void Model::setBlendedVertices(int blendNumber, const QWeakPointer<NetworkGeomet · 10 unmodified lines | ||
| 1118 | 1103 | } |
| 1119 | 1104 | } |
| 1120 | 1105 | |
| 1121 | −void Model::setGeometry(const QSharedPointer<NetworkGeometry>& newGeometry) { | |
| 1122 | − if (_geometry == newGeometry) { | |
| 1123 | − return; | |
| 1124 | − } | |
| 1125 | − _geometry = newGeometry; | |
| 1126 | −} | |
| 1127 | − | |
| 1128 | 1106 | void Model::deleteGeometry() { |
| 1129 | 1107 | _blendedVertexBuffers.clear(); |
| 1130 | 1108 | _meshStates.clear(); |
| @@ -1134,7 +1112,7 @@ void Model::deleteGeometry() { · 3 unmodified lines | ||
| 1134 | 1112 | |
| 1135 | 1113 | AABox Model::getPartBounds(int meshIndex, int partIndex, glm::vec3 modelPosition, glm::quat modelOrientation) const { |
| 1136 | 1114 | |
| 1137 | − if (!_geometry || !_geometry->isLoaded()) { | |
| 1115 | + if (!isLoaded()) { | |
| 1138 | 1116 | return AABox(); |
| 1139 | 1117 | } |
| 1140 | 1118 | |
| @@ -1143,10 +1121,10 @@ AABox Model::getPartBounds(int meshIndex, int partIndex, glm::vec3 modelPosition · 2 unmodified lines | ||
| 1143 | 1121 | bool isSkinned = state.clusterMatrices.size() > 1; |
| 1144 | 1122 | if (isSkinned) { |
| 1145 | 1123 | // if we're skinned return the entire mesh extents because we can't know for sure our clusters don't move us |
| 1146 | − return calculateScaledOffsetAABox(_geometry->getFBXGeometry().meshExtents, modelPosition, modelOrientation); | |
| 1124 | + return calculateScaledOffsetAABox(getFBXGeometry().meshExtents, modelPosition, modelOrientation); | |
| 1147 | 1125 | } |
| 1148 | 1126 | } |
| 1149 | − if (_geometry->getFBXGeometry().meshes.size() > meshIndex) { | |
| 1127 | + if (getFBXGeometry().meshes.size() > meshIndex) { | |
| 1150 | 1128 | |
| 1151 | 1129 | // FIX ME! - This is currently a hack because for some mesh parts our efforts to calculate the bounding |
| 1152 | 1130 | // box of the mesh part fails. It seems to create boxes that are not consistent with where the |
| @@ -1160,27 +1138,28 @@ AABox Model::getPartBounds(int meshIndex, int partIndex, glm::vec3 modelPosition · 7 unmodified lines | ||
| 1160 | 1138 | // return _calculatedMeshBoxes[meshIndex]; |
| 1161 | 1139 | // |
| 1162 | 1140 | // If we not skinned use the bounds of the subMesh for all it's parts |
| 1163 | − const FBXMesh& mesh = _geometry->getFBXGeometry().meshes.at(meshIndex); | |
| 1141 | + const FBXMesh& mesh = getFBXGeometry().meshes.at(meshIndex); | |
| 1164 | 1142 | return calculateScaledOffsetExtents(mesh.meshExtents, modelPosition, modelOrientation); |
| 1165 | 1143 | } |
| 1166 | 1144 | return AABox(); |
| 1167 | 1145 | } |
| 1168 | 1146 | |
| 1169 | 1147 | void Model::segregateMeshGroups() { |
| 1170 | − QSharedPointer<NetworkGeometry> networkGeometry; | |
| 1148 | + NetworkGeometry::Pointer networkGeometry; | |
| 1171 | 1149 | bool showingCollisionHull = false; |
| 1172 | 1150 | if (_showCollisionHull && _collisionGeometry) { |
| 1173 | − if (_collisionGeometry->isLoaded()) { | |
| 1151 | + if (isCollisionLoaded()) { | |
| 1174 | 1152 | networkGeometry = _collisionGeometry; |
| 1175 | 1153 | showingCollisionHull = true; |
| 1176 | 1154 | } else { |
| 1177 | 1155 | return; |
| 1178 | 1156 | } |
| 1179 | 1157 | } else { |
| 1158 | + assert(isLoaded()); | |
| 1180 | 1159 | networkGeometry = _geometry; |
| 1181 | 1160 | } |
| 1182 | − const FBXGeometry& geometry = networkGeometry->getFBXGeometry(); | |
| 1183 | − const std::vector<std::unique_ptr<NetworkMesh>>& networkMeshes = networkGeometry->getMeshes(); | |
| 1161 | + const FBXGeometry& geometry = networkGeometry->getGeometry()->getGeometry(); | |
| 1162 | + const auto& networkMeshes = networkGeometry->getGeometry()->getMeshes(); | |
| 1184 | 1163 | |
| 1185 | 1164 | // all of our mesh vectors must match in size |
| 1186 | 1165 | auto geoMeshesSize = geometry.meshes.size(); |
| @@ -1208,7 +1187,7 @@ void Model::segregateMeshGroups() { · 21 unmodified lines | ||
| 1208 | 1187 | int shapeID = 0; |
| 1209 | 1188 | for (int i = 0; i < (int)networkMeshes.size(); i++) { |
| 1210 | 1189 | const FBXMesh& mesh = geometry.meshes.at(i); |
| 1211 | − const NetworkMesh& networkMesh = *(networkMeshes.at(i).get()); | |
| 1190 | + const auto& networkMesh = networkMeshes.at(i); | |
| 1212 | 1191 | |
| 1213 | 1192 | // Create the render payloads |
| 1214 | 1193 | int totalParts = mesh.parts.size(); |
| @@ -1220,7 +1199,7 @@ void Model::segregateMeshGroups() { · 5 unmodified lines | ||
| 1220 | 1199 | _collisionHullMaterial->setMetallic(0.02f); |
| 1221 | 1200 | _collisionHullMaterial->setRoughness(0.5f); |
| 1222 | 1201 | } |
| 1223 | − _renderItemsSet << std::make_shared<MeshPartPayload>(networkMesh._mesh, partIndex, _collisionHullMaterial, transform, offset); | |
| 1202 | + _renderItemsSet << std::make_shared<MeshPartPayload>(networkMesh, partIndex, _collisionHullMaterial, transform, offset); | |
| 1224 | 1203 | } else { |
| 1225 | 1204 | _renderItemsSet << std::make_shared<ModelMeshPartPayload>(this, i, partIndex, shapeID, transform, offset); |
| 1226 | 1205 | } |
| @@ -1285,7 +1264,7 @@ void ModelBlender::noteRequiresBlend(ModelPointer model) { · 58 unmodified lines | ||
| 1285 | 1264 | } |
| 1286 | 1265 | |
| 1287 | 1266 | void ModelBlender::setBlendedVertices(ModelPointer model, int blendNumber, |
| 1288 | − const QWeakPointer<NetworkGeometry>& geometry, const QVector<glm::vec3>& vertices, const QVector<glm::vec3>& normals) { | |
| 1267 | + const std::weak_ptr<NetworkGeometry>& geometry, const QVector<glm::vec3>& vertices, const QVector<glm::vec3>& normals) { | |
| 1289 | 1268 | if (model) { |
| 1290 | 1269 | model->setBlendedVertices(blendNumber, geometry, vertices, normals); |
| 1291 | 1270 | } |