Skip to content

Commit

Permalink
update remove logic, cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Nov 14, 2023
1 parent 00dba93 commit 1e2bcdd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
25 changes: 15 additions & 10 deletions bullet-featherstone/src/Base.hh
Original file line number Diff line number Diff line change
Expand Up @@ -405,17 +405,22 @@ class Base : public Implements3d<FeatureList<Feature>>
model->nestedModelEntityIds.clear();

// remove references in parent model or world model
auto *parentModel = this->ReferenceInterface<ModelInfo>(_parentID);
auto nestedModelIt =
parentModel->nestedModelNameToEntityId.find(model->name);
if (nestedModelIt != parentModel->nestedModelNameToEntityId.end())
auto parentModelIt = this->models.find(_parentID);
if (parentModelIt != this->models.end())
{
std::size_t nestedModelID = nestedModelIt->second;
parentModel->nestedModelNameToEntityId.erase(nestedModelIt);
parentModel->nestedModelEntityIds.erase(std::remove(
parentModel->nestedModelEntityIds.begin(),
parentModel->nestedModelEntityIds.end(), nestedModelID),
parentModel->nestedModelEntityIds.end());
auto parentModel = parentModelIt->second;
auto nestedModelIt =
parentModel->nestedModelNameToEntityId.find(model->name);
if (nestedModelIt !=
parentModel->nestedModelNameToEntityId.end())
{
std::size_t nestedModelID = nestedModelIt->second;
parentModel->nestedModelNameToEntityId.erase(nestedModelIt);
parentModel->nestedModelEntityIds.erase(std::remove(
parentModel->nestedModelEntityIds.begin(),
parentModel->nestedModelEntityIds.end(), nestedModelID),
parentModel->nestedModelEntityIds.end());
}
}

// If nested, we are done here. No need to remove multibody
Expand Down
4 changes: 0 additions & 4 deletions bullet-featherstone/src/EntityManagementFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,6 @@ bool EntityManagementFeatures::RemoveModel(const Identity &_modelID)
bool EntityManagementFeatures::ModelRemoved(
const Identity &_modelID) const
{
// auto *model = this->ReferenceInterface<ModelInfo>(_modelID);
// auto *world = this->ReferenceInterface<WorldInfo>(model->world);
// return world->modelIndexToEntityId.count(model->indexInWorld) == 0;

return this->models.find(_modelID) == this->models.end();
}

Expand Down

0 comments on commit 1e2bcdd

Please sign in to comment.