History

Re-name FBXGeometry to HFMGeometry and do the same for related classes

sabrina-shanman committed 8 years ago

Commit becee7f1 parent e01401252 files · +578 −578Browse files

Showing the changes to libraries/render-utils/src/Model.cpp (1 of 52 files). Show all

Unified · Split

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