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

7 -> main #873

Merged
merged 6 commits into from
Jul 25, 2023
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
8 changes: 8 additions & 0 deletions ogre/src/OgreCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ void OgreCamera::Destroy()
this->ogreCamera = nullptr;
}
}

if (this->selectionBuffer)
{
delete this->selectionBuffer;
this->selectionBuffer = nullptr;
}

BaseCamera::Destroy();
}

//////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions ogre/src/OgreGpuRays.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ void OgreGpuRays::Destroy()

this->dataPtr->texIdx.clear();
this->dataPtr->texCount = 0u;

BaseGpuRays::Destroy();
}

/////////////////////////////////////////////////
Expand Down
1 change: 0 additions & 1 deletion ogre/src/OgreLightVisual.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ void OgreLightVisual::CreateVisual()
this->dataPtr->line->AddPoint(p.X(), p.Y(), p.Z());
}
this->dataPtr->line->Update();
this->ogreNode->setVisible(true);
}

//////////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions ogre/src/OgreSelectionBuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ void OgreSelectionBuffer::DeleteRTTBuffer()
this->dataPtr->buffer = nullptr;
}
if (this->dataPtr->pixelBox)
{
delete this->dataPtr->pixelBox;
this->dataPtr->pixelBox = nullptr;
}
}

/////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions ogre/src/OgreThermalCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ void OgreThermalCamera::Destroy()
this->ogreCamera = nullptr;
}
}

BaseThermalCamera::Destroy();
}

//////////////////////////////////////////////////
Expand Down
13 changes: 12 additions & 1 deletion ogre/src/OgreWideAngleCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
#include "gz/rendering/ogre/OgreWideAngleCamera.hh"

#include "gz/rendering/ogre/OgreConversions.hh"
#include "gz/rendering/ogre/OgreRTShaderSystem.hh"
#include "gz/rendering/ogre/OgreRenderEngine.hh"
#include "gz/rendering/ogre/OgreRenderPass.hh"
#include "gz/rendering/ogre/OgreRTShaderSystem.hh"

/// \brief Private data for the WideAngleCamera class
class gz::rendering::OgreWideAngleCamera::Implementation
Expand Down Expand Up @@ -180,6 +180,9 @@ void OgreWideAngleCamera::PreRender()
//////////////////////////////////////////////////
void OgreWideAngleCamera::Destroy()
{
if (!this->dataPtr->ogreCamera)
return;

this->RemoveAllRenderPasses();

if (this->dataPtr->imageBuffer)
Expand Down Expand Up @@ -218,6 +221,13 @@ void OgreWideAngleCamera::Destroy()
}
}

if (this->dataPtr->ogreCamera)
{
this->scene->OgreSceneManager()->destroyCamera(
this->dataPtr->ogreCamera->getName());
this->dataPtr->ogreCamera = nullptr;
}

if (this->dataPtr->envCubeMapTexture)
{
Ogre::TextureManager::getSingleton().remove(
Expand All @@ -240,6 +250,7 @@ void OgreWideAngleCamera::Destroy()
}

this->DestroyRenderTexture();
BaseWideAngleCamera::Destroy();
}

//////////////////////////////////////////////////
Expand Down
4 changes: 1 addition & 3 deletions ogre2/include/gz/rendering/ogre2/Ogre2Heightmap.hh
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ namespace gz
public: void UpdateForRender(Ogre::Camera *_activeCamera);

// Documentation inherited.
// \todo(iche033) rename this to Destroy and
// make this function public and virtual
private: void DestroyImpl();
public: virtual void Destroy() override;

/// \brief Heightmap should only be created by scene.
private: friend class OgreScene;
Expand Down
4 changes: 3 additions & 1 deletion ogre2/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ set(engine_name "ogre2")

gz_add_component(${engine_name} SOURCES ${sources} GET_TARGET_NAME ogre2_target)

set(OGRE2_RESOURCE_PATH_STR "${OGRE2_RESOURCE_PATH}")
string(REPLACE ";" ":" OGRE2_RESOURCE_PATH_STR "${OGRE2_RESOURCE_PATH}")
set_property(
SOURCE Ogre2RenderEngine.cc
PROPERTY COMPILE_DEFINITIONS
OGRE2_RESOURCE_PATH="${OGRE2_RESOURCE_PATH}"
OGRE2_RESOURCE_PATH="${OGRE2_RESOURCE_PATH_STR}"
OGRE2_VERSION="${OGRE2_VERSION}"
)

Expand Down
8 changes: 8 additions & 0 deletions ogre2/src/Ogre2Camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ void Ogre2Camera::Destroy()
ogreSceneManager->destroyCamera(this->ogreCamera);
this->ogreCamera = nullptr;
}

if (this->selectionBuffer)
{
delete this->selectionBuffer;
this->selectionBuffer = nullptr;
}

BaseCamera::Destroy();
}

//////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions ogre2/src/Ogre2DepthCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ void Ogre2DepthCamera::Destroy()
this->ogreCamera = nullptr;
}
}

BaseDepthCamera::Destroy();
}

//////////////////////////////////////////////////
Expand Down
7 changes: 7 additions & 0 deletions ogre2/src/Ogre2Heightmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ Ogre2Heightmap::Ogre2Heightmap(const HeightmapDescriptor &_desc)
//////////////////////////////////////////////////
Ogre2Heightmap::~Ogre2Heightmap()
{
this->Destroy();
}

//////////////////////////////////////////////////
void Ogre2Heightmap::Destroy()
{
this->dataPtr->terra.reset();
}

//////////////////////////////////////////////////
Expand Down
10 changes: 10 additions & 0 deletions ogre2/src/Ogre2RayQuery.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ Ogre2RayQuery::Ogre2RayQuery()
//////////////////////////////////////////////////
Ogre2RayQuery::~Ogre2RayQuery()
{
if (this->dataPtr->rayQuery)
{
Ogre2ScenePtr ogreScene =
std::dynamic_pointer_cast<Ogre2Scene>(this->Scene());
if (ogreScene)
{
ogreScene->OgreSceneManager()->destroyQuery(this->dataPtr->rayQuery);
this->dataPtr->rayQuery = nullptr;
}
}
}

//////////////////////////////////////////////////
Expand Down
10 changes: 8 additions & 2 deletions ogre2/src/Ogre2RenderEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,17 @@
this->dummyWindowId = 0;

std::string ogrePath = std::string(OGRE2_RESOURCE_PATH);
this->ogrePaths.push_back(ogrePath);
std::vector<std::string> paths = common::split(ogrePath, ":");
for (const auto &path : paths)
this->ogrePaths.push_back(path);

const char *env = std::getenv("OGRE2_RESOURCE_PATH");
if (env)
this->ogrePaths.push_back(std::string(env));
{
paths = common::split(std::string(env), ":");
for (const auto &path : paths)
this->ogrePaths.push_back(path);

Check warning on line 161 in ogre2/src/Ogre2RenderEngine.cc

View check run for this annotation

Codecov / codecov/patch

ogre2/src/Ogre2RenderEngine.cc#L159-L161

Added lines #L159 - L161 were not covered by tests
}
}

//////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions ogre2/src/Ogre2SegmentationCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ void Ogre2SegmentationCamera::Destroy()
}

this->dataPtr->materialSwitcher.reset();

BaseCamera::Destroy();
}

/////////////////////////////////////////////////
Expand Down
18 changes: 13 additions & 5 deletions ogre2/src/Ogre2SelectionBuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,19 @@ void Ogre2SelectionBuffer::DeleteRTTBuffer()
this->dataPtr->ogreCompositorWorkspace = nullptr;
}

auto engine = Ogre2RenderEngine::Instance();
auto ogreRoot = engine->OgreRoot();
ogreRoot->getRenderSystem()->getTextureGpuManager()->destroyTexture(
this->dataPtr->renderTexture);
this->dataPtr->renderTexture = nullptr;
if (this->dataPtr->renderTexture)
{
auto engine = Ogre2RenderEngine::Instance();
auto ogreRoot = engine->OgreRoot();
Ogre::TextureGpuManager *textureMgr =
ogreRoot->getRenderSystem()->getTextureGpuManager();
if (textureMgr->findTextureNoThrow(
this->dataPtr->renderTexture->getName()))
{
textureMgr->destroyTexture(this->dataPtr->renderTexture);
this->dataPtr->renderTexture = nullptr;
}
}
}

/////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions ogre2/src/Ogre2ThermalCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,8 @@ void Ogre2ThermalCamera::Destroy()
}

this->dataPtr->thermalMaterialSwitcher.reset();

BaseThermalCamera::Destroy();
}

//////////////////////////////////////////////////
Expand Down
Loading