Skip to content

Commit

Permalink
geom_make_plane fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
luboslenco committed Jan 16, 2025
1 parent b9d762d commit 40d0bbf
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions base/sources/geom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ function geom_make_plane(size_x: f32 = 1.0, size_y: f32 = 1.0, verts_x: i32 = 2,

let mesh: raw_mesh_t = {};
mesh.scale_pos = 1.0;
mesh.scale_tex = 1.0;
mesh.scale_tex = uv_scale;
mesh.name = "";
mesh.has_next = false;

// Pack positions to (-1, 1) range
let half_x: f32 = size_x / 2;
let half_y: f32 = size_y / 2;
mesh.scale_pos = math_max(half_x, half_y);
mesh.scale_pos = math_max(size_x, size_y);
let inv: f32 = (1 / mesh.scale_pos) * 32767;

mesh.posa = i16_array_create(verts_x * verts_y * 4);
Expand All @@ -30,10 +30,8 @@ function geom_make_plane(size_x: f32 = 1.0, size_y: f32 = 1.0, verts_x: i32 = 2,
mesh.posa[i * 4 + 3] = 32767;
x = (i % verts_x) / (verts_x - 1);
y = 1.0 - math_floor(i / verts_x) / (verts_y - 1);
let tx: i32 = (math_floor(x * 32767 * uv_scale) - 1);
let ty: i32 = (math_floor(y * 32767 * uv_scale) - 1);
mesh.texa[i * 2 ] = tx % 32767;
mesh.texa[i * 2 + 1] = ty % 32767;
mesh.texa[i * 2 ] = math_floor(x * 32767);
mesh.texa[i * 2 + 1] = math_floor(y * 32767);
}
for (let i: i32 = 0; i < (verts_x - 1) * (verts_y - 1); ++i) {
let x: f32 = i % (verts_x - 1);
Expand Down

0 comments on commit 40d0bbf

Please sign in to comment.