00001 #ifndef DGN_HEIGHT_H
00002 #define DGN_HEIGHT_H
00003
00004 #include "env.h"
00005 #include "fixedarray.h"
00006 #include <vector>
00007
00008
00009 static inline short &dgn_height_at(const coord_def &c)
00010 {
00011 return (*env.heightmap)(c);
00012 }
00013
00014 typedef FixedArray<bool, GXM, GYM> grid_bool;
00015 typedef FixedArray<short, GXM, GYM> grid_short;
00016 typedef std::pair<int, int> int_range;
00017
00018 const int DGN_UNDEFINED_HEIGHT = -10000;
00019
00020 int resolve_range(int_range range, int nrolls = 1);
00021
00022 void dgn_initialise_heightmap(int initial_height = 0);
00023 void dgn_smooth_height_at(coord_def c, int radius = 1,
00024 int max_height = DGN_UNDEFINED_HEIGHT);
00025 void dgn_smooth_heights(int radius = 1, int npasses = 1);
00026
00027
00028 void dgn_island_centred_at(const coord_def &c,
00029
00030
00031 int n_points,
00032
00033
00034
00035 int radius,
00036
00037
00038
00039 int_range height_delta_range,
00040
00041 int border_margin = 6,
00042
00043
00044
00045
00046 bool make_atoll = false);
00047
00048 struct dgn_island_plan
00049 {
00050 public:
00051
00052 int level_border_depth;
00053
00054
00055 int_range n_aux_centres;
00056
00057
00058 int_range aux_centre_offset_range;
00059
00060
00061 int atoll_roll;
00062
00063
00064 std::vector<coord_def> islands;
00065
00066
00067
00068
00069 int island_separation_dist2;
00070
00071
00072
00073 int_range n_island_centre_delta_points;
00074
00075
00076 int_range island_centre_radius_range;
00077
00078 int_range island_centre_point_height_increment;
00079
00080
00081
00082 int_range n_island_aux_delta_points;
00083
00084
00085 int_range island_aux_radius_range;
00086
00087 int_range island_aux_point_height_increment;
00088
00089 public:
00090 void build(int nislands);
00091 coord_def pick_and_remove_random_island();
00092
00093 private:
00094 coord_def pick_island_spot();
00095 void build_island();
00096 };
00097
00098 #endif