Updated world module (now voronoi roads work
This commit is contained in:
104
modules/world/roads.h
Normal file
104
modules/world/roads.h
Normal file
@@ -0,0 +1,104 @@
|
||||
#include <modules/world/road_grid.h>
|
||||
|
||||
#include <scene/main/node.h>
|
||||
#include <scene/3d/mesh_instance.h>
|
||||
#include <scene/3d/immediate_geometry.h>
|
||||
#include <scene/resources/concave_polygon_shape.h>
|
||||
|
||||
class StaticBody;
|
||||
|
||||
class Roads: public MeshInstance {
|
||||
GDCLASS(Roads, MeshInstance);
|
||||
protected:
|
||||
Mutex mutex;
|
||||
Ref<Curve> curve;
|
||||
Ref<OpenSimplexNoise> noise;
|
||||
Ref<Material> mat;
|
||||
Ref<PackedScene> road_data;
|
||||
HashMap<String, Array> mesh_data;
|
||||
HashMap<String, Vector3> offsets;
|
||||
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();
|
||||
void update_all();
|
||||
PoolVector<Vector3> vertices;
|
||||
struct thread_data {
|
||||
Thread thread;
|
||||
Ref<Material> mat;
|
||||
int vshape;
|
||||
float width;
|
||||
float sidewalk_width;
|
||||
int flags;
|
||||
Node *root;
|
||||
Ref<ArrayMesh> mesh;
|
||||
MeshInstance *xmi;
|
||||
};
|
||||
struct thread_data thread;
|
||||
static void generate_threaded(void *p_userdata);
|
||||
StaticBody *body;
|
||||
#if 0
|
||||
struct edge_data {
|
||||
int a;
|
||||
int b;
|
||||
float width;
|
||||
bool sidewalk;
|
||||
float sidewalk_width;
|
||||
edge_data(): a(-1), b(-1), width(1.0f), sidewalk(false), sidewalk_width(1.0f)
|
||||
{}
|
||||
};
|
||||
#endif
|
||||
struct vshape {
|
||||
AABB area;
|
||||
int instance;
|
||||
int e1, e2;
|
||||
int site;
|
||||
Vector3 p1, p2, p3;
|
||||
};
|
||||
#if 0
|
||||
PoolVector<struct edge_data> edges;
|
||||
#endif
|
||||
PoolVector<struct vshape> vshapes;
|
||||
void setup_vshapes();
|
||||
void sort_angle(Vector<int> &sort_data);
|
||||
#if 0
|
||||
void extrude_direct(Array &out, const Array &arrays, const struct edge_data *data) const;
|
||||
void extrude_vshape(Array &out, const Array &arrays, const struct vshape *data) const;
|
||||
#endif
|
||||
int find_edge(int a, int b);
|
||||
void _notification(int p_what);
|
||||
int counter;
|
||||
friend class RoadsData;
|
||||
public:
|
||||
#if 0
|
||||
void update(Ref<RoadGrid> roads, Vector3 where, float radius);
|
||||
#endif
|
||||
Roads();
|
||||
~Roads();
|
||||
Vector3 calculate_offsets(const Array &data) const;
|
||||
Vector3 quadratic_bezier(const Vector3 &p1, const Vector3 &p2,
|
||||
const Vector3 &p3, float t) const;
|
||||
void all_offsets();
|
||||
PoolVector<String> build_item_list(float width, int flags, float sidewalk_width) const;
|
||||
Ref<Curve3D> build_curve(Vector3 p1, Vector3 p2, Vector3 p3, float total_width) const;
|
||||
Array curve_mesh(PoolVector<Vector3> points, float width, int flags, float sidewalk_width);
|
||||
int make_vmesh(Node *root, Ref<Material> mat, Ref<ArrayMesh> mesh, MeshInstance *xmi, Vector3 p1, Vector3 p2,
|
||||
Vector3 p3, float width, int flags, float sidewalk_width);
|
||||
void process_vshapes();
|
||||
void add_scene_element(Node *root, Node *xnode, const Vector3 &p2, Ref<ConcavePolygonShape> shape);
|
||||
};
|
||||
|
||||
class RoadsData: public Object {
|
||||
GDCLASS(RoadsData, Object);
|
||||
protected:
|
||||
RoadGrid *rg;
|
||||
static void _bind_methods();
|
||||
public:
|
||||
RoadsData();
|
||||
~RoadsData();
|
||||
static RoadsData *get_singleton();
|
||||
static void create_singleton();
|
||||
static void destroy_singleton();
|
||||
RoadGrid *get_road_grid();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user