Merge lp:~alocritani/widelands/fix_editor_noise_height_tool into lp:widelands

Proposed by Angelo Locritani
Status: Merged
Merged at revision: 6173
Proposed branch: lp:~alocritani/widelands/fix_editor_noise_height_tool
Merge into: lp:widelands
Diff against target: 12 lines (+1/-1)
1 file modified
src/editor/tools/editor_noise_height_tool.cc (+1/-1)
To merge this branch: bzr merge lp:~alocritani/widelands/fix_editor_noise_height_tool
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+86899@code.launchpad.net

Description of the change

At the moment, the noise height tool returns an height between min + (min-max) * rand and min.

In other words, it lowers terrain below the min value; this is not what the user expect and creates problem (negative value of terrain height -> very high value because of the "negative overflow" -> assertion height <= max_height failed) if you set the gap between min and max to high value (ie: min=0, max = 10).

This branch changes it in order to return a value between min and min+(max-min)+1*rand

so min = 0, max = 10 -> 0<=values<=10

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/editor/tools/editor_noise_height_tool.cc'
2--- src/editor/tools/editor_noise_height_tool.cc 2011-12-07 22:32:39 +0000
3+++ src/editor/tools/editor_noise_height_tool.cc 2011-12-26 13:08:27 +0000
4@@ -47,7 +47,7 @@
5 +
6 static_cast<int32_t>
7 (static_cast<double>
8- (m_interval.min - m_interval.max) * rand()
9+ (m_interval.max - m_interval.min + 1) * rand()
10 /
11 (RAND_MAX + 1.0))));
12 while (mr.advance(map));

Subscribers

People subscribed via source and target branches

to status/vote changes: