From 798576ef12854e985ee3049b103a74a4bb3383b6 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Thu, 29 Sep 2011 23:03:00 +0000 Subject: [PATCH] Cosmetic changes only. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9918 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/graphics/stars.cpp | 51 +++++++++++++++++-------------------- src/modes/profile_world.cpp | 13 +++++++--- src/utils/ptr_vector.hpp | 49 ++++++++++++++++++----------------- 3 files changed, 58 insertions(+), 55 deletions(-) diff --git a/src/graphics/stars.cpp b/src/graphics/stars.cpp index 10c5eec68..1f7ac6332 100644 --- a/src/graphics/stars.cpp +++ b/src/graphics/stars.cpp @@ -36,32 +36,27 @@ Stars::Stars(scene::ISceneNode* parentKart, core::vector3df center) m_enabled = false; video::ITexture* texture = irr_driver->getTexture("starparticle.png"); - Material* star_material = material_manager->getMaterial("starparticle.png"); + Material* star_material = + material_manager->getMaterial("starparticle.png"); m_center = center; for (int n=0; naddBillboard(core::dimension2d< f32 >(STAR_SIZE, STAR_SIZE), - texture, - parentKart); + scene::ISceneNode* billboard = + irr_driver->addBillboard(core::dimension2df(STAR_SIZE, STAR_SIZE), + texture, parentKart); #ifdef DEBUG billboard->setName("star"); #endif star_material->setMaterialProperties(&(billboard->getMaterial(0))); - //billboard->getMaterial(0).MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; billboard->setMaterialTexture(0, star_material->getTexture()); billboard->setVisible(false); m_nodes.push_back(billboard); } - - // for debugging - //m_enabled = true; - //m_remaining_time = 99999.0f; - //update(0); -} +} // Stars // ---------------------------------------------------------------------------- @@ -72,7 +67,7 @@ Stars::~Stars() { m_parent_kart_node->removeChild(m_nodes[n]); } -} +} // ~Stars // ---------------------------------------------------------------------------- @@ -86,12 +81,13 @@ void Stars::showFor(float time) for (int n=0; nsetVisible(true); - ((scene::IBillboardSceneNode*)m_nodes[n])->setSize( core::dimension2d< f32 >(0.01f, 0.01f) ); + ((scene::IBillboardSceneNode*)m_nodes[n]) + ->setSize( core::dimension2df(0.01f, 0.01f) ); } // set stars initial position update(0); -} +} // showFor // ---------------------------------------------------------------------------- /** Resets the stars, esp. disabling them at a restart. @@ -124,7 +120,8 @@ void Stars::update(float delta_t) const int nodeAmount = m_nodes.size(); for (int n=0; n 0.0f) { - //m_nodes[n]->getMaterial(0).AmbientColor.setAlpha((1.0f - m_fade_in_time)*255.0f); - //m_nodes[n]->getMaterial(0).DiffuseColor.setAlpha((1.0f - m_fade_in_time)*255.0f); - float fade = (1.0f - m_fade_in_time); ((scene::IBillboardSceneNode*)m_nodes[n])->setSize( @@ -152,21 +146,22 @@ void Stars::update(float delta_t) // manage "fade-out" else if (m_remaining_time < 1.0f) { - //m_nodes[n]->getMaterial(0).AmbientColor.setAlpha(m_remaining_time*255.0f); - //m_nodes[n]->getMaterial(0).DiffuseColor.setAlpha(m_remaining_time*255.0f); - radius *= m_remaining_time; - ((scene::IBillboardSceneNode*)m_nodes[n])->setSize( core::dimension2d< f32 >(m_remaining_time*STAR_SIZE, - m_remaining_time*STAR_SIZE) ); + ((scene::IBillboardSceneNode*)m_nodes[n]) + ->setSize( core::dimension2df(m_remaining_time*STAR_SIZE, + m_remaining_time*STAR_SIZE) ); } - // set position - m_nodes[n]->setPosition(m_center + core::vector3df( std::cos(angle*M_PI*2.0f)*radius, // Position in circle - std::cos(angle*M_PI*2.0f + m_remaining_time*4.0f)*radius*0.25f, // Shake up and down like falling coin - std::sin(angle*M_PI*2.0f)*radius)); // Position in circle + // Set position: X and Z are the position in the cirlce, + // the Y components shakes the stars up and down like falling coin + core::vector3df offset(std::cos(angle*M_PI*2.0f)*radius, + std::cos(angle*M_PI*2.0f+m_remaining_time*4.0f) + *radius*0.25f, + std::sin(angle*M_PI*2.0f)*radius ); + m_nodes[n]->setPosition(m_center + offset); } // end for if (m_fade_in_time > 0.0f) m_fade_in_time -= delta_t; -} +} // update diff --git a/src/modes/profile_world.cpp b/src/modes/profile_world.cpp index 49a0b941c..ead91d7d7 100644 --- a/src/modes/profile_world.cpp +++ b/src/modes/profile_world.cpp @@ -41,7 +41,8 @@ ProfileWorld::ProfileWorld() // Set number of laps so that the end of the race can be detected by // quering the number of finished karts from the race manager (in laps // based profiling) - otherwise just a high number. - race_manager->setNumLaps(m_profile_mode==PROFILE_LAPS ? m_num_laps : 99999); + race_manager->setNumLaps(m_profile_mode==PROFILE_LAPS ? m_num_laps + : 99999); m_phase = RACE_PHASE; m_frame_count = 0; m_start_time = irr_driver->getRealTime(); @@ -128,7 +129,8 @@ void ProfileWorld::update(float dt) m_frame_count++; video::IVideoDriver *driver = irr_driver->getVideoDriver(); io::IAttributes *attr = irr_driver->getSceneManager()->getParameters(); - m_num_triangles += (int)(driver->getPrimitiveCountDrawn( 0 ) * ( 1.f / 1000.f )); + m_num_triangles += (int)(driver->getPrimitiveCountDrawn( 0 ) + * ( 1.f / 1000.f )); m_num_calls += attr->getAttributeAsInt("calls"); m_num_culls += attr->getAttributeAsInt("culled" ); m_num_solid += attr->getAttributeAsInt("drawn_solid" ); @@ -164,7 +166,8 @@ void ProfileWorld::enterRaceOverState() for (unsigned int i=0; igetNumberOfKarts(); i++) { // ---------- update rank ------ - if (m_karts[i]->hasFinishedRace() || m_karts[i]->isEliminated()) continue; + if (m_karts[i]->hasFinishedRace() || m_karts[i]->isEliminated()) + continue; m_karts[i]->finishedRace(estimateFinishTimeForKart(m_karts[i])); } @@ -196,7 +199,9 @@ void ProfileWorld::enterRaceOverState() printf("average_speed,"); } - printf("top_speed,skid_time,rescue_time,rescue_count,explosion_time,explosion_count,bonus_count,banana_count,small_nitro_count,large_nitro_count,bubblegum_count\n"); + printf("top_speed,skid_time,rescue_time,rescue_count,explosion_time," + "explosion_count,bonus_count,banana_count,small_nitro_count," + "large_nitro_count,bubblegum_count\n"); for ( KartList::size_type i = 0; i < m_karts.size(); ++i) { diff --git a/src/utils/ptr_vector.hpp b/src/utils/ptr_vector.hpp index fe1f81844..566f0a56c 100644 --- a/src/utils/ptr_vector.hpp +++ b/src/utils/ptr_vector.hpp @@ -15,8 +15,9 @@ */ /* - * I made this class to work like a regular vector, except that m_contents_vector are placed - * one the heap so third-party m_contents_vector can keep pointers to them. + * I made this class to work like a regular vector, except that + * m_contents_vector are placed* one the heap so third-party + * m_contents_vector can keep pointers to them. */ #ifndef HEADER_PtrVector_HPP @@ -43,21 +44,21 @@ public: PtrVector() { - } + } // PtrVector // ------------------------------------------------------------------------ ~PtrVector() { if(type == HOLD) clearAndDeleteAll(); - } + } // ~PtrVector // ------------------------------------------------------------------------ void push_back(TYPE* t) { m_contents_vector.push_back(t); - } + } // push_back // ------------------------------------------------------------------------ void swap(int ID1, int ID2) @@ -72,7 +73,7 @@ public: m_contents_vector[ID2] = m_contents_vector[ID1]; m_contents_vector[ID1] = temp; - } + } // swap // ------------------------------------------------------------------------ TYPE* get(const int ID) @@ -81,7 +82,7 @@ public: assert((unsigned int)ID < (unsigned int)m_contents_vector.size()); return m_contents_vector[ID]; - } + } // get // ------------------------------------------------------------------------ const TYPE* get(const int ID) const @@ -90,13 +91,13 @@ public: assert((unsigned int)ID < (unsigned int)m_contents_vector.size()); return m_contents_vector[ID]; - } + } // get // ------------------------------------------------------------------------ int size() const { return m_contents_vector.size(); - } + } // size // ------------------------------------------------------------------------ void erase(const int ID) @@ -115,7 +116,7 @@ public: #else m_contents_vector.erase(m_contents_vector.begin()+ID); #endif - } + } // erase // ------------------------------------------------------------------------ TYPE* remove(const int ID) @@ -135,7 +136,7 @@ public: m_contents_vector.erase(m_contents_vector.begin()+ID); #endif return out; - } + } // remove // ------------------------------------------------------------------------ bool contains( const TYPE* instance ) const @@ -148,7 +149,7 @@ public: } return false; - } + } // contains // ------------------------------------------------------------------------ void clearAndDeleteAll() @@ -164,7 +165,7 @@ public: assert( !contains(pointer) ); } m_contents_vector.clear(); - } + } // clearAndDeleteAll // ------------------------------------------------------------------------ TYPE& operator[](const unsigned int ID) @@ -172,7 +173,7 @@ public: assert((unsigned int)ID < (unsigned int)m_contents_vector.size()); return *(m_contents_vector[ID]); - } + } // operator[] // ------------------------------------------------------------------------ const TYPE& operator[](const unsigned int ID) const @@ -180,13 +181,13 @@ public: assert((unsigned int)ID < (unsigned int)m_contents_vector.size()); return *(m_contents_vector[ID]); - } + } // operator[] // ------------------------------------------------------------------------ void clearWithoutDeleting() { m_contents_vector.clear(); - } + } // clearWithoutDeleting // ------------------------------------------------------------------------ /** @@ -213,9 +214,9 @@ public: #endif return; } - } + } // for n < size() - } + } // remove // ------------------------------------------------------------------------ /** @@ -243,15 +244,15 @@ public: delete pointer; return true; } - } + } // for n < size() return false; - } + } // erase // ------------------------------------------------------------------------ void insertionSort(unsigned int start=0) { - // We should not used unsigned ints here, because if the vector is empty - // j needs to be compared against -1 + // We should not used unsigned ints here, because if the vector is + // empty j needs to be compared against -1 for(int j=(int)start; j<(int)m_contents_vector.size()-1; j++) { if(*(m_contents_vector[j])<*(m_contents_vector[j+1])) continue; @@ -272,7 +273,9 @@ public: }; // class ptrVector -#define for_in( VAR, VECTOR ) for (int _foreach_i = 0; VAR = (_foreach_i < VECTOR.size() ? VECTOR.get(_foreach_i) : NULL), _foreach_i < VECTOR.size(); _foreach_i++) +#define for_in( VAR, VECTOR ) for (int _foreach_i = 0; \ + VAR = (_foreach_i < VECTOR.size() ? VECTOR.get(_foreach_i) : NULL),\ + _foreach_i < VECTOR.size(); _foreach_i++) #endif