Changeset - r21866:bde0469f0745
[Not reviewed]
master
0 1 0
rubidium - 10 years ago 2014-10-14 17:49:32
rubidium@openttd.org
(svn r27018) -Fix [FS#6141] (r27008): the higher amplitudes needed for higher maps were not ignored properly causing much smoother maps than wanted
1 file changed with 9 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/tgp.cpp
Show inline comments
 
@@ -277,7 +277,7 @@ static amplitude_t GetAmplitude(int freq
 

	
 
	/* We need to extrapolate the amplitude. */
 
	double extrapolation_factor = extrapolation_factors[smoothness];
 
	int height_range = 16;
 
	int height_range = I2H(16);
 
	do {
 
		amplitude = (amplitude_t)(extrapolation_factor * (double)amplitude);
 
		height_range <<= 1;
 
@@ -352,12 +352,18 @@ static void HeightMapGenerate()
 
	assert(_height_map.h != NULL);
 

	
 
	int start = max(MAX_TGP_FREQUENCIES - (int)min(MapLogX(), MapLogY()), 0);
 
	bool first = true;
 

	
 
	for (int frequency = start; frequency < MAX_TGP_FREQUENCIES; frequency++) {
 
		const amplitude_t amplitude = GetAmplitude(frequency);
 

	
 
		/* Ignore zero amplitudes; it means our map isn't height enough for this
 
		 * amplitude, so ignore it and continue with the next set of amplitude. */
 
		if (amplitude == 0) continue;
 

	
 
		const int step = 1 << (MAX_TGP_FREQUENCIES - frequency - 1);
 

	
 
		if (frequency == start) {
 
		if (first) {
 
			/* This is first round, we need to establish base heights with step = size_min */
 
			for (int y = 0; y <= _height_map.size_y; y += step) {
 
				for (int x = 0; x <= _height_map.size_x; x += step) {
 
@@ -365,6 +371,7 @@ static void HeightMapGenerate()
 
					_height_map.height(x, y) = height;
 
				}
 
			}
 
			first = false;
 
			continue;
 
		}
 

	
0 comments (0 inline, 0 general)