The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: gerw on July 08, 2009, 12:19:38 PM

Title: [bug+fix] Origin is ignored.
Post by: gerw on July 08, 2009, 12:19:38 PM
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.

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;
}

Title: Re: [bug+fix] Origin is ignored.
Post by: Spike on July 08, 2009, 01:13:39 PM
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();

Title: Re: [bug+fix] Origin is ignored.
Post by: gerw on July 08, 2009, 01:36:00 PM
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??
Title: Re: [bug+fix] Origin is ignored.
Post by: Spike on July 08, 2009, 01:45:06 PM
I can't say. In the beginning I often used (x,y) pairs, and later introduced the koord class. 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.
Title: Re: [bug+fix] Origin is ignored.
Post by: prissi on July 08, 2009, 02:35:46 PM
Actually gerd you introduced the origin yourself ...
Title: Re: [bug+fix] Origin is ignored.
Post by: gerw on July 08, 2009, 04:22:16 PM
Quote from: prissi on July 08, 2009, 02:35:46 PM
Actually gerd you introduced the origin yourself ...
Yes, you're right... But now, I think it should be a coordinate... "Zeiten ändern sich" :)