Skip to content

Commit

Permalink
[api] Improve glm.
Browse files Browse the repository at this point in the history
  • Loading branch information
travisdoor committed Dec 2, 2024
1 parent a4cf551 commit 1f60c77
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/bl/api/extra/glm/glm.bl
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,28 @@ quat_forward :: fn (q: quat) v3 {
return v3.{ z2x + y2w, z2y - x2w, 1.0f - (x2x + y2y) };
}

quat_for :: fn (dir: v3, up: v3) quat {
m2 :: mul(normalize(dir), -1.f);
m0 :: normalize(cross(up, m2));
m1 :: cross(m2, m0);

m := MAT4_IDENTITY;
m[0][0] = m0.x;
m[0][1] = m0.y;
m[0][2] = m0.z;

m[1][0] = m1.x;
m[1][1] = m1.y;
m[1][2] = m1.z;

m[2][0] = m2.x;
m[2][1] = m2.y;
m[2][2] = m2.z;


return mat4_get_quat(&m);
}

lerp :: fn (a: ?T, b: T, t: f32) T #inline {
#if T == v2 || T == v3 || T == v4 {
return add(a, mul(sub(b, a), t));
Expand Down

0 comments on commit 1f60c77

Please sign in to comment.