Split out some code for refactoring purposes

This commit is contained in:
Segey Lapin
2021-10-23 22:11:53 +03:00
parent 2945dd1904
commit eef15ea522
2 changed files with 81 additions and 34 deletions

View File

@@ -6,6 +6,16 @@
#include <scene/resources/concave_polygon_shape.h>
class StaticBody;
struct RoadGrid::vshape;
struct RoadMeshData {
PoolVector<Vector3> points;
float width1;
float width2;
int flags;
float sidewalk_width;
struct RoadGrid::vshape *vshape;
};
class Roads: public MeshInstance {
GDCLASS(Roads, MeshInstance);
@@ -25,13 +35,10 @@ protected:
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 RoadMeshData data;
};
struct thread_data thread;
static void generate_threaded(void *p_userdata);
@@ -70,11 +77,16 @@ public:
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 width1, float width2, 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 width1, float width2, int flags, float sidewalk_width);
// Array curve_mesh(PoolVector<Vector3> points, float width1, float width2, int flags, float sidewalk_width);
Array curve_mesh(const PoolVector<Vector3> &points, Ref<Curve3D> curve3, float width1, float width2, int flags, float sidewalk_width);
int make_vmesh(Node *root, Ref<Material> mat, Ref<ArrayMesh> mesh, MeshInstance *xmi, RoadMeshData *data);
void process_vshapes();
void create_data(struct RoadGrid::vshape *v,
struct RoadMeshData *data,
int flags, float sidewalk_width);
void add_scene_element(Node *root, Node *xnode, const Vector3 &p2, Ref<ConcavePolygonShape> shape);
inline float get_total_width(float width, int flags, float sidewalk_width);
inline Ref<Curve3D> get_curve(const PoolVector<Vector3> &points, float width, int flags, float sidewalk_width);
};
class RoadsData: public Object {