Skip to content

Commit

Permalink
Propagate bone's ResetPoseToRest
Browse files Browse the repository at this point in the history
This helps for intialization and if the users wants to reset
the pose mode.

See Issue 13676
  • Loading branch information
vovythevov committed Nov 9, 2012
1 parent ea2efa2 commit d4f7217
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Libs/VTK/Widgets/vtkArmatureWidget.cxx
Expand Up @@ -178,6 +178,7 @@ vtkArmatureWidget::vtkArmatureWidget()
this->WidgetState = vtkArmatureWidget::Rest;
this->ShowAxes = vtkBoneWidget::Hidden;
this->ShowParenthood = true;
this->ShouldResetPoseToRest = true;
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -384,8 +385,14 @@ void vtkArmatureWidget::SetWidgetState(int state)
for (NodeIteratorType it = this->Bones->begin();
it != this->Bones->end(); ++it)
{
if (this->ShouldResetPoseToRest)
{
(*it)->Bone->ResetPoseToRest();
}
(*it)->Bone->SetWidgetStateToPose();
}

this->ShouldResetPoseToRest = false;
break;
}
default:
Expand Down Expand Up @@ -632,6 +639,11 @@ ::UpdateBoneWithArmatureOptions(vtkBoneWidget* bone, vtkBoneWidget* parent)
bone->SetShowAxes(this->ShowAxes);
bone->SetShowParenthood(this->ShowParenthood);

if (this->ShouldResetPoseToRest)
{
bone->ResetPoseToRest();
}

if (this->WidgetState == vtkArmatureWidget::Rest)
{
this->SetBoneWorldToParentRestTransform(bone, parent);
Expand Down Expand Up @@ -675,6 +687,18 @@ ::ReparentBone(vtkBoneWidget* bone, vtkBoneWidget* newParent)
}
}

//----------------------------------------------------------------------------
void vtkArmatureWidget::ResetPoseToRest()
{
int oldState = this->WidgetState;
this->ShouldResetPoseToRest = true;
this->SetWidgetState(vtkArmatureWidget::Pose);
if(oldState == vtkArmatureWidget::Rest)
{
this->SetWidgetState(vtkArmatureWidget::Rest);
}
}

//----------------------------------------------------------------------------
void vtkArmatureWidget
::SetBoneWorldToParentTransform(vtkBoneWidget* bone, vtkBoneWidget* parent)
Expand Down
6 changes: 6 additions & 0 deletions Libs/VTK/Widgets/vtkArmatureWidget.h
Expand Up @@ -238,6 +238,11 @@ class VTK_BENDER_WIDGETS_EXPORT vtkArmatureWidget : public vtkAbstractWidget
// Sa AddBone(), RemoveBone, ArmatureEventType
void ReparentBone(vtkBoneWidget* bone, vtkBoneWidget* newParent);

// Description:
// Reset the pose positions to the initial rest position with no rotations
// or translations.
void ResetPoseToRest();

protected:
vtkArmatureWidget();
~vtkArmatureWidget();
Expand All @@ -261,6 +266,7 @@ class VTK_BENDER_WIDGETS_EXPORT vtkArmatureWidget : public vtkAbstractWidget
int WidgetState;
int ShowAxes;
int ShowParenthood;
bool ShouldResetPoseToRest;

// Add/Remove all the necessaries observers to a bone
void AddBoneObservers(vtkBoneWidget* bone);
Expand Down

0 comments on commit d4f7217

Please sign in to comment.