Revision: 2552 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2552&view=rev Author: ulteq Date: 2012-05-14 05:48:33 +0000 (Mon, 14 May 2012) Log Message: ----------- -Bugfix: fixes #939
Modified Paths: -------------- trunk/source/main/physics/Beam.cpp trunk/source/main/physics/Beam.h Modified: trunk/source/main/physics/Beam.cpp =================================================================== --- trunk/source/main/physics/Beam.cpp 2012-05-13 12:31:08 UTC (rev 2551) +++ trunk/source/main/physics/Beam.cpp 2012-05-14 05:48:33 UTC (rev 2552) @@ -1353,8 +1353,21 @@ { if (!withLocked) return totalmass; // already computed in calc_masses2 + float mass = 0.0f; + + std::list<Beam*> linkedBeams = getAllLinkedBeams(); + + for (std::list<Beam*>::iterator it = linkedBeams.begin(); it != linkedBeams.end(); ++it) + mass += dynamic_cast<Beam*>(*it)->totalmass; + + return mass; +} + +std::list<Beam*> Beam::getAllLinkedBeams() +{ + std::list<Beam*> result; + bool found = true; - float mass = 0.0f; std::map< Beam*, bool> lookup_table; std::pair<std::map< Beam*, bool>::iterator, bool> ret; @@ -1376,13 +1389,13 @@ found = found || ret.second; } } - mass += it_beam->first->totalmass; it_beam->second = true; + result.push_back(it_beam->first); } } } - return mass; + return result; } int Beam::getWheelNodeCount() @@ -4253,7 +4266,7 @@ } } -void Beam::showSkeleton(bool meshes, bool newMode) +void Beam::showSkeleton(bool meshes, bool newMode, bool linked) { if(lockSkeletonchange) return; @@ -4334,16 +4347,21 @@ if (it->beam->disabled) it->beam->mSceneNode->detachAllObjects(); - for(std::vector<hook_t>::iterator it=hooks.begin(); it!=hooks.end(); it++) - if (it->lockTruck && it->lockTruck->getTruckName() != getTruckName()) - it->lockTruck->showSkeleton(); + if (linked) + { + // apply to the locked truck + std::list<Beam*> linkedBeams = getAllLinkedBeams(); + for (std::list<Beam*>::iterator it = linkedBeams.begin(); it != linkedBeams.end(); ++it) + dynamic_cast<Beam*>(*it)->showSkeleton(meshes, newMode , false); + } + lockSkeletonchange=false; TRIGGER_EVENT(SE_TRUCK_SKELETON_TOGGLE, trucknum); } -void Beam::hideSkeleton(bool newMode) +void Beam::hideSkeleton(bool newMode, bool linked) { if(lockSkeletonchange) return; @@ -4418,10 +4436,15 @@ if (it->beam->disabled) it->beam->mSceneNode->detachAllObjects(); - for(std::vector<hook_t>::iterator it=hooks.begin(); it!=hooks.end(); it++) - if (it->lockTruck && it->lockTruck->getTruckName() != getTruckName()) - it->lockTruck->hideSkeleton(); + if (linked) + { + // apply to the locked truck + std::list<Beam*> linkedBeams = getAllLinkedBeams(); + for (std::list<Beam*>::iterator it = linkedBeams.begin(); it != linkedBeams.end(); ++it) + dynamic_cast<Beam*>(*it)->showSkeleton(newMode , false); + } + lockSkeletonchange=false; } @@ -4503,7 +4526,7 @@ } } -void Beam::setMeshVisibility(bool visible) +void Beam::setMeshVisibility(bool visible, bool linked) { int i=0; for(i=0;i<free_prop;i++) @@ -4528,10 +4551,14 @@ if(cabMesh) cabNode->setVisible(visible); meshesVisible = visible; - // apply to the locked truck - for(std::vector<hook_t>::iterator it=hooks.begin(); it!=hooks.end(); it++) - if (it->lockTruck && it->lockTruck->getTruckName() != getTruckName()) - it->lockTruck->setMeshVisibility(visible); + if (linked) + { + // apply to the locked truck + std::list<Beam*> linkedBeams = getAllLinkedBeams(); + + for (std::list<Beam*>::iterator it = linkedBeams.begin(); it != linkedBeams.end(); ++it) + dynamic_cast<Beam*>(*it)->setMeshVisibility(visible, false); + } } void Beam::cabFade(float amount) Modified: trunk/source/main/physics/Beam.h =================================================================== --- trunk/source/main/physics/Beam.h 2012-05-13 12:31:08 UTC (rev 2551) +++ trunk/source/main/physics/Beam.h 2012-05-14 05:48:33 UTC (rev 2552) @@ -148,8 +148,8 @@ //v=0: full detail //v=1: no beams void setDetailLevel(int v); - void showSkeleton(bool meshes=true, bool newMode=false); - void hideSkeleton(bool newMode=false); + void showSkeleton(bool meshes=true, bool newMode=false, bool linked=true); + void hideSkeleton(bool newMode=false, bool linked=true); void resetAutopilot(); void disconnectAutopilot(); void scaleTruck(float value); @@ -287,8 +287,11 @@ Ogre::String realtruckfilename; + /* + *@return Returns a list of all connected (hooked) beams + */ + std::list<Beam*> getAllLinkedBeams(); - // this must be in the header as the network stuff is using it... bool getBrakeLightVisible(); @@ -317,7 +320,7 @@ bool abs_state; float abs_timer; - void setMeshVisibility(bool visible); + void setMeshVisibility(bool visible, bool linked=true); bool meshesVisible; bool inRange(float num, float min, float max); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Rigsofrods-devel mailing list Rigsofrods-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel