Updated world module (now voronoi roads work
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
#define DENSITY_MAP_H
|
||||
#include <core/resource.h>
|
||||
#include <core/math/random_number_generator.h>
|
||||
#include <modules/opensimplex/open_simplex_noise.h>
|
||||
#include <modules/voxel/util/math/vector3i.h>
|
||||
#include "world_height_map.h"
|
||||
|
||||
class DensityMap: public Resource {
|
||||
GDCLASS(DensityMap, Resource);
|
||||
@@ -10,47 +12,19 @@ public:
|
||||
DensityMap();
|
||||
~DensityMap();
|
||||
protected:
|
||||
Ref<WorldHeightMap> height_map;
|
||||
Ref<RandomNumberGenerator> rnd;
|
||||
struct area {
|
||||
Vector2i pos;
|
||||
float radius;
|
||||
struct area *parent;
|
||||
inline bool has_point(const Vector2i &pt)
|
||||
{
|
||||
int tox = pos.x - pt.x;
|
||||
int toy = pos.y - pt.y;
|
||||
int tdst = tox * tox + toy * toy;
|
||||
int rsq = (int)(radius * radius);
|
||||
return tdst < rsq;
|
||||
}
|
||||
};
|
||||
List<struct area> clusters;
|
||||
List<struct area> regions;
|
||||
List<struct area> counties;
|
||||
List<struct area> cities;
|
||||
List<struct area> districts;
|
||||
int num_clusters;
|
||||
int num_regions;
|
||||
int num_counties;
|
||||
int num_cities;
|
||||
int num_districts;
|
||||
HashMap<Vector2i, Vector<struct area> > circle_grid;
|
||||
void split_area(struct area *area, int num_split, List<struct area> &list);
|
||||
void populate_grid(List<struct area> &list);
|
||||
|
||||
void set_num_clusters(int num);
|
||||
int get_num_clusters() const;
|
||||
/* 100m grid */
|
||||
int grid_size;
|
||||
uint32_t world_x_size;
|
||||
uint32_t world_y_size;
|
||||
uint32_t world_z_size;
|
||||
Vector3i world_center;
|
||||
int seed;
|
||||
Ref<OpenSimplexNoise> noise;
|
||||
Ref<Curve> curve;
|
||||
float max_height;
|
||||
bool _set(const StringName &p_name, const Variant &p_value);
|
||||
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||
void _get_property_list(List<PropertyInfo> *p_list) const;
|
||||
static void _bind_methods();
|
||||
public:
|
||||
void update_clusters();
|
||||
void update_all();
|
||||
float get_population_density(float x, float y);
|
||||
private:
|
||||
int seed;
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user