Showing the changes to libraries/render-utils/src/Model.cpp (1 of 52 files). Show all
Unified · Split
| @@ -183,7 +183,7 @@ bool Model::shouldInvalidatePayloadShapeKey(int meshIndex) { · 182 unmodified lines | ||
| 183 | 183 | return true; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | − const FBXGeometry& geometry = getFBXGeometry(); | |
| 186 | + const HFMGeometry& geometry = getHFMGeometry(); | |
| 187 | 187 | const auto& networkMeshes = getGeometry()->getMeshes(); |
| 188 | 188 | // if our index is ever out of range for either meshes or networkMeshes, then skip it, and set our _meshGroupsKnown |
| 189 | 189 | // to false to rebuild out mesh groups. |
| @@ -278,7 +278,7 @@ void Model::setRenderItemsNeedUpdate() { · 88 unmodified lines | ||
| 278 | 278 | |
| 279 | 279 | void Model::reset() { |
| 280 | 280 | if (isLoaded()) { |
| 281 | − const FBXGeometry& geometry = getFBXGeometry(); | |
| 281 | + const HFMGeometry& geometry = getHFMGeometry(); | |
| 282 | 282 | _rig.reset(geometry); |
| 283 | 283 | emit rigReset(); |
| 284 | 284 | emit rigReady(); |
| @@ -295,13 +295,13 @@ bool Model::updateGeometry() { · 10 unmodified lines | ||
| 295 | 295 | _needsReload = false; |
| 296 | 296 | |
| 297 | 297 | // TODO: should all Models have a valid _rig? |
| 298 | − if (_rig.jointStatesEmpty() && getFBXGeometry().joints.size() > 0) { | |
| 298 | + if (_rig.jointStatesEmpty() && getHFMGeometry().joints.size() > 0) { | |
| 299 | 299 | initJointStates(); |
| 300 | 300 | assert(_meshStates.empty()); |
| 301 | 301 | |
| 302 | − const FBXGeometry& fbxGeometry = getFBXGeometry(); | |
| 302 | + const HFMGeometry& hfmGeometry = getHFMGeometry(); | |
| 303 | 303 | int i = 0; |
| 304 | − foreach (const FBXMesh& mesh, fbxGeometry.meshes) { | |
| 304 | + foreach (const HFMMesh& mesh, hfmGeometry.meshes) { | |
| 305 | 305 | MeshState state; |
| 306 | 306 | state.clusterDualQuaternions.resize(mesh.clusters.size()); |
| 307 | 307 | state.clusterMatrices.resize(mesh.clusters.size()); |
| @@ -319,7 +319,7 @@ bool Model::updateGeometry() { · 11 unmodified lines | ||
| 319 | 319 | |
| 320 | 320 | // virtual |
| 321 | 321 | void Model::initJointStates() { |
| 322 | − const FBXGeometry& geometry = getFBXGeometry(); | |
| 322 | + const HFMGeometry& geometry = getHFMGeometry(); | |
| 323 | 323 | glm::mat4 modelOffset = glm::scale(_scale) * glm::translate(_offset); |
| 324 | 324 | |
| 325 | 325 | _rig.initJointStates(geometry, modelOffset); |
| @@ -363,7 +363,7 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g · 37 unmodified lines | ||
| 363 | 363 | int bestShapeID = 0; |
| 364 | 364 | int bestSubMeshIndex = 0; |
| 365 | 365 | |
| 366 | − const FBXGeometry& geometry = getFBXGeometry(); | |
| 366 | + const HFMGeometry& geometry = getHFMGeometry(); | |
| 367 | 367 | if (!_triangleSetsValid) { |
| 368 | 368 | calculateTriangleSets(geometry); |
| 369 | 369 | } |
| @@ -506,7 +506,7 @@ bool Model::findParabolaIntersectionAgainstSubMeshes(const glm::vec3& origin, co · 136 unmodified lines | ||
| 506 | 506 | int bestShapeID = 0; |
| 507 | 507 | int bestSubMeshIndex = 0; |
| 508 | 508 | |
| 509 | − const FBXGeometry& geometry = getFBXGeometry(); | |
| 509 | + const HFMGeometry& geometry = getHFMGeometry(); | |
| 510 | 510 | if (!_triangleSetsValid) { |
| 511 | 511 | calculateTriangleSets(geometry); |
| 512 | 512 | } |
| @@ -641,7 +641,7 @@ bool Model::convexHullContains(glm::vec3 point) { · 128 unmodified lines | ||
| 641 | 641 | QMutexLocker locker(&_mutex); |
| 642 | 642 | |
| 643 | 643 | if (!_triangleSetsValid) { |
| 644 | − calculateTriangleSets(getFBXGeometry()); | |
| 644 | + calculateTriangleSets(getHFMGeometry()); | |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | // If we are inside the models box, then consider the submeshes... |
| @@ -753,14 +753,14 @@ bool Model::replaceScriptableModelMeshPart(scriptable::ScriptableModelBasePointe · 105 unmodified lines | ||
| 753 | 753 | } |
| 754 | 754 | // update triangles for picking |
| 755 | 755 | { |
| 756 | − FBXGeometry geometry; | |
| 756 | + HFMGeometry geometry; | |
| 757 | 757 | for (const auto& newMesh : meshes) { |
| 758 | − FBXMesh mesh; | |
| 758 | + HFMMesh mesh; | |
| 759 | 759 | mesh._mesh = newMesh.getMeshPointer(); |
| 760 | 760 | mesh.vertices = buffer_helpers::mesh::attributeToVector<glm::vec3>(mesh._mesh, gpu::Stream::POSITION); |
| 761 | 761 | int numParts = (int)newMesh.getMeshPointer()->getNumParts(); |
| 762 | 762 | for (int partID = 0; partID < numParts; partID++) { |
| 763 | − FBXMeshPart part; | |
| 763 | + HFMMeshPart part; | |
| 764 | 764 | part.triangleIndices = buffer_helpers::bufferToVector<int>(mesh._mesh->getIndexBuffer(), "part.triangleIndices"); |
| 765 | 765 | mesh.parts << part; |
| 766 | 766 | } |
| @@ -789,12 +789,12 @@ scriptable::ScriptableModelBase Model::getScriptableModel() { · 22 unmodified lines | ||
| 789 | 789 | return result; |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | − const FBXGeometry& geometry = getFBXGeometry(); | |
| 792 | + const HFMGeometry& geometry = getHFMGeometry(); | |
| 793 | 793 | int numberOfMeshes = geometry.meshes.size(); |
| 794 | 794 | int shapeID = 0; |
| 795 | 795 | for (int i = 0; i < numberOfMeshes; i++) { |
| 796 | − const FBXMesh& fbxMesh = geometry.meshes.at(i); | |
| 797 | − if (auto mesh = fbxMesh._mesh) { | |
| 796 | + const HFMMesh& hfmMesh = geometry.meshes.at(i); | |
| 797 | + if (auto mesh = hfmMesh._mesh) { | |
| 798 | 798 | result.append(mesh); |
| 799 | 799 | |
| 800 | 800 | int numParts = (int)mesh->getNumParts(); |
| @@ -808,7 +808,7 @@ scriptable::ScriptableModelBase Model::getScriptableModel() { · 7 unmodified lines | ||
| 808 | 808 | return result; |
| 809 | 809 | } |
| 810 | 810 | |
| 811 | −void Model::calculateTriangleSets(const FBXGeometry& geometry) { | |
| 811 | +void Model::calculateTriangleSets(const HFMGeometry& geometry) { | |
| 812 | 812 | PROFILE_RANGE(render, __FUNCTION__); |
| 813 | 813 | |
| 814 | 814 | int numberOfMeshes = geometry.meshes.size(); |
| @@ -818,14 +818,14 @@ void Model::calculateTriangleSets(const FBXGeometry& geometry) { · 3 unmodified lines | ||
| 818 | 818 | _modelSpaceMeshTriangleSets.resize(numberOfMeshes); |
| 819 | 819 | |
| 820 | 820 | for (int i = 0; i < numberOfMeshes; i++) { |
| 821 | − const FBXMesh& mesh = geometry.meshes.at(i); | |
| 821 | + const HFMMesh& mesh = geometry.meshes.at(i); | |
| 822 | 822 | |
| 823 | 823 | const int numberOfParts = mesh.parts.size(); |
| 824 | 824 | auto& meshTriangleSets = _modelSpaceMeshTriangleSets[i]; |
| 825 | 825 | meshTriangleSets.resize(numberOfParts); |
| 826 | 826 | |
| 827 | 827 | for (int j = 0; j < numberOfParts; j++) { |
| 828 | − const FBXMeshPart& part = mesh.parts.at(j); | |
| 828 | + const HFMMeshPart& part = mesh.parts.at(j); | |
| 829 | 829 | |
| 830 | 830 | auto& partTriangleSet = meshTriangleSets[j]; |
| 831 | 831 | |
| @@ -1114,7 +1114,7 @@ Extents Model::getBindExtents() const { · 282 unmodified lines | ||
| 1114 | 1114 | if (!isActive()) { |
| 1115 | 1115 | return Extents(); |
| 1116 | 1116 | } |
| 1117 | − const Extents& bindExtents = getFBXGeometry().bindExtents; | |
| 1117 | + const Extents& bindExtents = getHFMGeometry().bindExtents; | |
| 1118 | 1118 | Extents scaledExtents = { bindExtents.minimum * _scale, bindExtents.maximum * _scale }; |
| 1119 | 1119 | return scaledExtents; |
| 1120 | 1120 | } |
| @@ -1128,12 +1128,12 @@ Extents Model::getMeshExtents() const { · 7 unmodified lines | ||
| 1128 | 1128 | if (!isActive()) { |
| 1129 | 1129 | return Extents(); |
| 1130 | 1130 | } |
| 1131 | − const Extents& extents = getFBXGeometry().meshExtents; | |
| 1131 | + const Extents& extents = getHFMGeometry().meshExtents; | |
| 1132 | 1132 | |
| 1133 | 1133 | // even though our caller asked for "unscaled" we need to include any fst scaling, translation, and rotation, which |
| 1134 | 1134 | // is captured in the offset matrix |
| 1135 | − glm::vec3 minimum = glm::vec3(getFBXGeometry().offset * glm::vec4(extents.minimum, 1.0f)); | |
| 1136 | − glm::vec3 maximum = glm::vec3(getFBXGeometry().offset * glm::vec4(extents.maximum, 1.0f)); | |
| 1135 | + glm::vec3 minimum = glm::vec3(getHFMGeometry().offset * glm::vec4(extents.minimum, 1.0f)); | |
| 1136 | + glm::vec3 maximum = glm::vec3(getHFMGeometry().offset * glm::vec4(extents.maximum, 1.0f)); | |
| 1137 | 1137 | Extents scaledExtents = { minimum * _scale, maximum * _scale }; |
| 1138 | 1138 | return scaledExtents; |
| 1139 | 1139 | } |
| @@ -1143,12 +1143,12 @@ Extents Model::getUnscaledMeshExtents() const { · 3 unmodified lines | ||
| 1143 | 1143 | return Extents(); |
| 1144 | 1144 | } |
| 1145 | 1145 | |
| 1146 | − const Extents& extents = getFBXGeometry().meshExtents; | |
| 1146 | + const Extents& extents = getHFMGeometry().meshExtents; | |
| 1147 | 1147 | |
| 1148 | 1148 | // even though our caller asked for "unscaled" we need to include any fst scaling, translation, and rotation, which |
| 1149 | 1149 | // is captured in the offset matrix |
| 1150 | − glm::vec3 minimum = glm::vec3(getFBXGeometry().offset * glm::vec4(extents.minimum, 1.0f)); | |
| 1151 | − glm::vec3 maximum = glm::vec3(getFBXGeometry().offset * glm::vec4(extents.maximum, 1.0f)); | |
| 1150 | + glm::vec3 minimum = glm::vec3(getHFMGeometry().offset * glm::vec4(extents.minimum, 1.0f)); | |
| 1151 | + glm::vec3 maximum = glm::vec3(getHFMGeometry().offset * glm::vec4(extents.maximum, 1.0f)); | |
| 1152 | 1152 | Extents scaledExtents = { minimum, maximum }; |
| 1153 | 1153 | |
| 1154 | 1154 | return scaledExtents; |
| @@ -1171,11 +1171,11 @@ void Model::setJointTranslation(int index, bool valid, const glm::vec3& translat · 16 unmodified lines | ||
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | 1173 | int Model::getParentJointIndex(int jointIndex) const { |
| 1174 | − return (isActive() && jointIndex != -1) ? getFBXGeometry().joints.at(jointIndex).parentIndex : -1; | |
| 1174 | + return (isActive() && jointIndex != -1) ? getHFMGeometry().joints.at(jointIndex).parentIndex : -1; | |
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | int Model::getLastFreeJointIndex(int jointIndex) const { |
| 1178 | − return (isActive() && jointIndex != -1) ? getFBXGeometry().joints.at(jointIndex).freeLineage.last() : -1; | |
| 1178 | + return (isActive() && jointIndex != -1) ? getHFMGeometry().joints.at(jointIndex).freeLineage.last() : -1; | |
| 1179 | 1179 | } |
| 1180 | 1180 | |
| 1181 | 1181 | void Model::setTextures(const QVariantMap& textures) { |
| @@ -1275,7 +1275,7 @@ QStringList Model::getJointNames() const { · 93 unmodified lines | ||
| 1275 | 1275 | Q_RETURN_ARG(QStringList, result)); |
| 1276 | 1276 | return result; |
| 1277 | 1277 | } |
| 1278 | − return isActive() ? getFBXGeometry().getJointNames() : QStringList(); | |
| 1278 | + return isActive() ? getHFMGeometry().getJointNames() : QStringList(); | |
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | void Model::setScaleToFit(bool scaleToFit, const glm::vec3& dimensions, bool forceRescale) { |
| @@ -1415,12 +1415,12 @@ void Model::updateClusterMatrices() { · 133 unmodified lines | ||
| 1415 | 1415 | } |
| 1416 | 1416 | |
| 1417 | 1417 | _needsUpdateClusterMatrices = false; |
| 1418 | − const FBXGeometry& geometry = getFBXGeometry(); | |
| 1418 | + const HFMGeometry& geometry = getHFMGeometry(); | |
| 1419 | 1419 | for (int i = 0; i < (int) _meshStates.size(); i++) { |
| 1420 | 1420 | MeshState& state = _meshStates[i]; |
| 1421 | − const FBXMesh& mesh = geometry.meshes.at(i); | |
| 1421 | + const HFMMesh& mesh = geometry.meshes.at(i); | |
| 1422 | 1422 | for (int j = 0; j < mesh.clusters.size(); j++) { |
| 1423 | − const FBXCluster& cluster = mesh.clusters.at(j); | |
| 1423 | + const HFMCluster& cluster = mesh.clusters.at(j); | |
| 1424 | 1424 | if (_useDualQuaternionSkinning) { |
| 1425 | 1425 | auto jointPose = _rig.getJointPose(cluster.jointIndex); |
| 1426 | 1426 | Transform jointTransform(jointPose.rot(), jointPose.scale(), jointPose.trans()); |
| @@ -1505,7 +1505,7 @@ void Model::createRenderItemSet() { · 78 unmodified lines | ||
| 1505 | 1505 | // Run through all of the meshes, and place them into their segregated, but unsorted buckets |
| 1506 | 1506 | int shapeID = 0; |
| 1507 | 1507 | uint32_t numMeshes = (uint32_t)meshes.size(); |
| 1508 | − auto& fbxGeometry = getFBXGeometry(); | |
| 1508 | + auto& hfmGeometry = getHFMGeometry(); | |
| 1509 | 1509 | for (uint32_t i = 0; i < numMeshes; i++) { |
| 1510 | 1510 | const auto& mesh = meshes.at(i); |
| 1511 | 1511 | if (!mesh) { |
| @@ -1515,7 +1515,7 @@ void Model::createRenderItemSet() { · 3 unmodified lines | ||
| 1515 | 1515 | // Create the render payloads |
| 1516 | 1516 | int numParts = (int)mesh->getNumParts(); |
| 1517 | 1517 | for (int partIndex = 0; partIndex < numParts; partIndex++) { |
| 1518 | − initializeBlendshapes(fbxGeometry.meshes[i], i); | |
| 1518 | + initializeBlendshapes(hfmGeometry.meshes[i], i); | |
| 1519 | 1519 | _modelMeshRenderItems << std::make_shared<ModelMeshPartPayload>(shared_from_this(), i, partIndex, shapeID, transform, offset); |
| 1520 | 1520 | auto material = getGeometry()->getShapeMaterial(shapeID); |
| 1521 | 1521 | _modelMeshMaterialNames.push_back(material ? material->getName() : ""); |
| @@ -1600,7 +1600,7 @@ void Model::removeMaterial(graphics::MaterialPointer material, const std::string · 78 unmodified lines | ||
| 1600 | 1600 | class CollisionRenderGeometry : public Geometry { |
| 1601 | 1601 | public: |
| 1602 | 1602 | CollisionRenderGeometry(graphics::MeshPointer mesh) { |
| 1603 | − _fbxGeometry = std::make_shared<FBXGeometry>(); | |
| 1603 | + _hfmGeometry = std::make_shared<HFMGeometry>(); | |
| 1604 | 1604 | std::shared_ptr<GeometryMeshes> meshes = std::make_shared<GeometryMeshes>(); |
| 1605 | 1605 | meshes->push_back(mesh); |
| 1606 | 1606 | _meshes = meshes; |
| @@ -1656,9 +1656,9 @@ void Blender::run() { · 49 unmodified lines | ||
| 1656 | 1656 | if (_model && _model->isLoaded()) { |
| 1657 | 1657 | DETAILED_PROFILE_RANGE_EX(simulation_animation, __FUNCTION__, 0xFFFF0000, 0, { { "url", _model->getURL().toString() } }); |
| 1658 | 1658 | int offset = 0; |
| 1659 | − auto meshes = _model->getFBXGeometry().meshes; | |
| 1659 | + auto meshes = _model->getHFMGeometry().meshes; | |
| 1660 | 1660 | int meshIndex = 0; |
| 1661 | − foreach(const FBXMesh& mesh, meshes) { | |
| 1661 | + foreach(const HFMMesh& mesh, meshes) { | |
| 1662 | 1662 | auto modelMeshBlendshapeOffsets = _model->_blendshapeOffsets.find(meshIndex++); |
| 1663 | 1663 | if (mesh.blendshapes.isEmpty() || modelMeshBlendshapeOffsets == _model->_blendshapeOffsets.end()) { |
| 1664 | 1664 | // Not blendshaped or not initialized |
| @@ -1688,7 +1688,7 @@ void Blender::run() { · 23 unmodified lines | ||
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | 1690 | float normalCoefficient = vertexCoefficient * NORMAL_COEFFICIENT_SCALE; |
| 1691 | − const FBXBlendshape& blendshape = mesh.blendshapes.at(i); | |
| 1691 | + const HFMBlendshape& blendshape = mesh.blendshapes.at(i); | |
| 1692 | 1692 | |
| 1693 | 1693 | tbb::parallel_for(tbb::blocked_range<int>(0, blendshape.indices.size()), [&](const tbb::blocked_range<int>& range) { |
| 1694 | 1694 | for (auto j = range.begin(); j < range.end(); j++) { |
| @@ -1731,7 +1731,7 @@ bool Model::maybeStartBlender() { · 36 unmodified lines | ||
| 1731 | 1731 | return false; |
| 1732 | 1732 | } |
| 1733 | 1733 | |
| 1734 | −void Model::initializeBlendshapes(const FBXMesh& mesh, int index) { | |
| 1734 | +void Model::initializeBlendshapes(const HFMMesh& mesh, int index) { | |
| 1735 | 1735 | if (mesh.blendshapes.empty()) { |
| 1736 | 1736 | // mesh doesn't have blendshape, did we allocate one though ? |
| 1737 | 1737 | if (_blendshapeOffsets.find(index) != _blendshapeOffsets.end()) { |