]> git.tdb.fi Git - r2c2.git/commitdiff
Automatically adjust the secondary_axis flag when elevations are changed
authorMikko Rasa <tdb@tdb.fi>
Thu, 21 Nov 2013 23:33:30 +0000 (01:33 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 21 Nov 2013 23:33:30 +0000 (01:33 +0200)
source/libr2c2/terrain.cpp
source/libr2c2/terrain.h

index 5a317747e74f96f57f3b598e934ee2e2773a012e..072a6e5a26b322066e2818873dd6b8b026332b25 100644 (file)
@@ -97,7 +97,7 @@ void Terrain::set_node_elevation(const NodeCoordinates &c, float elev, bool join
                                Tile &tile = tiles[x+y*width];
                                if(tile.nodes[i].elevation==ref)
                                {
-                                       tile.nodes[i].elevation = elev;
+                                       tile.set_node_elevation(i, elev);
                                        signal_tile_changed.emit(x, y);
                                }
                        }
@@ -105,7 +105,7 @@ void Terrain::set_node_elevation(const NodeCoordinates &c, float elev, bool join
        }
        else
        {
-               tiles[c.x+c.y*width].nodes[c.i].elevation = elev;
+               tiles[c.x+c.y*width].set_node_elevation(c.i, elev);
                signal_tile_changed.emit(c.x, c.y);
        }
 }
@@ -186,6 +186,12 @@ Terrain::Tile::Tile():
        secondary_axis(false)
 { }
 
+void Terrain::Tile::set_node_elevation(unsigned i, float e)
+{
+       nodes[i].elevation = e;
+       secondary_axis = ((nodes[1].elevation+nodes[2].elevation) < (nodes[0].elevation+nodes[3].elevation));
+}
+
 void Terrain::Tile::save(list<DataFile::Statement> &st) const
 {
        bool flat = true;
index 837119e00429d916d342db09dfad5c03cd3bb8f5..fb3328e63e9d7acb93eab43e8bb08f165abcc40f 100644 (file)
@@ -69,6 +69,7 @@ public:
 
                Tile();
 
+               void set_node_elevation(unsigned, float);
                void save(std::list<Msp::DataFile::Statement> &) const;
        };