MCPcopy Create free account
hub / github.com/Kitware/VTK / LoadSkinMatrixData

Method LoadSkinMatrixData

IO/Geometry/vtkGLTFDocumentLoader.cxx:957–1003  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

955
956//------------------------------------------------------------------------------
957bool vtkGLTFDocumentLoader::LoadSkinMatrixData()
958{
959 if (!this->LoadSkinMatrix)
960 {
961 // Skip loading the skin bind matrices
962 return true;
963 }
964 AccessorLoadingWorker worker;
965 worker.Accessors = &(this->InternalModel->Accessors);
966 worker.BufferViews = &(this->InternalModel->BufferViews);
967 worker.Buffers = &(this->InternalModel->Buffers);
968
969 using AttributeArrayTypes = vtkTypeList::Create<vtkFloatArray, vtkIntArray>;
970
971 for (Skin& skin : this->InternalModel->Skins)
972 {
973 if (skin.InverseBindMatricesAccessorId < 0)
974 {
975 // Default is an identity matrix
976 vtkNew<vtkMatrix4x4> id;
977 id->Identity();
978 skin.InverseBindMatrices.emplace_back(id);
979 continue;
980 }
981 vtkNew<vtkFloatArray> matrixValues;
982 worker.Setup(skin.InverseBindMatricesAccessorId, AccessorType::MAT4);
983 vtkArrayDispatch::DispatchByArray<AttributeArrayTypes>::Execute(matrixValues, worker);
984
985 size_t totalNumberOfComponents =
986 skin.Joints.size() * vtkGLTFDocumentLoader::GetNumberOfComponentsForType(AccessorType::MAT4);
987 if (!worker.Result ||
988 static_cast<size_t>(matrixValues->GetNumberOfValues()) != totalNumberOfComponents)
989 {
990 vtkErrorMacro("Error loading skin.invertBindMatrices data");
991 return false;
992 }
993
994 for (unsigned int matrixId = 0; matrixId < skin.Joints.size(); matrixId++)
995 {
996 vtkNew<vtkMatrix4x4> matrix;
997 matrix->DeepCopy(matrixValues->GetTuple(matrixId));
998 matrix->Transpose();
999 skin.InverseBindMatrices.emplace_back(matrix);
1000 }
1001 }
1002 return true;
1003}
1004
1005//------------------------------------------------------------------------------
1006bool vtkGLTFDocumentLoader::LoadModelData(const std::vector<char>& glbBuffer)

Callers 1

LoadModelDataMethod · 0.95

Calls 9

SetupMethod · 0.80
ExecuteFunction · 0.50
IdentityMethod · 0.45
emplace_backMethod · 0.45
sizeMethod · 0.45
GetNumberOfValuesMethod · 0.45
DeepCopyMethod · 0.45
GetTupleMethod · 0.45
TransposeMethod · 0.45

Tested by

no test coverage detected