Skip to content

Mesh cleanup on destruction #807

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

Merged
merged 1 commit into from
Jan 19, 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
3 changes: 2 additions & 1 deletion ogre2/src/Ogre2Mesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ Ogre2Mesh::Ogre2Mesh()
//////////////////////////////////////////////////
Ogre2Mesh::~Ogre2Mesh()
{
this->Destroy();
}

//////////////////////////////////////////////////
void Ogre2Mesh::Destroy()
{
if (!this->ogreItem)
if (!this->ogreItem || !this->Scene()->IsInitialized())
return;

// We need to override BaseMesh::Destroy for ogre2 implementation to control
Expand Down
6 changes: 5 additions & 1 deletion src/Mesh_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ void MeshTest::MeshSubMesh(const std::string &_renderEngine)
// create the mesh using mesh descriptor
MeshDescriptor descriptor("unit_box");
MeshPtr mesh = scene->CreateMesh(descriptor);
ASSERT_TRUE(mesh!= nullptr);
ASSERT_NE(nullptr, mesh);

// make sure we can create the mesh again with same descriptor
mesh = scene->CreateMesh(descriptor);
ASSERT_NE(nullptr, mesh);

// test mesh API
EXPECT_EQ(mesh->SubMeshCount(), 1u);
Expand Down