set_find_wall_direction

This commit is contained in:
Isaac0-dev 2025-02-22 11:54:07 +10:00
parent 077bbc4d54
commit 2ec4b5e53c
7 changed files with 80 additions and 7 deletions

View file

@ -110,7 +110,7 @@ override_disallowed_functions = {
"src/game/interaction.h": [ "process_interaction", "_handle_" ],
"src/game/sound_init.h": [ "_loop_", "thread4_", "set_sound_mode" ],
"src/pc/network/network_utils.h": [ "network_get_player_text_color[^_]" ],
"src/pc/network/network_player.h": [ "_init", "_connected[^_]", "_shutdown", "_disconnected", "_update", "construct_player_popup" ],
"src/pc/network/network_player.h": [ "_init", "_connected[^_]", "_shutdown", "_disconnected", "_update", "construct_player_popup", "network_player_name_valid" ],
"src/game/object_helpers.c": [ "spawn_obj", "^bhv_", "abs[fi]", "^bit_shift", "_debug$", "^stub_", "_set_model", "cur_obj_set_direction_table", "cur_obj_progress_direction_table" ],
"src/game/obj_behaviors.c": [ "debug_" ],
"src/game/obj_behaviors_2.c": [ "wiggler_jumped_on_attack_handler", "huge_goomba_weakly_attacked" ],

View file

@ -10545,6 +10545,14 @@ function find_water_level(x, z)
-- ...
end
--- @param dir Vec3f
--- @param active boolean
--- @param airborne boolean
--- Sets whether collision finding functions should check wall directions.
function set_find_wall_direction(dir, active, airborne)
-- ...
end
--- @param data Pointer_integer
--- @return integer
function get_area_terrain_size(data)

View file

@ -3577,6 +3577,31 @@ Finds the height of water at a given position (x, z), if the position is within
<br />
## [set_find_wall_direction](#set_find_wall_direction)
### Description
Sets whether collision finding functions should check wall directions.
### Lua Example
`set_find_wall_direction(dir, active, airborne)`
### Parameters
| Field | Type |
| ----- | ---- |
| dir | [Vec3f](structs.md#Vec3f) |
| active | `boolean` |
| airborne | `boolean` |
### Returns
- None
### C Prototype
`void set_find_wall_direction(Vec3f dir, bool active, bool airborne);`
[:arrow_up_small:](#)
<br />
---
# functions from surface_load.h

View file

@ -1930,6 +1930,7 @@
- [find_poison_gas_level](functions-6.md#find_poison_gas_level)
- [find_wall_collisions](functions-6.md#find_wall_collisions)
- [find_water_level](functions-6.md#find_water_level)
- [set_find_wall_direction](functions-6.md#set_find_wall_direction)
<br />

View file

@ -19,6 +19,14 @@ u8 gFindWallDirectionAirborne = false;
#define CLAMP(_val, _min, _max) MAX(MIN((_val), _max), _min)
void set_find_wall_direction(Vec3f dir, bool active, bool airborne) {
if (active) {
vec3f_copy(gFindWallDirection, dir);
}
gFindWallDirectionActive = active;
gFindWallDirectionAirborne = airborne;
}
static void closest_point_to_triangle(struct Surface* surf, Vec3f src, Vec3f out) {
Vec3f v1; vec3s_to_vec3f(v1, surf->vertex1);
Vec3f v2; vec3s_to_vec3f(v2, surf->vertex2);

View file

@ -11,7 +11,7 @@
#define CELL_HEIGHT_LIMIT 20000
#define FLOOR_LOWER_LIMIT -11000
#define FLOOR_LOWER_LIMIT_MISC (FLOOR_LOWER_LIMIT + 1000)
// same as FLOOR_LOWER_LIMIT_MISC, explicitly for shadow.c
// same as FLOOR_LOWER_LIMIT_MISC, explicitly for shadow.c
// It doesn't match if ".0" is removed or ".f" is added
#define FLOOR_LOWER_LIMIT_SHADOW (FLOOR_LOWER_LIMIT + 1000.0)
@ -45,38 +45,43 @@ extern u8 gFindWallDirectionAirborne;
s32 f32_find_wall_collision(f32 *xPtr, f32 *yPtr, f32 *zPtr, f32 offsetY, f32 radius);
/* |description|
Detects wall collisions at a given position and adjusts the position based on the walls found.
Detects wall collisions at a given position and adjusts the position based on the walls found.
Returns the number of wall collisions detected
|descriptionEnd| */
s32 find_wall_collisions(struct WallCollisionData *colData);
f32 find_ceil(f32 posX, f32 posY, f32 posZ, struct Surface **pceil);
/* |description|
Finds the height of the highest ceiling above a given position (x, y, z).
Finds the height of the highest ceiling above a given position (x, y, z).
If no ceiling is found, returns the default height limit of `gLevelValues.cellHeightLimit`(20000 by default)
|descriptionEnd| */
f32 find_ceil_height(f32 x, f32 y, f32 z);
f32 find_floor_height_and_data(f32 xPos, f32 yPos, f32 zPos, struct FloorGeometry **floorGeo);
/* |description|
Finds the height of the highest floor below a given position (x, y, z).
Finds the height of the highest floor below a given position (x, y, z).
If no floor is found, returns the default floor height of `gLevelValues.floorLowerLimit`(-11000 by default)
|descriptionEnd| */
f32 find_floor_height(f32 x, f32 y, f32 z);
f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor);
/* |description|
Finds the height of water at a given position (x, z), if the position is within a water region.
Finds the height of water at a given position (x, z), if the position is within a water region.
If no water is found, returns the default height of `gLevelValues.floorLowerLimit`(-11000 by default)
|descriptionEnd| */
f32 find_water_level(f32 x, f32 z);
/* |description|
Finds the height of the poison gas at a given position (x, z), if the position is within a gas region.
Finds the height of the poison gas at a given position (x, z), if the position is within a gas region.
If no gas is found, returns the default height of `gLevelValues.floorLowerLimit`(-11000 by default)
|descriptionEnd| */
f32 find_poison_gas_level(f32 x, f32 z);
void debug_surface_list_info(f32 xPos, f32 zPos);
void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos, f32 precision);
/* |description|
Sets whether collision finding functions should check wall directions.
|descriptionEnd| */
void set_find_wall_direction(Vec3f dir, bool active, bool airborne);
#endif // SURFACE_COLLISION_H

View file

@ -31892,6 +31892,31 @@ int smlua_func_find_water_level(lua_State* L) {
return 1;
}
int smlua_func_set_find_wall_direction(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 3) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_find_wall_direction", 3, top);
return 0;
}
Vec3f dir;
smlua_get_vec3f(dir, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_find_wall_direction"); return 0; }
bool active = smlua_to_boolean(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_find_wall_direction"); return 0; }
bool airborne = smlua_to_boolean(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "set_find_wall_direction"); return 0; }
set_find_wall_direction(dir, active, airborne);
smlua_push_vec3f(dir, 1);
return 1;
}
////////////////////
// surface_load.h //
////////////////////
@ -33824,6 +33849,7 @@ void smlua_bind_functions_autogen(void) {
//smlua_bind_function(L, "find_surface_on_ray", smlua_func_find_surface_on_ray); <--- UNIMPLEMENTED
smlua_bind_function(L, "find_wall_collisions", smlua_func_find_wall_collisions);
smlua_bind_function(L, "find_water_level", smlua_func_find_water_level);
smlua_bind_function(L, "set_find_wall_direction", smlua_func_set_find_wall_direction);
// surface_load.h
smlua_bind_function(L, "get_area_terrain_size", smlua_func_get_area_terrain_size);