Fix texture leaks on NB delete, and fix flip/rotate not rebuilding meshes
This commit is contained in:
parent
0f152ab919
commit
866ca6b16a
@ -38,6 +38,7 @@ Node::~Node()
|
|||||||
for (std::vector<NodeBox*>::iterator it = boxes.begin();
|
for (std::vector<NodeBox*>::iterator it = boxes.begin();
|
||||||
it != boxes.end();
|
it != boxes.end();
|
||||||
++it) {
|
++it) {
|
||||||
|
(*it)->removeMesh(state->device->getVideoDriver());
|
||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
boxes.clear();
|
boxes.clear();
|
||||||
@ -82,6 +83,7 @@ void Node::deleteNodebox(int id)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boxes[id]->removeMesh(state->device->getVideoDriver());
|
||||||
delete boxes[id];
|
delete boxes[id];
|
||||||
boxes.erase(boxes.begin() + id);
|
boxes.erase(boxes.begin() + id);
|
||||||
if (GetId() >= (int)boxes.size())
|
if (GetId() >= (int)boxes.size())
|
||||||
|
@ -186,6 +186,17 @@ ITexture* darken(IVideoDriver* driver, IImage* image, f32 amt, const char *name)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeBox::removeMesh(IVideoDriver *driver)
|
||||||
|
{
|
||||||
|
if (model) {
|
||||||
|
for (int i = 0; i < model->getMaterialCount(); i++)
|
||||||
|
driver->removeTexture(model->getMaterial(i).getTexture(0));
|
||||||
|
|
||||||
|
model->remove();
|
||||||
|
model = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NodeBox::buildNode(EditorState* editor, vector3di nd_position, IrrlichtDevice* device, Media::Image* images[6])
|
void NodeBox::buildNode(EditorState* editor, vector3di nd_position, IrrlichtDevice* device, Media::Image* images[6])
|
||||||
{
|
{
|
||||||
if (!rebuild_needed)
|
if (!rebuild_needed)
|
||||||
@ -203,13 +214,9 @@ void NodeBox::buildNode(EditorState* editor, vector3di nd_position, IrrlichtDevi
|
|||||||
copied[i] = def;
|
copied[i] = def;
|
||||||
}
|
}
|
||||||
ISceneManager* smgr = device->getSceneManager();
|
ISceneManager* smgr = device->getSceneManager();
|
||||||
if (model) {
|
|
||||||
for (int i = 0; i < model->getMaterialCount(); i++)
|
|
||||||
driver->removeTexture(model->getMaterial(i).getTexture(0));
|
|
||||||
|
|
||||||
model->remove();
|
removeMesh(driver);
|
||||||
model = NULL;
|
|
||||||
}
|
|
||||||
vector3df position = vector3df(
|
vector3df position = vector3df(
|
||||||
nd_position.X + one.X + ((two.X - one.X) / 2),
|
nd_position.X + one.X + ((two.X - one.X) / 2),
|
||||||
nd_position.Y + one.Y + ((two.Y - one.Y) / 2),
|
nd_position.Y + one.Y + ((two.Y - one.Y) / 2),
|
||||||
@ -437,6 +444,7 @@ void NodeBox::rotate(EAxis axis)
|
|||||||
one.Z = two.Z;
|
one.Z = two.Z;
|
||||||
two.Z = tmp;
|
two.Z = tmp;
|
||||||
}
|
}
|
||||||
|
rebuild_needed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeBox::flip(EAxis axis)
|
void NodeBox::flip(EAxis axis)
|
||||||
@ -480,4 +488,5 @@ void NodeBox::flip(EAxis axis)
|
|||||||
one.Z = two.Z;
|
one.Z = two.Z;
|
||||||
two.Z = tmp;
|
two.Z = tmp;
|
||||||
}
|
}
|
||||||
|
rebuild_needed = true;
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,7 @@ public:
|
|||||||
name(name), one(one), two(two), model(NULL), rebuild_needed(true)
|
name(name), one(one), two(two), model(NULL), rebuild_needed(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~NodeBox()
|
void removeMesh(IVideoDriver *driver);
|
||||||
{
|
|
||||||
if (model)
|
|
||||||
model->remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
irr::core::vector3df one;
|
irr::core::vector3df one;
|
||||||
irr::core::vector3df two;
|
irr::core::vector3df two;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user