News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

[bug+fix] Origin is ignored.

Started by gerw, July 08, 2009, 12:19:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gerw

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


Spike

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();


gerw

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??

Spike

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.

prissi

Actually gerd you introduced the origin yourself ...

gerw

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" :)