fix aspect ratio as well as billboard scaling

This commit is contained in:
veclavtalica
2025-01-05 21:08:54 +03:00
parent cb6c1df0be
commit d7a119a592
3 changed files with 10 additions and 10 deletions

View File

@ -80,10 +80,10 @@ void finally_draw_billboard_batch(struct MeshBatch const *batch,
const float xr = srcrect.x / dims.w;
const float yr = srcrect.y / dims.h;
const Vec2 uv0 = { xr + 1 * wr, yr + 0 * hr };
const Vec2 uv1 = { xr + 1 * wr, yr + 1 * hr };
const Vec2 uv2 = { xr + 0 * wr, yr + 1 * hr };
const Vec2 uv3 = { xr + 0 * wr, yr + 0 * hr };
const Vec2 uv0 = { xr + wr, yr };
const Vec2 uv1 = { xr + wr, yr + hr };
const Vec2 uv2 = { xr, yr + hr };
const Vec2 uv3 = { xr, yr };
/* emit vertex data */
VertexBuffer const buffer = get_scratch_vertex_array();
@ -95,11 +95,11 @@ void finally_draw_billboard_batch(struct MeshBatch const *batch,
/* a = (right + up) * size, b = (right - up) * size*/
Vec3 a, b;
if (billboard.cylindrical) {
a = vec3_mul(right_plus_up_cylindrical, ((Vec3){billboard.size.x, billboard.size.y, billboard.size.x}));
b = vec3_mul(right_minus_up_cylindrical, ((Vec3){billboard.size.x, billboard.size.y, billboard.size.x}));
a = vec3_mul(right_plus_up_cylindrical, ((Vec3){billboard.size.x, billboard.size.y, billboard.size.x }));
b = vec3_mul(right_minus_up_cylindrical, ((Vec3){billboard.size.x, billboard.size.y, billboard.size.x }));
} else {
a = vec3_mul(right_plus_up, ((Vec3){billboard.size.x, billboard.size.y, billboard.size.x}));
b = vec3_mul(right_minus_up, ((Vec3){billboard.size.x, billboard.size.y, billboard.size.x}));
a = vec3_mul(right_plus_up, ((Vec3){billboard.size.x, billboard.size.y, billboard.size.x }));
b = vec3_mul(right_minus_up, ((Vec3){billboard.size.x, billboard.size.y, billboard.size.x }));
}
struct ElementIndexedBillboard const payload = {