diff --git a/src/utilities/shapes.cpp b/src/utilities/shapes.cpp index dbeb0ac..1e6dc82 100644 --- a/src/utilities/shapes.cpp +++ b/src/utilities/shapes.cpp @@ -313,7 +313,7 @@ Mesh generateSphere(float sphereRadius, int slices, int layers) { return mesh; } -Mesh generateSegmentedPlane(float width, float height, uint x_segments, uint y_segments) { +Mesh generateSegmentedPlane(float width, float height, uint x_segments, uint y_segments, float uv_scale) { // i should perhaps initialize these to the length they should be, but insert is prettier :3 vector vertices; vector normals; @@ -322,8 +322,8 @@ Mesh generateSegmentedPlane(float width, float height, uint x_segments, uint y_s float step_x = width/x_segments; float step_y = height/y_segments; - float tex_step_x = 1.0/x_segments; - float tex_step_y = 1.0/y_segments; + float tex_step_x = uv_scale/x_segments; + float tex_step_y = uv_scale/y_segments; uint index_offset = 0; for (uint x = 0; x < x_segments; x++) @@ -334,7 +334,7 @@ Mesh generateSegmentedPlane(float width, float height, uint x_segments, uint y_s vec3(step_x*(x+1), step_y*(y+0), 0), vec3(step_x*(x+1), step_y*(y+1), 0), }); - normals.insert(vertices.end(), { + normals.insert(normals.end(), { vec3(0.0, 0.0, 1.0), vec3(0.0, 0.0, 1.0), vec3(0.0, 0.0, 1.0), diff --git a/src/utilities/shapes.h b/src/utilities/shapes.h index 5851371..9a7a795 100644 --- a/src/utilities/shapes.h +++ b/src/utilities/shapes.h @@ -2,4 +2,5 @@ #include "mesh.h" Mesh generateBox(float width, float height, float depth, bool flipFaces = false); -Mesh generateSphere(float radius, int slices, int layers); \ No newline at end of file +Mesh generateSphere(float radius, int slices, int layers); +Mesh generateSegmentedPlane(float width, float height, uint x_segments, uint y_segments, float uv_scale = 1.0);