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

Override SetProjectionMatrix and ProjectionMatrix functions in derived ogre2 camera classes. #1021

Merged
merged 2 commits into from
Jul 26, 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
7 changes: 7 additions & 0 deletions ogre2/include/gz/rendering/ogre2/Ogre2BoundingBoxCamera.hh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ namespace gz
// Documentation inherited
public: virtual void PostRender() override;

// Documentation inherited.
public: virtual math::Matrix4d ProjectionMatrix() const override;

// Documentation inherited.
public: virtual void SetProjectionMatrix(
const math::Matrix4d &_matrix) override;

// Documentation inherited
public: virtual const std::vector<BoundingBox> &BoundingBoxData() const
override;
Expand Down
7 changes: 7 additions & 0 deletions ogre2/include/gz/rendering/ogre2/Ogre2SegmentationCamera.hh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ namespace gz
// Documentation inherited
public: virtual void PostRender() override;

// Documentation inherited.
public: virtual math::Matrix4d ProjectionMatrix() const override;

// Documentation inherited.
public: virtual void SetProjectionMatrix(
const math::Matrix4d &_matrix) override;

// Documentation inherited
public: virtual gz::common::ConnectionPtr
ConnectNewSegmentationFrame(
Expand Down
7 changes: 7 additions & 0 deletions ogre2/include/gz/rendering/ogre2/Ogre2ThermalCamera.hh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ namespace gz
/// \brief Render the camera
public: virtual void PostRender() override;

// Documentation inherited.
public: virtual math::Matrix4d ProjectionMatrix() const override;

// Documentation inherited.
public: virtual void SetProjectionMatrix(
const math::Matrix4d &_matrix) override;

/// \brief Connect to the new thermal image event
/// \param[in] _subscriber Subscriber callback function
/// \return Pointer to the new Connection. This must be kept in scope
Expand Down
30 changes: 15 additions & 15 deletions ogre2/src/Ogre2BoundingBoxCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -465,21 +465,6 @@ void Ogre2BoundingBoxCamera::PreRender()
if (!this->dataPtr->ogreRenderTexture)
this->CreateBoundingBoxTexture();

// todo(iche033) Override BaseCamera::SetProjectionMatrix() function in
// main / gz-rendering9 instead of checking and setting the custom
// projection matrix here
if (this->dataPtr->ogreCamera &&
this->projectionMatrix != gz::math::Matrix4d::Zero)
{
if (this->projectionMatrix !=
Ogre2Conversions::Convert(
this->dataPtr->ogreCamera->getProjectionMatrix()))
{
this->dataPtr->ogreCamera->setCustomProjectionMatrix(true,
Ogre2Conversions::Convert(this->projectionMatrix));
}
}

this->dataPtr->outputBoxes.clear();
}

Expand Down Expand Up @@ -1549,3 +1534,18 @@ BoundingBoxType Ogre2BoundingBoxCamera::Type() const
{
return this->dataPtr->type;
}

/////////////////////////////////////////////////
math::Matrix4d Ogre2BoundingBoxCamera::ProjectionMatrix() const
{
return Ogre2Conversions::Convert(
this->dataPtr->ogreCamera->getProjectionMatrix());
}

/////////////////////////////////////////////////
void Ogre2BoundingBoxCamera::SetProjectionMatrix(const math::Matrix4d &_matrix)
{
BaseBoundingBoxCamera::SetProjectionMatrix(_matrix);
this->dataPtr->ogreCamera->setCustomProjectionMatrix(
true, Ogre2Conversions::Convert(this->projectionMatrix));
}
20 changes: 4 additions & 16 deletions ogre2/src/Ogre2DepthCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1021,12 +1021,14 @@ void Ogre2DepthCamera::CreateWorkspaceInstance()
}

/////////////////////////////////////////////////
math::Matrix4d Ogre2DepthCamera::ProjectionMatrix() const {
math::Matrix4d Ogre2DepthCamera::ProjectionMatrix() const
{
return Ogre2Conversions::Convert(this->ogreCamera->getProjectionMatrix());
}

/////////////////////////////////////////////////
void Ogre2DepthCamera::SetProjectionMatrix(const math::Matrix4d &_matrix) {
void Ogre2DepthCamera::SetProjectionMatrix(const math::Matrix4d &_matrix)
{
BaseDepthCamera::SetProjectionMatrix(_matrix);
this->ogreCamera->setCustomProjectionMatrix(
true, Ogre2Conversions::Convert(this->projectionMatrix));
Expand Down Expand Up @@ -1069,20 +1071,6 @@ void Ogre2DepthCamera::PreRender()
if (!this->dataPtr->ogreCompositorWorkspace)
this->CreateWorkspaceInstance();

// todo(iche033) Override BaseCamera::SetProjectionMatrix() function in
// main / gz-rendering9 instead of checking and setting the custom
// projection matrix here
if (this->ogreCamera &&
this->projectionMatrix != gz::math::Matrix4d::Zero)
{
if (this->projectionMatrix !=
Ogre2Conversions::Convert(this->ogreCamera->getProjectionMatrix()))
{
this->ogreCamera->setCustomProjectionMatrix(true,
Ogre2Conversions::Convert(this->projectionMatrix));
}
}

// Disable color target (set to clear pass) if there are no rgb point cloud
// connections
if (this->dataPtr->colorTargetDef)
Expand Down
28 changes: 14 additions & 14 deletions ogre2/src/Ogre2SegmentationCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,6 @@ void Ogre2SegmentationCamera::PreRender()
{
if (!this->dataPtr->ogreSegmentationTexture)
this->CreateSegmentationTexture();

// todo(iche033) Override BaseCamera::SetProjectionMatrix() function in
// main / gz-rendering9 instead of checking and setting the custom
// projection matrix here
if (this->ogreCamera &&
this->projectionMatrix != gz::math::Matrix4d::Zero)
{
if (this->projectionMatrix !=
Ogre2Conversions::Convert(this->ogreCamera->getProjectionMatrix()))
{
this->ogreCamera->setCustomProjectionMatrix(true,
Ogre2Conversions::Convert(this->projectionMatrix));
}
}
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -439,3 +425,17 @@ Ogre::Camera *Ogre2SegmentationCamera::OgreCamera() const
{
return this->ogreCamera;
}

/////////////////////////////////////////////////
math::Matrix4d Ogre2SegmentationCamera::ProjectionMatrix() const
{
return Ogre2Conversions::Convert(this->ogreCamera->getProjectionMatrix());
}

/////////////////////////////////////////////////
void Ogre2SegmentationCamera::SetProjectionMatrix(const math::Matrix4d &_matrix)
{
BaseSegmentationCamera::SetProjectionMatrix(_matrix);
this->ogreCamera->setCustomProjectionMatrix(
true, Ogre2Conversions::Convert(this->projectionMatrix));
}
28 changes: 14 additions & 14 deletions ogre2/src/Ogre2ThermalCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1131,20 +1131,6 @@ void Ogre2ThermalCamera::PreRender()
{
if (!this->dataPtr->ogreThermalTexture)
this->CreateThermalTexture();

// todo(iche033) Override BaseCamera::SetProjectionMatrix() function in
// main / gz-rendering9 instead of checking and setting the custom
// projection matrix here
if (this->ogreCamera &&
this->projectionMatrix != gz::math::Matrix4d::Zero)
{
if (this->projectionMatrix !=
Ogre2Conversions::Convert(this->ogreCamera->getProjectionMatrix()))
{
this->ogreCamera->setCustomProjectionMatrix(true,
Ogre2Conversions::Convert(this->projectionMatrix));
}
}
}

//////////////////////////////////////////////////
Expand Down Expand Up @@ -1236,3 +1222,17 @@ Ogre::Camera *Ogre2ThermalCamera::OgreCamera() const
{
return this->ogreCamera;
}

/////////////////////////////////////////////////
math::Matrix4d Ogre2ThermalCamera::ProjectionMatrix() const
{
return Ogre2Conversions::Convert(this->ogreCamera->getProjectionMatrix());
}

/////////////////////////////////////////////////
void Ogre2ThermalCamera::SetProjectionMatrix(const math::Matrix4d &_matrix)
{
BaseThermalCamera::SetProjectionMatrix(_matrix);
this->ogreCamera->setCustomProjectionMatrix(
true, Ogre2Conversions::Convert(this->projectionMatrix));
}