Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions Sofa/GUI/Common/src/sofa/gui/common/BaseViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,7 @@ bool BaseViewer::load()

if (groot)
{
groot->get(currentCamera, core::objectmodel::BaseContext::SearchDown);
if (!currentCamera)
{
currentCamera = sofa::core::objectmodel::New<sofa::component::visual::InteractiveCamera>();
currentCamera->setName(groot->getNameHelper().resolveName(currentCamera->getClassName(), sofa::core::ComponentNameHelper::Convention::python));
groot->addObject(currentCamera);
currentCamera->bwdInit();
msg_info("BaseViewer") << "There is no camera in this scene, I created one. To remove this error message, add a camera in your scene.";
}
addCameraIfRequired();
sofa::component::visual::VisualStyle::SPtr visualStyle = nullptr;
groot->get(visualStyle);
if (!visualStyle)
Expand All @@ -304,6 +296,19 @@ bool BaseViewer::load()

return false;
}
void BaseViewer::addCameraIfRequired()
{
groot->get(currentCamera, core::objectmodel::BaseContext::SearchDown);
if (!currentCamera)
{
currentCamera = sofa::core::objectmodel::New<sofa::component::visual::InteractiveCamera>();
currentCamera->setName(groot->getNameHelper().resolveName(currentCamera->getClassName(), sofa::core::ComponentNameHelper::Convention::python));
groot->addObject(currentCamera);
currentCamera->bwdInit();
msg_info("BaseViewer") << "There is no camera in this scene, I created one. To remove this error message, add a camera in your scene.";
}

}

bool BaseViewer::unload()
{
Expand Down
1 change: 1 addition & 0 deletions Sofa/GUI/Common/src/sofa/gui/common/BaseViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class SOFA_GUI_COMMON_API BaseViewer
virtual void setSceneFileName(const std::string &f);
virtual void setScene(sofa::simulation::Node::SPtr scene, const char* filename = nullptr, bool /*keepParams*/= false);
virtual void setCameraMode(core::visual::VisualParams::CameraType);
void addCameraIfRequired();

/// true when the viewer keep the hand on the render
/// false when it's not in activity
Expand Down
Loading