Skip to content

Commit

Permalink
Fix macOS Ogre 1.x tests (#409)
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 authored Sep 16, 2021
1 parent 1567c35 commit 4bff736
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
10 changes: 8 additions & 2 deletions ogre/src/OgreGpuRays.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ class ignition::rendering::OgreGpuRaysPrivate

/// \brief Number of cameras needed to generate the rays.
public: unsigned int cameraCount = 1;

/// \brief Min allowed angle in radians;
public: const math::Angle kMinAllowedAngle = 1e-4;
};

using namespace ignition;
Expand Down Expand Up @@ -245,7 +248,9 @@ void OgreGpuRays::CreateCamera()
void OgreGpuRays::ConfigureCameras()
{
// horizontal gpu rays setup
this->SetHFOV(this->AngleMax() - this->AngleMin());
auto hfovAngle = this->AngleMax() - this->AngleMin();
hfovAngle = std::max(this->dataPtr->kMinAllowedAngle, hfovAngle);
this->SetHFOV(hfovAngle);

if (this->HFOV().Radian() > 2.0 * IGN_PI)
{
Expand Down Expand Up @@ -288,7 +293,8 @@ void OgreGpuRays::ConfigureCameras()

if (this->VerticalRangeCount() > 1)
{
vfovAngle = (this->VerticalAngleMax() - this->VerticalAngleMin()).Radian();
vfovAngle = std::max(this->dataPtr->kMinAllowedAngle.Radian(),
(this->VerticalAngleMax() - this->VerticalAngleMin()).Radian());
}
else
{
Expand Down
7 changes: 5 additions & 2 deletions ogre/src/OgreMesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,11 @@ Ogre::SubEntity *OgreSubMesh::OgreSubEntity() const
//////////////////////////////////////////////////
void OgreSubMesh::Destroy()
{
Ogre::MaterialManager::getSingleton().remove(
this->ogreSubEntity->getMaterialName());
// this causes several tests to crash on exit because MaterialManager
// is already deleted before this call
// todo(anyone) check if ogre root is deleted before removing material?
// Ogre::MaterialManager::getSingleton().remove(
// this->ogreSubEntity->getMaterialName());
OgreRTShaderSystem::Instance()->DetachEntity(this);

BaseSubMesh::Destroy();
Expand Down
2 changes: 1 addition & 1 deletion ogre/src/OgreNode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void OgreNode::Destroy()
{
BaseNode::Destroy();

if (nullptr != this->scene)
if (nullptr != this->scene && nullptr != this->ogreNode)
{
Ogre::SceneManager *ogreSceneManager = this->scene->OgreSceneManager();
if (nullptr != ogreSceneManager)
Expand Down
4 changes: 4 additions & 0 deletions src/Utils_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ void UtilTest::ClickToScene(const std::string &_renderEngine)
box->SetLocalScale(1.0, 1.0, 1.0);
root->AddChild(box);

// add camera and render one frame
root->AddChild(camera);
camera->Update();

// API without RayQueryResult and default max distance
result = screenToScene(centerClick, camera, rayQuery, rayResult);

Expand Down
14 changes: 9 additions & 5 deletions test/integration/gpu_rays.cc
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,15 @@ void GpuRaysTest::RaysUnitBox(const std::string &_renderEngine)
EXPECT_NEAR(scan[0], expectedRangeAtMidPointBox2, LASER_TOL);
EXPECT_FLOAT_EQ(scan[last], ignition::math::INF_F);

// rays cater should see box01 with laser retro value set to laserRetro1
// and box02 with laser retro value set to laserRetro2
EXPECT_NEAR(scan[mid+1], laserRetro1, 5.0);
EXPECT_NEAR(scan[0+1], laserRetro2, 5.0);
EXPECT_FLOAT_EQ(scan[last+1], 0.0);
// laser retro is currently only supported in ogre2
if (_renderEngine == "ogre2")
{
// rays cater should see box01 with laser retro value set to laserRetro1
// and box02 with laser retro value set to laserRetro2
EXPECT_NEAR(scan[mid+1], laserRetro1, 5.0);
EXPECT_NEAR(scan[0+1], laserRetro2, 5.0);
EXPECT_FLOAT_EQ(scan[last+1], 0.0);
}

// Verify rays caster 2 range readings
// listen to new gpu rays frames
Expand Down

0 comments on commit 4bff736

Please sign in to comment.