Revision: 2787 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2787&view=rev Author: ulteq Date: 2012-06-06 22:18:45 +0000 (Wed, 06 Jun 2012) Log Message: ----------- -Cleanup: materialmapping_t now class member
Modified Paths: -------------- trunk/source/main/gfx/MaterialFunctionMapper.cpp trunk/source/main/gfx/MaterialFunctionMapper.h trunk/source/main/physics/input_output/SerializedRig.cpp Modified: trunk/source/main/gfx/MaterialFunctionMapper.cpp =================================================================== --- trunk/source/main/gfx/MaterialFunctionMapper.cpp 2012-06-06 22:13:59 UTC (rev 2786) +++ trunk/source/main/gfx/MaterialFunctionMapper.cpp 2012-06-06 22:18:45 UTC (rev 2787) @@ -24,6 +24,8 @@ using namespace Ogre; +int MaterialFunctionMapper::simpleMaterialCounter = 0; + void MaterialFunctionMapper::addMaterial(int flareid, materialmapping_t t) { MaterialPtr m = Ogre::MaterialManager::getSingleton().getByName(t.material); @@ -100,7 +102,6 @@ } } - void MaterialFunctionMapper::replaceMeshMaterials(Ogre::Entity *e) { if (!e) @@ -109,14 +110,14 @@ return; } // this is not nice, but required (its not so much performance relevant ... - for (std::map <int, std::vector<materialmapping_t> >::iterator mfb=materialBindings.begin();mfb!=materialBindings.end();mfb++) + for (std::map <int, std::vector<materialmapping_t> >::iterator mfb = materialBindings.begin(); mfb!=materialBindings.end(); mfb++) { - for (std::vector<materialmapping_t>::iterator mm=mfb->second.begin();mm!=mfb->second.end();mm++) + for (std::vector<materialmapping_t>::iterator mm = mfb->second.begin(); mm != mfb->second.end(); mm++) { MeshPtr m = e->getMesh(); if (!m.isNull()) { - for (int n=0; n<(int)m->getNumSubMeshes();n++) + for (int n=0; n < (int)m->getNumSubMeshes(); n++) { SubMesh *sm = m->getSubMesh(n); if (sm->getMaterialName() == mm->originalmaterial) @@ -127,7 +128,7 @@ } } - for (int n=0; n<(int)e->getNumSubEntities();n++) + for (int n=0; n < (int)e->getNumSubEntities(); n++) { SubEntity *subent = e->getSubEntity(n); if (subent->getMaterialName() == mm->originalmaterial) @@ -140,7 +141,6 @@ } } -int MaterialFunctionMapper::simpleMaterialCounter = 0; void MaterialFunctionMapper::replaceSimpleMeshMaterials(Ogre::Entity *e, Ogre::ColourValue c) { if (!e) @@ -163,14 +163,14 @@ MeshPtr m = e->getMesh(); if (!m.isNull()) { - for (int n=0; n<(int)m->getNumSubMeshes();n++) + for (int n=0; n < (int)m->getNumSubMeshes(); n++) { SubMesh *sm = m->getSubMesh(n); sm->setMaterialName(newMatName); } } - for (int n=0; n<(int)e->getNumSubEntities();n++) + for (int n=0; n < (int)e->getNumSubEntities(); n++) { SubEntity *subent = e->getSubEntity(n); subent->setMaterialName(newMatName); Modified: trunk/source/main/gfx/MaterialFunctionMapper.h =================================================================== --- trunk/source/main/gfx/MaterialFunctionMapper.h 2012-06-06 22:13:59 UTC (rev 2786) +++ trunk/source/main/gfx/MaterialFunctionMapper.h 2012-06-06 22:18:45 UTC (rev 2787) @@ -17,29 +17,29 @@ You should have received a copy of the GNU General Public License along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>. */ +#ifndef __MaterialFunctionMapper_H_ +#define __MaterialFunctionMapper_H_ -#ifndef __MATERIALTRUCKMAPPING_H_ -#define __MATERIALTRUCKMAPPING_H_ - #include "RoRPrerequisites.h" -typedef struct -{ - Ogre::ColourValue emissiveColour; - Ogre::String material; - Ogre::String originalmaterial; - bool laststate; - int type; -} materialmapping_t; - class MaterialFunctionMapper : public ZeroedMemoryAllocator { public: + typedef struct materialmapping_t + { + Ogre::ColourValue emissiveColour; + Ogre::String material; + Ogre::String originalmaterial; + bool laststate; + int type; + } materialmapping_t; + void addMaterial(int flareid, materialmapping_t t); void toggleFunction(int flareid, bool enabled); // this function searches and replaces materials in meshes void replaceMeshMaterials(Ogre::Entity *e); + static void replaceSimpleMeshMaterials(Ogre::Entity *e, Ogre::ColourValue c = Ogre::ColourValue::White); private: @@ -48,4 +48,4 @@ std::map <int, std::vector<materialmapping_t> > materialBindings; }; -#endif // __MATERIALTRUCKMAPPING_H_ +#endif // __MaterialFunctionMapper_H_ Modified: trunk/source/main/physics/input_output/SerializedRig.cpp =================================================================== --- trunk/source/main/physics/input_output/SerializedRig.cpp 2012-06-06 22:13:59 UTC (rev 2786) +++ trunk/source/main/physics/input_output/SerializedRig.cpp 2012-06-06 22:18:45 UTC (rev 2787) @@ -37,6 +37,7 @@ #include "InputEngine.h" #include "JSON.h" #include "MaterialReplacer.h" +#include "MaterialFunctionMapper.h" #include "MeshObject.h" #include "RoRFrameListener.h" #include "RoRVersion.h" @@ -1918,7 +1919,7 @@ if (!triggerblocker && !triggerblocker_inverted && !hooktoggle) { // this is no Trigger-Blocker, make the full check - if ((triggershort < 1 || triggershort > MAX_COMMANDS) || ((triggerlong < 1 || triggerlong > MAX_COMMANDS) && triggerlong !=-1 && triggerlong !=0)) + if ((triggershort < 1 || triggershort > MAX_COMMANDS) || ((triggerlong < 1 || triggerlong > MAX_COMMANDS) && triggerlong != -1 && triggerlong != 0)) { parser_warning(c, "Error: Wrong command-eventnumber (Triggers). Trigger deactivated.", PARSER_ERROR); continue; @@ -2891,11 +2892,11 @@ if (n > 14) commandCoupling = PARSEREAL(args[14]); } - //verify array limits so we dont overflow + //verify array limits so we don't overflow if (keys >= MAX_COMMANDS || keyl >= MAX_COMMANDS) { - parser_warning(c, "Command key invalid", PARSER_ERROR); - continue; + parser_warning(c, "Command key invalid", PARSER_ERROR); + continue; } int htype=BEAM_HYDRO; @@ -4526,7 +4527,7 @@ //clone the material MaterialPtr newmat = mat->clone(newMaterialName); //create structes and add - materialmapping_t t; + MaterialFunctionMapper::materialmapping_t t; t.originalmaterial = materialName; t.material = newMaterialName; t.type=0; 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