From f16244e3d0f92e482374ce92431e77626fa5d059 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Sun, 14 Jul 2013 21:57:34 +0000 Subject: [PATCH] Added support for physics-only meshes (i.e. invisible walls), see #1014. Some changes to the exporter still required. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@13219 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/tracks/track.cpp | 20 ++++++++++++++++++-- src/tracks/track.hpp | 6 ++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index 9badf4043..c16d41fcd 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -121,6 +121,7 @@ Track::Track(const std::string &filename) m_minimap_x_scale = 1.0f; m_minimap_y_scale = 1.0f; m_all_nodes.clear(); + m_all_physics_only_nodes.clear(); m_all_cached_meshes.clear(); loadTrackInfo(); } // Track @@ -182,6 +183,7 @@ void Track::cleanup() irr_driver->removeNode(m_all_nodes[i]); } m_all_nodes.clear(); + m_all_physics_only_nodes.clear(); m_all_emitters.clearAndDeleteAll(); @@ -955,6 +957,8 @@ bool Track::loadMainTrack(const XMLNode &root) model_name=""; n->get("model", &model_name); full_path = m_root+model_name; + std::string interaction; + n->get("interaction", &interaction); // a special challenge orb object for overworld std::string challenge; @@ -1035,7 +1039,6 @@ bool Track::loadMainTrack(const XMLNode &root) scene_node->setPosition(xyz); scene_node->setRotation(hpr); scene_node->setScale(scale); - #ifdef DEBUG std::string debug_name = model_name+" (static track-object)"; scene_node->setName(debug_name.c_str()); @@ -1117,7 +1120,10 @@ bool Track::loadMainTrack(const XMLNode &root) } else { - m_all_nodes.push_back( scene_node ); + if(interaction=="physics-only") + m_all_physics_only_nodes.push_back( scene_node ); + else + m_all_nodes.push_back( scene_node ); } } @@ -1138,6 +1144,16 @@ bool Track::loadMainTrack(const XMLNode &root) { convertTrackToBullet(m_all_nodes[i]); } + + // Now convert all objects that are only used for the physics + // (like invisible walls). + for(unsigned int i=0; iremoveNode(m_all_physics_only_nodes[i]); + } + m_all_physics_only_nodes.clear(); + if (m_track_mesh == NULL) { Log::fatal("track", "m_track_mesh == NULL, cannot loadMainTrack\n"); diff --git a/src/tracks/track.hpp b/src/tracks/track.hpp index 1fb7caa89..0d180f3ef 100644 --- a/src/tracks/track.hpp +++ b/src/tracks/track.hpp @@ -174,8 +174,14 @@ private: /** The base dir of all files of this track. */ std::string m_root; std::vector m_groups; + + /** The list of all nodes. */ std::vector m_all_nodes; + /** The list of all nodes that are to be converted into physics, + * but not to be drawn (e.g. invisible walls). */ + std::vector m_all_physics_only_nodes; + /** The list of all meshes that are loaded from disk, which means * that those meshes are being cached by irrlicht, and need to be freed. */ std::vector m_all_cached_meshes;