mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 13:35:12 +00:00
Add some more functions for use in LUA, And expose others. (#129)
* Add some functions, and restore one.
This commit is contained in:
parent
68634493de
commit
913f41f6ae
18 changed files with 3399 additions and 1491 deletions
|
@ -13,7 +13,9 @@ out_filename_defs = 'autogen/lua_definitions/functions.lua'
|
|||
|
||||
in_files = [
|
||||
"src/audio/external.h",
|
||||
"src/engine/math_util.h",
|
||||
"src/engine/surface_collision.h",
|
||||
"src/engine/surface_load.h",
|
||||
"src/game/camera.h",
|
||||
"src/game/characters.h",
|
||||
"src/game/mario_actions_airborne.c",
|
||||
|
@ -47,7 +49,6 @@ in_files = [
|
|||
"src/game/obj_behaviors.c",
|
||||
"src/game/obj_behaviors_2.c",
|
||||
"src/game/spawn_sound.c",
|
||||
"src/engine/surface_load.h",
|
||||
"src/game/object_list_processor.h",
|
||||
"src/game/behavior_actions.h",
|
||||
"src/game/mario_misc.h",
|
||||
|
@ -65,6 +66,7 @@ override_allowed_functions = {
|
|||
|
||||
override_disallowed_functions = {
|
||||
"src/audio/external.h": [ " func_" ],
|
||||
"src/engine/math_util.h": [ "atan2s", "atan2f" ],
|
||||
"src/engine/surface_collision.h": [ " debug_", "f32_find_wall_collision" ],
|
||||
"src/game/mario_actions_airborne.c": [ "^[us]32 act_.*" ],
|
||||
"src/game/mario_actions_automatic.c": [ "^[us]32 act_.*" ],
|
||||
|
@ -468,6 +470,7 @@ def build_call(function):
|
|||
|
||||
def build_function(function, do_extern):
|
||||
s = ''
|
||||
fid = function['identifier']
|
||||
|
||||
if len(function['params']) <= 0:
|
||||
s = 'int smlua_func_%s(UNUSED lua_State* L) {\n' % function['identifier']
|
||||
|
@ -479,7 +482,7 @@ def build_function(function, do_extern):
|
|||
i = 1
|
||||
for param in function['params']:
|
||||
s += build_param(param, i)
|
||||
s += ' if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %d"); return 0; }\n' % i
|
||||
s += ' if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %d for function \'%s\'"); return 0; }\n' % (i, fid)
|
||||
i += 1
|
||||
s += '\n'
|
||||
|
||||
|
|
|
@ -4186,12 +4186,20 @@ function play_sound_if_no_flag(m, soundBits, flags)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param pos Vec3f
|
||||
--- @param offset number
|
||||
--- @param radius number
|
||||
--- @return Surface
|
||||
function resolve_and_return_wall_collisions(pos, offset, radius)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param pos Vec3f
|
||||
--- @param offset number
|
||||
--- @param radius number
|
||||
--- @param collisionData WallCollisionData
|
||||
--- @return nil
|
||||
function resolve_and_return_wall_collisions(pos, offset, radius, collisionData)
|
||||
function resolve_and_return_wall_collisions_data(pos, offset, radius, collisionData)
|
||||
-- ...
|
||||
end
|
||||
|
||||
|
@ -5066,6 +5074,96 @@ function stop_and_set_height_to_floor(arg0)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param m MarioState
|
||||
--- @param result Vec3f
|
||||
--- @return integer
|
||||
function anim_spline_poll(m, result)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param current number
|
||||
--- @param target number
|
||||
--- @param inc number
|
||||
--- @param dec number
|
||||
--- @return number
|
||||
function approach_f32(current, target, inc, dec)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param current integer
|
||||
--- @param target integer
|
||||
--- @param inc integer
|
||||
--- @param dec integer
|
||||
--- @return integer
|
||||
function approach_s32(current, target, inc, dec)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param value number
|
||||
--- @param replacement number
|
||||
--- @return number
|
||||
function not_zero(value, replacement)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param dest Vec3f
|
||||
--- @param vecA Vec3f
|
||||
--- @param vecB Vec3f
|
||||
--- @param sclA number
|
||||
--- @param sclB number
|
||||
--- @return nil
|
||||
function vec3f_combine(dest, vecA, vecB, sclA, sclB)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param v1 Vec3f
|
||||
--- @param v2 Vec3f
|
||||
--- @return number
|
||||
function vec3f_dist(v1, v2)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param a Vec3f
|
||||
--- @param b Vec3f
|
||||
--- @return number
|
||||
function vec3f_dot(a, b)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param from Vec3f
|
||||
--- @param to Vec3f
|
||||
--- @param dist Pointer_number
|
||||
--- @param pitch Pointer_integer
|
||||
--- @param yaw Pointer_integer
|
||||
--- @return nil
|
||||
function vec3f_get_dist_and_angle(from, to, dist, pitch, yaw)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param a Vec3f
|
||||
--- @return number
|
||||
function vec3f_length(a)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param vec Vec3f
|
||||
--- @param onto Vec3f
|
||||
--- @param out Vec3f
|
||||
--- @return nil
|
||||
function vec3f_project(vec, onto, out)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param from Vec3f
|
||||
--- @param to Vec3f
|
||||
--- @param dist number
|
||||
--- @param pitch integer
|
||||
--- @param yaw integer
|
||||
--- @return nil
|
||||
function vec3f_set_dist_and_angle(from, to, dist, pitch, yaw)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param courseNum integer
|
||||
--- @param actNum integer
|
||||
--- @param levelNum integer
|
||||
|
@ -7662,11 +7760,23 @@ end
|
|||
|
||||
--- @param o1 Object
|
||||
--- @param o2 Object
|
||||
--- @return integer
|
||||
--- @return boolean
|
||||
function obj_check_hitbox_overlap(o1, o2)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param o Object
|
||||
--- @param x number
|
||||
--- @param y number
|
||||
--- @param z number
|
||||
--- @param h number
|
||||
--- @param r number
|
||||
--- @param d number
|
||||
--- @return boolean
|
||||
function obj_check_overlap_with_hitbox_params(o, x, y, z, h, r, d)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param behaviorId BehaviorId
|
||||
--- @return integer
|
||||
function obj_count_objects_with_behavior_id(behaviorId)
|
||||
|
@ -7757,7 +7867,7 @@ function obj_has_model_extended(o, modelId)
|
|||
end
|
||||
|
||||
--- @param o Object
|
||||
--- @return integer
|
||||
--- @return boolean
|
||||
function obj_is_valid_for_interaction(o)
|
||||
-- ...
|
||||
end
|
||||
|
|
|
@ -3936,7 +3936,29 @@
|
|||
## [resolve_and_return_wall_collisions](#resolve_and_return_wall_collisions)
|
||||
|
||||
### Lua Example
|
||||
`resolve_and_return_wall_collisions(pos, offset, radius, collisionData)`
|
||||
`local SurfaceValue = resolve_and_return_wall_collisions(pos, offset, radius)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| pos | [Vec3f](structs.md#Vec3f) |
|
||||
| offset | `number` |
|
||||
| radius | `number` |
|
||||
|
||||
### Returns
|
||||
[Surface](structs.md#Surface)
|
||||
|
||||
### C Prototype
|
||||
`struct Surface *resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [resolve_and_return_wall_collisions_data](#resolve_and_return_wall_collisions_data)
|
||||
|
||||
### Lua Example
|
||||
`resolve_and_return_wall_collisions_data(pos, offset, radius, collisionData)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
|
@ -3950,7 +3972,7 @@
|
|||
- None
|
||||
|
||||
### C Prototype
|
||||
`void resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius, struct WallCollisionData* collisionData);`
|
||||
`void resolve_and_return_wall_collisions_data(Vec3f pos, f32 offset, f32 radius, struct WallCollisionData* collisionData);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
|
@ -6679,6 +6701,256 @@
|
|||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from math_util.h
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
## [anim_spline_poll](#anim_spline_poll)
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = anim_spline_poll(m, result)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| m | [MarioState](structs.md#MarioState) |
|
||||
| result | [Vec3f](structs.md#Vec3f) |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`s32 anim_spline_poll(struct MarioState* m, Vec3f result);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [approach_f32](#approach_f32)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = approach_f32(current, target, inc, dec)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| current | `number` |
|
||||
| target | `number` |
|
||||
| inc | `number` |
|
||||
| dec | `number` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [approach_s32](#approach_s32)
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = approach_s32(current, target, inc, dec)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| current | `integer` |
|
||||
| target | `integer` |
|
||||
| inc | `integer` |
|
||||
| dec | `integer` |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`s32 approach_s32(s32 current, s32 target, s32 inc, s32 dec);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [not_zero](#not_zero)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = not_zero(value, replacement)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| value | `number` |
|
||||
| replacement | `number` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 not_zero(f32 value, f32 replacement);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [vec3f_combine](#vec3f_combine)
|
||||
|
||||
### Lua Example
|
||||
`vec3f_combine(dest, vecA, vecB, sclA, sclB)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| dest | [Vec3f](structs.md#Vec3f) |
|
||||
| vecA | [Vec3f](structs.md#Vec3f) |
|
||||
| vecB | [Vec3f](structs.md#Vec3f) |
|
||||
| sclA | `number` |
|
||||
| sclB | `number` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void vec3f_combine(Vec3f dest, Vec3f vecA, Vec3f vecB, f32 sclA, f32 sclB);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [vec3f_dist](#vec3f_dist)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = vec3f_dist(v1, v2)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| v1 | [Vec3f](structs.md#Vec3f) |
|
||||
| v2 | [Vec3f](structs.md#Vec3f) |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 vec3f_dist(Vec3f v1, Vec3f v2);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [vec3f_dot](#vec3f_dot)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = vec3f_dot(a, b)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| a | [Vec3f](structs.md#Vec3f) |
|
||||
| b | [Vec3f](structs.md#Vec3f) |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 vec3f_dot(Vec3f a, Vec3f b);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [vec3f_get_dist_and_angle](#vec3f_get_dist_and_angle)
|
||||
|
||||
### Lua Example
|
||||
`vec3f_get_dist_and_angle(from, to, dist, pitch, yaw)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| from | [Vec3f](structs.md#Vec3f) |
|
||||
| to | [Vec3f](structs.md#Vec3f) |
|
||||
| dist | `Pointer` <`number`> |
|
||||
| pitch | `Pointer` <`integer`> |
|
||||
| yaw | `Pointer` <`integer`> |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *yaw);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [vec3f_length](#vec3f_length)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = vec3f_length(a)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| a | [Vec3f](structs.md#Vec3f) |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 vec3f_length(Vec3f a);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [vec3f_project](#vec3f_project)
|
||||
|
||||
### Lua Example
|
||||
`vec3f_project(vec, onto, out)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| vec | [Vec3f](structs.md#Vec3f) |
|
||||
| onto | [Vec3f](structs.md#Vec3f) |
|
||||
| out | [Vec3f](structs.md#Vec3f) |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void vec3f_project(Vec3f vec, Vec3f onto, Vec3f out);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [vec3f_set_dist_and_angle](#vec3f_set_dist_and_angle)
|
||||
|
||||
### Lua Example
|
||||
`vec3f_set_dist_and_angle(from, to, dist, pitch, yaw)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| from | [Vec3f](structs.md#Vec3f) |
|
||||
| to | [Vec3f](structs.md#Vec3f) |
|
||||
| dist | `number` |
|
||||
| pitch | `integer` |
|
||||
| yaw | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from network_player.h
|
||||
|
||||
|
|
|
@ -7167,7 +7167,7 @@
|
|||
## [obj_check_hitbox_overlap](#obj_check_hitbox_overlap)
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = obj_check_hitbox_overlap(o1, o2)`
|
||||
`local booleanValue = obj_check_hitbox_overlap(o1, o2)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
|
@ -7176,10 +7176,36 @@
|
|||
| o2 | [Object](structs.md#Object) |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
- `boolean`
|
||||
|
||||
### C Prototype
|
||||
`s32 obj_check_hitbox_overlap(struct Object *o1, struct Object *o2);`
|
||||
`bool obj_check_hitbox_overlap(struct Object *o1, struct Object *o2);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [obj_check_overlap_with_hitbox_params](#obj_check_overlap_with_hitbox_params)
|
||||
|
||||
### Lua Example
|
||||
`local booleanValue = obj_check_overlap_with_hitbox_params(o, x, y, z, h, r, d)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| o | [Object](structs.md#Object) |
|
||||
| x | `number` |
|
||||
| y | `number` |
|
||||
| z | `number` |
|
||||
| h | `number` |
|
||||
| r | `number` |
|
||||
| d | `number` |
|
||||
|
||||
### Returns
|
||||
- `boolean`
|
||||
|
||||
### C Prototype
|
||||
`bool obj_check_overlap_with_hitbox_params(struct Object *o, f32 x, f32 y, f32 z, f32 h, f32 r, f32 d);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
|
@ -7459,7 +7485,7 @@
|
|||
## [obj_is_valid_for_interaction](#obj_is_valid_for_interaction)
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = obj_is_valid_for_interaction(o)`
|
||||
`local booleanValue = obj_is_valid_for_interaction(o)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
|
@ -7467,10 +7493,10 @@
|
|||
| o | [Object](structs.md#Object) |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
- `boolean`
|
||||
|
||||
### C Prototype
|
||||
`s32 obj_is_valid_for_interaction(struct Object *o);`
|
||||
`bool obj_is_valid_for_interaction(struct Object *o);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
|
|
|
@ -816,6 +816,7 @@
|
|||
- [play_sound_and_spawn_particles](functions-3.md#play_sound_and_spawn_particles)
|
||||
- [play_sound_if_no_flag](functions-3.md#play_sound_if_no_flag)
|
||||
- [resolve_and_return_wall_collisions](functions-3.md#resolve_and_return_wall_collisions)
|
||||
- [resolve_and_return_wall_collisions_data](functions-3.md#resolve_and_return_wall_collisions_data)
|
||||
- [return_mario_anim_y_translation](functions-3.md#return_mario_anim_y_translation)
|
||||
- [set_anim_to_frame](functions-3.md#set_anim_to_frame)
|
||||
- [set_jump_from_landing](functions-3.md#set_jump_from_landing)
|
||||
|
@ -984,6 +985,21 @@
|
|||
|
||||
<br />
|
||||
|
||||
- math_util.h
|
||||
- [anim_spline_poll](functions-3.md#anim_spline_poll)
|
||||
- [approach_f32](functions-3.md#approach_f32)
|
||||
- [approach_s32](functions-3.md#approach_s32)
|
||||
- [not_zero](functions-3.md#not_zero)
|
||||
- [vec3f_combine](functions-3.md#vec3f_combine)
|
||||
- [vec3f_dist](functions-3.md#vec3f_dist)
|
||||
- [vec3f_dot](functions-3.md#vec3f_dot)
|
||||
- [vec3f_get_dist_and_angle](functions-3.md#vec3f_get_dist_and_angle)
|
||||
- [vec3f_length](functions-3.md#vec3f_length)
|
||||
- [vec3f_project](functions-3.md#vec3f_project)
|
||||
- [vec3f_set_dist_and_angle](functions-3.md#vec3f_set_dist_and_angle)
|
||||
|
||||
<br />
|
||||
|
||||
- network_player.h
|
||||
- [get_network_player_from_area](functions-3.md#get_network_player_from_area)
|
||||
- [get_network_player_from_level](functions-3.md#get_network_player_from_level)
|
||||
|
@ -1436,6 +1452,7 @@
|
|||
- [get_temp_object_hitbox](functions-4.md#get_temp_object_hitbox)
|
||||
- [get_trajectory](functions-4.md#get_trajectory)
|
||||
- [obj_check_hitbox_overlap](functions-4.md#obj_check_hitbox_overlap)
|
||||
- [obj_check_overlap_with_hitbox_params](functions-4.md#obj_check_overlap_with_hitbox_params)
|
||||
- [obj_count_objects_with_behavior_id](functions-4.md#obj_count_objects_with_behavior_id)
|
||||
- [obj_get_first](functions-4.md#obj_get_first)
|
||||
- [obj_get_first_with_behavior_id](functions-4.md#obj_get_first_with_behavior_id)
|
||||
|
|
|
@ -171,6 +171,34 @@ void vec3f_combine(Vec3f dest, Vec3f vecA, Vec3f vecB, f32 sclA, f32 sclB) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a vector rotated around the z axis, then the x axis, then the y
|
||||
* axis.
|
||||
*/
|
||||
void *vec3f_rotate_zxy(Vec3f dest, Vec3s rotate) {
|
||||
Vec3f v = { dest[0], dest[1], dest[2] };
|
||||
|
||||
f32 sx = sins(rotate[0]);
|
||||
f32 cx = coss(rotate[0]);
|
||||
|
||||
f32 sy = sins(rotate[1]);
|
||||
f32 cy = coss(rotate[1]);
|
||||
|
||||
f32 sz = sins(rotate[2]);
|
||||
f32 cz = coss(rotate[2]);
|
||||
|
||||
f32 sysz = (sy * sz);
|
||||
f32 cycz = (cy * cz);
|
||||
f32 cysz = (cy * sz);
|
||||
f32 sycz = (sy * cz);
|
||||
|
||||
dest[0] = v[0] * ((sysz * sx) + cycz) + v[1] * ((sycz * sx) - cysz) + v[2] * (cx * sy);
|
||||
dest[1] = v[0] * (cx * sz) + v[1] * (cx * cz) + v[2] * -sx;
|
||||
dest[2] = v[0] * ((cysz * sx) - sycz) + v[1] * ((cycz * sx) + sysz) + v[2] * (cx * cy);
|
||||
|
||||
return &dest;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
/// Copy matrix 'src' to 'dest'
|
||||
|
|
|
@ -63,6 +63,7 @@ void *vec3f_normalize(Vec3f dest);
|
|||
f32 vec3f_length(Vec3f a);
|
||||
f32 vec3f_dot(Vec3f a, Vec3f b);
|
||||
void vec3f_combine(Vec3f dest, Vec3f vecA, Vec3f vecB, f32 sclA, f32 sclB);
|
||||
void *vec3f_rotate_zxy(Vec3f v, Vec3s rotate);
|
||||
void mtxf_copy(Mat4 dest, Mat4 src);
|
||||
void mtxf_identity(Mat4 mtx);
|
||||
void mtxf_translate(Mat4 dest, Vec3f b);
|
||||
|
|
|
@ -2143,7 +2143,7 @@ void check_kick_or_punch_wall(struct MarioState *m) {
|
|||
detector[1] = m->pos[1];
|
||||
|
||||
struct WallCollisionData wcd = { 0 };
|
||||
resolve_and_return_wall_collisions(detector, 80.0f, 5.0f, &wcd);
|
||||
resolve_and_return_wall_collisions_data(detector, 80.0f, 5.0f, &wcd);
|
||||
if (wcd.numWalls > 0) {
|
||||
if (m->action != ACT_MOVE_PUNCHING || m->forwardVel >= 0.0f) {
|
||||
if (m->action == ACT_PUNCHING) {
|
||||
|
|
|
@ -591,7 +591,32 @@ u32 mario_get_terrain_sound_addend(struct MarioState *m) {
|
|||
/**
|
||||
* Collides with walls and returns the most recent wall.
|
||||
*/
|
||||
void resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius, struct WallCollisionData* collisionData) {
|
||||
struct Surface *resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius) {
|
||||
struct WallCollisionData collisionData;
|
||||
struct Surface *wall = NULL;
|
||||
|
||||
collisionData.x = pos[0];
|
||||
collisionData.y = pos[1];
|
||||
collisionData.z = pos[2];
|
||||
collisionData.radius = radius;
|
||||
collisionData.offsetY = offset;
|
||||
|
||||
if (find_wall_collisions(&collisionData)) {
|
||||
wall = collisionData.walls[collisionData.numWalls - 1];
|
||||
}
|
||||
|
||||
// I'm not sure if this code is actually ever used or not.
|
||||
pos[0] = collisionData.x;
|
||||
pos[1] = collisionData.y;
|
||||
pos[2] = collisionData.z;
|
||||
|
||||
return wall;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collides with walls and returns the wall collision data.
|
||||
*/
|
||||
void resolve_and_return_wall_collisions_data(Vec3f pos, f32 offset, f32 radius, struct WallCollisionData* collisionData) {
|
||||
if (!collisionData || !pos) { return; }
|
||||
|
||||
collisionData->x = pos[0];
|
||||
|
|
|
@ -33,7 +33,8 @@ void mario_set_bubbled(struct MarioState* m);
|
|||
void mario_set_forward_vel(struct MarioState *m, f32 speed);
|
||||
s32 mario_get_floor_class(struct MarioState *m);
|
||||
u32 mario_get_terrain_sound_addend(struct MarioState *m);
|
||||
void resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius, struct WallCollisionData* collisionData);
|
||||
struct Surface *resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius);
|
||||
void resolve_and_return_wall_collisions_data(Vec3f pos, f32 offset, f32 radius, struct WallCollisionData* collisionData);
|
||||
f32 vec3f_find_ceil(Vec3f pos, f32 height, struct Surface **ceil);
|
||||
f32 vec3f_mario_ceil(Vec3f pos, f32 height, struct Surface **ceil);
|
||||
s32 mario_facing_downhill(struct MarioState *m, s32 turnYaw);
|
||||
|
|
|
@ -332,7 +332,7 @@ s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos) {
|
|||
smlua_call_event_hooks_mario_param(HOOK_BEFORE_PHYS_STEP, m);
|
||||
|
||||
struct WallCollisionData wcd = { 0 };
|
||||
resolve_and_return_wall_collisions(nextPos, 50.0f, 50.0f, &wcd);
|
||||
resolve_and_return_wall_collisions_data(nextPos, 50.0f, 50.0f, &wcd);
|
||||
m->wall = (wcd.numWalls > 0)
|
||||
? wcd.walls[wcd.numWalls - 1]
|
||||
: NULL;
|
||||
|
|
|
@ -647,7 +647,7 @@ s32 act_debug_free_move(struct MarioState *m) {
|
|||
}
|
||||
|
||||
struct WallCollisionData wcd = { 0 };
|
||||
resolve_and_return_wall_collisions(pos, 60.0f, 50.0f, &wcd);
|
||||
resolve_and_return_wall_collisions_data(pos, 60.0f, 50.0f, &wcd);
|
||||
|
||||
struct Surface *surf = NULL;
|
||||
f32 floorHeight = find_floor(pos[0], pos[1], pos[2], &surf);
|
||||
|
|
|
@ -87,7 +87,7 @@ u32 perform_water_full_step(struct MarioState *m, Vec3f nextPos) {
|
|||
f32 ceilHeight;
|
||||
f32 floorHeight;
|
||||
|
||||
resolve_and_return_wall_collisions(nextPos, 10.0f, 110.0f, &wcd);
|
||||
resolve_and_return_wall_collisions_data(nextPos, 10.0f, 110.0f, &wcd);
|
||||
floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
||||
ceilHeight = vec3f_mario_ceil(nextPos, floorHeight, &ceil);
|
||||
|
||||
|
|
|
@ -267,8 +267,8 @@ static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos) {
|
|||
f32 floorHeight;
|
||||
f32 waterLevel;
|
||||
|
||||
resolve_and_return_wall_collisions(nextPos, 30.0f, 24.0f, &lowerWcd);
|
||||
resolve_and_return_wall_collisions(nextPos, 60.0f, 50.0f, &upperWcd);
|
||||
resolve_and_return_wall_collisions_data(nextPos, 30.0f, 24.0f, &lowerWcd);
|
||||
resolve_and_return_wall_collisions_data(nextPos, 60.0f, 50.0f, &upperWcd);
|
||||
|
||||
floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
||||
ceilHeight = vec3f_mario_ceil(nextPos, floorHeight, &ceil);
|
||||
|
@ -421,8 +421,8 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
|
|||
|
||||
vec3f_copy(nextPos, intendedPos);
|
||||
|
||||
resolve_and_return_wall_collisions(nextPos, 150.0f, 50.0f, &upperWcd);
|
||||
resolve_and_return_wall_collisions(nextPos, 30.0f, 50.0f, &lowerWcd);
|
||||
resolve_and_return_wall_collisions_data(nextPos, 150.0f, 50.0f, &upperWcd);
|
||||
resolve_and_return_wall_collisions_data(nextPos, 30.0f, 50.0f, &lowerWcd);
|
||||
|
||||
floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
||||
ceilHeight = vec3f_mario_ceil(nextPos, floorHeight, &ceil);
|
||||
|
|
|
@ -132,10 +132,12 @@ void smlua_init(void) {
|
|||
// load libraries
|
||||
luaopen_base(L);
|
||||
//luaopen_coroutine(L);
|
||||
//luaopen_debug(L);
|
||||
//luaopen_io(L);
|
||||
#if defined(LUA_PROFILER)
|
||||
luaL_requiref(L, "debug", luaopen_debug, 1);
|
||||
luaL_requiref(L, "io", luaopen_io, 1);
|
||||
luaL_requiref(L, "os", luaopen_os, 1);
|
||||
#endif
|
||||
luaL_requiref(L, "math", luaopen_math, 1);
|
||||
//luaopen_os(L);
|
||||
//luaopen_package(L);
|
||||
luaL_requiref(L, "string", luaopen_string, 1);
|
||||
luaL_requiref(L, "table", luaopen_table, 1);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -260,20 +260,45 @@ struct ObjectHitbox* get_temp_object_hitbox(void) {
|
|||
return &sTmpHitbox;
|
||||
}
|
||||
|
||||
s32 obj_is_valid_for_interaction(struct Object *o) {
|
||||
bool obj_is_valid_for_interaction(struct Object *o) {
|
||||
return o->activeFlags != ACTIVE_FLAG_DEACTIVATED && o->oIntangibleTimer == 0 && (o->oInteractStatus & INT_STATUS_INTERACTED) == 0;
|
||||
}
|
||||
|
||||
s32 obj_check_hitbox_overlap(struct Object *o1, struct Object *o2) {
|
||||
f32 r2 = sqr(max(o1->hitboxRadius, o1->hurtboxRadius) + max(o2->hitboxRadius, o2->hurtboxRadius));
|
||||
bool obj_check_hitbox_overlap(struct Object *o1, struct Object *o2) {
|
||||
if (o1 == NULL || o2 == NULL) { return FALSE; }
|
||||
|
||||
f32 o1H = max(o1->hitboxHeight, o1->hurtboxHeight);
|
||||
f32 o1R = max(o1->hitboxRadius, o1->hurtboxRadius);
|
||||
f32 o2H = max(o2->hitboxHeight, o2->hurtboxHeight);
|
||||
f32 o2R = max(o2->hitboxRadius, o2->hurtboxRadius);
|
||||
|
||||
f32 r2 = sqr(o1R + o2R);
|
||||
f32 d2 = sqr(o1->oPosX - o2->oPosX) + sqr(o1->oPosZ - o2->oPosZ);
|
||||
if (d2 > r2) return FALSE;
|
||||
f32 hb1lb = o1->oPosY - o1->hitboxDownOffset;
|
||||
f32 hb1ub = hb1lb + max(o1->hitboxHeight, o1->hurtboxHeight);
|
||||
f32 hb1ub = hb1lb + o1H;
|
||||
f32 hb2lb = o2->oPosY - o2->hitboxDownOffset;
|
||||
f32 hb2ub = hb2lb + max(o2->hitboxHeight, o2->hurtboxHeight);
|
||||
f32 hbsoh = max(o1->hitboxHeight, o1->hurtboxHeight) + max(o2->hitboxHeight, o2->hurtboxHeight);
|
||||
if (hb2ub - hb1lb > hbsoh || hb1ub - hb2lb > hbsoh) return FALSE;
|
||||
f32 hb2ub = hb2lb + o2H;
|
||||
f32 hbsoh = o1H + o2H;
|
||||
if ((hb2ub - hb1lb) > hbsoh || (hb1ub - hb2lb) > hbsoh) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool obj_check_overlap_with_hitbox_params(struct Object *o, f32 x, f32 y, f32 z, f32 h, f32 r, f32 d) {
|
||||
if (o == NULL) { return FALSE; }
|
||||
|
||||
f32 oH = max(o->hitboxHeight, o->hurtboxHeight);
|
||||
f32 oR = max(o->hitboxRadius, o->hurtboxRadius);
|
||||
|
||||
f32 r2 = sqr(oR + r);
|
||||
f32 d2 = sqr(o->oPosX - x) + sqr(o->oPosZ - z);
|
||||
if (d2 > r2) return FALSE;
|
||||
f32 hb1lb = o->oPosY - o->hitboxDownOffset;
|
||||
f32 hb1ub = hb1lb + oH;
|
||||
f32 hb2lb = y - d;
|
||||
f32 hb2ub = hb2lb + h;
|
||||
f32 hbsoh = oH + h;
|
||||
if ((hb2ub - hb1lb) > hbsoh || (hb1ub - hb2lb) > hbsoh) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,8 +37,9 @@ s32 obj_count_objects_with_behavior_id(enum BehaviorId behaviorId);
|
|||
struct SpawnParticlesInfo* obj_get_temp_spawn_particles_info(enum ModelExtendedId modelId);
|
||||
struct ObjectHitbox* get_temp_object_hitbox(void);
|
||||
|
||||
s32 obj_is_valid_for_interaction(struct Object *o);
|
||||
s32 obj_check_hitbox_overlap(struct Object *o1, struct Object *o2);
|
||||
bool obj_is_valid_for_interaction(struct Object *o);
|
||||
bool obj_check_hitbox_overlap(struct Object *o1, struct Object *o2);
|
||||
bool obj_check_overlap_with_hitbox_params(struct Object *o, f32 x, f32 y, f32 z, f32 h, f32 r, f32 d);
|
||||
void obj_set_vel(struct Object *o, f32 vx, f32 vy, f32 vz);
|
||||
void obj_move_xyz(struct Object *o, f32 dx, f32 dy, f32 dz);
|
||||
|
||||
|
|
Loading…
Reference in a new issue