@@ -42,6 +42,7 @@ SkinningMapping<TIn, TOut>::SkinningMapping ()
4242 , d_index (initData (&d_index, " indices" , " parent indices for each child." ) )
4343 , d_weight (initData (&d_weight, " weight" , " influence weights of the Dofs." ) )
4444 , d_showFromIndex (initData (&d_showFromIndex, ( unsigned int ) 0 , " showFromIndex" , " Displayed From Index." ) )
45+ , d_computeWeightsFromPosition (initData (&d_computeWeightsFromPosition, false , " computeWeightsFromPosition" , " By default, the weights are computed w.r.t the rest positions of the input model. Set to true to compute them from the position instead." ) )
4546 , d_showWeights (initData (&d_showWeights, false , " showWeights" , " Show influence." ) )
4647{
4748 type::vector<unsigned int > defaultNbRef;
@@ -86,7 +87,7 @@ void SkinningMapping<TIn, TOut>::reinit()
8687
8788 sofa::helper::ReadAccessor<Data<OutVecCoord> > out (*this ->toModel ->read (core::vec_id::read_access::position));
8889 sofa::helper::ReadAccessor<Data<OutVecCoord> > xto (this ->d_initPos );
89- sofa::helper::ReadAccessor<Data<InVecCoord> > xfrom = *this ->fromModel ->read (core::vec_id::read_access::restPosition);
90+ sofa::helper::ReadAccessor<Data<InVecCoord> > xfrom = *this ->fromModel ->read (d_computeWeightsFromPosition. getValue ()? core::vec_id::read_access::position : core::vec_id::read_access::restPosition);
9091 sofa::helper::WriteAccessor<Data<type::vector<sofa::type::SVector<InReal> > > > m_weights (d_weight );
9192 const sofa::helper::ReadAccessor<Data<type::vector<sofa::type::SVector<unsigned int > > > > index ( this ->d_index );
9293
@@ -133,7 +134,8 @@ void SkinningMapping<TIn, TOut>::updateWeights ()
133134 msg_info () << " UPDATE WEIGHTS" ;
134135
135136 sofa::helper::ReadAccessor<Data<OutVecCoord> > xto (this ->d_initPos );
136- sofa::helper::ReadAccessor<Data<InVecCoord> > xfrom = *this ->fromModel ->read (core::vec_id::read_access::restPosition);
137+ sofa::helper::ReadAccessor<Data<InVecCoord> > xfrom = *this ->fromModel ->read (d_computeWeightsFromPosition.getValue ()? core::vec_id::read_access::position : core::vec_id::read_access::restPosition);
138+
137139 sofa::helper::WriteAccessor<Data<type::vector<sofa::type::SVector<InReal> > > > m_weights (d_weight );
138140 sofa::helper::WriteAccessor<Data<type::vector<sofa::type::SVector<unsigned int > > > > index (d_index );
139141
0 commit comments