Changeset - r21800:f246d1c981f3
[Not reviewed]
master
0 1 0
rubidium - 10 years ago 2014-10-02 17:32:45
rubidium@openttd.org
(svn r26945) -Fix-ish: better scaling of the "cells" in which variety distribution happens for non-square maps (attempt to make reasonably square areas)
1 file changed with 6 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/tgp.cpp
Show inline comments
 
@@ -511,9 +511,10 @@ static void HeightMapCurves(uint level)
 
	height_t ht[lengthof(_curve_maps)];
 
	MemSetT(ht, 0, lengthof(ht));
 

	
 
	/* Set up a grid to choose curve maps based on location */
 
	uint sx = Clamp(1 << level, 2, 32);
 
	uint sy = Clamp(1 << level, 2, 32);
 
	/* Set up a grid to choose curve maps based on location; attempt to get a somewhat square grid */
 
	float factor = sqrt((float)_height_map.size_x / (float)_height_map.size_y);
 
	uint sx = Clamp(round((1 << level) * factor), 1, 128);
 
	uint sy = Clamp(round((1 << level) / factor), 1, 128);
 
	byte *c = AllocaM(byte, sx * sy);
 

	
 
	for (uint i = 0; i < sx * sy; i++) {
 
@@ -524,7 +525,7 @@ static void HeightMapCurves(uint level)
 
	for (uint x = 0; x < _height_map.size_x; x++) {
 

	
 
		/* Get our X grid positions and bi-linear ratio */
 
		float fx = (float)(sx * x) / _height_map.size_x + 0.5f;
 
		float fx = (float)(sx * x) / _height_map.size_x + 1.0f;
 
		uint x1 = (uint)fx;
 
		uint x2 = x1;
 
		float xr = 2.0f * (fx - x1) - 1.0f;
 
@@ -541,7 +542,7 @@ static void HeightMapCurves(uint level)
 
		for (uint y = 0; y < _height_map.size_y; y++) {
 

	
 
			/* Get our Y grid position and bi-linear ratio */
 
			float fy = (float)(sy * y) / _height_map.size_y + 0.5f;
 
			float fy = (float)(sy * y) / _height_map.size_y + 1.0f;
 
			uint y1 = (uint)fy;
 
			uint y2 = y1;
 
			float yr = 2.0f * (fy - y1) - 1.0f;
0 comments (0 inline, 0 general)