Index: experimental/TerrainTest/rampedEllipsoidTechnique.cpp
===================================================================
--- experimental/TerrainTest/rampedEllipsoidTechnique.cpp	(revision 288)
+++ experimental/TerrainTest/rampedEllipsoidTechnique.cpp	(revision 289)
@@ -57,5 +57,5 @@
 	clampValue(Y_endCore, Y_start, Y_end);
 	clampValue(Y_endRamp, Y_start, Y_end);
-	//OSG_NOTIFY( osg::ALWAYS ) << "Y_startRamp:" << Y_startRamp << " Y_startCore:" << Y_startCore << " Y_endCore:" << Y_endCore << " Y_endRamp:" << Y_endRamp << std::endl;
+	OSG_NOTIFY( osg::ALWAYS ) << "Y_startRamp:" << Y_startRamp << " Y_startCore:" << Y_startCore << " Y_endCore:" << Y_endCore << " Y_endRamp:" << Y_endRamp << std::endl;
 
 	// Lon
@@ -69,5 +69,5 @@
 	clampValue(X_endCore, X_start, X_end);
 	clampValue(X_endRamp, X_start, X_end);
-	//OSG_NOTIFY( osg::ALWAYS ) << "X_startRamp:" << X_startRamp << " X_startCore:" << X_startCore << " X_endCore:" << X_endCore << " X_endRamp:" << X_endRamp << std::endl;
+	OSG_NOTIFY( osg::ALWAYS ) << "X_startRamp:" << X_startRamp << " X_startCore:" << X_startCore << " X_endCore:" << X_endCore << " X_endRamp:" << X_endRamp << std::endl;
 
 	// Modify height value of affected vertices in the core ROI
@@ -83,11 +83,12 @@
 			double delta_h = _height - height_org;
 			// preset offset value to max and let every ramp function try to lower it...
-			double destination_height = std::numeric_limits<double>::max();
+			double current_vertex_delta = std::numeric_limits<double>::max();
+			double destination_height = _height;
 
 			// Calculate vertex height according to the region it is in.
-			if( Y_startCore<=y && y<=Y_endCore && X_startCore<=x && x<=X_endCore )	// If vertex is inside core: Apply final height
-			{
-				destination_height = _height;
-			}
+			//if( Y_startCore<=y && y<=Y_endCore && X_startCore<=x && x<=X_endCore )	// If vertex is inside core: Apply final height
+			//{
+			//	destination_height = _height;
+			//}
 			// Startramp
 			if(Y_startRamp<=y && y<=Y_startCore) // Vertex is inside Y start ramp
@@ -95,7 +96,11 @@
 				double delta_s = abs(modificationROI._lat_min-vertex_lat);
 				double gradient = delta_h/deltaLatPerSide;
-				double dest = delta_s*gradient + height_org;
-				if(dest<destination_height)
-					destination_height = dest;			
+				double calculated_height = delta_s*gradient + height_org;
+				double local_test_delta = abs(calculated_height-height_org);
+				if(local_test_delta<current_vertex_delta)
+				{
+					current_vertex_delta = local_test_delta;
+					destination_height = calculated_height;			
+				}
 			}
 			if(X_startRamp<=x && x<=X_startCore)	// Vertex is inside X start ramp
@@ -103,7 +108,11 @@
 				double delta_s = abs(modificationROI._lon_min-vertex_lon);
 				double gradient = delta_h/deltaLonPerSide;
-				double dest = delta_s*gradient + height_org;
-				if(dest<destination_height)
-					destination_height = dest;
+				double calculated_height = delta_s*gradient + height_org;
+				double local_test_delta = abs(calculated_height-height_org);
+				if(local_test_delta<current_vertex_delta)
+				{
+					current_vertex_delta = local_test_delta;
+					destination_height = calculated_height;			
+				}
 			}
 			// End ramp
@@ -112,7 +121,11 @@
 				double delta_s = abs(modificationROI._lat_max-vertex_lat);
 				double gradient = delta_h/deltaLatPerSide;
-				double dest = delta_s*gradient + height_org;
-				if(dest<destination_height)
-					destination_height = dest;
+				double calculated_height = delta_s*gradient + height_org;
+				double local_test_delta = abs(calculated_height-height_org);
+				if(local_test_delta<current_vertex_delta)
+				{
+					current_vertex_delta = local_test_delta;
+					destination_height = calculated_height;			
+				}
 			}
 			if (X_endCore<=x && x<=X_endRamp) // Vertex is inside X end ramp
@@ -120,11 +133,15 @@
 				double delta_s = abs(modificationROI._lon_max-vertex_lon);
 				double gradient = delta_h/deltaLonPerSide;
-				double dest = delta_s*gradient + height_org;
-				if(dest<destination_height)
-					destination_height = dest;
+				double calculated_height = delta_s*gradient + height_org;
+				double local_test_delta = abs(calculated_height-height_org);
+				if(local_test_delta<current_vertex_delta)
+				{
+					current_vertex_delta = local_test_delta;
+					destination_height = calculated_height;			
+				}
 			}
 			
 			// Set height to calculated value
-			//OSG_NOTIFY( osg::ALWAYS ) << "rampedEllipsoidTechnique: destination_height=" << destination_height << std::endl;
+			OSG_NOTIFY( osg::ALWAYS ) << "rampedEllipsoidTechnique: X,Y:"<<x<<","<<y<<" destination_height=" << destination_height << std::endl;
 			h->setHeight( x, y, destination_height);
 		}
