Skip to content

Commit e6f5300

Browse files
committed
QuakeMDL: Fix disabling animation
1 parent cb3e9ae commit e6f5300

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

plugins/native/module/vtkF3DQuakeMDLImporter.cxx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ struct vtkF3DQuakeMDLImporter::vtkInternals
437437
std::vector<std::vector<double>> AnimationTimes;
438438
std::vector<std::vector<vtkSmartPointer<vtkPolyData>>> AnimationFrames;
439439

440-
vtkIdType ActiveAnimation = 0;
440+
vtkIdType ActiveAnimation = -1;
441441
};
442442

443443
//----------------------------------------------------------------------------
@@ -461,20 +461,23 @@ void vtkF3DQuakeMDLImporter::ImportActors(vtkRenderer* renderer)
461461
//----------------------------------------------------------------------------
462462
bool vtkF3DQuakeMDLImporter::UpdateAtTimeValue(double timeValue)
463463
{
464-
const std::vector<double>& times =
465-
this->Internals->AnimationTimes[this->Internals->ActiveAnimation];
464+
if (this->Internals->ActiveAnimation != -1)
465+
{
466+
const std::vector<double>& times =
467+
this->Internals->AnimationTimes[this->Internals->ActiveAnimation];
466468

467-
// Find frameIndex for the provided timeValue so that t0 <= timeValue < t1
469+
// Find frameIndex for the provided timeValue so that t0 <= timeValue < t1
468470

469-
// First time >= value
470-
const auto found = std::lower_bound(times.begin(), times.end(), timeValue);
471-
// If none, select last, if found, select distance
472-
const size_t i = found == times.end() ? times.size() - 1 : std::distance(times.begin(), found);
473-
// If found time > timeValue, the the previous one
474-
const size_t frameIndex = *found > timeValue && i > 0 ? i - 1 : i;
471+
// First time >= value
472+
const auto found = std::lower_bound(times.begin(), times.end(), timeValue);
473+
// If none, select last, if found, select distance
474+
const size_t i = found == times.end() ? times.size() - 1 : std::distance(times.begin(), found);
475+
// If found time > timeValue, the the previous one
476+
const size_t frameIndex = *found > timeValue && i > 0 ? i - 1 : i;
475477

476-
this->Internals->Mapper->SetInputData(
477-
this->Internals->AnimationFrames[this->Internals->ActiveAnimation][frameIndex]);
478+
this->Internals->Mapper->SetInputData(
479+
this->Internals->AnimationFrames[this->Internals->ActiveAnimation][frameIndex]);
480+
}
478481
return true;
479482
}
480483

0 commit comments

Comments
 (0)