Add SurfaceFlags, and more formatting :)
Build libsm64 / Build libsm64 for linux (push) Successful in 32s
Build libsm64 / Build libsm64 for web (push) Successful in 39s
Build libsm64 / Build libsm64 for windows (push) Successful in 25s

This commit is contained in:
2026-05-24 18:03:08 -05:00
parent d3ea4e5e99
commit bd3dd8f523
38 changed files with 716 additions and 1295 deletions
+21 -44
View File
@@ -1591,11 +1591,10 @@ void *vec3f_normalize(Vec3f dest)
/// Copy matrix 'src' to 'dest'
void mtxf_copy(Mat4 dest, Mat4 src)
{
register s32 i;
register u32 *d = (u32 *)dest;
register u32 *s = (u32 *)src;
for (i = 0; i < 16; i++)
for (register s32 i = 0; i < 16; i++)
{
*d++ = *s++;
}
@@ -1636,42 +1635,29 @@ void mtxf_translate(Mat4 dest, Vec3f b)
*/
void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll)
{
register f32 invLength;
f32 dx;
f32 dz;
f32 xColY;
f32 yColY;
f32 zColY;
f32 xColZ;
f32 yColZ;
f32 zColZ;
f32 xColX;
f32 yColX;
f32 zColX;
f32 dx = to[0] - from[0];
f32 dz = to[2] - from[2];
dx = to[0] - from[0];
dz = to[2] - from[2];
invLength = -1.0 / sqrtf(dx * dx + dz * dz);
register f32 invLength = -1.0 / sqrtf(dx * dx + dz * dz);
dx *= invLength;
dz *= invLength;
yColY = coss(roll);
xColY = sins(roll) * dz;
zColY = -sins(roll) * dx;
f32 yColY = coss(roll);
f32 xColY = sins(roll) * dz;
f32 zColY = -sins(roll) * dx;
xColZ = to[0] - from[0];
yColZ = to[1] - from[1];
zColZ = to[2] - from[2];
f32 xColZ = to[0] - from[0];
f32 yColZ = to[1] - from[1];
f32 zColZ = to[2] - from[2];
invLength = -1.0 / sqrtf(xColZ * xColZ + yColZ * yColZ + zColZ * zColZ);
xColZ *= invLength;
yColZ *= invLength;
zColZ *= invLength;
xColX = yColY * zColZ - zColY * yColZ;
yColX = zColY * xColZ - xColY * zColZ;
zColX = xColY * yColZ - yColY * xColZ;
f32 xColX = yColY * zColZ - zColY * yColZ;
f32 yColX = zColY * xColZ - xColY * zColZ;
f32 zColX = xColY * yColZ - yColY * xColZ;
invLength = 1.0 / sqrtf(xColX * xColX + yColX * yColX + zColX * zColX);
@@ -1872,7 +1858,6 @@ void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius)
Vec3f xColumn;
Vec3f yColumn;
Vec3f zColumn;
f32 avgY;
f32 minY = -radius * 3;
point0[0] = pos[0] + radius * sins(yaw + 0x2AAA);
@@ -1901,7 +1886,7 @@ void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius)
point2[1] = pos[1];
}
avgY = (point0[1] + point1[1] + point2[1]) / 3;
f32 avgY = (point0[1] + point1[1] + point2[1]) / 3;
vec3f_set(forward, sins(yaw), 0, coss(yaw));
find_vector_perpendicular_to_plane(yColumn, point0, point1, point2);
@@ -1943,14 +1928,11 @@ void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius)
void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b)
{
Mat4 temp;
register f32 entry0;
register f32 entry1;
register f32 entry2;
// column 0
entry0 = a[0][0];
entry1 = a[0][1];
entry2 = a[0][2];
register f32 entry0 = a[0][0];
register f32 entry1 = a[0][1];
register f32 entry2 = a[0][2];
temp[0][0] = entry0 * b[0][0] + entry1 * b[1][0] + entry2 * b[2][0];
temp[0][1] = entry0 * b[0][1] + entry1 * b[1][1] + entry2 * b[2][1];
temp[0][2] = entry0 * b[0][2] + entry1 * b[1][2] + entry2 * b[2][2];
@@ -1990,9 +1972,7 @@ void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b)
*/
void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s)
{
register s32 i;
for (i = 0; i < 4; i++)
for (register s32 i = 0; i < 4; i++)
{
dest[0][i] = mtx[0][i] * s[0];
dest[1][i] = mtx[1][i] * s[1];
@@ -2363,12 +2343,11 @@ void anim_spline_init(Vec4s *keyFrames)
s32 anim_spline_poll(Vec3f result)
{
Vec4f weights;
s32 i;
s32 hasEnded = FALSE;
vec3f_copy(result, gVec3fZero);
spline_get_weights(weights, gSplineKeyframeFraction, gSplineState);
for (i = 0; i < 4; i++)
for (s32 i = 0; i < 4; i++)
{
result[0] += weights[i] * gSplineKeyframe[i][1];
result[1] += weights[i] * gSplineKeyframe[i][2];
@@ -2412,8 +2391,7 @@ s32 anim_spline_poll(Vec3f result)
*/
void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v)
{
s32 i;
for (i = 0; i < 3; i++)
for (s32 i = 0; i < 3; i++)
{
dst[i] = m[0][i] * v[0] + m[1][i] * v[1] + m[2][i] * v[2];
}
@@ -2429,8 +2407,7 @@ void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v)
*/
void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v)
{
s32 i;
for (i = 0; i < 3; i++)
for (s32 i = 0; i < 3; i++)
{
dst[i] = m[i][0] * v[0] + m[i][1] * v[1] + m[i][2] * v[2];
}