From 2db419a1e0c5b9f51f3b5a20542cdb5a7d6fa479 Mon Sep 17 00:00:00 2001 From: erihel Date: Tue, 25 Sep 2012 18:26:16 +0200 Subject: * Building should work now without 'ground not flat' message --- src/graphics/engine/terrain.cpp | 12 ++++++------ src/graphics/engine/terrain.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/graphics/engine') diff --git a/src/graphics/engine/terrain.cpp b/src/graphics/engine/terrain.cpp index d70ba0c..d2ddecc 100644 --- a/src/graphics/engine/terrain.cpp +++ b/src/graphics/engine/terrain.cpp @@ -1716,22 +1716,22 @@ float CTerrain::GetFlatZoneRadius(Math::Vector center, float max) return 0.0f; float ref = GetFloorLevel(center, true); - + Math::Point c(center.x, center.z); float radius = 1.0f; + while (radius <= max) { angle = 0.0f; int nb = static_cast(2.0f*Math::PI*radius); if (nb < 8) nb = 8; + Math::Point p (center.x+radius, center.z); for (int i = 0; i < nb; i++) { - Math::Point c(center.x, center.z); - Math::Point p (center.x+radius, center.z); - p = Math::RotatePoint(c, angle, p); + Math::Point result = Math::RotatePoint(c, angle, p); Math::Vector pos; - pos.x = p.x; - pos.z = p.y; + pos.x = result.x; + pos.z = result.y; float h = GetFloorLevel(pos, true); if ( fabs(h-ref) > 1.0f ) return radius; diff --git a/src/graphics/engine/terrain.h b/src/graphics/engine/terrain.h index b83bfc8..3012e62 100644 --- a/src/graphics/engine/terrain.h +++ b/src/graphics/engine/terrain.h @@ -37,7 +37,7 @@ class CWater; //! Limit of slope considered a flat piece of land -const short TERRAIN_FLATLIMIT = (5.0f*Math::PI/180.0f); +const float TERRAIN_FLATLIMIT = (5.0f*Math::PI/180.0f); /** -- cgit v1.2.3-1-g7c22