Skip to main content
Topic: [bug+fix] Origin is ignored. (Read 4080 times) previous topic - next topic

[bug+fix] Origin is ignored.

In perlin_noise the origin setting is ignored. So, if you enlarge a map which was already enlarged while it was rotated, the heights are wrong. Try: Rotate a map twice, enlarge it, rotate twice, enlarge it again -> messy world.

Code: [Select]
Index: simworld.cc
===================================================================
--- simworld.cc (revision 2570)
+++ simworld.cc (working copy)
@@ -379,6 +379,7 @@
        }
 //    double perlin_noise_2D(double x, double y, double persistence);
 //    return ((int)(perlin_noise_2D(x, y, 0.6)*160.0)) & 0xFFFFFFF0;
+       k = k + koord(sets->get_origin_x(), sets->get_origin_y());
        return ((int)(perlin_noise_2D(k.x, k.y, sets->get_map_roughness())*(double)sets->get_max_mountain_height())) / 16;
 }
 

Re: [bug+fix] Origin is ignored.

Reply #1
Instead

k = k + koord(sets->get_origin_x(), sets->get_origin_y());

wouldn't this perform better?

k.x += sets->get_origin_x();
k.y += sets->get_origin_y();


Re: [bug+fix] Origin is ignored.

Reply #2
Yes, indeed. But when I wrote the patch, I thought in coordinates  ;D

Is there any reason, why the two origin-coordinates aren't saved in a single koord instead of two single sint16??

Re: [bug+fix] Origin is ignored.

Reply #3
I can't say. In the beginning I often used (x,y) pairs, and later introduced the koord cl****. So old code had to be converted, and maybe not all code was converted. It'd be nice to have all that in koord's though, for easier arithmetic.

Re: [bug+fix] Origin is ignored.

Reply #4
Actually gerd you introduced the origin yourself ...

 

Re: [bug+fix] Origin is ignored.

Reply #5
Actually gerd you introduced the origin yourself ...
Yes, you're right... But now, I think it should be a coordinate... "Zeiten ändern sich" :)