Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when wide angle camera FOV is > 180 #1016

Merged
merged 1 commit into from
Jul 22, 2024
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
6 changes: 5 additions & 1 deletion ogre/src/OgreWideAngleCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,11 @@ void OgreWideAngleCamera::CreateWideAngleTexture()

double vfov = 2.0 * atan(tan(this->HFOV().Radian() / 2.0) / ratio);
this->dataPtr->ogreCamera->setAspectRatio(ratio);
this->dataPtr->ogreCamera->setFOVy(Ogre::Radian(vfov));
// Setting the fov is likely not necessary for the ogreCamera but
// clamp to max fov supported by ogre to avoid issues with building the
// frustum
this->dataPtr->ogreCamera->setFOVy(Ogre::Radian(
Ogre::Real(std::clamp(vfov, 0.0, GZ_PI))));

// create the env cameras and textures
this->CreateEnvCameras();
Expand Down
7 changes: 6 additions & 1 deletion ogre2/src/Ogre2WideAngleCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,12 @@ void Ogre2WideAngleCamera::PrepareForFinalPass(Ogre::Pass *_pass)
const double ratio = static_cast<double>(this->ImageWidth()) /
static_cast<double>(this->ImageHeight());
const double vfov = 2.0 * atan(tan(this->HFOV().Radian() / 2.0) / ratio);
this->dataPtr->ogreCamera->setFOVy(Ogre::Radian(Ogre::Real(vfov)));

// Setting the fov is likely not necessary in the final pass but
// clamp to max fov supported by ogre to avoid issues with building the
// frustum
this->dataPtr->ogreCamera->setFOVy(Ogre::Radian(
Ogre::Real(std::clamp(vfov, 0.0, GZ_PI))));

const float localHfov = static_cast<float>(this->HFOV().Radian());

Expand Down
Loading