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

Method LoadAnimationData

IO/Geometry/vtkGLTFDocumentLoader.cxx:751–833  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

749
750//------------------------------------------------------------------------------
751bool vtkGLTFDocumentLoader::LoadAnimationData()
752{
753 if (!this->LoadAnimation)
754 {
755 // Skip loading animation key frames
756 return true;
757 }
758 AccessorLoadingWorker worker;
759 worker.Accessors = &(this->InternalModel->Accessors);
760 worker.BufferViews = &(this->InternalModel->BufferViews);
761 worker.Buffers = &(this->InternalModel->Buffers);
762
763 using AttributeArrayTypes = vtkTypeList::Create<vtkFloatArray>;
764
765 for (Animation& animation : this->InternalModel->Animations)
766 {
767 float maxDuration = 0;
768 std::set<float> allTimestamps;
769 for (Animation::Sampler& sampler : animation.Samplers)
770 {
771 // Create arrays
772 sampler.InputData = vtkSmartPointer<vtkFloatArray>::New();
773 sampler.OutputData = vtkSmartPointer<vtkFloatArray>::New();
774
775 // Load inputs (time stamps)
776 worker.Setup(sampler.Input, AccessorType::SCALAR);
777 vtkArrayDispatch::DispatchByArray<AttributeArrayTypes>::Execute(sampler.InputData, worker);
778 if (!worker.Result)
779 {
780 vtkErrorMacro(
781 "Error loading animation.sampler.input buffer data for animation " << animation.Name);
782 return false;
783 }
784 // Get max duration
785 float duration = sampler.InputData->GetValueRange()[1];
786 maxDuration = vtkMath::Max(maxDuration, duration);
787
788 // fill allTimestamps
789 for (vtkIdType i = 0; i < sampler.InputData->GetNumberOfValues(); i++)
790 {
791 allTimestamps.emplace(sampler.InputData->GetValue(i));
792 }
793
794 // Load outputs (frame data)
795 worker.Setup(sampler.Output, this->InternalModel->Accessors[sampler.Output].Type);
796 vtkArrayDispatch::DispatchByArray<AttributeArrayTypes>::Execute(sampler.OutputData, worker);
797 if (!worker.Result)
798 {
799 vtkErrorMacro(
800 "Error loading animation.sampler.output buffer data for animation " << animation.Name);
801 return false;
802 }
803
804 // Get actual tuple size when loading morphing weights
805 unsigned int numberOfComponents = sampler.OutputData->GetNumberOfComponents();
806 // If we're loading T/R/S, tuple size is already set (to 3 or 4) in outputdata.
807 if (numberOfComponents ==
808 vtkGLTFDocumentLoader::GetNumberOfComponentsForType(AccessorType::SCALAR))

Callers 1

LoadModelDataMethod · 0.95

Calls 9

SetupMethod · 0.80
NewFunction · 0.50
ExecuteFunction · 0.50
MaxFunction · 0.50
GetNumberOfValuesMethod · 0.45
emplaceMethod · 0.45
GetValueMethod · 0.45
GetNumberOfComponentsMethod · 0.45
SetNumberOfComponentsMethod · 0.45

Tested by

no test coverage detected