]> git.tdb.fi Git - r2c2.git/commitdiff
Properly round negative elevations
authorMikko Rasa <tdb@tdb.fi>
Fri, 22 Nov 2013 12:43:24 +0000 (14:43 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 22 Nov 2013 12:43:24 +0000 (14:43 +0200)
source/libr2c2/terrain.cpp

index e012bc9426e927feaf5733c189899e4ea05208c8..c89d0f8cf20621df2e5befa06f4d57b404c7c1c3 100644 (file)
@@ -1,3 +1,4 @@
+#include <cmath>
 #include <msp/geometry/box.h>
 #include <msp/geometry/transformedshape.h>
 #include "layout.h"
@@ -83,7 +84,7 @@ void Terrain::set_node_elevation(const NodeCoordinates &c, float elev, bool join
                throw out_of_range("Terrain::set_node_elevation");
 
        float eg = type.get_elevation_granularity();
-       elev = int(elev/eg+0.5)*eg;
+       elev = floor(elev/eg+0.5)*eg;
 
        if(joined)
        {