@@ -166,8 +166,6 @@ void SimulationFeatures::Write(ChangedWorldPoses &_changedPoses) const
166166 _changedPoses.entries .clear ();
167167 _changedPoses.entries .reserve (this ->links .size ());
168168
169- std::unordered_map<std::size_t , math::Pose3d> newPoses;
170-
171169 for (const auto &[id, info] : this ->links .idToObject )
172170 {
173171 // make sure the link exists
@@ -180,23 +178,15 @@ void SimulationFeatures::Write(ChangedWorldPoses &_changedPoses) const
180178
181179 // If the link's pose is new or has changed, save this new pose and
182180 // add it to the output poses. Otherwise, keep the existing link pose
183- auto iter = this ->prevLinkPoses .find (id);
184- if ((iter == this ->prevLinkPoses .end ()) ||
185- !iter->second .Pos ().Equal (wp.pose .Pos (), 1e-6 ) ||
186- !iter->second .Rot ().Equal (wp.pose .Rot (), 1e-6 ))
181+ if (!info->prevPose .has_value () ||
182+ !info->prevPose ->Pos ().Equal (wp.pose .Pos (), 1e-6 ) ||
183+ !info->prevPose ->Rot ().Equal (wp.pose .Rot (), 1e-6 ))
187184 {
188185 _changedPoses.entries .push_back (wp);
189- newPoses[id] = wp.pose ;
186+ info-> prevPose = wp.pose ;
190187 }
191- else
192- newPoses[id] = iter->second ;
193188 }
194189 }
195-
196- // Save the new poses so that they can be used to check for updates in the
197- // next iteration. Re-setting this->prevLinkPoses with the contents of
198- // newPoses ensures that we aren't caching data for links that were removed
199- this ->prevLinkPoses = std::move (newPoses);
200190}
201191
202192SimulationFeatures::RayIntersection
0 commit comments