Fixed the messy Track::cleanup function (correctly this time). No longer crashes when you re-play a track that you had previously played.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3806 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
9f38ccb15b
commit
c4bcec281f
@ -111,18 +111,24 @@ void Track::cleanup()
|
||||
for(unsigned int i=0; i<m_animated_textures.size(); i++)
|
||||
{
|
||||
delete m_animated_textures[i];
|
||||
m_animated_textures.clear();
|
||||
}
|
||||
for(unsigned int i=0; i<m_all_nodes.size(); i++)
|
||||
{
|
||||
irr_driver->removeNode(m_all_nodes[i]);
|
||||
m_all_nodes.clear();
|
||||
}
|
||||
for(unsigned int i=0; i<m_all_meshes.size(); i++)
|
||||
{
|
||||
irr_driver->removeMesh(m_all_meshes[i]);
|
||||
m_all_meshes.clear();
|
||||
}
|
||||
|
||||
|
||||
delete m_non_collision_mesh;
|
||||
m_non_collision_mesh = new TriangleMesh();
|
||||
delete m_track_mesh;
|
||||
m_track_mesh = new TriangleMesh();
|
||||
|
||||
// remove temporary materials loaded by the material manager
|
||||
material_manager->popTempMaterial();
|
||||
@ -351,6 +357,18 @@ void Track::createPhysicsModel()
|
||||
// Note that removing the rigid body does not remove the already collected
|
||||
// triangle information, so there is no need to convert the actual track
|
||||
// (first element in m_track_mesh) again!
|
||||
|
||||
if (m_track_mesh == NULL)
|
||||
{
|
||||
fprintf(stderr, "ERROR: m_track_mesh == NULL, cannot createPhysicsModel\n");
|
||||
return;
|
||||
}
|
||||
if (m_non_collision_mesh == NULL)
|
||||
{
|
||||
fprintf(stderr, "ERROR: m_track_mesh == NULL, cannot createPhysicsModel\n");
|
||||
return;
|
||||
}
|
||||
|
||||
m_track_mesh->removeBody();
|
||||
for(unsigned int i=1; i<m_all_meshes.size(); i++)
|
||||
{
|
||||
@ -424,6 +442,12 @@ bool Track::loadMainTrack(const XMLNode &xml_node)
|
||||
RaceManager::getWorld()->getPhysics()->init(min, max);
|
||||
// This will (at this stage) only convert the main track model.
|
||||
convertTrackToBullet(mesh);
|
||||
if (m_track_mesh == NULL)
|
||||
{
|
||||
fprintf(stderr, "ERROR: m_track_mesh == NULL, cannot loadMainTrack\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_track_mesh->createBody();
|
||||
|
||||
|
||||
@ -488,6 +512,7 @@ void Track::update(float dt)
|
||||
{
|
||||
for(unsigned int i=0; i<m_animated_textures.size(); i++)
|
||||
{
|
||||
if (m_animated_textures[i] != NULL)
|
||||
m_animated_textures[i]->update(dt);
|
||||
}
|
||||
for(unsigned int i=0; i<m_physical_objects.size(); i++)
|
||||
|
Loading…
Reference in New Issue
Block a user