From: <hik...@us...> - 2010-07-11 13:26:32
|
Revision: 5678 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5678&view=rev Author: hikerstk Date: 2010-07-11 13:26:26 +0000 (Sun, 11 Jul 2010) Log Message: ----------- Simplified skid structure by removing pointer to mesh (which is not needed at all). Modified Paths: -------------- main/trunk/src/graphics/skid_marks.cpp main/trunk/src/graphics/skid_marks.hpp Modified: main/trunk/src/graphics/skid_marks.cpp =================================================================== --- main/trunk/src/graphics/skid_marks.cpp 2010-07-11 13:14:09 UTC (rev 5677) +++ main/trunk/src/graphics/skid_marks.cpp 2010-07-11 13:26:26 UTC (rev 5678) @@ -59,17 +59,12 @@ for(unsigned int i=0; i<m_nodes.size(); i++) { irr_driver->removeNode(m_nodes[i]); - // No need to call irr_driver->removeMesh, since this only - // removes the mesh from the mesh cache (if it exists in it), - // and this ('manual') mesh was never added to the cash. - m_meshes[i]->drop(); m_left[i]->drop(); m_right[i]->drop(); } m_left.clear(); m_right.clear(); m_nodes.clear(); - m_meshes.clear(); m_skid_marking = false; m_current = -1; } // reset @@ -130,10 +125,10 @@ raycast_right.m_contactPointWS); // Adjust the boundary box of the mesh to include the // adjusted aabb of its buffers. - core::aabbox3df aabb=m_meshes[m_current]->getBoundingBox(); + core::aabbox3df aabb=m_nodes[m_current]->getMesh()->getBoundingBox(); aabb.addInternalBox(m_left[m_current]->getAABB()); aabb.addInternalBox(m_right[m_current]->getAABB()); - m_meshes[m_current]->setBoundingBox(aabb); + m_nodes[m_current]->getMesh()->setBoundingBox(aabb); return; } @@ -182,8 +177,11 @@ m_material, m_avoid_z_fighting); new_mesh->addMeshBuffer(smq_right); - scene::ISceneNode *new_node = irr_driver->addMesh(new_mesh); - + scene::IMeshSceneNode *new_node = irr_driver->addMesh(new_mesh); + // We don't keep a reference to the mesh here, so we have to decrement + // the reference count (which is set to 1 when doing "new SMesh()". + // The scene node will keep the mesh alive. + new_mesh->drop(); m_current++; if(m_current>=stk_config->m_max_skidmarks) m_current = 0; @@ -191,7 +189,6 @@ { m_left. push_back (smq_left ); m_right.push_back (smq_right); - m_meshes.push_back(new_mesh); m_nodes.push_back (new_node); } else @@ -199,13 +196,11 @@ irr_driver->removeNode(m_nodes[m_current]); // Not necessary to delete m_nodes: removeNode // deletes the node since its refcount reaches zero. - delete m_meshes[m_current]; delete m_left [m_current]; delete m_right [m_current]; m_left [m_current] = smq_left; m_right [m_current] = smq_right; - m_meshes[m_current] = new_mesh; m_nodes [m_current] = new_node; } Modified: main/trunk/src/graphics/skid_marks.hpp =================================================================== --- main/trunk/src/graphics/skid_marks.hpp 2010-07-11 13:14:09 UTC (rev 5677) +++ main/trunk/src/graphics/skid_marks.hpp 2010-07-11 13:26:26 UTC (rev 5678) @@ -76,11 +76,8 @@ /** Two skidmark objects for the left and right wheel. */ std::vector<SkidMarkQuads *> m_left, m_right; - /** The meshes - each mesh containing two mesh buffers (left/right). */ - std::vector<scene::IMesh *> m_meshes; - /** The nodes where each left/right pair is attached to. */ - std::vector<scene::ISceneNode *> m_nodes; + std::vector<scene::IMeshSceneNode *> m_nodes; /** Shared static so that consecutive skidmarks are at a slightly * different height. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |