Revision: 2717 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2717&view=rev Author: ulteq Date: 2012-05-26 23:39:12 +0000 (Sat, 26 May 2012) Log Message: ----------- wip
Modified Paths: -------------- trunk/source/main/gameplay/RoRFrameListener.cpp trunk/source/main/gameplay/autopilot.h trunk/source/main/gui/gui_mp.cpp trunk/source/main/gui/gui_mp.h trunk/source/main/network/network.h trunk/source/main/terrain/TerrainObjectManager.cpp trunk/source/main/terrain/TerrainObjectManager.h Modified: trunk/source/main/gameplay/RoRFrameListener.cpp =================================================================== --- trunk/source/main/gameplay/RoRFrameListener.cpp 2012-05-26 23:16:21 UTC (rev 2716) +++ trunk/source/main/gameplay/RoRFrameListener.cpp 2012-05-26 23:39:12 UTC (rev 2717) @@ -51,6 +51,7 @@ #include "GlowMaterialListener.h" #include "hdrlistener.h" #include "Heathaze.h" +#include "IHeightFinder.h" #include "InputEngine.h" #include "IWater.h" #include "language.h" @@ -61,7 +62,6 @@ #include "OverlayWrapper.h" #include "PlayerColours.h" #include "PreviewRenderer.h" -#include "ProceduralManager.h" #include "Replay.h" #include "RigsOfRods.h" #include "Road.h" @@ -96,19 +96,6 @@ #include "MapEntity.h" #endif //USE_MYGUI -#include "IHeightFinder.h" - -#include "ResourceBuffer.h" - -#ifdef USE_PAGED -#include "BatchPage.h" -#include "GrassLoader.h" -#include "ImpostorPage.h" -#include "PagedGeometry.h" -#include "TreeLoader2D.h" -#include "TreeLoader3D.h" -#endif //USE_PAGED - #ifdef USE_MPLATFORM #include "mplatform_fd.h" #endif //USE_MPLATFORM @@ -1005,7 +992,7 @@ LoadingWindow::getSingleton().hide(); #ifdef USE_SOCKETW - new GUI_Multiplayer(net, cam); + new GUI_Multiplayer(net); GUI_Multiplayer::getSingleton().update(); #endif //USE_SOCKETW @@ -1346,7 +1333,7 @@ // add some more data into the image - AdvancedScreen *as = new AdvancedScreen(mWindow, tmpfn); + AdvancedScreen *as = new AdvancedScreen(globalEnvironment->ogreRenderWindow, tmpfn); as->addData("terrain_Name", loadedTerrain); as->addData("terrain_ModHash", terrainModHash); as->addData("terrain_FileHash", terrainFileHash); @@ -1371,15 +1358,15 @@ as->addData("Camera_Mode", CameraManager::singletonExists() ? TOSTRING(CameraManager::getSingleton().getCameraBehavior()) : "None"); as->addData("Camera_Position", TOSTRING(globalEnvironment->ogreCamera->getPosition())); - const RenderTarget::FrameStats& stats = mWindow->getStatistics(); + const RenderTarget::FrameStats& stats = globalEnvironment->ogreRenderWindow->getStatistics(); as->addData("AVGFPS", TOSTRING(stats.avgFPS)); as->write(); delete(as); } else { - mWindow->update(); - mWindow->writeContentsToFile(tmpfn); + globalEnvironment->ogreRenderWindow->update(); + globalEnvironment->ogreRenderWindow->writeContentsToFile(tmpfn); } #ifdef USE_MYGUI @@ -1500,21 +1487,21 @@ if (INPUTENGINE.getEventBoolValueBounce(EV_COMMON_FULLSCREEN_TOGGLE, 2.0f)) { static int org_width = -1, org_height = -1; - int width = mWindow->getWidth(); - int height = mWindow->getHeight(); + int width = globalEnvironment->ogreRenderWindow->getWidth(); + int height = globalEnvironment->ogreRenderWindow->getHeight(); if (org_width == -1) org_width = width; if (org_height == -1) org_height = height; - bool mode = mWindow->isFullScreen(); + bool mode = globalEnvironment->ogreRenderWindow->isFullScreen(); if (!mode) { - mWindow->setFullscreen(true, org_width, org_height); + globalEnvironment->ogreRenderWindow->setFullscreen(true, org_width, org_height); LOG(" ** switched to fullscreen: "+TOSTRING(width)+"x"+TOSTRING(height)); } else { - mWindow->setFullscreen(false, 640, 480); - mWindow->setFullscreen(false, org_width, org_height); + globalEnvironment->ogreRenderWindow->setFullscreen(false, 640, 480); + globalEnvironment->ogreRenderWindow->setFullscreen(false, org_width, org_height); LOG(" ** switched to windowed mode: "); } } @@ -2725,10 +2712,10 @@ } //update window - if (!mWindow->isAutoUpdated()) + if (!globalEnvironment->ogreRenderWindow->isAutoUpdated()) { if (dirty) - mWindow->update(); + globalEnvironment->ogreRenderWindow->update(); else sleepMilliSeconds(10); } @@ -3145,7 +3132,7 @@ if (dt==0) return true; if (dt>1.0/20.0) dt=1.0/20.0; rtime+=dt; //real time - if (mWindow->isClosed()) + if (globalEnvironment->ogreRenderWindow->isClosed()) return false; // update GUI Modified: trunk/source/main/gameplay/autopilot.h =================================================================== --- trunk/source/main/gameplay/autopilot.h 2012-05-26 23:16:21 UTC (rev 2716) +++ trunk/source/main/gameplay/autopilot.h 2012-05-26 23:39:12 UTC (rev 2717) @@ -56,7 +56,6 @@ void getRadioFix(TerrainObjectManager::localizer_t *localizers, int free_localizer, float *vdev, float *hdev); - private: int mode_heading; Modified: trunk/source/main/gui/gui_mp.cpp =================================================================== --- trunk/source/main/gui/gui_mp.cpp 2012-05-26 23:16:21 UTC (rev 2716) +++ trunk/source/main/gui/gui_mp.cpp 2012-05-26 23:39:12 UTC (rev 2717) @@ -24,17 +24,15 @@ #include "gui_mp.h" #include "BeamFactory.h" -#include "PlayerColours.h" -#include "RoRFrameListener.h" #include "gui_manager.h" #include "language.h" #include "network.h" +#include "PlayerColours.h" using namespace Ogre; -GUI_Multiplayer::GUI_Multiplayer(Network *_net, Camera *cam) : +GUI_Multiplayer::GUI_Multiplayer(Network *_net) : net(_net) - , mCamera(cam) , clients(0) , lineheight(16) , msgwin(0) @@ -356,10 +354,10 @@ int height = lineheight * (slotid + 1); mpPanel->setSize(sidebarWidth, height); - if(globalEnvironment->frameListener && globalEnvironment->frameListener->getNetQuality(true) != 0) + if(globalEnvironment->frameListener && globalEnvironment-network>getNetQuality(true) != 0) { netmsgwin->setVisible(true); - } else if(globalEnvironment->frameListener && globalEnvironment->frameListener->getNetQuality(true) == 0) + } else if(globalEnvironment->frameListener && globalEnvironment-network>getNetQuality(true) == 0) { netmsgwin->setVisible(false); } Modified: trunk/source/main/gui/gui_mp.h =================================================================== --- trunk/source/main/gui/gui_mp.h 2012-05-26 23:16:21 UTC (rev 2716) +++ trunk/source/main/gui/gui_mp.h 2012-05-26 23:39:12 UTC (rev 2717) @@ -18,12 +18,11 @@ along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>. */ // created by Thomas Fischer thomas{AT}thomasfischer{DOT}biz, 18th of July 2010 - #ifdef USE_MYGUI #ifdef USE_SOCKETW -#ifndef GUI_MP_H__ -#define GUI_MP_H__ +#ifndef __GUI_MP_H_ +#define __GUI_MP_H_ #include "RoRPrerequisites.h" @@ -35,12 +34,14 @@ class GUI_Multiplayer : public RoRSingletonNoCreation< GUI_Multiplayer > { public: - GUI_Multiplayer(Network *net, Ogre::Camera *mCamera); + + GUI_Multiplayer(Network *net); ~GUI_Multiplayer(); int update(); void setVisible(bool value); bool getVisible(); + protected: typedef struct player_row_t { @@ -68,16 +69,13 @@ void updateSlot(player_row_t *row, user_info_t *c, bool self); - Ogre::Camera *mCamera; int lineheight; client_t *clients; static const int sidebarWidth = 250; - }; -#endif //GUI_MP_H__ +#endif // __GUI_MP_H_ #endif // USE_SOCKETW #endif // USE_MYGUI - Modified: trunk/source/main/network/network.h =================================================================== --- trunk/source/main/network/network.h 2012-05-26 23:16:21 UTC (rev 2716) +++ trunk/source/main/network/network.h 2012-05-26 23:39:12 UTC (rev 2717) @@ -51,7 +51,6 @@ void receivethreadstart(); Ogre::UTFString getNickname(bool colour=false); - bool getNetQualityChanged(); char *getTerrainName() { return server_settings.terrain; }; client_t *getClientInfo(unsigned int uid); int getClientInfos(client_t c[MAX_PEERS]); @@ -104,11 +103,13 @@ Ogre::UTFString getUserChatName(client_t *c); // mutex'ed data + bool net_quality_changed; int net_quality; - bool net_quality_changed; + pthread_mutex_t mutex_data; + + bool getNetQualityChanged(); + int getNetQuality(bool ack=false); void setNetQuality(int q); - int getNetQuality(bool ack=false); - pthread_mutex_t mutex_data; }; #endif // __Network_H_ Modified: trunk/source/main/terrain/TerrainObjectManager.cpp =================================================================== --- trunk/source/main/terrain/TerrainObjectManager.cpp 2012-05-26 23:16:21 UTC (rev 2716) +++ trunk/source/main/terrain/TerrainObjectManager.cpp 2012-05-26 23:39:12 UTC (rev 2717) @@ -21,13 +21,34 @@ #include "BeamFactory.h" #include "CameraManager.h" +#include "language.h" +#include "LoadingWindow.h" +#include "Ogre.h" +#include "ProceduralManager.h" #include "RoRFrameListener.h" #include "SkyManager.h" +#ifdef USE_PAGED +#include "BatchPage.h" +#include "GrassLoader.h" +#include "ImpostorPage.h" +#include "PagedGeometry.h" +#include "TreeLoader2D.h" +#include "TreeLoader3D.h" +#endif //USE_PAGED + +#ifdef USE_PAGED +namespace Forests +{ + class PagedGeometry; + class TreeLoader2D; +} +#endif //USE_PAGED + using namespace Ogre; TerrainObjectManager::TerrainObjectManager(TerrainManager *terrainManager) : -terrainManager(terrainManager) + terrainManager(terrainManager) { } @@ -36,13 +57,14 @@ } -void TerrainObjectManager::loadObjectConfigFile( Ogre::String filename ) +void TerrainObjectManager::loadObjectConfigFile(Ogre::String odefname) { +#if 0 //prepare for baking SceneNode *bakeNode=globalEnvironment->ogreSceneManager->getRootSceneNode()->createChildSceneNode(); #ifdef USE_PAGED - treeLoader = 0; + Forests::TreeLoader2D *treeLoader = 0; Entity *curTree = 0; String treename = ""; #endif @@ -52,7 +74,12 @@ int r2oldmode = 0; int lastprogress = -1; bool proroad = false; + + String odefgroup = ResourceGroupManager::getSingleton().findGroupContainingResource(odefname); + DataStreamPtr ds=ResourceGroupManager::getSingleton().openResource(odefname, odefgroup); + long line = 0; + while (!ds->eof()) { int progress = ((float)(ds->tell()) / (float)(ds->size())) * 100.0f; @@ -79,7 +106,7 @@ { long amount = Collisions::MAX_COLLISION_TRIS; sscanf(line, "collision-tris %ld", &amount); - collisions->resizeMemory(amount); + globalEnvironment->collisions->resizeMemory(amount); } if (!strncmp(line,"grid", 4)) @@ -167,7 +194,7 @@ } if (!strncmp("landuse-config", line, 14)) { - collisions->setupLandUse(line+15); + globalEnvironment->collisions->setupLandUse(line+15); continue; } if (!strncmp("gravity", line, 7)) @@ -250,9 +277,9 @@ if (gridspacing > 0) { // grid style - for(float x=0; x < mapsizex; x += gridspacing) + for (float x=0; x < mapsizex; x += gridspacing) { - for(float z=0; z < mapsizez; z += gridspacing) + for (float z=0; z < mapsizez; z += gridspacing) { float density = densityMap->_getDensityAt_Unfiltered(x, z, bounds); if (density < 0.8f) continue; @@ -264,9 +291,9 @@ treeLoader->addTree(curTree, pos, Degree(yaw), (Ogre::Real)scale); if (strlen(treeCollmesh)) { - pos.y = hfinder->getHeightAt(pos.x, pos.z); + pos.y = globalEnvironment->terrainManager->getHeightFinder()->getHeightAt(pos.x, pos.z); scale *= 0.1f; - collisions->addCollisionMesh(String(treeCollmesh), pos, Quaternion(Degree(yaw), Vector3::UNIT_Y), Vector3(scale, scale, scale)); + globalEnvironment->collisions->addCollisionMesh(String(treeCollmesh), pos, Quaternion(Degree(yaw), Vector3::UNIT_Y), Vector3(scale, scale, scale)); } } } @@ -280,9 +307,9 @@ } float hd = highdens; // normal style, random - for(float x=0; x < mapsizex; x += gridsize) + for (float x=0; x < mapsizex; x += gridsize) { - for(float z=0; z < mapsizez; z += gridsize) + for (float z=0; z < mapsizez; z += gridsize) { if (highdens < 0) hd = Math::RangeRandom(0, -highdens); float density = densityMap->_getDensityAt_Unfiltered(x, z, bounds); @@ -298,8 +325,8 @@ treeLoader->addTree(curTree, pos, Degree(yaw), (Ogre::Real)scale); if (strlen(treeCollmesh)) { - pos.y = hfinder->getHeightAt(pos.x, pos.z); - collisions->addCollisionMesh(String(treeCollmesh),pos, Quaternion(Degree(yaw), Vector3::UNIT_Y), Vector3(scale, scale, scale)); + pos.y = globalEnvironment->terrainManager->getHeightFinder()->getHeightAt(pos.x, pos.z); + globalEnvironment->collisions->addCollisionMesh(String(treeCollmesh),pos, Quaternion(Degree(yaw), Vector3::UNIT_Y), Vector3(scale, scale, scale)); } } } @@ -601,10 +628,12 @@ LOG("error while baking roads. ignoring."); } +#endif } void TerrainObjectManager::unloadObject(const char* instancename) { +#if 0 if (loadedObjects.find(std::string(instancename)) == loadedObjects.end()) { LOG("unable to unload object: " + std::string(instancename)); @@ -620,34 +649,36 @@ // unload any collision tris if (obj.collTris.size() > 0) { - for(std::vector<int>::iterator it = obj.collTris.begin(); it != obj.collTris.end(); it++) + for (std::vector<int>::iterator it = obj.collTris.begin(); it != obj.collTris.end(); it++) { - collisions->removeCollisionTri(*it); + globalEnvironment->collisions->removeCollisionTri(*it); } } // and any collision boxes if (obj.collBoxes.size() > 0) { - for(std::vector<int>::iterator it = obj.collBoxes.begin(); it != obj.collBoxes.end(); it++) + for (std::vector<int>::iterator it = obj.collBoxes.begin(); it != obj.collBoxes.end(); it++) { - collisions->removeCollisionBox(*it); + globalEnvironment->collisions->removeCollisionBox(*it); } } obj.sceneNode->detachAllObjects(); obj.sceneNode->setVisible(false); obj.enabled = false; +#endif } void TerrainObjectManager::loadObject(const char* name, float px, float py, float pz, float rx, float ry, float rz, SceneNode * bakeNode, const char* instancename, bool enable_collisions, int scripthandler, const char *type, bool uniquifyMaterial) { +#if 0 ScopeLog log("object_"+String(name)); if (type && !strcmp(type, "grid")) { // some fast grid object hacks :) - for(int x=0;x<500;x+=50) - for(int z=0;z<500;z+=50) + for (int x=0;x<500;x+=50) + for (int z=0;z<500;z+=50) loadObject(name, px+x, py, pz+z, rx, ry, rz, bakeNode, 0, enable_collisions, scripthandler, 0); return; } @@ -755,7 +786,7 @@ if (mo && uniquifyMaterial && instancename) { - for(unsigned int i = 0; i < mo->getEntity()->getNumSubEntities(); i++) + for (unsigned int i = 0; i < mo->getEntity()->getNumSubEntities(); i++) { SubEntity *se = mo->getEntity()->getSubEntity(i); String matname = se->getMaterialName(); @@ -774,7 +805,7 @@ bool rotating=false; bool classic_ref=true; // everything is of concrete by default - ground_model_t *gm = collisions->getGroundModelByString("concrete"); + ground_model_t *gm = globalEnvironment->collisions->getGroundModelByString("concrete"); char eventname[256]; eventname[0]=0; while (!ds->eof()) @@ -846,7 +877,7 @@ event_filter=EVENT_NONE; eventname[0]=0; collmesh[0]=0; - gm = collisions->getGroundModelByString("concrete"); + gm = globalEnvironment->collisions->getGroundModelByString("concrete"); continue; }; if (!strncmp("boxcoords", ptline, 9)) @@ -879,13 +910,13 @@ if (!strncmp("frictionconfig", ptline, 14) && strlen(ptline) > 15) { // load a custom friction config - collisions->loadGroundModelsConfigFile(String(ptline + 15)); + globalEnvironment->collisions->loadGroundModelsConfigFile(String(ptline + 15)); continue; } if ((!strncmp("stdfriction", ptline, 11) || !strncmp("usefriction", ptline, 11)) && strlen(ptline) > 12) { String modelName = String(ptline + 12); - gm = collisions->getGroundModelByString(modelName); + gm = globalEnvironment->collisions->getGroundModelByString(modelName); continue; } if (!strcmp("virtual", ptline)) {virt=true;continue;}; @@ -917,14 +948,14 @@ { if (enable_collisions) { - int boxnum = collisions->addCollisionBox(tenode, rotating, virt,px,py,pz,rx,ry,rz,lx,hx,ly,hy,lz,hz,srx,sry,srz,eventname, instancename, forcecam, Vector3(fcx, fcy, fcz), scx, scy, scz, drx, dry, drz, event_filter, scripthandler); + int boxnum = globalEnvironment->collisions->addCollisionBox(tenode, rotating, virt,px,py,pz,rx,ry,rz,lx,hx,ly,hy,lz,hz,srx,sry,srz,eventname, instancename, forcecam, Vector3(fcx, fcy, fcz), scx, scy, scz, drx, dry, drz, event_filter, scripthandler); obj->collBoxes.push_back((boxnum)); } continue; } if (!strcmp("endmesh", ptline)) { - collisions->addCollisionMesh(collmesh, Vector3(px,py,pz), tenode->getOrientation(), Vector3(scx, scy, scz), gm, &(obj->collTris)); + globalEnvironment->collisions->addCollisionMesh(collmesh, Vector3(px,py,pz), tenode->getOrientation(), Vector3(scx, scy, scz), gm, &(obj->collTris)); continue; } @@ -949,7 +980,7 @@ #ifdef USE_ANGELSCRIPT unsigned short affCount = pParticleSys->getNumAffectors(); ParticleAffector* pAff; - for(unsigned short i = 0; i<affCount; ++i) + for (unsigned short i = 0; i<affCount; ++i) { pAff = pParticleSys->getAffector(i); if (pAff->getType()=="ExtinguishableFire") @@ -1137,14 +1168,17 @@ } } #endif //USE_MYGUI +#endif } bool TerrainObjectManager::updateAnimatedObjects(float dt) { - if (animatedObjects.size() == 0) - return true; +#if 0 + if (animatedObjects.size() == 0) return true; + std::vector<animated_object_t>::iterator it; - for(it=animatedObjects.begin(); it!=animatedObjects.end(); it++) + + for (it=animatedObjects.begin(); it!=animatedObjects.end(); it++) { if (it->anim && it->speedfactor != 0) { @@ -1152,5 +1186,6 @@ it->anim->addTime(time); } } +#endif return true; -} \ No newline at end of file +} Modified: trunk/source/main/terrain/TerrainObjectManager.h =================================================================== --- trunk/source/main/terrain/TerrainObjectManager.h 2012-05-26 23:16:21 UTC (rev 2716) +++ trunk/source/main/terrain/TerrainObjectManager.h 2012-05-26 23:39:12 UTC (rev 2717) @@ -29,9 +29,10 @@ TerrainObjectManager(TerrainManager *terrainManager); ~TerrainObjectManager(); - void loadObjectConfigFile(Ogre::String filename); + bool updateAnimatedObjects(float dt); + typedef struct localizer_t { int type; @@ -71,7 +72,6 @@ void loadObject(const char* name, float px, float py, float pz, float rx, float ry, float rz, Ogre::SceneNode * bakeNode, const char* instancename, bool enable_collisions=true, int scripthandler=-1, const char *type=0, bool uniquifyMaterial=false); void unloadObject(const char* name); - bool updateAnimatedObjects(float dt); }; #endif // __TerrainObjectManager_H_ 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