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
+26 -28
View File
@@ -69,9 +69,9 @@ static void update_transform(struct SM64SurfaceObjectTransform *out, const struc
* Returns whether a surface has exertion/moves Mario
* based on the surface type.
*/
static s32 surface_has_force(s16 surfaceType)
static bool surface_has_force(s16 surfaceType)
{
s32 hasForce = FALSE;
bool hasForce = false;
switch (surfaceType)
{
@@ -82,7 +82,7 @@ static s32 surface_has_force(s16 surfaceType)
case SURFACE_MOVING_QUICKSAND:
case SURFACE_HORIZONTAL_WIND:
case SURFACE_INSTANT_MOVING_QUICKSAND:
hasForce = TRUE;
hasForce = true;
break;
default:
@@ -93,21 +93,17 @@ static s32 surface_has_force(s16 surfaceType)
static void engine_surface_from_lib_surface(struct SM64SurfaceCollisionData *surface, const struct SM64Surface *libSurf, struct SM64SurfaceObjectTransform *transform)
{
int16_t type = libSurf->type;
int16_t force = libSurf->force;
f32 x1 = libSurf->vertices[0][0];
f32 y1 = libSurf->vertices[0][1];
f32 z1 = libSurf->vertices[0][2];
f32 x2 = libSurf->vertices[1][0];
f32 y2 = libSurf->vertices[1][1];
f32 z2 = libSurf->vertices[1][2];
f32 x3 = libSurf->vertices[2][0];
f32 y3 = libSurf->vertices[2][1];
f32 z3 = libSurf->vertices[2][2];
f32 x1 = libSurf->vertices[0][0]; // v1.x
f32 y1 = libSurf->vertices[0][1]; // v1.y
f32 z1 = libSurf->vertices[0][2]; // v1.z
f32 maxY, minY;
f32 nx, ny, nz;
f32 mag;
f32 x2 = libSurf->vertices[1][0]; // v2.x
f32 y2 = libSurf->vertices[1][1]; // v2.y
f32 z2 = libSurf->vertices[1][2]; // v2.z
f32 x3 = libSurf->vertices[2][0]; // v3.x
f32 y3 = libSurf->vertices[2][1]; // v3.y
f32 z3 = libSurf->vertices[2][2]; // v3.z
if (transform != NULL)
{
@@ -127,9 +123,11 @@ static void engine_surface_from_lib_surface(struct SM64SurfaceCollisionData *sur
x1 = v1[0];
y1 = v1[1];
z1 = v1[2];
x2 = v2[0];
y2 = v2[1];
z2 = v2[2];
x3 = v3[0];
y3 = v3[1];
z3 = v3[2];
@@ -142,13 +140,13 @@ static void engine_surface_from_lib_surface(struct SM64SurfaceCollisionData *sur
}
// (v2 - v1) x (v3 - v2)
nx = (y2 - y1) * (z3 - z2) - (z2 - z1) * (y3 - y2);
ny = (z2 - z1) * (x3 - x2) - (x2 - x1) * (z3 - z2);
nz = (x2 - x1) * (y3 - y2) - (y2 - y1) * (x3 - x2);
mag = sqrtf(nx * nx + ny * ny + nz * nz);
f32 nx = (y2 - y1) * (z3 - z2) - (z2 - z1) * (y3 - y2);
f32 ny = (z2 - z1) * (x3 - x2) - (x2 - x1) * (z3 - z2);
f32 nz = (x2 - x1) * (y3 - y2) - (y2 - y1) * (x3 - x2);
f32 mag = sqrtf(nx * nx + ny * ny + nz * nz);
// Could have used min_3 and max_3 for this...
minY = y1;
f32 minY = y1;
if (y2 < minY)
{
minY = y2;
@@ -158,7 +156,7 @@ static void engine_surface_from_lib_surface(struct SM64SurfaceCollisionData *sur
minY = y3;
}
maxY = y1;
f32 maxY = y1;
if (y2 > maxY)
{
maxY = y2;
@@ -204,17 +202,17 @@ static void engine_surface_from_lib_surface(struct SM64SurfaceCollisionData *sur
surface->lowerY = minY - 5;
surface->upperY = maxY + 5;
s16 hasForce = surface_has_force(type);
s16 flags = 0; // surf_has_no_cam_collision(type);
int16_t type = libSurf->type;
// s16 flags = 0; // surf_has_no_cam_collision(type);
surface->room = 0;
surface->type = type;
surface->flags = (s8)flags;
surface->flags = libSurf->flags;
surface->terrain = libSurf->terrain;
if (hasForce)
if (surface_has_force(type))
{
surface->force = force;
surface->force = libSurf->force;
}
else
{