Revision: 2773
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2773&view=rev
Author:   rorthomas
Date:     2012-06-02 20:04:00 +0000 (Sat, 02 Jun 2012)
Log Message:
-----------
collisions working again

Modified Paths:
--------------
    trunk/source/main/gameplay/Landusemap.cpp
    trunk/source/main/gameplay/Landusemap.h
    trunk/source/main/gameplay/RoRFrameListener.cpp
    trunk/source/main/gfx/Water.cpp
    trunk/source/main/physics/collision/Collisions.cpp
    trunk/source/main/terrain/TerrainGeometryManager.cpp
    trunk/source/main/terrain/TerrainGeometryManager.h
    trunk/source/main/terrain/TerrainManager.cpp
    trunk/source/main/terrain/TerrainManager.h
    trunk/source/main/terrain/map/MapTextureCreator.cpp

Modified: trunk/source/main/gameplay/Landusemap.cpp
===================================================================
--- trunk/source/main/gameplay/Landusemap.cpp   2012-06-02 19:36:39 UTC (rev 
2772)
+++ trunk/source/main/gameplay/Landusemap.cpp   2012-06-02 20:04:00 UTC (rev 
2773)
@@ -17,7 +17,6 @@
 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/>.
 */
-#if 0
 #include "Landusemap.h"
 #include "Collisions.h"
 #include <Ogre.h>
@@ -26,9 +25,8 @@
 #include <OgreStringConverter.h>
 #include "Language.h"
 #include "ErrorUtils.h"
-#include ""
+#include "TerrainManager.h"
 
-
 #ifdef USE_PAGED
 #include "PropertyMaps.h"
 #include "PagedGeometry.h"
@@ -42,7 +40,7 @@
          data(0)
        , mapsize(Vector3::ZERO)
 {
-       mapsize = gEnv->terrainManager->getMax();
+       mapsize = gEnv->terrainManager->getMaxTerrainSize();
        loadConfig(configFilename);
 #ifndef USE_PAGED
        LOG("RoR was not compiled with PagedGeometry support. You cannot use 
Landuse maps with it.");
@@ -57,12 +55,13 @@
 ground_model_t *Landusemap::getGroundModelAt(int x, int z)
 {
        if (!data) return 0;
+       Vector3 mapsize = gEnv->terrainManager->getMaxTerrainSize();
 #ifdef USE_PAGED
        // we return the default ground model if we are not anymore in this map
-       if (x < 0 || x >= mapsizex || z < 0 || z >= mapsizez)
+       if (x < 0 || x >= mapsize.x || z < 0 || z >= mapsize.z)
                return default_ground_model;
 
-       return data[x + z * mapsizex];
+       return data[x + z * (int)mapsize.x];
 #else
        return 0;
 #endif // USE_PAGED
@@ -71,6 +70,7 @@
 
 int Landusemap::loadConfig(Ogre::String filename)
 {
+       Vector3 mapsize = gEnv->terrainManager->getMaxTerrainSize();
        std::map<unsigned int, String> usemap;
        int version = 1;
        String textureFilename = "";
@@ -118,9 +118,9 @@
                                if (kname == "texture")
                                        textureFilename = kvalue;
                                else if (kname == "frictionconfig" || kname == 
"loadGroundModelsConfig")
-                                       
coll->loadGroundModelsConfigFile(kvalue);
+                                       
gEnv->collisions->loadGroundModelsConfigFile(kvalue);
                                else if (kname == "defaultuse")
-                                       default_ground_model = 
coll->getGroundModelByString(kvalue);
+                                       default_ground_model = 
gEnv->collisions->getGroundModelByString(kvalue);
                                else if (kname == "version")
                                        version = 
StringConverter::parseInt(kvalue);
 
@@ -142,7 +142,7 @@
        // process the config data and load the buffers finally
        Forests::ColorMap *colourMap = Forests::ColorMap::load(textureFilename, 
Forests::CHANNEL_COLOR);
        colourMap->setFilter(Forests::MAPFILTER_NONE);
-       Ogre::TRect<Ogre::Real> bounds = Forests::TBounds(0, 0, mapsizex, 
mapsizez);
+       Ogre::TRect<Ogre::Real> bounds = Forests::TBounds(0, 0, mapsize.x, 
mapsize.z);
 
        /*
        // debug things below
@@ -156,12 +156,12 @@
        bool bgr = colourMap->getPixelBox().format == PF_A8B8G8R8;
 
        // now allocate the data buffer to hold pointers to ground models
-       data = new ground_model_t*[mapsizex * mapsizez];
+       data = new ground_model_t*[(int)(mapsize.x * mapsize.z)];
        ground_model_t **ptr = data;
        //std::map < String, int > counters;
-       for (int z=0; z<mapsizez; z++)
+       for (int z=0; z<mapsize.z; z++)
        {
-               for (int x=0; x<mapsizex; x++)
+               for (int x=0; x<mapsize.x; x++)
                {
                        unsigned int col = colourMap->getColorAt(x, z, bounds);
                        if (bgr)
@@ -177,11 +177,10 @@
                        //      counters[use]++;
 
                        // store the pointer to the ground model in the data 
slot
-                       *ptr = coll->getGroundModelByString(use);
+                       *ptr = gEnv->collisions->getGroundModelByString(use);
                        ptr++;
                }
        }
 #endif // USE_PAGED
        return 0;
 }
-#endif
\ No newline at end of file

Modified: trunk/source/main/gameplay/Landusemap.h
===================================================================
--- trunk/source/main/gameplay/Landusemap.h     2012-06-02 19:36:39 UTC (rev 
2772)
+++ trunk/source/main/gameplay/Landusemap.h     2012-06-02 20:04:00 UTC (rev 
2773)
@@ -18,7 +18,6 @@
 along with Rigs of Rods.  If not, see <http://www.gnu.org/licenses/>.
 */
 //created by thomas fischer 23 February 2009
-#if 0
 #ifndef __LandUseMap_H_
 #define __LandUseMap_H_
 
@@ -43,4 +42,3 @@
 };
 
 #endif // __LandUseMap_H_
-#endif
\ No newline at end of file

Modified: trunk/source/main/gameplay/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/gameplay/RoRFrameListener.cpp     2012-06-02 19:36:39 UTC 
(rev 2772)
+++ trunk/source/main/gameplay/RoRFrameListener.cpp     2012-06-02 20:04:00 UTC 
(rev 2773)
@@ -2880,7 +2880,7 @@
        
        if (mtc)
        {
-               Vector3 mapsize = gEnv->terrainManager->getMax();
+               Vector3 mapsize = gEnv->terrainManager->getMaxTerrainSize();
                Vector3 position = Vector3(mapsize.x / 2.0f, 0.0f, mapsize.z / 
2.0f);
                mtc->setMapCenter(position);
                mtc->update();
@@ -3167,7 +3167,7 @@
                                
gEnv->terrainManager->getEnvmap()->update(curr_truck->getPosition(), 
curr_truck);
                        } else
                        {
-                               float height = gEnv->terrainManager->getMax().y;
+                               float height = 
gEnv->terrainManager->getMaxTerrainSize().y;
                                if (gEnv->terrainManager->getHeightFinder())
                                {
                                        height = 
gEnv->terrainManager->getHeightFinder()->getHeightAt(terrainxsize / 2.0f, 
terrainzsize / 2.0f );

Modified: trunk/source/main/gfx/Water.cpp
===================================================================
--- trunk/source/main/gfx/Water.cpp     2012-06-02 19:36:39 UTC (rev 2772)
+++ trunk/source/main/gfx/Water.cpp     2012-06-02 20:04:00 UTC (rev 2773)
@@ -80,9 +80,10 @@
 
 Water::Water(const Ogre::ConfigFile &mTerrainConfig)
 {
+       Vector3 mapsize = gEnv->terrainManager->getMaxTerrainSize();
        vRtt1 = vRtt2 = 0;
        mScale = 1.0f;
-       if (gEnv->terrainManager->getMax().x < 1500)
+       if (mapsize.x < 1500)
                mScale = 1.5f;
        //reading wavefield
        visible=true;
@@ -233,7 +234,7 @@
                mprt=MeshManager::getSingleton().createPlane("ReflectPlane",
                        ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                        waterPlane,
-                       gEnv->terrainManager->getMax().x * 
mScale,gEnv->terrainManager->getMax().z * 
mScale,WAVEREZ,WAVEREZ,true,1,50,50,Vector3::UNIT_Z, 
HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
+                       mapsize.x * mScale,mapsize.z * 
mScale,WAVEREZ,WAVEREZ,true,1,50,50,Vector3::UNIT_Z, 
HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
                pPlaneEnt = gEnv->sceneManager->createEntity( "plane", 
"ReflectPlane" );
                if (mType==WATER_FULL_QUALITY || mType==WATER_FULL_SPEED) 
pPlaneEnt->setMaterialName("Examples/FresnelReflectionRefraction");
                else pPlaneEnt->setMaterialName("Examples/FresnelReflection");
@@ -241,7 +242,7 @@
                //position
                pTestNode = 
gEnv->sceneManager->getRootSceneNode()->createChildSceneNode("WaterPlane");
                pTestNode->attachObject(pPlaneEnt);
-               pTestNode->setPosition( 
Vector3((gEnv->terrainManager->getMax().x * 
mScale)/2,0,(gEnv->terrainManager->getMax().z * mScale)/2) );
+               pTestNode->setPosition( Vector3((mapsize.x * 
mScale)/2,0,(mapsize.z * mScale)/2) );
        }
        else
        {
@@ -251,13 +252,13 @@
                mprt=MeshManager::getSingleton().createPlane("WaterPlane",
                        ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                        waterPlane,
-                       gEnv->terrainManager->getMax().x * 
mScale,gEnv->terrainManager->getMax().z * 
mScale,WAVEREZ,WAVEREZ,true,1,50,50,Vector3::UNIT_Z, 
HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
+                       mapsize.x * mScale,mapsize.z * 
mScale,WAVEREZ,WAVEREZ,true,1,50,50,Vector3::UNIT_Z, 
HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
                pPlaneEnt = gEnv->sceneManager->createEntity( "plane", 
"WaterPlane" );
                pPlaneEnt->setMaterialName("tracks/basicwater");
                //position
                pTestNode = 
gEnv->sceneManager->getRootSceneNode()->createChildSceneNode("WaterPlane");
                pTestNode->attachObject(pPlaneEnt);
-               pTestNode->setPosition( 
Vector3((gEnv->terrainManager->getMax().x * 
mScale)/2,0,(gEnv->terrainManager->getMax().z * mScale)/2) );
+               pTestNode->setPosition( Vector3((mapsize.x * 
mScale)/2,0,(mapsize.z * mScale)/2) );
        }
        //bottom
        bottomPlane.normal = Vector3::UNIT_Y;
@@ -265,13 +266,13 @@
        MeshManager::getSingleton().createPlane("BottomPlane",
                ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                bottomPlane,
-               gEnv->terrainManager->getMax().x * 
mScale,gEnv->terrainManager->getMax().z * 
mScale,1,1,true,1,1,1,Vector3::UNIT_Z);
+               mapsize.x * mScale,mapsize.z * 
mScale,1,1,true,1,1,1,Vector3::UNIT_Z);
        Entity *pE = gEnv->sceneManager->createEntity( "bplane", "BottomPlane" 
);
        pE->setMaterialName("tracks/seabottom");
        //position
        pBottomNode = 
gEnv->sceneManager->getRootSceneNode()->createChildSceneNode("BottomWaterPlane");
        pBottomNode->attachObject(pE);
-       pBottomNode->setPosition( Vector3((gEnv->terrainManager->getMax().x * 
mScale)/2,0,(gEnv->terrainManager->getMax().z * mScale)/2) );
+       pBottomNode->setPosition( Vector3((mapsize.x * mScale)/2,0,(mapsize.z * 
mScale)/2) );
        //setup for waves
        wbuf=mprt->sharedVertexData->vertexBufferBinding->getBuffer(0);
        if (wbuf->getSizeInBytes()==(WAVEREZ+1)*(WAVEREZ+1)*32)
@@ -308,13 +309,14 @@
 
 void Water::moveTo(Camera *cam, float centerheight)
 {
+       Vector3 mapsize = gEnv->terrainManager->getMaxTerrainSize();
        if (pTestNode)
        {
                Vector3 pos=cam->getPosition();
                Vector3 offset=cam->getDirection();
                offset.y=0;
                offset.normalise();
-               pos = pos + offset * gEnv->terrainManager->getMax().x * mScale 
* 0.46666;
+               pos = pos + offset * mapsize.x * mScale * 0.46666;
                pos.y=orgheight - height;
                pos.x=((int)pos.x/60)*60;
                pos.z=((int)pos.z/60)*60;
@@ -333,7 +335,8 @@
        {
                for (pz=0; pz<WAVEREZ+1; pz++)
                {
-                       
wbuffer[(pz*(WAVEREZ+1)+px)*8+1]=getHeightWaves(refpos+Vector3((gEnv->terrainManager->getMax().x
 * mScale)/2-(float)px*(gEnv->terrainManager->getMax().x * mScale)/WAVEREZ, 0, 
(float)pz*(gEnv->terrainManager->getMax().z * 
mScale)/WAVEREZ-(gEnv->terrainManager->getMax().z * mScale)/2));
+                       Vector3 mapsize = 
gEnv->terrainManager->getMaxTerrainSize();
+                       
wbuffer[(pz*(WAVEREZ+1)+px)*8+1]=getHeightWaves(refpos+Vector3((mapsize.x * 
mScale)/2-(float)px*(mapsize.x * mScale)/WAVEREZ, 0, (float)pz*(mapsize.z * 
mScale)/WAVEREZ-(mapsize.z * mScale)/2));
                }
        }
        //normals
@@ -427,10 +430,11 @@
                return height;
 
        // calculate how high the waves should be at this point
-       //  (gEnv->terrainManager->getMax().x * mScale) / 2 = terrain width / 2
-       //  (gEnv->terrainManager->getMax().z * mScale) / 2 = terrain height / 2
+       //  (mapsize.x * mScale) / 2 = terrain width / 2
+       //  (mapsize.z * mScale) / 2 = terrain height / 2
        // calculates the distance to the center of the terrain and dives it 
through 3.000.000
-       float waveheight = (pos - Vector3((gEnv->terrainManager->getMax().x * 
mScale) / 2, height, (gEnv->terrainManager->getMax().z * mScale) / 
2)).squaredLength() / 3000000.0;
+       Vector3 mapsize = gEnv->terrainManager->getMaxTerrainSize();
+       float waveheight = (pos - Vector3((mapsize.x * mScale) / 2, height, 
(mapsize.z * mScale) / 2)).squaredLength() / 3000000.0;
        // we will store the result in this variable, init it with the default 
height
        float result = height;
        // now walk through all the wave trains. One 'train' is one sin/cos set 
that will generate once wave. All the trains together will sum up, so that they 
generate a 'rough' sea
@@ -461,7 +465,8 @@
 
        if (pos.y>height+maxampl) return Vector3::ZERO;
        int i;
-       float waveheight=(pos-Vector3((gEnv->terrainManager->getMax().x * 
mScale)/2, height, (gEnv->terrainManager->getMax().z * 
mScale)/2)).squaredLength()/3000000.0;
+       Vector3 mapsize = gEnv->terrainManager->getMaxTerrainSize();
+       float waveheight=(pos-Vector3((mapsize.x * mScale)/2, height, 
(mapsize.z * mScale)/2)).squaredLength()/3000000.0;
        Vector3 result=Vector3::ZERO;
        for (i=0; i<free_wavetrain; i++)
        {

Modified: trunk/source/main/physics/collision/Collisions.cpp
===================================================================
--- trunk/source/main/physics/collision/Collisions.cpp  2012-06-02 19:36:39 UTC 
(rev 2772)
+++ trunk/source/main/physics/collision/Collisions.cpp  2012-06-02 20:04:00 UTC 
(rev 2773)
@@ -892,7 +892,8 @@
        int refx, refz;
        unsigned int k;
 
-       if (!(refpos->x>0 && refpos->x<gEnv->terrainManager->getMax().x && 
refpos->z>0 && refpos->z<gEnv->terrainManager->getMax().z)) return false;
+       Vector3 mapSize = gEnv->terrainManager->getMaxTerrainSize();
+       if (!(refpos->x>0 && refpos->x<mapSize.x && refpos->z>0 && 
refpos->z<mapSize.z)) return false;
 
        refx=(int)(refpos->x/(float)CELL_SIZE);
        refz=(int)(refpos->z/(float)CELL_SIZE);
@@ -1501,9 +1502,10 @@
                mat->setReceiveShadows(false);
        }
 
-       for (int x=0; x<(int)(gEnv->terrainManager->getMax().x); 
x+=(int)CELL_SIZE)
+       Vector3 mapSize = gEnv->terrainManager->getMaxTerrainSize();
+       for (int x=0; x<(int)(mapSize.x); x+=(int)CELL_SIZE)
        {
-               for (int z=0; z<(int)(gEnv->terrainManager->getMax().z); 
z+=(int)CELL_SIZE)
+               for (int z=0; z<(int)(mapSize.z); z+=(int)CELL_SIZE)
                {
                        int cellx = (int)(x/(float)CELL_SIZE);
                        int cellz = (int)(z/(float)CELL_SIZE);

Modified: trunk/source/main/terrain/TerrainGeometryManager.cpp
===================================================================
--- trunk/source/main/terrain/TerrainGeometryManager.cpp        2012-06-02 
19:36:39 UTC (rev 2772)
+++ trunk/source/main/terrain/TerrainGeometryManager.cpp        2012-06-02 
20:04:00 UTC (rev 2773)
@@ -316,3 +316,8 @@
        }
 }
 
+Ogre::Vector3 TerrainGeometryManager::getMaxTerrainSize()
+{
+       return Vector3(mapsizex, mapsizey, mapsizez);
+}
+

Modified: trunk/source/main/terrain/TerrainGeometryManager.h
===================================================================
--- trunk/source/main/terrain/TerrainGeometryManager.h  2012-06-02 19:36:39 UTC 
(rev 2772)
+++ trunk/source/main/terrain/TerrainGeometryManager.h  2012-06-02 20:04:00 UTC 
(rev 2773)
@@ -59,6 +59,7 @@
                return down;
        }
 
+       Ogre::Vector3 getMaxTerrainSize();
 protected:
 
        Ogre::ConfigFile terrainConfig;
@@ -67,6 +68,7 @@
        TerrainObjectManager *objectManager;
        bool disableCaching;
        bool mTerrainsImported;
+
        int mapsizex, mapsizey, mapsizez, pageSize, terrainSize, worldSize;
        int pageMinX, pageMaxX, pageMinY, pageMaxY;
        int terrainLayers;

Modified: trunk/source/main/terrain/TerrainManager.cpp
===================================================================
--- trunk/source/main/terrain/TerrainManager.cpp        2012-06-02 19:36:39 UTC 
(rev 2772)
+++ trunk/source/main/terrain/TerrainManager.cpp        2012-06-02 20:04:00 UTC 
(rev 2773)
@@ -538,7 +538,7 @@
                        }
                } catch(Exception &e)
                {
-                       LOG("Exception while trying load script");
+                       LOG("Exception while trying load script: " + 
e.getFullDescription());
                }
        }
        
@@ -572,3 +572,10 @@
 {
        object_manager = new TerrainObjectManager(this);
 }
+
+Ogre::Vector3 TerrainManager::getMaxTerrainSize()
+{
+       if(!geometry_manager)
+               return Vector3::ZERO;
+       return geometry_manager->getMaxTerrainSize();
+}

Modified: trunk/source/main/terrain/TerrainManager.h
===================================================================
--- trunk/source/main/terrain/TerrainManager.h  2012-06-02 19:36:39 UTC (rev 
2772)
+++ trunk/source/main/terrain/TerrainManager.h  2012-06-02 20:04:00 UTC (rev 
2773)
@@ -43,7 +43,7 @@
        void setGravity(float value);
        float getGravity() { return gravity; };
 
-       Ogre::Vector3 getMax() { return Ogre::Vector3::ZERO; };
+       Ogre::Vector3 getMaxTerrainSize();
 
        // some getters
        Collisions *getCollisions() { return collisions; };

Modified: trunk/source/main/terrain/map/MapTextureCreator.cpp
===================================================================
--- trunk/source/main/terrain/map/MapTextureCreator.cpp 2012-06-02 19:36:39 UTC 
(rev 2772)
+++ trunk/source/main/terrain/map/MapTextureCreator.cpp 2012-06-02 20:04:00 UTC 
(rev 2773)
@@ -103,7 +103,7 @@
 {
        if ( !mRttTex ) return;
 
-       Vector3 mapSize = gEnv->terrainManager->getMax();
+       Vector3 mapSize = gEnv->terrainManager->getMaxTerrainSize();
        float orthoWindowWidth  = mapSize.x - (mapSize.x - 20.0f) * mMapZoom;
        float orthoWindowHeight = mapSize.z - (mapSize.z - 20.0f) * mMapZoom;
 

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

Reply via email to