diff --git a/src/anglesmooth.cpp b/src/anglesmooth.cpp index 9017d937..7c8367c5 100644 --- a/src/anglesmooth.cpp +++ b/src/anglesmooth.cpp @@ -8,29 +8,29 @@ void angleSmooth(const std::vector &vertices, const std::vector &triangleNormals, float thresholdAngleDegrees, std::vector &triangleVertexNormals) { - std::vector>> triangleVertexNormalsMapByIndicies(vertices.size()); + std::vector>> triangleVertexNormalsMapByIndices(vertices.size()); std::vector angleAreaWeightedNormals; for (size_t triangleIndex = 0; triangleIndex < triangles.size(); ++triangleIndex) { const auto &sourceTriangle = triangles[triangleIndex]; - size_t indicies[] = {std::get<0>(sourceTriangle), + size_t indices[] = {std::get<0>(sourceTriangle), std::get<1>(sourceTriangle), std::get<2>(sourceTriangle)}; - const auto &v1 = vertices[indicies[0]]; - const auto &v2 = vertices[indicies[1]]; - const auto &v3 = vertices[indicies[2]]; + const auto &v1 = vertices[indices[0]]; + const auto &v2 = vertices[indices[1]]; + const auto &v3 = vertices[indices[2]]; float area = areaOfTriangle(v1, v2, v3); float angles[] = {radianBetweenVectors(v2-v1, v3-v1), radianBetweenVectors(v1-v2, v3-v2), radianBetweenVectors(v1-v3, v2-v3)}; for (int i = 0; i < 3; ++i) { - triangleVertexNormalsMapByIndicies[indicies[i]].push_back({triangleIndex, angleAreaWeightedNormals.size()}); + triangleVertexNormalsMapByIndices[indices[i]].push_back({triangleIndex, angleAreaWeightedNormals.size()}); angleAreaWeightedNormals.push_back(triangleNormals[triangleIndex] * area * angles[i]); } } triangleVertexNormals = angleAreaWeightedNormals; std::map, float> degreesBetweenFacesMap; for (size_t vertexIndex = 0; vertexIndex < vertices.size(); ++vertexIndex) { - const auto &triangleVertices = triangleVertexNormalsMapByIndicies[vertexIndex]; + const auto &triangleVertices = triangleVertexNormalsMapByIndices[vertexIndex]; for (const auto &triangleVertex: triangleVertices) { for (const auto &otherTriangleVertex: triangleVertices) { if (triangleVertex.first == otherTriangleVertex.first) diff --git a/src/animalrigger.cpp b/src/animalrigger.cpp index 27c1da94..86554629 100644 --- a/src/animalrigger.cpp +++ b/src/animalrigger.cpp @@ -31,11 +31,11 @@ BoneMark AnimalRigger::translateBoneMark(BoneMark boneMark) return boneMark; } -bool AnimalRigger::collectJontsForChain(int markIndex, std::vector &jointMarkIndicies) +bool AnimalRigger::collectJontsForChain(int markIndex, std::vector &jointMarkIndices) { const auto &mark = m_marks[markIndex]; - jointMarkIndicies.push_back(markIndex); + jointMarkIndices.push_back(markIndex); // First insert joints, then the limb node, // because the limb node may contains the triangles of other joint becuase of expanding in split @@ -66,7 +66,7 @@ bool AnimalRigger::collectJontsForChain(int markIndex, std::vector &jointMa for (const auto &triangle: group) { for (int i = 0; i < 3; ++i) { int j = (i + 1) % 3; - edgeToTriangleMap.insert({{triangle.indicies[i], triangle.indicies[j]}, &triangle}); + edgeToTriangleMap.insert({{triangle.indices[i], triangle.indices[j]}, &triangle}); } } @@ -75,7 +75,7 @@ bool AnimalRigger::collectJontsForChain(int markIndex, std::vector &jointMa for (const auto &triangle: mark.markTriangles) { for (int i = 0; i < 3; i++) { int j = (i + 1) % 3; - auto findOppositeTriangleResult = edgeToTriangleMap.find({triangle.indicies[j], triangle.indicies[i]}); + auto findOppositeTriangleResult = edgeToTriangleMap.find({triangle.indices[j], triangle.indices[i]}); if (findOppositeTriangleResult == edgeToTriangleMap.end()) continue; const MeshSplitterTriangle *startupTriangle = findOppositeTriangleResult->second; @@ -106,7 +106,7 @@ bool AnimalRigger::collectJontsForChain(int markIndex, std::vector &jointMa } for (int i = 0; i < 3; i++) { int j = (i + 1) % 3; - auto findOppositeTriangleResult = edgeToTriangleMap.find({triangle->indicies[j], triangle->indicies[i]}); + auto findOppositeTriangleResult = edgeToTriangleMap.find({triangle->indices[j], triangle->indices[i]}); if (findOppositeTriangleResult == edgeToTriangleMap.end()) continue; const MeshSplitterTriangle *neighborTriangle = findOppositeTriangleResult->second; @@ -166,7 +166,7 @@ bool AnimalRigger::collectJontsForChain(int markIndex, std::vector &jointMa qDebug() << "Find nearest joint failed"; return false; } - jointMarkIndicies.push_back(nearestMarkIndex); + jointMarkIndices.push_back(nearestMarkIndex); visited.insert(nearestMarkIndex); findPairResult = pairs.find(nearestMarkIndex); } @@ -179,7 +179,7 @@ bool AnimalRigger::collectJontsForChain(int markIndex, std::vector &jointMa linkTo = item; //qDebug() << "Link" << findPairResult->first << "to" << linkTo; visited.insert(linkTo); - jointMarkIndicies.push_back(linkTo); + jointMarkIndices.push_back(linkTo); break; } if (-1 == linkTo) @@ -210,43 +210,43 @@ bool AnimalRigger::rig() qDebug() << "isMainBodyVerticalAligned:" << isMainBodyVerticalAligned; // Collect all branchs - auto neckIndicies = m_marksMap.find(std::make_pair(BoneMark::Neck, SkeletonSide::None)); - auto tailIndicies = m_marksMap.find(std::make_pair(BoneMark::Tail, SkeletonSide::None)); - auto leftLimbIndicies = m_marksMap.find(std::make_pair(BoneMark::Limb, SkeletonSide::Left)); - auto rightLimbIndicies = m_marksMap.find(std::make_pair(BoneMark::Limb, SkeletonSide::Right)); - std::vector nosideMarkIndicies; - std::vector leftMarkIndicies; - std::vector righMarkIndicies; - if (neckIndicies != m_marksMap.end()) { - for (const auto &index: neckIndicies->second) - nosideMarkIndicies.push_back(index); + auto neckIndices = m_marksMap.find(std::make_pair(BoneMark::Neck, SkeletonSide::None)); + auto tailIndices = m_marksMap.find(std::make_pair(BoneMark::Tail, SkeletonSide::None)); + auto leftLimbIndices = m_marksMap.find(std::make_pair(BoneMark::Limb, SkeletonSide::Left)); + auto rightLimbIndices = m_marksMap.find(std::make_pair(BoneMark::Limb, SkeletonSide::Right)); + std::vector nosideMarkIndices; + std::vector leftMarkIndices; + std::vector righMarkIndices; + if (neckIndices != m_marksMap.end()) { + for (const auto &index: neckIndices->second) + nosideMarkIndices.push_back(index); } - if (tailIndicies != m_marksMap.end()) { - for (const auto &index: tailIndicies->second) - nosideMarkIndicies.push_back(index); + if (tailIndices != m_marksMap.end()) { + for (const auto &index: tailIndices->second) + nosideMarkIndices.push_back(index); } - if (leftLimbIndicies != m_marksMap.end()) { - for (const auto &index: leftLimbIndicies->second) - leftMarkIndicies.push_back(index); + if (leftLimbIndices != m_marksMap.end()) { + for (const auto &index: leftLimbIndices->second) + leftMarkIndices.push_back(index); } - if (rightLimbIndicies != m_marksMap.end()) { - for (const auto &index: rightLimbIndicies->second) - righMarkIndicies.push_back(index); + if (rightLimbIndices != m_marksMap.end()) { + for (const auto &index: rightLimbIndices->second) + righMarkIndices.push_back(index); } // Generate spine for main body - auto sortMarkIndiciesInSpineOrder = [=](const int &first, const int &second) { + auto sortMarkIndicesInSpineOrder = [=](const int &first, const int &second) { return isMainBodyVerticalAligned ? (m_marks[first].bonePosition.y() < m_marks[second].bonePosition.y()) : (m_marks[first].bonePosition.z() < m_marks[second].bonePosition.z()); }; - std::sort(nosideMarkIndicies.begin(), nosideMarkIndicies.end(), sortMarkIndiciesInSpineOrder); - std::sort(leftMarkIndicies.begin(), leftMarkIndicies.end(), sortMarkIndiciesInSpineOrder); - std::sort(righMarkIndicies.begin(), righMarkIndicies.end(), sortMarkIndiciesInSpineOrder); + std::sort(nosideMarkIndices.begin(), nosideMarkIndices.end(), sortMarkIndicesInSpineOrder); + std::sort(leftMarkIndices.begin(), leftMarkIndices.end(), sortMarkIndicesInSpineOrder); + std::sort(righMarkIndices.begin(), righMarkIndices.end(), sortMarkIndicesInSpineOrder); const static std::vector s_empty; - const std::vector *chainColumns[3] = {&leftMarkIndicies, - &nosideMarkIndicies, - &righMarkIndicies + const std::vector *chainColumns[3] = {&leftMarkIndices, + &nosideMarkIndices, + &righMarkIndices }; enum Column { @@ -258,18 +258,18 @@ bool AnimalRigger::rig() { float coord; QVector3D position; - std::set chainMarkIndicies; + std::set chainMarkIndices; }; std::vector rawSpineNodes; - for (size_t sideIndicies[3] = {0, 0, 0}; - sideIndicies[Column::Noside] < chainColumns[Column::Noside]->size() || - sideIndicies[Column::Left] < chainColumns[Column::Left]->size() || - sideIndicies[Column::Right] < chainColumns[Column::Right]->size();) { + for (size_t sideIndices[3] = {0, 0, 0}; + sideIndices[Column::Noside] < chainColumns[Column::Noside]->size() || + sideIndices[Column::Left] < chainColumns[Column::Left]->size() || + sideIndices[Column::Right] < chainColumns[Column::Right]->size();) { float choosenCoord = std::numeric_limits::max(); int choosenColumn = -1; for (size_t side = Column::Left; side <= Column::Right; ++side) { - if (sideIndicies[side] < chainColumns[side]->size()) { - const auto &mark = m_marks[chainColumns[side]->at(sideIndicies[side])]; + if (sideIndices[side] < chainColumns[side]->size()) { + const auto &mark = m_marks[chainColumns[side]->at(sideIndices[side])]; const auto &coord = isMainBodyVerticalAligned ? mark.bonePosition.y() : mark.bonePosition.z(); if (coord < choosenCoord) { @@ -285,17 +285,17 @@ bool AnimalRigger::rig() // Find all the chains before or near this choosenCoord QVector3D sumOfChainPositions; int countOfChains = 0; - std::set chainMarkIndicies; + std::set chainMarkIndices; for (size_t side = Column::Left; side <= Column::Right; ++side) { - if (sideIndicies[side] < chainColumns[side]->size()) { - const auto &mark = m_marks[chainColumns[side]->at(sideIndicies[side])]; + if (sideIndices[side] < chainColumns[side]->size()) { + const auto &mark = m_marks[chainColumns[side]->at(sideIndices[side])]; const auto &coord = isMainBodyVerticalAligned ? mark.bonePosition.y() : mark.bonePosition.z(); if (coord <= choosenCoord + 0.001) { - chainMarkIndicies.insert(chainColumns[side]->at(sideIndicies[side])); + chainMarkIndices.insert(chainColumns[side]->at(sideIndices[side])); sumOfChainPositions += mark.bonePosition; ++countOfChains; - ++sideIndicies[side]; + ++sideIndices[side]; } } } @@ -307,7 +307,7 @@ bool AnimalRigger::rig() rawSpineNodes.push_back(SpineNode()); SpineNode &spineNode = rawSpineNodes.back(); spineNode.coord = choosenCoord; - spineNode.chainMarkIndicies = chainMarkIndicies; + spineNode.chainMarkIndices = chainMarkIndices; spineNode.position = sumOfChainPositions / countOfChains; } @@ -329,19 +329,19 @@ bool AnimalRigger::rig() spineNodes.push_back(intermediate); } } - // Move the chain mark indicies to the new generated intermediate spine + // Move the chain mark indices to the new generated intermediate spine for (size_t i = 2; i < spineNodes.size(); i += 2) { auto &spineNode = spineNodes[i]; - std::vector needMoveIndicies; - for (const auto &markIndex: spineNode.chainMarkIndicies) { + std::vector needMoveIndices; + for (const auto &markIndex: spineNode.chainMarkIndices) { const auto &chain = m_marks[markIndex]; if (chain.boneSide != SkeletonSide::None) - needMoveIndicies.push_back(markIndex); + needMoveIndices.push_back(markIndex); } auto &previousSpineNode = spineNodes[i - 1]; - for (const auto &markIndex: needMoveIndicies) { - previousSpineNode.chainMarkIndicies.insert(markIndex); - spineNode.chainMarkIndicies.erase(markIndex); + for (const auto &markIndex: needMoveIndices) { + previousSpineNode.chainMarkIndices.insert(markIndex); + spineNode.chainMarkIndices.erase(markIndex); } } @@ -438,12 +438,12 @@ bool AnimalRigger::rig() m_resultBones[boneIndexMap[namingSpine(spineGenerateOrder - 1)]].children.push_back(spineBone.index); } - for (const auto &chainMarkIndex: spineNode.chainMarkIndicies) { + for (const auto &chainMarkIndex: spineNode.chainMarkIndices) { const auto &chainMark = m_marks[chainMarkIndex]; QString chainBaseName = BoneMarkToString(chainMark.boneMark); int chainGenerateOrder = ++chainOrderMapBySide[{chainBaseName, chainMark.boneSide}]; - QString chainName = namingChainPrefix(chainBaseName, chainMark.boneSide, chainGenerateOrder, spineNode.chainMarkIndicies.size()); + QString chainName = namingChainPrefix(chainBaseName, chainMark.boneSide, chainGenerateOrder, spineNode.chainMarkIndices.size()); m_resultBones.push_back(RiggerBone()); RiggerBone &ribBone = m_resultBones.back(); @@ -458,12 +458,12 @@ bool AnimalRigger::rig() m_resultBones[boneIndexMap[namingSpine(spineGenerateOrder)]].children.push_back(ribBone.index); } - std::vector jointMarkIndicies; - if (!collectJontsForChain(chainMarkIndex, jointMarkIndicies)) { + std::vector jointMarkIndices; + if (!collectJontsForChain(chainMarkIndex, jointMarkIndices)) { m_jointErrorItems.push_back(chainName); } - //qDebug() << "Adding chain:" << chainName << " joints:" << jointMarkIndicies.size(); + //qDebug() << "Adding chain:" << chainName << " joints:" << jointMarkIndices.size(); int jointGenerateOrder = 1; @@ -475,7 +475,7 @@ bool AnimalRigger::rig() m_resultBones[boneIndexMap[namingConnector(spineName, chainName)]].tailPosition = headPosition; m_resultBones[boneIndexMap[namingConnector(spineName, chainName)]].children.push_back(boneIndex); } else { - QString parentLimbBoneName = namingChain(chainBaseName, side, chainGenerateOrder, spineNode.chainMarkIndicies.size(), jointGenerateOrder - 1); + QString parentLimbBoneName = namingChain(chainBaseName, side, chainGenerateOrder, spineNode.chainMarkIndices.size(), jointGenerateOrder - 1); m_resultBones[boneIndexMap[parentLimbBoneName]].tailPosition = headPosition; m_resultBones[boneIndexMap[parentLimbBoneName]].children.push_back(boneIndex); } @@ -486,8 +486,8 @@ bool AnimalRigger::rig() addTrianglesToVertices(chainMark.markTriangles, remainingLimbVertices); std::vector jointPositions; - for (jointGenerateOrder = 1; jointGenerateOrder <= (int)jointMarkIndicies.size(); ++jointGenerateOrder) { - int jointMarkIndex = jointMarkIndicies[jointGenerateOrder - 1]; + for (jointGenerateOrder = 1; jointGenerateOrder <= (int)jointMarkIndices.size(); ++jointGenerateOrder) { + int jointMarkIndex = jointMarkIndices[jointGenerateOrder - 1]; const auto jointMark = m_marks[jointMarkIndex]; jointPositions.push_back(jointMark.bonePosition); } @@ -510,21 +510,21 @@ bool AnimalRigger::rig() // Calculate the tail position from remaining verticies jointPositions.push_back(findExtremPointFrom(lastJointBoneVerticies, jointPositions.back())); - for (jointGenerateOrder = 1; jointGenerateOrder <= (int)jointMarkIndicies.size(); ++jointGenerateOrder) { - int jointMarkIndex = jointMarkIndicies[jointGenerateOrder - 1]; + for (jointGenerateOrder = 1; jointGenerateOrder <= (int)jointMarkIndices.size(); ++jointGenerateOrder) { + int jointMarkIndex = jointMarkIndices[jointGenerateOrder - 1]; const auto &jointMark = m_marks[jointMarkIndex]; m_resultBones.push_back(RiggerBone()); RiggerBone &jointBone = m_resultBones.back(); jointBone.index = m_resultBones.size() - 1; - jointBone.name = namingChain(chainBaseName, chainMark.boneSide, chainGenerateOrder, spineNode.chainMarkIndicies.size(), jointGenerateOrder); + jointBone.name = namingChain(chainBaseName, chainMark.boneSide, chainGenerateOrder, spineNode.chainMarkIndices.size(), jointGenerateOrder); jointBone.headPosition = jointPositions[jointGenerateOrder - 1]; jointBone.tailPosition = jointPositions[jointGenerateOrder]; jointBone.baseNormal = jointMark.baseNormal; jointBone.color = boneColor(); - if (jointGenerateOrder == (int)jointMarkIndicies.size()) { + if (jointGenerateOrder == (int)jointMarkIndices.size()) { addVerticesToWeights(remainingLimbVertices, jointBone.index); } else { - int nextJointMarkIndex = jointMarkIndicies[jointGenerateOrder]; + int nextJointMarkIndex = jointMarkIndices[jointGenerateOrder]; const auto &nextJointMark = m_marks[nextJointMarkIndex]; auto nextBoneDirection = (jointPositions[jointGenerateOrder + 1] - jointPositions[jointGenerateOrder]).normalized(); auto currentBoneDirection = (jointBone.tailPosition - jointBone.headPosition).normalized(); diff --git a/src/animalrigger.h b/src/animalrigger.h index 0a7c846e..24d1d622 100644 --- a/src/animalrigger.h +++ b/src/animalrigger.h @@ -18,7 +18,7 @@ protected: bool rig() override; BoneMark translateBoneMark(BoneMark boneMark) override; private: - bool collectJontsForChain(int markIndex, std::vector &jointMarkIndicies); + bool collectJontsForChain(int markIndex, std::vector &jointMarkIndices); static QString namingSpine(int spineOrder); static QString namingConnector(const QString &spineName, const QString &chainName); static QString namingChain(const QString &baseName, SkeletonSide side, int orderInSide, int totalInSide, int jointOrder); diff --git a/src/fbxfile.cpp b/src/fbxfile.cpp index 939ba071..3d8728fd 100644 --- a/src/fbxfile.cpp +++ b/src/fbxfile.cpp @@ -1703,11 +1703,11 @@ FbxFileWriter::FbxFileWriter(Outcome &outcome, positions.push_back((double)vertex.y()); positions.push_back((double)vertex.z()); } - std::vector indicies; + std::vector indices; for (const auto &triangle: outcome.triangles) { - indicies.push_back(triangle[0]); - indicies.push_back(triangle[1]); - indicies.push_back(triangle[2] ^ -1); + indices.push_back(triangle[0]); + indices.push_back(triangle[1]); + indices.push_back(triangle[2] ^ -1); } FBXNode layerElementNormal("LayerElementNormal"); const auto triangleVertexNormals = outcome.triangleVertexNormals(); @@ -1758,7 +1758,7 @@ FbxFileWriter::FbxFileWriter(Outcome &outcome, layer.addChild(FBXNode()); geometry.addPropertyNode("GeometryVersion", (int32_t)124); geometry.addPropertyNode("Vertices", positions); - geometry.addPropertyNode("PolygonVertexIndex", indicies); + geometry.addPropertyNode("PolygonVertexIndex", indices); if (nullptr != triangleVertexNormals) geometry.addChild(layerElementNormal); geometry.addChild(layerElementMaterial); @@ -1837,7 +1837,7 @@ FbxFileWriter::FbxFileWriter(Outcome &outcome, if (resultRigWeights && !resultRigWeights->empty()) { for (const auto &item: *resultRigWeights) { for (int i = 0; i < 4; ++i) { - const auto &boneIndex = item.second.boneIndicies[i]; + const auto &boneIndex = item.second.boneIndices[i]; Q_ASSERT(boneIndex < bindPerBone.size()); if (0 == boneIndex) break; diff --git a/src/glbfile.cpp b/src/glbfile.cpp index 1c0c352d..ec3d1a78 100644 --- a/src/glbfile.cpp +++ b/src/glbfile.cpp @@ -140,11 +140,11 @@ GlbFileWriter::GlbFileWriter(Outcome &outcome, } std::vector triangleVertexPositions; - std::vector triangleVertexOldIndicies; - for (const auto &triangleIndicies: outcome.triangles) { + std::vector triangleVertexOldIndices; + for (const auto &triangleIndices: outcome.triangles) { for (size_t j = 0; j < 3; ++j) { - triangleVertexOldIndicies.push_back(triangleIndicies[j]); - triangleVertexPositions.push_back(outcome.vertices[triangleIndicies[j]]); + triangleVertexOldIndices.push_back(triangleIndices[j]); + triangleVertexPositions.push_back(outcome.vertices[triangleIndices[j]]); } } @@ -180,7 +180,7 @@ GlbFileWriter::GlbFileWriter(Outcome &outcome, Q_ASSERT((int)triangleVertexPositions.size() * sizeof(quint16) == m_binByteArray.size() - bufferViewFromOffset); alignBin(); if (m_enableComment) - m_json["accessors"][bufferViewIndex]["__comment"] = QString("/accessors/%1: triangle indicies").arg(QString::number(bufferViewIndex)).toUtf8().constData(); + m_json["accessors"][bufferViewIndex]["__comment"] = QString("/accessors/%1: triangle indices").arg(QString::number(bufferViewIndex)).toUtf8().constData(); m_json["accessors"][bufferViewIndex]["bufferView"] = bufferViewIndex; m_json["accessors"][bufferViewIndex]["byteOffset"] = 0; m_json["accessors"][bufferViewIndex]["componentType"] = 5123; @@ -279,14 +279,14 @@ GlbFileWriter::GlbFileWriter(Outcome &outcome, m_json["bufferViews"][bufferViewIndex]["byteOffset"] = bufferViewFromOffset; QStringList boneList; int weightItIndex = 0; - for (const auto &oldIndex: triangleVertexOldIndicies) { + for (const auto &oldIndex: triangleVertexOldIndices) { auto i = 0u; if (m_enableComment) boneList.append(QString("%1:<").arg(QString::number(weightItIndex))); auto findWeight = resultRigWeights->find(oldIndex); if (findWeight != resultRigWeights->end()) { for (; i < MAX_WEIGHT_NUM; i++) { - quint16 nodeIndex = (quint16)findWeight->second.boneIndicies[i]; + quint16 nodeIndex = (quint16)findWeight->second.boneIndices[i]; binStream << (quint16)nodeIndex; if (m_enableComment) boneList.append(QString("%1").arg(nodeIndex)); @@ -304,11 +304,11 @@ GlbFileWriter::GlbFileWriter(Outcome &outcome, m_json["bufferViews"][bufferViewIndex]["byteLength"] = m_binByteArray.size() - bufferViewFromOffset; alignBin(); if (m_enableComment) - m_json["accessors"][bufferViewIndex]["__comment"] = QString("/accessors/%1: bone indicies %2").arg(QString::number(bufferViewIndex)).arg(boneList.join(" ")).toUtf8().constData(); + m_json["accessors"][bufferViewIndex]["__comment"] = QString("/accessors/%1: bone indices %2").arg(QString::number(bufferViewIndex)).arg(boneList.join(" ")).toUtf8().constData(); m_json["accessors"][bufferViewIndex]["bufferView"] = bufferViewIndex; m_json["accessors"][bufferViewIndex]["byteOffset"] = 0; m_json["accessors"][bufferViewIndex]["componentType"] = 5123; - m_json["accessors"][bufferViewIndex]["count"] = triangleVertexOldIndicies.size(); + m_json["accessors"][bufferViewIndex]["count"] = triangleVertexOldIndices.size(); m_json["accessors"][bufferViewIndex]["type"] = "VEC4"; bufferViewIndex++; @@ -317,7 +317,7 @@ GlbFileWriter::GlbFileWriter(Outcome &outcome, m_json["bufferViews"][bufferViewIndex]["byteOffset"] = bufferViewFromOffset; QStringList weightList; weightItIndex = 0; - for (const auto &oldIndex: triangleVertexOldIndicies) { + for (const auto &oldIndex: triangleVertexOldIndices) { auto i = 0u; if (m_enableComment) weightList.append(QString("%1:<").arg(QString::number(weightItIndex))); @@ -346,7 +346,7 @@ GlbFileWriter::GlbFileWriter(Outcome &outcome, m_json["accessors"][bufferViewIndex]["bufferView"] = bufferViewIndex; m_json["accessors"][bufferViewIndex]["byteOffset"] = 0; m_json["accessors"][bufferViewIndex]["componentType"] = 5126; - m_json["accessors"][bufferViewIndex]["count"] = triangleVertexOldIndicies.size(); + m_json["accessors"][bufferViewIndex]["count"] = triangleVertexOldIndices.size(); m_json["accessors"][bufferViewIndex]["type"] = "VEC4"; bufferViewIndex++; } diff --git a/src/meshgenerator.cpp b/src/meshgenerator.cpp index e610cd16..29248662 100644 --- a/src/meshgenerator.cpp +++ b/src/meshgenerator.cpp @@ -186,13 +186,13 @@ void MeshGenerator::loadGeneratedPositionsToOutcome(void *meshliteContext, int t for (int i = 0, triangleVertIndex = 0, normalIndex=0; i < triangleCount; i++, triangleVertIndex+=3, normalIndex += 3) { - std::vector triangleIndicies(3); + std::vector triangleIndices(3); QVector3D triangleNormal; - triangleIndicies[0] = verticesMap[triangleIndexBuffer[triangleVertIndex + 0]]; - triangleIndicies[1] = verticesMap[triangleIndexBuffer[triangleVertIndex + 1]]; - triangleIndicies[2] = verticesMap[triangleIndexBuffer[triangleVertIndex + 2]]; + triangleIndices[0] = verticesMap[triangleIndexBuffer[triangleVertIndex + 0]]; + triangleIndices[1] = verticesMap[triangleIndexBuffer[triangleVertIndex + 1]]; + triangleIndices[2] = verticesMap[triangleIndexBuffer[triangleVertIndex + 2]]; triangleNormal = QVector3D(normalBuffer[normalIndex + 0], normalBuffer[normalIndex + 1], normalBuffer[normalIndex + 2]); - m_outcome->triangles.push_back(triangleIndicies); + m_outcome->triangles.push_back(triangleIndices); m_outcome->triangleNormals.push_back(triangleNormal); } delete[] positionBuffer; @@ -642,14 +642,14 @@ void *MeshGenerator::combineComponentMesh(QString componentId, CombineMode *comb if (!positionsBeforeSmooth.empty()) { std::vector seamVerticesIds; - std::unordered_set seamVerticesIndicies; + std::unordered_set seamVerticesIndices; if (!positionsBeforeCombination.map().empty()) { for (size_t vertexIndex = 0; vertexIndex < positionsBeforeSmooth.size(); vertexIndex++) { const auto &oldPosition = positionsBeforeSmooth[vertexIndex]; if (!positionsBeforeCombination.findPosition(oldPosition.x(), oldPosition.y(), oldPosition.z())) { seamVerticesIds.push_back(vertexIndex + 1); - seamVerticesIndicies.insert(vertexIndex); + seamVerticesIndices.insert(vertexIndex); } } } @@ -658,7 +658,7 @@ void *MeshGenerator::combineComponentMesh(QString componentId, CombineMode *comb if (smoothSeam) { if (!seamVerticesIds.empty()) { - //qDebug() << "smoothSeamFactor:" << smoothSeamFactor << "seamVerticesIndicies.size():" << seamVerticesNum; + //qDebug() << "smoothSeamFactor:" << smoothSeamFactor << "seamVerticesIndices.size():" << seamVerticesNum; meshlite_smooth_vertices(m_meshliteContext, meshIdForSmooth, smoothSeamFactor, seamVerticesIds.data(), seamVerticesIds.size()); meshChanged = true; } diff --git a/src/meshloader.cpp b/src/meshloader.cpp index 8e5dd73e..859a64b6 100644 --- a/src/meshloader.cpp +++ b/src/meshloader.cpp @@ -145,7 +145,7 @@ MeshLoader::MeshLoader(void *meshlite, int meshId, int triangulatedMeshId, QColo assert(firstIndex + j < loadedTriangleVertexIndexItemCount); int posIndex = triangleIndices[firstIndex + j] * 3; assert(posIndex < loadedTriangleVertexPositionItemCount); - triangulatedFace.indicies[j] = triangleIndices[firstIndex + j]; + triangulatedFace.indices[j] = triangleIndices[firstIndex + j]; Vertex *v = &m_triangleVertices[firstIndex + j]; v->posX = triangleVertexPositions[posIndex + 0]; v->posY = triangleVertexPositions[posIndex + 1]; diff --git a/src/meshloader.h b/src/meshloader.h index 8eabc92f..adf250fe 100644 --- a/src/meshloader.h +++ b/src/meshloader.h @@ -35,7 +35,7 @@ typedef struct struct TriangulatedFace { - int indicies[3]; + int indices[3]; QColor color; }; diff --git a/src/meshquadify.cpp b/src/meshquadify.cpp index 143d7c98..7c7cfa54 100644 --- a/src/meshquadify.cpp +++ b/src/meshquadify.cpp @@ -24,7 +24,7 @@ int meshQuadify(void *meshlite, int meshId, const std::set> newFaceIndicies; + std::vector> newFaceIndices; while (i < filledLength) { int num = faceVertexNumAndIndices[i++]; Q_ASSERT(num > 0 && num <= MAX_VERTICES_PER_FACE); @@ -38,20 +38,20 @@ int meshQuadify(void *meshlite, int meshId, const std::set= 0 && index < vertexCount); indices.push_back(index); } - newFaceIndicies.push_back(indices); + newFaceIndices.push_back(indices); } int quadMesh = 0; std::map, std::pair> triangleEdgeMap; - for (int i = 0; i < (int)newFaceIndicies.size(); i++) { - const auto &faceIndicies = newFaceIndicies[i]; - if (faceIndicies.size() == 3) { - triangleEdgeMap[std::make_pair(faceIndicies[0], faceIndicies[1])] = std::make_pair(i, faceIndicies[2]); - triangleEdgeMap[std::make_pair(faceIndicies[1], faceIndicies[2])] = std::make_pair(i, faceIndicies[0]); - triangleEdgeMap[std::make_pair(faceIndicies[2], faceIndicies[0])] = std::make_pair(i, faceIndicies[1]); + for (int i = 0; i < (int)newFaceIndices.size(); i++) { + const auto &faceIndices = newFaceIndices[i]; + if (faceIndices.size() == 3) { + triangleEdgeMap[std::make_pair(faceIndices[0], faceIndices[1])] = std::make_pair(i, faceIndices[2]); + triangleEdgeMap[std::make_pair(faceIndices[1], faceIndices[2])] = std::make_pair(i, faceIndices[0]); + triangleEdgeMap[std::make_pair(faceIndices[2], faceIndices[0])] = std::make_pair(i, faceIndices[1]); } } std::unordered_set unionedFaces; - std::vector> newUnionedFaceIndicies; + std::vector> newUnionedFaceIndices; for (const auto &edge: triangleEdgeMap) { if (unionedFaces.find(edge.second.first) != unionedFaces.end()) continue; @@ -69,24 +69,24 @@ int meshQuadify(void *meshlite, int meshId, const std::setsecond.second); indices.push_back(edge.first.second); - newUnionedFaceIndicies.push_back(indices); + newUnionedFaceIndices.push_back(indices); } } } } std::vector newFaceVertexNumAndIndices; - for (int i = 0; i < (int)newFaceIndicies.size(); i++) { + for (int i = 0; i < (int)newFaceIndices.size(); i++) { if (unionedFaces.find(i) == unionedFaces.end()) { - const auto &faceIndicies = newFaceIndicies[i]; - newFaceVertexNumAndIndices.push_back(faceIndicies.size()); - for (const auto &index: faceIndicies) { + const auto &faceIndices = newFaceIndices[i]; + newFaceVertexNumAndIndices.push_back(faceIndices.size()); + for (const auto &index: faceIndices) { newFaceVertexNumAndIndices.push_back(index); } } } - for (const auto &faceIndicies: newUnionedFaceIndicies) { - newFaceVertexNumAndIndices.push_back(faceIndicies.size()); - for (const auto &index: faceIndicies) { + for (const auto &faceIndices: newUnionedFaceIndices) { + newFaceVertexNumAndIndices.push_back(faceIndices.size()); + for (const auto &index: faceIndices) { newFaceVertexNumAndIndices.push_back(index); } } diff --git a/src/meshsplitter.cpp b/src/meshsplitter.cpp index d4514426..0d9f43e2 100644 --- a/src/meshsplitter.cpp +++ b/src/meshsplitter.cpp @@ -17,7 +17,7 @@ bool MeshSplitter::split(const std::set &input, for (const auto &triangle: input) { for (int i = 0; i < 3; i++) { int next = (i + 1) % 3; - edgeToTriangleMap[std::make_pair(triangle.indicies[i], triangle.indicies[next])] = triangle; + edgeToTriangleMap[std::make_pair(triangle.indices[i], triangle.indices[next])] = triangle; } } @@ -27,7 +27,7 @@ bool MeshSplitter::split(const std::set &input, for (const auto &triangle: splitter) { for (int i = 0; i < 3; i++) { int next = (i + 1) % 3; - auto oppositeEdge = std::make_pair(triangle.indicies[next], triangle.indicies[i]); + auto oppositeEdge = std::make_pair(triangle.indices[next], triangle.indices[i]); auto oppositeTriangle = edgeToTriangleMap.find(oppositeEdge); if (oppositeTriangle == edgeToTriangleMap.end()) { qDebug() << "Find opposite edge failed:" << oppositeEdge.first << oppositeEdge.second; @@ -57,7 +57,7 @@ bool MeshSplitter::split(const std::set &input, for (const auto &triangle: splitter) { for (int i = 0; i < 3; i++) { int next = (i + 1) % 3; - auto oppositeEdge = std::make_pair(triangle.indicies[next], triangle.indicies[i]); + auto oppositeEdge = std::make_pair(triangle.indices[next], triangle.indices[i]); auto oppositeTriangle = edgeToTriangleMap.find(oppositeEdge); if (oppositeTriangle == edgeToTriangleMap.end()) { qDebug() << "Find opposite edge failed:" << oppositeEdge.first << oppositeEdge.second; @@ -90,7 +90,7 @@ bool MeshSplitter::split(const std::set &input, continue; for (int i = 0; i < 3; i++) { int next = (i + 1) % 3; - auto oppositeEdge = std::make_pair(triangle.indicies[next], triangle.indicies[i]); + auto oppositeEdge = std::make_pair(triangle.indices[next], triangle.indices[i]); auto oppositeTriangle = edgeToTriangleMap.find(oppositeEdge); if (oppositeTriangle == edgeToTriangleMap.end()) { qDebug() << "Find opposite edge failed:" << oppositeEdge.first << oppositeEdge.second; diff --git a/src/meshsplitter.h b/src/meshsplitter.h index 81a2791d..10e42d60 100644 --- a/src/meshsplitter.h +++ b/src/meshsplitter.h @@ -5,12 +5,12 @@ class MeshSplitterTriangle { public: - int indicies[3] = {0, 0, 0}; + int indices[3] = {0, 0, 0}; bool operator<(const MeshSplitterTriangle &other) const { - return std::make_tuple(indicies[0], indicies[1], indicies[2]) < - std::make_tuple(other.indicies[0], other.indicies[1], other.indicies[2]); + return std::make_tuple(indices[0], indices[1], indices[2]) < + std::make_tuple(other.indices[0], other.indices[1], other.indices[2]); } }; diff --git a/src/meshweldseam.cpp b/src/meshweldseam.cpp index 938224a9..d0bcb6cd 100644 --- a/src/meshweldseam.cpp +++ b/src/meshweldseam.cpp @@ -30,7 +30,7 @@ int meshWeldSeam(void *meshlite, int meshId, float allowedSmallestDistance, cons int *faceVertexNumAndIndices = new int[faceCount * MAX_VERTICES_PER_FACE]; int filledLength = meshlite_get_face_index_array(meshlite, meshId, faceVertexNumAndIndices, faceCount * MAX_VERTICES_PER_FACE); int i = 0; - std::vector> newFaceIndicies; + std::vector> newFaceIndices; while (i < filledLength) { int num = faceVertexNumAndIndices[i++]; Q_ASSERT(num > 0 && num <= MAX_VERTICES_PER_FACE); @@ -44,7 +44,7 @@ int meshWeldSeam(void *meshlite, int meshId, float allowedSmallestDistance, cons Q_ASSERT(index >= 0 && index < vertexCount); indices.push_back(index); } - newFaceIndicies.push_back(indices); + newFaceIndices.push_back(indices); } float squareOfAllowedSmallestDistance = allowedSmallestDistance * allowedSmallestDistance; int weldedMesh = 0; @@ -53,33 +53,33 @@ int meshWeldSeam(void *meshlite, int meshId, float allowedSmallestDistance, cons std::unordered_set processedFaces; std::map, std::pair> triangleEdgeMap; std::unordered_map vertexAdjFaceCountMap; - for (int i = 0; i < (int)newFaceIndicies.size(); i++) { - const auto &faceIndicies = newFaceIndicies[i]; - if (faceIndicies.size() == 3) { - vertexAdjFaceCountMap[faceIndicies[0]]++; - vertexAdjFaceCountMap[faceIndicies[1]]++; - vertexAdjFaceCountMap[faceIndicies[2]]++; - triangleEdgeMap[std::make_pair(faceIndicies[0], faceIndicies[1])] = std::make_pair(i, faceIndicies[2]); - triangleEdgeMap[std::make_pair(faceIndicies[1], faceIndicies[2])] = std::make_pair(i, faceIndicies[0]); - triangleEdgeMap[std::make_pair(faceIndicies[2], faceIndicies[0])] = std::make_pair(i, faceIndicies[1]); + for (int i = 0; i < (int)newFaceIndices.size(); i++) { + const auto &faceIndices = newFaceIndices[i]; + if (faceIndices.size() == 3) { + vertexAdjFaceCountMap[faceIndices[0]]++; + vertexAdjFaceCountMap[faceIndices[1]]++; + vertexAdjFaceCountMap[faceIndices[2]]++; + triangleEdgeMap[std::make_pair(faceIndices[0], faceIndices[1])] = std::make_pair(i, faceIndices[2]); + triangleEdgeMap[std::make_pair(faceIndices[1], faceIndices[2])] = std::make_pair(i, faceIndices[0]); + triangleEdgeMap[std::make_pair(faceIndices[2], faceIndices[0])] = std::make_pair(i, faceIndices[1]); } } - for (int i = 0; i < (int)newFaceIndicies.size(); i++) { + for (int i = 0; i < (int)newFaceIndices.size(); i++) { if (processedFaces.find(i) != processedFaces.end()) continue; - const auto &faceIndicies = newFaceIndicies[i]; - if (faceIndicies.size() == 3) { - bool indiciesSeamCheck[3] = { - excludeVertices.find(faceIndicies[0]) == excludeVertices.end(), - excludeVertices.find(faceIndicies[1]) == excludeVertices.end(), - excludeVertices.find(faceIndicies[2]) == excludeVertices.end() + const auto &faceIndices = newFaceIndices[i]; + if (faceIndices.size() == 3) { + bool indicesSeamCheck[3] = { + excludeVertices.find(faceIndices[0]) == excludeVertices.end(), + excludeVertices.find(faceIndices[1]) == excludeVertices.end(), + excludeVertices.find(faceIndices[2]) == excludeVertices.end() }; for (int j = 0; j < 3; j++) { int next = (j + 1) % 3; int nextNext = (j + 2) % 3; - if (indiciesSeamCheck[j] && indiciesSeamCheck[next]) { - std::pair edge = std::make_pair(faceIndicies[j], faceIndicies[next]); - int thirdVertexIndex = faceIndicies[nextNext]; + if (indicesSeamCheck[j] && indicesSeamCheck[next]) { + std::pair edge = std::make_pair(faceIndices[j], faceIndices[next]); + int thirdVertexIndex = faceIndices[nextNext]; if ((positions[edge.first] - positions[edge.second]).lengthSquared() < squareOfAllowedSmallestDistance) { auto oppositeEdge = std::make_pair(edge.second, edge.first); auto findOppositeFace = triangleEdgeMap.find(oppositeEdge); @@ -113,11 +113,11 @@ int meshWeldSeam(void *meshlite, int meshId, float allowedSmallestDistance, cons std::vector newFaceVertexNumAndIndices; int weldedCount = 0; int faceCountAfterWeld = 0; - for (int i = 0; i < (int)newFaceIndicies.size(); i++) { - const auto &faceIndicies = newFaceIndicies[i]; - std::vector mappedFaceIndicies; + for (int i = 0; i < (int)newFaceIndices.size(); i++) { + const auto &faceIndices = newFaceIndices[i]; + std::vector mappedFaceIndices; bool errored = false; - for (const auto &index: faceIndicies) { + for (const auto &index: faceIndices) { int finalIndex = index; int mapTimes = 0; while (mapTimes < 500) { @@ -132,14 +132,14 @@ int meshWeldSeam(void *meshlite, int meshId, float allowedSmallestDistance, cons errored = true; break; } - mappedFaceIndicies.push_back(finalIndex); + mappedFaceIndices.push_back(finalIndex); } - if (errored || mappedFaceIndicies.size() < 3) + if (errored || mappedFaceIndices.size() < 3) continue; bool welded = false; - for (decltype(mappedFaceIndicies.size()) j = 0; j < mappedFaceIndicies.size(); j++) { + for (decltype(mappedFaceIndices.size()) j = 0; j < mappedFaceIndices.size(); j++) { int next = (j + 1) % 3; - if (mappedFaceIndicies[j] == mappedFaceIndicies[next]) { + if (mappedFaceIndices[j] == mappedFaceIndices[next]) { welded = true; break; } @@ -149,14 +149,14 @@ int meshWeldSeam(void *meshlite, int meshId, float allowedSmallestDistance, cons continue; } faceCountAfterWeld++; - newFaceVertexNumAndIndices.push_back(mappedFaceIndicies.size()); - for (const auto &index: mappedFaceIndicies) { + newFaceVertexNumAndIndices.push_back(mappedFaceIndices.size()); + for (const auto &index: mappedFaceIndices) { newFaceVertexNumAndIndices.push_back(index); } } if (affectedNum) *affectedNum = weldedCount; - qDebug() << "Welded" << weldedCount << "triangles(" << newFaceIndicies.size() << " - " << weldedCount << " = " << faceCountAfterWeld << ")"; + qDebug() << "Welded" << weldedCount << "triangles(" << newFaceIndices.size() << " - " << weldedCount << " = " << faceCountAfterWeld << ")"; weldedMesh = meshlite_build(meshlite, vertexPositions, vertexCount, newFaceVertexNumAndIndices.data(), newFaceVertexNumAndIndices.size()); delete[] faceVertexNumAndIndices; delete[] vertexPositions; diff --git a/src/riggenerator.cpp b/src/riggenerator.cpp index 60176869..89cc5631 100644 --- a/src/riggenerator.cpp +++ b/src/riggenerator.cpp @@ -90,7 +90,7 @@ void RigGenerator::generate() const auto &sourceTriangle = m_outcome->triangles[triangleIndex]; MeshSplitterTriangle newTriangle; for (int i = 0; i < 3; i++) - newTriangle.indicies[i] = sourceTriangle[i]; + newTriangle.indices[i] = sourceTriangle[i]; auto findMarkedNodeResult = markedNodes.find(triangleSourceNodes[triangleIndex]); if (findMarkedNodeResult != markedNodes.end()) { auto &markedNode = findMarkedNodeResult->second; @@ -188,7 +188,7 @@ void RigGenerator::generate() const auto &weight = weightItem.second; int blendR = 0, blendG = 0, blendB = 0; for (int i = 0; i < 4; i++) { - int boneIndex = weight.boneIndicies[i]; + int boneIndex = weight.boneIndices[i]; if (boneIndex > 0) { const auto &bone = resultBones[boneIndex]; blendR += bone.color.red() * weight.boneWeights[i]; diff --git a/src/rigger.cpp b/src/rigger.cpp index 1c0475c8..e5a66d0e 100644 --- a/src/rigger.cpp +++ b/src/rigger.cpp @@ -121,7 +121,7 @@ void Rigger::addTrianglesToVertices(const std::set &triang { for (const auto &triangle: triangles) { for (int i = 0; i < 3; i++) { - vertices.insert(triangle.indicies[i]); + vertices.insert(triangle.indices[i]); } } } diff --git a/src/rigger.h b/src/rigger.h index 9cc848bb..b20faa27 100644 --- a/src/rigger.h +++ b/src/rigger.h @@ -52,7 +52,7 @@ private: float minDistance2 = std::numeric_limits::max(); for (const auto &triangle: triangles) { for (size_t i = 0; i < 3; ++i) { - float distance2 = verticesPositions[triangle.indicies[i]].lengthSquared(); + float distance2 = verticesPositions[triangle.indices[i]].lengthSquared(); if (distance2 < minDistance2) minDistance2 = distance2; } @@ -82,13 +82,13 @@ public: class RiggerVertexWeights { public: - int boneIndicies[4] = {0, 0, 0, 0}; + int boneIndices[4] = {0, 0, 0, 0}; float boneWeights[4] = {0, 0, 0, 0}; void addBone(int boneIndex, float distance) { - if (m_boneRawIndicies.find(boneIndex) != m_boneRawIndicies.end()) + if (m_boneRawIndices.find(boneIndex) != m_boneRawIndices.end()) return; - m_boneRawIndicies.insert(boneIndex); + m_boneRawIndices.insert(boneIndex); if (qFuzzyIsNull(distance)) distance = 0.0001; m_boneRawWeights.push_back(std::make_pair(boneIndex, 1.0 / distance)); @@ -107,7 +107,7 @@ public: if (totalDistance > 0) { for (size_t i = 0; i < m_boneRawWeights.size() && i < 4; i++) { const auto &item = m_boneRawWeights[i]; - boneIndicies[i] = item.first; + boneIndices[i] = item.first; boneWeights[i] = item.second / totalDistance; } } else { @@ -115,7 +115,7 @@ public: } } private: - std::set m_boneRawIndicies; + std::set m_boneRawIndices; std::vector> m_boneRawWeights; }; diff --git a/src/skinnedmeshcreator.cpp b/src/skinnedmeshcreator.cpp index 3775a06f..4be2d8fb 100644 --- a/src/skinnedmeshcreator.cpp +++ b/src/skinnedmeshcreator.cpp @@ -6,14 +6,14 @@ SkinnedMeshCreator::SkinnedMeshCreator(const Outcome &outcome, m_outcome(outcome), m_resultWeights(resultWeights) { - m_verticesOldIndicies.resize(m_outcome.triangles.size()); + m_verticesOldIndices.resize(m_outcome.triangles.size()); m_verticesBindNormals.resize(m_outcome.triangles.size()); m_verticesBindPositions.resize(m_outcome.triangles.size()); const std::vector> *triangleVertexNormals = m_outcome.triangleVertexNormals(); for (size_t triangleIndex = 0; triangleIndex < m_outcome.triangles.size(); triangleIndex++) { for (int j = 0; j < 3; j++) { int oldIndex = m_outcome.triangles[triangleIndex][j]; - m_verticesOldIndicies[triangleIndex].push_back(oldIndex); + m_verticesOldIndices[triangleIndex].push_back(oldIndex); m_verticesBindPositions[triangleIndex].push_back(m_outcome.vertices[oldIndex]); if (nullptr != triangleVertexNormals) m_verticesBindNormals[triangleIndex].push_back((*triangleVertexNormals)[triangleIndex][j]); @@ -44,15 +44,15 @@ MeshLoader *SkinnedMeshCreator::createMeshFromTransform(const std::vector 0) { - transformedPositions[i][j] += matricies[weight.boneIndicies[x]] * m_verticesBindPositions[i][j] * factor; - transformedPoseNormals[i][j] += matricies[weight.boneIndicies[x]] * m_verticesBindNormals[i][j] * factor; + transformedPositions[i][j] += matricies[weight.boneIndices[x]] * m_verticesBindPositions[i][j] * factor; + transformedPoseNormals[i][j] += matricies[weight.boneIndices[x]] * m_verticesBindNormals[i][j] * factor; } } } diff --git a/src/skinnedmeshcreator.h b/src/skinnedmeshcreator.h index a4318a24..1c62678e 100644 --- a/src/skinnedmeshcreator.h +++ b/src/skinnedmeshcreator.h @@ -17,7 +17,7 @@ public: private: Outcome m_outcome; std::map m_resultWeights; - std::vector> m_verticesOldIndicies; + std::vector> m_verticesOldIndices; std::vector> m_verticesBindPositions; std::vector> m_verticesBindNormals; std::vector m_triangleColors; diff --git a/src/uvunwrap.cpp b/src/uvunwrap.cpp index 4f64eb2f..a32577fa 100644 --- a/src/uvunwrap.cpp +++ b/src/uvunwrap.cpp @@ -28,9 +28,9 @@ void uvUnwrap(const Outcome &outcome, std::vector> &trian const auto &triangle = choosenTriangles[i]; const auto &sourceNode = triangleSourceNodes[i]; simpleuv::Face f; - f.indicies[0] = triangle[0]; - f.indicies[1] = triangle[1]; - f.indicies[2] = triangle[2]; + f.indices[0] = triangle[0]; + f.indices[1] = triangle[1]; + f.indices[2] = triangle[2]; inputMesh.faces.push_back(f); auto findPartitionResult = partIdToPartitionMap.find(sourceNode.first); if (findPartitionResult == partIdToPartitionMap.end()) { diff --git a/thirdparty/simpleuv/simpleuv/meshdatatype.h b/thirdparty/simpleuv/simpleuv/meshdatatype.h index 043d5a83..02886213 100644 --- a/thirdparty/simpleuv/simpleuv/meshdatatype.h +++ b/thirdparty/simpleuv/simpleuv/meshdatatype.h @@ -13,7 +13,7 @@ struct Vertex struct Face { - size_t indicies[3]; + size_t indices[3]; }; struct TextureCoord diff --git a/thirdparty/simpleuv/simpleuv/parametrize.cpp b/thirdparty/simpleuv/simpleuv/parametrize.cpp index b3334a8f..176f780c 100644 --- a/thirdparty/simpleuv/simpleuv/parametrize.cpp +++ b/thirdparty/simpleuv/simpleuv/parametrize.cpp @@ -31,7 +31,7 @@ bool parametrize(const std::vector &verticies, for (decltype(faces.size()) i = 0; i < faces.size(); i++) { const auto &face = faces[i]; - F.row(i) << face.indicies[0], face.indicies[1], face.indicies[2]; + F.row(i) << face.indices[0], face.indices[1], face.indices[2]; } // Compute the initial solution for ARAP (harmonic parametrization) diff --git a/thirdparty/simpleuv/simpleuv/triangulate.cpp b/thirdparty/simpleuv/simpleuv/triangulate.cpp index ebc1c641..52c38b8d 100644 --- a/thirdparty/simpleuv/simpleuv/triangulate.cpp +++ b/thirdparty/simpleuv/simpleuv/triangulate.cpp @@ -89,9 +89,9 @@ void triangulate(const std::vector &vertices, std::vector &faces, } if (isEar) { Face newFace; - newFace.indicies[0] = fillRing[i]; - newFace.indicies[1] = fillRing[j]; - newFace.indicies[2] = fillRing[k]; + newFace.indices[0] = fillRing[i]; + newFace.indices[1] = fillRing[j]; + newFace.indices[2] = fillRing[k]; faces.push_back(newFace); fillRing.erase(fillRing.begin() + j); newFaceGenerated = true; @@ -104,9 +104,9 @@ void triangulate(const std::vector &vertices, std::vector &faces, } if (fillRing.size() == 3) { Face newFace; - newFace.indicies[0] = fillRing[0]; - newFace.indicies[1] = fillRing[1]; - newFace.indicies[2] = fillRing[2]; + newFace.indices[0] = fillRing[0]; + newFace.indices[1] = fillRing[1]; + newFace.indices[2] = fillRing[2]; faces.push_back(newFace); } } diff --git a/thirdparty/simpleuv/simpleuv/uvunwrapper.cpp b/thirdparty/simpleuv/simpleuv/uvunwrapper.cpp index 421dec56..de9f35e6 100644 --- a/thirdparty/simpleuv/simpleuv/uvunwrapper.cpp +++ b/thirdparty/simpleuv/simpleuv/uvunwrapper.cpp @@ -28,7 +28,7 @@ void UvUnwrapper::buildEdgeToFaceMap(const std::vector &faces, std::map &group, std::map< const auto &face = m_mesh.faces[index]; for (size_t i = 0; i < 3; i++) { size_t j = (i + 1) % 3; - edgeToFaceMap[{face.indicies[i], face.indicies[j]}] = index; + edgeToFaceMap[{face.indices[i], face.indices[j]}] = index; } } } @@ -65,7 +65,7 @@ void UvUnwrapper::splitPartitionToIslands(const std::vector &group, std: const auto &face = m_mesh.faces[index]; for (size_t i = 0; i < 3; i++) { size_t j = (i + 1) % 3; - auto findOppositeFaceResult = edgeToFaceMap.find({face.indicies[j], face.indicies[i]}); + auto findOppositeFaceResult = edgeToFaceMap.find({face.indices[j], face.indices[i]}); if (findOppositeFaceResult == edgeToFaceMap.end()) continue; waitFaces.push(findOppositeFaceResult->second); @@ -134,10 +134,10 @@ bool UvUnwrapper::fixHolesExceptTheLongestRing(const std::vector &vertic for (const auto &face: faces) { for (size_t i = 0; i < 3; i++) { size_t j = (i + 1) % 3; - auto findOppositeFaceResult = edgeToFaceMap.find({face.indicies[j], face.indicies[i]}); + auto findOppositeFaceResult = edgeToFaceMap.find({face.indices[j], face.indices[i]}); if (findOppositeFaceResult != edgeToFaceMap.end()) continue; - holeVertexLink[face.indicies[j]].push_back(face.indicies[i]); + holeVertexLink[face.indices[j]].push_back(face.indices[i]); } } @@ -220,7 +220,7 @@ bool UvUnwrapper::fixHolesExceptTheLongestRing(const std::vector &vertic } if (holeRings.size() > 1) { - // Sort by ring length, the longer ring sit in the lower array indicies + // Sort by ring length, the longer ring sit in the lower array indices std::sort(holeRings.begin(), holeRings.end(), [](const std::pair, double> &first, const std::pair, double> &second) { return first.second > second.second; }); @@ -248,7 +248,7 @@ void UvUnwrapper::makeSeamAndCut(const std::vector &verticies, for (decltype(faces.size()) i = 0; i < faces.size(); ++i) { const auto &face = faces[i]; for (int j = 0; j < 3; ++j) { - const auto &vertex = verticies[face.indicies[j]]; + const auto &vertex = verticies[face.indices[j]]; if (firstTime || vertex.xyz[2] > maxY) { maxY = vertex.xyz[2]; firstTime = false; @@ -273,7 +273,7 @@ void UvUnwrapper::makeSeamAndCut(const std::vector &verticies, const auto &face = faces[index]; for (size_t i = 0; i < 3; i++) { size_t j = (i + 1) % 3; - auto findOppositeFaceResult = edgeToFaceMap.find({face.indicies[j], face.indicies[i]}); + auto findOppositeFaceResult = edgeToFaceMap.find({face.indices[j], face.indices[i]}); if (findOppositeFaceResult == edgeToFaceMap.end()) continue; waitFaces.push(findOppositeFaceResult->second); @@ -400,12 +400,12 @@ void UvUnwrapper::unwrapSingleIsland(const std::vector &group, bool skip const auto &globalFace = m_mesh.faces[group[i]]; Face localFace; for (size_t j = 0; j < 3; j++) { - int globalVertexIndex = globalFace.indicies[j]; + int globalVertexIndex = globalFace.indices[j]; if (globalToLocalVerticesMap.find(globalVertexIndex) == globalToLocalVerticesMap.end()) { localVertices.push_back(m_mesh.verticies[globalVertexIndex]); globalToLocalVerticesMap[globalVertexIndex] = (int)localVertices.size() - 1; } - localFace.indicies[j] = globalToLocalVerticesMap[globalVertexIndex]; + localFace.indices[j] = globalToLocalVerticesMap[globalVertexIndex]; } localFaces.push_back(localFace); localToGlobalFacesMap[localFaces.size() - 1] = group[i]; @@ -455,7 +455,7 @@ void UvUnwrapper::parametrizeSingleGroup(const std::vector &verticies, auto globalFaceIndex = localToGlobalFacesMap[i]; FaceTextureCoords faceUv; for (size_t j = 0; j < 3; j++) { - const auto &localVertexIndex = localFace.indicies[j]; + const auto &localVertexIndex = localFace.indices[j]; const auto &vertexUv = localVertexUvs[localVertexIndex]; faceUv.coords[j].uv[0] = vertexUv.uv[0]; faceUv.coords[j].uv[1] = vertexUv.uv[1];