Check datablock in use by another item
-
Lax
- Orc Shaman
- Posts: 721
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 83
- Contact:
Check datablock in use by another item
Hi,
Is it possible somehow to check if a datablock is used by another item or entity?
I have the issue, that when an entity is deleted its datablock will be deleted. Yet there is another entity, that uses the same datablock when this being deleted, of course I get a crash, because the datablock pointer is crap.
Best Regards
Lax
Is it possible somehow to check if a datablock is used by another item or entity?
I have the issue, that when an entity is deleted its datablock will be deleted. Yet there is another entity, that uses the same datablock when this being deleted, of course I get a crash, because the datablock pointer is crap.
Best Regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
zxz
- Gremlin
- Posts: 184
- Joined: Sat Apr 16, 2016 9:25 pm
- x 19
Re: Check datablock in use by another item
You can use the HlmsDatablock::getLinkedRenderables() function to find all uses of the datablock.
-
Lax
- Orc Shaman
- Posts: 721
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 83
- Contact:
Re: Check datablock in use by another item
Ok thanks!
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
zxz
- Gremlin
- Posts: 184
- Joined: Sat Apr 16, 2016 9:25 pm
- x 19
Re: Check datablock in use by another item
For reference, a function like this is useful:
Code: Select all
void destroyDatablock(Ogre::HlmsDatablock* block)
{
auto hlms = block->getCreator();
for (auto renderable : block->getLinkedRenderables())
renderable->setDatablock(hlms->getDefaultDatablock());
hlms->destroyDatablock(block->getName());
}