diff --git a/src/libopenrave/kinbody.cpp b/src/libopenrave/kinbody.cpp index bc7507c800..f9fb754e73 100644 --- a/src/libopenrave/kinbody.cpp +++ b/src/libopenrave/kinbody.cpp @@ -2160,28 +2160,26 @@ void KinBody::SetDOFValues(const dReal* pJointValues, int dof, uint32_t checklim int expecteddof = dofindices.size() > 0 ? (int)dofindices.size() : GetDOF(); OPENRAVE_ASSERT_OP_FORMAT((int)dof,>=,expecteddof, "env=%s, not enough values %d<%d", GetEnv()->GetNameId()%dof%GetDOF(),ORE_InvalidArguments); - if(checklimits == CLA_Nothing && dofindices.empty()) { - _vTempJoints.assign(pJointValues, pJointValues + dof); - } - else { - GetDOFValues(_vTempJoints); - if( dofindices.size() > 0 ) { - // user only set a certain number of indices, so have to fill the temporary array with the full set of values first - // and then overwrite with the user set values - for(size_t i = 0; i < dofindices.size(); ++i) { - if( !std::isnan(pJointValues[i]) ) { - _vTempJoints.at(dofindices[i]) = pJointValues[i]; - } + GetDOFValues(_vTempJoints); + if( dofindices.size() > 0 ) { + // user only set a certain number of indices, so have to fill the temporary array with the full set of values first + // and then overwrite with the user set values + for(size_t i = 0; i < dofindices.size(); ++i) { + if( !std::isnan(pJointValues[i]) ) { + _vTempJoints.at(dofindices[i]) = pJointValues[i]; } } - else { - for(size_t i = 0; i < _vTempJoints.size(); ++i) { - if( !std::isnan(pJointValues[i]) ) { - _vTempJoints[i] = pJointValues[i]; - } + } + else { + for(size_t i = 0; i < _vTempJoints.size(); ++i) { + if( !std::isnan(pJointValues[i]) ) { + _vTempJoints[i] = pJointValues[i]; } } - pJointValues = &_vTempJoints[0]; + } + pJointValues = &_vTempJoints[0]; + + if( checklimits != CLA_Nothing ) { dReal* ptempjoints = &_vTempJoints[0]; // check the limits @@ -2189,13 +2187,6 @@ void KinBody::SetDOFValues(const dReal* pJointValues, int dof, uint32_t checklim const Joint& joint = *pjoint; const dReal* p = pJointValues+joint.GetDOFIndex(); - if( checklimits == CLA_Nothing ) { - // limits should not be checked, so just copy - for(int i = 0; i < joint.GetDOF(); ++i) { - *ptempjoints++ = p[i]; - } - continue; - } if( joint.GetType() == JointSpherical ) { dReal fcurang = fmod(RaveSqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]),2*PI); dReal lowerlimit = joint.GetLowerLimit(0);