Skip to content

Commit

Permalink
Simplify iterators syntax, add missing delete
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
  • Loading branch information
Blast545 committed Mar 11, 2021
1 parent ab71031 commit 607b609
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions bullet/src/EntityManagementFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ bool EntityManagementFeatures::RemoveModel(const Identity &_modelID)

// Clean up joints, this section considers both links in the joint
// are part of the same world
std::unordered_map<std::size_t, JointInfoPtr>::iterator joint_it =
this->joints.begin();
auto joint_it = this->joints.begin();
while (joint_it != this->joints.end())
{
const auto &jointInfo = joint_it->second;
Expand All @@ -79,8 +78,7 @@ bool EntityManagementFeatures::RemoveModel(const Identity &_modelID)
}

// Clean up collisions
std::unordered_map<std::size_t, CollisionInfoPtr>::iterator collision_it =
this->collisions.begin();
auto collision_it = this->collisions.begin();
while (collision_it != this->collisions.end())
{
const auto &collisionInfo = collision_it->second;
Expand All @@ -94,8 +92,7 @@ bool EntityManagementFeatures::RemoveModel(const Identity &_modelID)
}

// Clean up links
std::unordered_map<std::size_t, LinkInfoPtr>::iterator it =
this->links.begin();
auto it = this->links.begin();
while (it != this->links.end())
{
const auto &linkInfo = it->second;
Expand Down Expand Up @@ -137,8 +134,7 @@ bool EntityManagementFeatures::RemoveModelByIndex(

// Clean up joints, this section considers both links in the joint
// are part of the same world
std::unordered_map<std::size_t, JointInfoPtr>::iterator joint_it =
this->joints.begin();
auto joint_it = this->joints.begin();
while (joint_it != this->joints.end())
{
const auto &jointInfo = joint_it->second;
Expand All @@ -155,8 +151,7 @@ bool EntityManagementFeatures::RemoveModelByIndex(
}

// Clean up collisions
std::unordered_map<std::size_t, CollisionInfoPtr>::iterator collision_it =
this->collisions.begin();
auto collision_it = this->collisions.begin();
while (collision_it != this->collisions.end())
{
const auto &collisionInfo = collision_it->second;
Expand All @@ -170,15 +165,15 @@ bool EntityManagementFeatures::RemoveModelByIndex(
}

// Clean up links
std::unordered_map<std::size_t, LinkInfoPtr>::iterator it =
this->links.begin();
auto it = this->links.begin();
while (it != this->links.end())
{
const auto &linkInfo = it->second;

if (linkInfo->model.id == _modelIndex)
{
bulletWorld->removeRigidBody(linkInfo->link);
delete linkInfo->link;
it = this->links.erase(it);
continue;
}
Expand Down

0 comments on commit 607b609

Please sign in to comment.