Fix a memory leak in PhysicalObject::init().
This commit is contained in:
parent
0d84239cd2
commit
a5a9b9f6c1
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "physics/physical_object.hpp"
|
#include "physics/physical_object.hpp"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -325,7 +326,6 @@ void PhysicalObject::init()
|
|||||||
case MP_EXACT:
|
case MP_EXACT:
|
||||||
{
|
{
|
||||||
extend.setY(0);
|
extend.setY(0);
|
||||||
TriangleMesh* triangle_mesh = new TriangleMesh();
|
|
||||||
|
|
||||||
// In case of readonly materials we have to get the material from
|
// In case of readonly materials we have to get the material from
|
||||||
// the mesh, otherwise from the node. This is esp. important for
|
// the mesh, otherwise from the node. This is esp. important for
|
||||||
@ -361,6 +361,8 @@ void PhysicalObject::init()
|
|||||||
return;
|
return;
|
||||||
} // switch node->getType()
|
} // switch node->getType()
|
||||||
|
|
||||||
|
std::auto_ptr<TriangleMesh> triangle_mesh(new TriangleMesh());
|
||||||
|
|
||||||
for(unsigned int i=0; i<mesh->getMeshBufferCount(); i++)
|
for(unsigned int i=0; i<mesh->getMeshBufferCount(); i++)
|
||||||
{
|
{
|
||||||
scene::IMeshBuffer *mb = mesh->getMeshBuffer(i);
|
scene::IMeshBuffer *mb = mesh->getMeshBuffer(i);
|
||||||
@ -385,7 +387,6 @@ void PhysicalObject::init()
|
|||||||
video::ITexture* t=irrMaterial.getTexture(0);
|
video::ITexture* t=irrMaterial.getTexture(0);
|
||||||
|
|
||||||
const Material* material=0;
|
const Material* material=0;
|
||||||
TriangleMesh *tmesh = triangle_mesh;
|
|
||||||
if(t)
|
if(t)
|
||||||
{
|
{
|
||||||
std::string image =
|
std::string image =
|
||||||
@ -414,10 +415,10 @@ void PhysicalObject::init()
|
|||||||
vertices[k]=v;
|
vertices[k]=v;
|
||||||
normals[k]=mbVertices[indx].Normal;
|
normals[k]=mbVertices[indx].Normal;
|
||||||
} // for k
|
} // for k
|
||||||
if(tmesh) tmesh->addTriangle(vertices[0], vertices[1],
|
triangle_mesh->addTriangle(vertices[0], vertices[1],
|
||||||
vertices[2], normals[0],
|
vertices[2], normals[0],
|
||||||
normals[1], normals[2],
|
normals[1], normals[2],
|
||||||
material );
|
material );
|
||||||
} // for j
|
} // for j
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -436,10 +437,10 @@ void PhysicalObject::init()
|
|||||||
vertices[k]=v;
|
vertices[k]=v;
|
||||||
normals[k]=mbVertices[indx].Normal;
|
normals[k]=mbVertices[indx].Normal;
|
||||||
} // for k
|
} // for k
|
||||||
if(tmesh) tmesh->addTriangle(vertices[0], vertices[1],
|
triangle_mesh->addTriangle(vertices[0], vertices[1],
|
||||||
vertices[2], normals[0],
|
vertices[2], normals[0],
|
||||||
normals[1], normals[2],
|
normals[1], normals[2],
|
||||||
material );
|
material );
|
||||||
} // for j
|
} // for j
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -448,7 +449,7 @@ void PhysicalObject::init()
|
|||||||
} // for i<getMeshBufferCount
|
} // for i<getMeshBufferCount
|
||||||
triangle_mesh->createCollisionShape();
|
triangle_mesh->createCollisionShape();
|
||||||
m_shape = &triangle_mesh->getCollisionShape();
|
m_shape = &triangle_mesh->getCollisionShape();
|
||||||
m_triangle_mesh = triangle_mesh;
|
m_triangle_mesh = triangle_mesh.release();
|
||||||
m_init_pos.setOrigin(m_init_pos.getOrigin() + m_graphical_offset);
|
m_init_pos.setOrigin(m_init_pos.getOrigin() + m_graphical_offset);
|
||||||
// m_graphical_offset = Vec3(0,0,0);
|
// m_graphical_offset = Vec3(0,0,0);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user