Skip to content

Commit

Permalink
[SofaKernel] Removing double load() in Loaders (sofa-framework#2094)
Browse files Browse the repository at this point in the history
* [SofaKernel] Minor clean in MeshLoader

* Update MeshLoader.cpp

* Fix behavior of StringMeshCreator

Co-authored-by: Frederick Roy <fred.roy.me@gmail.com>
  • Loading branch information
hugtalbot and fredroy committed Jun 11, 2021
1 parent 86d67ef commit fb1e8c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,8 @@ void MeshLoader::parse(sofa::core::objectmodel::BaseObjectDescription* arg)
d_scale.setValue(d_scale.getValue()*s);
}

bool success = false;
if (canLoad())
success = load(/*m_filename.getFullPath().c_str()*/);

// File not loaded, component is set to invalid
if (!success)
if (!canLoad())
d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ int StringMeshCreatorClass = core::RegisterObject("Procedural creation of a one-
StringMeshCreator::StringMeshCreator(): MeshLoader()
, resolution( initData(&resolution,(unsigned)2,"resolution","Number of vertices"))
{
addUpdateCallback("updateResolution", {&resolution}, [this](const core::DataTracker& )
{
if(load())
{
return sofa::core::objectmodel::ComponentState::Valid;
}

return sofa::core::objectmodel::ComponentState::Invalid;

}, {&d_positions, &d_edges});
}

void StringMeshCreator::doClearBuffers()
Expand Down

0 comments on commit fb1e8c5

Please sign in to comment.