From ff41ecfceb3e52467dbef5eb31f0ebab3bb2988b Mon Sep 17 00:00:00 2001 From: MeltyPlayer Date: Mon, 7 Nov 2022 19:40:46 -0600 Subject: [PATCH] Exposed libsm64's raycasting/collision logic via its API. --- src/libsm64.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/libsm64.h | 10 ++++++++++ 2 files changed, 51 insertions(+) diff --git a/src/libsm64.c b/src/libsm64.c index 003837a..9db7347 100644 --- a/src/libsm64.c +++ b/src/libsm64.c @@ -268,3 +268,44 @@ SM64_LIB_FN void sm64_surface_object_delete( uint32_t objectId ) surfaces_unload_object( objectId ); } + + +SM64_LIB_FN s32 sm64_surface_find_wall_collision(f32 *xPtr, f32 *yPtr, f32 *zPtr, f32 offsetY, f32 radius) +{ + return f32_find_wall_collision( xPtr, yPtr, zPtr, offsetY, radius ); +} + +SM64_LIB_FN s32 sm64_surface_find_wall_collisions(struct WallCollisionData *colData) +{ + return find_wall_collisions( colData ); +} + +SM64_LIB_FN f32 sm64_surface_find_ceil(f32 posX, f32 posY, f32 posZ, struct Surface **pceil) +{ + return find_ceil( posX, posY, posZ, pceil ); +} + +SM64_LIB_FN f32 sm64_surface_find_floor_height_and_data(f32 xPos, f32 yPos, f32 zPos, struct FloorGeometry **floorGeo) +{ + return find_floor_height_and_data( xPos, yPos, zPos, floorGeo ); +} + +SM64_LIB_FN f32 sm64_surface_find_floor_height(f32 x, f32 y, f32 z) +{ + return find_floor_height( x, y, z ); +} + +SM64_LIB_FN f32 sm64_surface_find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) +{ + return find_floor( xPos, yPos, zPos, pfloor ); +} + +SM64_LIB_FN f32 sm64_surface_find_water_level(f32 x, f32 z) +{ + return find_water_level( x, z ); +} + +SM64_LIB_FN f32 sm64_surface_find_poison_gas_level(f32 x, f32 z) +{ + return find_poison_gas_level( x, z ); +} diff --git a/src/libsm64.h b/src/libsm64.h index 2a10146..b45e272 100644 --- a/src/libsm64.h +++ b/src/libsm64.h @@ -5,6 +5,7 @@ #include #include +#include "decomp/engine/surface_collision.h" #include "decomp/include/types.h" #ifdef _WIN32 @@ -90,4 +91,13 @@ extern SM64_LIB_FN uint32_t sm64_surface_object_create( const struct SM64Surface extern SM64_LIB_FN void sm64_surface_object_move( uint32_t objectId, const struct SM64ObjectTransform *transform ); extern SM64_LIB_FN void sm64_surface_object_delete( uint32_t objectId ); +extern SM64_LIB_FN s32 sm64_surface_find_wall_collision(f32 *xPtr, f32 *yPtr, f32 *zPtr, f32 offsetY, f32 radius); +extern SM64_LIB_FN s32 sm64_surface_find_wall_collisions(struct WallCollisionData *colData); +extern SM64_LIB_FN f32 sm64_surface_find_ceil(f32 posX, f32 posY, f32 posZ, struct Surface **pceil); +extern SM64_LIB_FN f32 sm64_surface_find_floor_height_and_data(f32 xPos, f32 yPos, f32 zPos, struct FloorGeometry **floorGeo); +extern SM64_LIB_FN f32 sm64_surface_find_floor_height(f32 x, f32 y, f32 z); +extern SM64_LIB_FN f32 sm64_surface_find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor); +extern SM64_LIB_FN f32 sm64_surface_find_water_level(f32 x, f32 z); +extern SM64_LIB_FN f32 sm64_surface_find_poison_gas_level(f32 x, f32 z); + #endif//LIB_SM64_H