@@ -742,9 +742,10 @@ namespace pinocchio
742742 if (current1_id > current2_id)
743743 {
744744 const JointModel & joint1 = model.joints [current1_id];
745+ const int j1nv = joint1.nv ();
745746 joint1_span_indexes.push_back ((Eigen::DenseIndex)current1_id);
746747 Eigen::DenseIndex current1_col_id = joint1.idx_v ();
747- for (int k = 0 ; k < joint1. nv () ; ++k, ++current1_col_id)
748+ for (int k = 0 ; k < j1nv ; ++k, ++current1_col_id)
748749 {
749750 colwise_joint1_sparsity[current1_col_id] = true ;
750751 }
@@ -753,9 +754,10 @@ namespace pinocchio
753754 else
754755 {
755756 const JointModel & joint2 = model.joints [current2_id];
757+ const int j2nv = joint2.nv ();
756758 joint2_span_indexes.push_back ((Eigen::DenseIndex)current2_id);
757759 Eigen::DenseIndex current2_col_id = joint2.idx_v ();
758- for (int k = 0 ; k < joint2. nv () ; ++k, ++current2_col_id)
760+ for (int k = 0 ; k < j2nv ; ++k, ++current2_col_id)
759761 {
760762 colwise_joint2_sparsity[current2_col_id] = true ;
761763 }
@@ -770,10 +772,11 @@ namespace pinocchio
770772 while (current_id > 0 )
771773 {
772774 const JointModel & joint = model.joints [current_id];
775+ const int jnv = joint.nv ();
773776 joint1_span_indexes.push_back ((Eigen::DenseIndex)current_id);
774777 joint2_span_indexes.push_back ((Eigen::DenseIndex)current_id);
775778 Eigen::DenseIndex current_row_id = joint.idx_v ();
776- for (int k = 0 ; k < joint. nv () ; ++k, ++current_row_id)
779+ for (int k = 0 ; k < jnv ; ++k, ++current_row_id)
777780 {
778781 colwise_joint1_sparsity[current_row_id] = true ;
779782 colwise_joint2_sparsity[current_row_id] = true ;
0 commit comments