Updated world module (now voronoi roads work
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
#include <core/object.h>
|
||||
#include <core/reference.h>
|
||||
#include <core/math/random_number_generator.h>
|
||||
#include <modules/opensimplex/open_simplex_noise.h>
|
||||
|
||||
class RoadMap: public Object {
|
||||
GDCLASS(RoadMap, Object)
|
||||
@@ -10,26 +13,47 @@ public:
|
||||
static void destroy_singleton();
|
||||
|
||||
protected:
|
||||
Vector<int> vertices;
|
||||
struct segment {
|
||||
int v1, v2;
|
||||
uint32_t flags;
|
||||
Ref<OpenSimplexNoise> noise;
|
||||
Ref<RandomNumberGenerator> rnd;
|
||||
struct Segment {
|
||||
Vector3 p1, p2;
|
||||
};
|
||||
Vector<segment> segments;
|
||||
struct intersection {
|
||||
#define MAX_NEIGHBORS 4
|
||||
int neighbors[MAX_NEIGHBORS];
|
||||
int ncount;
|
||||
uint32_t flags;
|
||||
Vector<Segment> segments;
|
||||
struct Pq {
|
||||
struct PqItem {
|
||||
struct Segment data;
|
||||
int priority;
|
||||
};
|
||||
List<PqItem> queue;
|
||||
void push(int priority, const struct Segment &seg)
|
||||
{
|
||||
List<PqItem>::Element *e;
|
||||
PqItem it;
|
||||
it.data = seg;
|
||||
it.priority = priority;
|
||||
|
||||
for (e = queue.front(); e; e = e->next()) {
|
||||
PqItem item = e->get();
|
||||
if (item.priority > priority) {
|
||||
queue.insert_before(e, it);
|
||||
break;
|
||||
}
|
||||
if (!e->next())
|
||||
queue.push_back(it);
|
||||
|
||||
}
|
||||
}
|
||||
Segment peek()
|
||||
{
|
||||
return queue.front()->get().data;
|
||||
}
|
||||
Segment pop()
|
||||
{
|
||||
Segment seg = queue.front()->get().data;
|
||||
queue.pop_front();
|
||||
return seg;
|
||||
}
|
||||
};
|
||||
Vector<intersection> intersections;
|
||||
/* cylindric area to define road */
|
||||
struct area {
|
||||
int x, z;
|
||||
int radius;
|
||||
int type;
|
||||
};
|
||||
Vector<area> areas;
|
||||
struct Pq queue;
|
||||
void gen_primary_network();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user