@@ -169,8 +169,6 @@ void SimulationFeatures::Write(ChangedWorldPoses &_changedPoses) const
169169 _changedPoses.entries .clear ();
170170 _changedPoses.entries .reserve (this ->links .size ());
171171
172- std::unordered_map<std::size_t , math::Pose3d> newPoses;
173-
174172 for (const auto &[id, info] : this ->links .idToObject )
175173 {
176174 // make sure the link exists
@@ -183,23 +181,15 @@ void SimulationFeatures::Write(ChangedWorldPoses &_changedPoses) const
183181
184182 // If the link's pose is new or has changed, save this new pose and
185183 // add it to the output poses. Otherwise, keep the existing link pose
186- auto iter = this ->prevLinkPoses .find (id);
187- if ((iter == this ->prevLinkPoses .end ()) ||
188- !iter->second .Pos ().Equal (wp.pose .Pos (), 1e-6 ) ||
189- !iter->second .Rot ().Equal (wp.pose .Rot (), 1e-6 ))
184+ if (!info->prevPose .has_value () ||
185+ !info->prevPose ->Pos ().Equal (wp.pose .Pos (), 1e-6 ) ||
186+ !info->prevPose ->Rot ().Equal (wp.pose .Rot (), 1e-6 ))
190187 {
191188 _changedPoses.entries .push_back (wp);
192- newPoses[id] = wp.pose ;
189+ info-> prevPose = wp.pose ;
193190 }
194- else
195- newPoses[id] = iter->second ;
196191 }
197192 }
198-
199- // Save the new poses so that they can be used to check for updates in the
200- // next iteration. Re-setting this->prevLinkPoses with the contents of
201- // newPoses ensures that we aren't caching data for links that were removed
202- this ->prevLinkPoses = std::move (newPoses);
203193}
204194
205195SimulationFeatures::RayIntersectionInternal
0 commit comments