City generation works now
This commit is contained in:
1308
src/modules/stream/road_lot.cpp
Normal file
1308
src/modules/stream/road_lot.cpp
Normal file
File diff suppressed because it is too large
Load Diff
38
src/modules/stream/road_lot.h
Normal file
38
src/modules/stream/road_lot.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* ~/godot-projects/streaming_world/src/modules/stream/road_lot.h */
|
||||
#ifndef ROAD_LOT_H_
|
||||
#define ROAD_LOT_H_
|
||||
#include <vector>
|
||||
#include <core/math/vector3.h>
|
||||
#include <core/math/aabb.h>
|
||||
#include "base_data.h"
|
||||
#include "road_lines_data.h"
|
||||
struct Lot {
|
||||
struct polygon {
|
||||
std::vector<Vector3> points;
|
||||
AABB aabb;
|
||||
std::pair<struct polygon, struct polygon> split() const;
|
||||
float area_cache;
|
||||
float area() const;
|
||||
int longest_edge() const;
|
||||
void update_aabb();
|
||||
mutable Vector<Vector<Vector2> > intersections;
|
||||
bool intersects(const struct polygon *other) const;
|
||||
void dump() const;
|
||||
bool is_inside(const Vector3 &point) const;
|
||||
bool is_inside(const Vector2 &point) const;
|
||||
bool is_inside(const AABB &aabb) const;
|
||||
bool is_inside(const Rect2 &rect) const;
|
||||
};
|
||||
struct polygon polygon;
|
||||
static void pack();
|
||||
static void get_lot_data(flecs::entity e,
|
||||
List<Pair<AABB, String> > *lot_data);
|
||||
static void get_lot_rotations(flecs::entity e,
|
||||
List<Transform> *lot_xform);
|
||||
static void
|
||||
get_lot_buildings(flecs::entity e,
|
||||
Vector<Pair<Rect2, String> > *lot_buildings);
|
||||
static Vector<Vector<Vector2> > get_lot_polygons(flecs::entity e);
|
||||
};
|
||||
|
||||
#endif // ROAD_LOT_H_
|
||||
1
src/modules/stream/rtree/growth_regions.cpp
Normal file
1
src/modules/stream/rtree/growth_regions.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "growth_regions.h"
|
||||
50
src/modules/stream/rtree/growth_regions.h
Normal file
50
src/modules/stream/rtree/growth_regions.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef GROWTH_REGIONS_H
|
||||
#define GROWTH_REGIONS_H
|
||||
#include <core/vector.h>
|
||||
#include <core/list.h>
|
||||
#include <core/pair.h>
|
||||
#include <core/math/vector2.h>
|
||||
#include "base_data.h"
|
||||
#include "region_rect2.h"
|
||||
struct region {
|
||||
flecs::entity_t parent;
|
||||
flecs::entity_t seed_et;
|
||||
flecs::entity_t region_et;
|
||||
RegionRect2i rect;
|
||||
int remains_area;
|
||||
bool can_grow_square;
|
||||
bool can_move;
|
||||
bool can_grow;
|
||||
bool complete;
|
||||
bool can_grow_region() const
|
||||
{
|
||||
bool ret = can_grow;
|
||||
if (remains_area <= 0)
|
||||
ret = false;
|
||||
return ret;
|
||||
}
|
||||
bool update_region_size(RegionRect2i &mrect)
|
||||
{
|
||||
bool ret = false;
|
||||
int old_area = rect.get_area();
|
||||
int new_area = mrect.get_area();
|
||||
int area_diff = new_area - old_area;
|
||||
if (area_diff > 0) {
|
||||
rect = mrect;
|
||||
remains_area -= area_diff;
|
||||
ret = true;
|
||||
}
|
||||
if (remains_area <= 0) {
|
||||
can_grow_square = false;
|
||||
can_grow = false;
|
||||
}
|
||||
flecs::log::dbg("update_region_size %d -> %d", area_diff, ret);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
struct growth_regions {
|
||||
List<struct grow_job> job_list;
|
||||
bool complete;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user