Fix vec3f bugs (#837)

This commit is contained in:
PeachyPeach 2025-06-05 11:44:09 +02:00 committed by GitHub
parent e1aab9c479
commit c79d59d8ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 599 additions and 763 deletions

View file

@ -902,8 +902,9 @@ def build_param(fid, param, i):
def build_param_after(param, i): def build_param_after(param, i):
ptype = param['type'] ptype = param['type']
pid = param['identifier'] pid = param['identifier']
is_output = param.get('out', False)
if ptype in VEC_TYPES: if ptype in VEC_TYPES and is_output:
return (vec_type_after % (ptype.lower())).replace('$[IDENTIFIER]', str(pid)).replace('$[INDEX]', str(i)) return (vec_type_after % (ptype.lower())).replace('$[IDENTIFIER]', str(pid)).replace('$[INDEX]', str(i))
else: else:
return '' return ''
@ -997,9 +998,12 @@ def build_function(function, do_extern):
i += 1 i += 1
s += '\n' s += '\n'
# To allow chaining vector functions calls, return the table corresponding to `dest` parameter # To allow chaining vector functions calls, return the table corresponding to the `OUT` parameter
if function['type'] in VECP_TYPES: if function['type'] in VECP_TYPES:
s += ' lua_settop(L, 1);\n' for i, param in enumerate(function['params']):
if param.get('out', False):
s += ' lua_settop(L, %d);\n' % (i + 1)
break
s += ' return 1;\n}\n' s += ' return 1;\n}\n'
@ -1099,6 +1103,11 @@ def process_function(fname, line, description):
for param_str in params_str.split(','): for param_str in params_str.split(','):
param = {} param = {}
param_str = param_str.strip() param_str = param_str.strip()
if param_str.startswith('OUT '):
param['out'] = True
param_str = param_str[len('OUT'):].strip()
if param_str.endswith('*') or ' ' not in param_str: if param_str.endswith('*') or ' ' not in param_str:
param['type'] = normalize_type(param_str) param['type'] = normalize_type(param_str)
param['identifier'] = 'arg%d' % param_index param['identifier'] = 'arg%d' % param_index

View file

@ -5,7 +5,7 @@ VEC3X_TO_VEC3Y = """
/* |description| /* |description|
Converts a 3D {{desc}} vector `a` into a 3D {{desc_2}} vector and stores the result in `dest` Converts a 3D {{desc}} vector `a` into a 3D {{desc_2}} vector and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix_2}}p vec3{{suffix}}_to_vec3{{suffix_2}}(Vec3{{suffix_2}} dest, Vec3{{suffix}} a) { INLINE OPTIMIZE_O3 Vec3{{suffix_2}}p vec3{{suffix}}_to_vec3{{suffix_2}}(OUT Vec3{{suffix_2}} dest, Vec3{{suffix}} a) {
dest[0] = a[0]{{rounding_0}}; dest[0] = a[0]{{rounding_0}};
dest[1] = a[1]{{rounding_1}}; dest[1] = a[1]{{rounding_1}};
dest[2] = a[2]{{rounding_2}}; dest[2] = a[2]{{rounding_2}};

View file

@ -61,7 +61,7 @@ end
----------- -----------
--- @type Vec3f --- @type Vec3f
gGlobalSoundSource = { x = 0, y = 0, z = 0 } gGlobalSoundSource = create_read_only_table({ x = 0, y = 0, z = 0 })
--- @param bank number --- @param bank number
--- @param soundID number --- @param soundID number

View file

@ -63,7 +63,7 @@ end
----------- -----------
--- @type Vec3f --- @type Vec3f
gGlobalSoundSource = { x = 0, y = 0, z = 0 } gGlobalSoundSource = create_read_only_table({ x = 0, y = 0, z = 0 })
--- @param bank number --- @param bank number
--- @param soundID number --- @param soundID number

View file

@ -109,13 +109,6 @@ function arc_to_goal_pos(goal, pos, yVel, gravity)
-- ... -- ...
end end
--- @param dest Vec3f
--- @param src Vec3f
--- Duplicate of vec3f_copy except without bad return
function vec3f_copy_2(dest, src)
-- ...
end
--- @param forwardVel number --- @param forwardVel number
--- @param a1 number --- @param a1 number
--- @param deltaPitch integer --- @param deltaPitch integer
@ -3144,6 +3137,34 @@ function vec3f_to_object_pos(o, src)
-- ... -- ...
end end
--- @param dst Vec3s
--- @param o Object
--- Converts an object's face angle to a `Vec3s` format
function object_face_angle_to_vec3s(dst, o)
-- ...
end
--- @param o Object
--- @param src Vec3s
--- Converts a `Vec3s` angle to an object's face angle internal format
function vec3s_to_object_face_angle(o, src)
-- ...
end
--- @param dst Vec3s
--- @param o Object
--- Converts an object's move angle to a `Vec3s` format
function object_move_angle_to_vec3s(dst, o)
-- ...
end
--- @param o Object
--- @param src Vec3s
--- Converts a `Vec3s` angle to an object's move angle internal format
function vec3s_to_object_move_angle(o, src)
-- ...
end
--- @param angle integer --- @param angle integer
--- @return integer --- @return integer
--- Selects an alternate camera mode based on the given angle. Used to toggle between predefined camera modes dynamically --- Selects an alternate camera mode based on the given angle. Used to toggle between predefined camera modes dynamically
@ -6497,7 +6518,7 @@ end
--- @param mtx Mat4 --- @param mtx Mat4
--- @param b Vec3s --- @param b Vec3s
--- @return Pointer_integer --- @return Vec3s
--- Multiplies the 3D signed-integer vector `b` with the 4x4 floating-point matrix `mtx`, which applies the transformation to the point --- Multiplies the 3D signed-integer vector `b` with the 4x4 floating-point matrix `mtx`, which applies the transformation to the point
function mtxf_mul_vec3s(mtx, b) function mtxf_mul_vec3s(mtx, b)
-- ... -- ...
@ -6583,7 +6604,7 @@ end
--- @param dest Mat4 --- @param dest Mat4
--- @param b Vec3f --- @param b Vec3f
--- Applies a translation to the 4x4 floating-point matrix `dest` by adding the coordinates in the 3D floating-point vector `b`. This shifts any transformed point by `b` --- Sets the 4x4 floating-point matrix `dest` to the translation matrix decribed by the 3D floating-point vector `b`. This matrix is used to shift any transformed point by `b`
function mtxf_translate(dest, b) function mtxf_translate(dest, b)
-- ... -- ...
end end

View file

@ -205,30 +205,6 @@ Calculates the time it takes for the current object to follow an arc from `pos`
<br /> <br />
## [vec3f_copy_2](#vec3f_copy_2)
### Description
Duplicate of vec3f_copy except without bad return
### Lua Example
`vec3f_copy_2(dest, src)`
### Parameters
| Field | Type |
| ----- | ---- |
| dest | [Vec3f](structs.md#Vec3f) |
| src | [Vec3f](structs.md#Vec3f) |
### Returns
- None
### C Prototype
`void vec3f_copy_2(Vec3f dest, Vec3f src);`
[:arrow_up_small:](#)
<br />
## [tox_box_move](#tox_box_move) ## [tox_box_move](#tox_box_move)
### Description ### Description

View file

@ -537,7 +537,7 @@ Converts an object's position to a `Vec3f` format. Useful for aligning object be
- None - None
### C Prototype ### C Prototype
`void object_pos_to_vec3f(Vec3f dst, struct Object *o);` `void object_pos_to_vec3f(OUT Vec3f dst, struct Object *o);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -567,6 +567,102 @@ Converts a `Vec3f` position to an object's internal format. Useful for syncing 3
<br /> <br />
## [object_face_angle_to_vec3s](#object_face_angle_to_vec3s)
### Description
Converts an object's face angle to a `Vec3s` format
### Lua Example
`object_face_angle_to_vec3s(dst, o)`
### Parameters
| Field | Type |
| ----- | ---- |
| dst | [Vec3s](structs.md#Vec3s) |
| o | [Object](structs.md#Object) |
### Returns
- None
### C Prototype
`void object_face_angle_to_vec3s(OUT Vec3s dst, struct Object *o);`
[:arrow_up_small:](#)
<br />
## [vec3s_to_object_face_angle](#vec3s_to_object_face_angle)
### Description
Converts a `Vec3s` angle to an object's face angle internal format
### Lua Example
`vec3s_to_object_face_angle(o, src)`
### Parameters
| Field | Type |
| ----- | ---- |
| o | [Object](structs.md#Object) |
| src | [Vec3s](structs.md#Vec3s) |
### Returns
- None
### C Prototype
`void vec3s_to_object_face_angle(struct Object *o, Vec3s src);`
[:arrow_up_small:](#)
<br />
## [object_move_angle_to_vec3s](#object_move_angle_to_vec3s)
### Description
Converts an object's move angle to a `Vec3s` format
### Lua Example
`object_move_angle_to_vec3s(dst, o)`
### Parameters
| Field | Type |
| ----- | ---- |
| dst | [Vec3s](structs.md#Vec3s) |
| o | [Object](structs.md#Object) |
### Returns
- None
### C Prototype
`void object_move_angle_to_vec3s(OUT Vec3s dst, struct Object *o);`
[:arrow_up_small:](#)
<br />
## [vec3s_to_object_move_angle](#vec3s_to_object_move_angle)
### Description
Converts a `Vec3s` angle to an object's move angle internal format
### Lua Example
`vec3s_to_object_move_angle(o, src)`
### Parameters
| Field | Type |
| ----- | ---- |
| o | [Object](structs.md#Object) |
| src | [Vec3s](structs.md#Vec3s) |
### Returns
- None
### C Prototype
`void vec3s_to_object_move_angle(struct Object *o, Vec3s src);`
[:arrow_up_small:](#)
<br />
## [cam_select_alt_mode](#cam_select_alt_mode) ## [cam_select_alt_mode](#cam_select_alt_mode)
### Description ### Description
@ -654,7 +750,7 @@ Activates a handheld camera shake effect. Calculates positional and focus adjust
- None - None
### C Prototype ### C Prototype
`void shake_camera_handheld(Vec3f pos, Vec3f focus);` `void shake_camera_handheld(Vec3f pos, OUT Vec3f focus);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -704,7 +800,7 @@ Checks for collisions between the camera and level geometry. Adjusts the camera'
- `integer` - `integer`
### C Prototype ### C Prototype
`s32 collide_with_walls(Vec3f pos, f32 offsetY, f32 radius);` `s32 collide_with_walls(OUT Vec3f pos, f32 offsetY, f32 radius);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -730,7 +826,7 @@ Clamps the camera's pitch angle between a maximum and minimum value. Prevents ov
- `integer` - `integer`
### C Prototype ### C Prototype
`s32 clamp_pitch(Vec3f from, Vec3f to, s16 maxPitch, s16 minPitch);` `s32 clamp_pitch(Vec3f from, OUT Vec3f to, s16 maxPitch, s16 minPitch);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -907,7 +1003,7 @@ Smoothly transitions a 3D vector (`current`) towards a target vector (`target`)
- None - None
### C Prototype ### C Prototype
`void approach_vec3f_asymptotic(Vec3f current, Vec3f target, f32 xMul, f32 yMul, f32 zMul);` `void approach_vec3f_asymptotic(OUT Vec3f current, Vec3f target, f32 xMul, f32 yMul, f32 zMul);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -934,7 +1030,7 @@ Smoothly transitions a 3D vector (`current`) toward a target vector (`goal`) usi
- None - None
### C Prototype ### C Prototype
`void set_or_approach_vec3f_asymptotic(Vec3f dst, Vec3f goal, f32 xMul, f32 yMul, f32 zMul);` `void set_or_approach_vec3f_asymptotic(OUT Vec3f dst, Vec3f goal, f32 xMul, f32 yMul, f32 zMul);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -1060,7 +1156,7 @@ Generates a random 3D vector with short integer components. Useful for randomize
- None - None
### C Prototype ### C Prototype
`void random_vec3s(Vec3s dst, s16 xRange, s16 yRange, s16 zRange);` `void random_vec3s(OUT Vec3s dst, s16 xRange, s16 yRange, s16 zRange);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -1088,7 +1184,7 @@ Clamps a position within specified X and Z bounds and calculates the yaw angle f
- `integer` - `integer`
### C Prototype ### C Prototype
`s32 clamp_positions_and_find_yaw(Vec3f pos, Vec3f origin, f32 xMax, f32 xMin, f32 zMax, f32 zMin);` `s32 clamp_positions_and_find_yaw(OUT Vec3f pos, Vec3f origin, f32 xMax, f32 xMin, f32 zMax, f32 zMin);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -1141,7 +1237,7 @@ Scales a point along a line between two 3D points (`from` and `to`). The scaling
- None - None
### C Prototype ### C Prototype
`void scale_along_line(Vec3f dest, Vec3f from, Vec3f to, f32 scale);` `void scale_along_line(OUT Vec3f dest, Vec3f from, Vec3f to, f32 scale);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -1288,7 +1384,7 @@ Rotates a vector around the XZ-plane by a specified yaw angle. The result is sto
- None - None
### C Prototype ### C Prototype
`void rotate_in_xz(Vec3f dst, Vec3f src, s16 yaw);` `void rotate_in_xz(OUT Vec3f dst, Vec3f src, s16 yaw);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -1313,7 +1409,7 @@ Rotates a vector around the YZ-plane by a specified pitch angle. The result is s
- None - None
### C Prototype ### C Prototype
`void rotate_in_yz(Vec3f dst, Vec3f src, s16 pitch);` `void rotate_in_yz(OUT Vec3f dst, Vec3f src, s16 pitch);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -1441,7 +1537,7 @@ Activates a pitch-based shake effect. Adds vertical vibrational movement to the
- None - None
### C Prototype ### C Prototype
`void shake_camera_pitch(Vec3f pos, Vec3f focus);` `void shake_camera_pitch(Vec3f pos, OUT Vec3f focus);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -1465,7 +1561,7 @@ Activates a yaw-based shake effect. Adds horizontal vibrational movement to the
- None - None
### C Prototype ### C Prototype
`void shake_camera_yaw(Vec3f pos, Vec3f focus);` `void shake_camera_yaw(Vec3f pos, OUT Vec3f focus);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -1894,7 +1990,7 @@ Offsets a vector by rotating it in 3D space relative to a reference position. Th
- None - None
### C Prototype ### C Prototype
`void offset_rotated(Vec3f dst, Vec3f from, Vec3f to, Vec3s rotation);` `void offset_rotated(OUT Vec3f dst, Vec3f from, Vec3f to, Vec3s rotation);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -1923,7 +2019,7 @@ Transitions the camera to the next Lakitu state, updating position and focus. Th
- `integer` - `integer`
### C Prototype ### C Prototype
`s16 next_lakitu_state(Vec3f newPos, Vec3f newFoc, Vec3f curPos, Vec3f curFoc, Vec3f oldPos, Vec3f oldFoc, s16 yaw);` `s16 next_lakitu_state(OUT Vec3f newPos, OUT Vec3f newFoc, Vec3f curPos, Vec3f curFoc, Vec3f oldPos, Vec3f oldFoc, s16 yaw);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -1993,7 +2089,7 @@ Resolves collisions between the camera and level geometry. Adjusts the camera's
- None - None
### C Prototype ### C Prototype
`void resolve_geometry_collisions(Vec3f pos, UNUSED Vec3f lastGood);` `void resolve_geometry_collisions(OUT Vec3f pos, UNUSED Vec3f lastGood);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -3366,7 +3462,7 @@ Converts a world position to screen position
- `boolean` - `boolean`
### C Prototype ### C Prototype
`bool djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out);` `bool djui_hud_world_pos_to_screen_pos(Vec3f pos, OUT Vec3f out);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6432,7 +6528,7 @@ Calculates the lighting with `lightIntensityScalar` at a position and outputs th
- None - None
### C Prototype ### C Prototype
`void le_calculate_lighting_color(Vec3f pos, Color out, f32 lightIntensityScalar);` `void le_calculate_lighting_color(Vec3f pos, OUT Color out, f32 lightIntensityScalar);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6456,7 +6552,7 @@ Calculates the lighting direction from a position and outputs the result in `out
- None - None
### C Prototype ### C Prototype
`void le_calculate_lighting_dir(Vec3f pos, Vec3f out);` `void le_calculate_lighting_dir(Vec3f pos, OUT Vec3f out);`
[:arrow_up_small:](#) [:arrow_up_small:](#)

View file

@ -222,7 +222,7 @@ Retrieves the current animation flags and calculates the translation for Mario's
- `integer` - `integer`
### C Prototype ### C Prototype
`s16 find_mario_anim_flags_and_translation(struct Object *o, s32 yaw, Vec3s translation);` `s16 find_mario_anim_flags_and_translation(struct Object *o, s32 yaw, OUT Vec3s translation);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -697,7 +697,7 @@ Checks for and resolves wall collisions at a given position `pos`, returning the
[Surface](structs.md#Surface) [Surface](structs.md#Surface)
### C Prototype ### C Prototype
`struct Surface *resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius);` `struct Surface *resolve_and_return_wall_collisions(OUT Vec3f pos, f32 offset, f32 radius);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -723,7 +723,7 @@ Similar to `resolve_and_return_wall_collisions` but also returns detailed collis
- None - None
### C Prototype ### C Prototype
`void resolve_and_return_wall_collisions_data(Vec3f pos, f32 offset, f32 radius, struct WallCollisionData* collisionData);` `void resolve_and_return_wall_collisions_data(OUT Vec3f pos, f32 offset, f32 radius, struct WallCollisionData* collisionData);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -1872,7 +1872,7 @@ Performs a single step of movement while Mario is hanging from a ceiling. It han
- `integer` - `integer`
### C Prototype ### C Prototype
`s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos);` `s32 perform_hanging_step(struct MarioState *m, OUT Vec3f nextPos);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -3620,7 +3620,7 @@ Performs a full water movement step where ceilings, floors, and walls are handle
- `integer` - `integer`
### C Prototype ### C Prototype
`u32 perform_water_full_step(struct MarioState *m, Vec3f nextPos);` `u32 perform_water_full_step(struct MarioState *m, OUT Vec3f nextPos);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -3644,7 +3644,7 @@ Calculates a water current and outputs it in `step`
- None - None
### C Prototype ### C Prototype
`void apply_water_current(struct MarioState *m, Vec3f step);` `void apply_water_current(struct MarioState *m, OUT Vec3f step);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4311,7 +4311,7 @@ Computes spline interpolation weights for a given parameter `t` and stores these
- None - None
### C Prototype ### C Prototype
`void spline_get_weights(struct MarioState* m, Vec4f result, f32 t, UNUSED s32 c);` `void spline_get_weights(struct MarioState* m, OUT Vec4f result, f32 t, UNUSED s32 c);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4359,7 +4359,7 @@ Advances the spline-based animation associated with `m` and stores the current i
- `integer` - `integer`
### C Prototype ### C Prototype
`s32 anim_spline_poll(struct MarioState* m, Vec3f result);` `s32 anim_spline_poll(struct MarioState* m, OUT Vec3f result);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4383,7 +4383,7 @@ Rotates the 3D floating-point vector `v` by the angles specified in the 3D signe
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_rotate_zxy(Vec3f v, Vec3s rotate);` `Vec3fp vec3f_rotate_zxy(OUT Vec3f v, Vec3s rotate);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4409,7 +4409,7 @@ Rotates the 3D floating-point vector `v` around the vector `n`, given a rotation
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_rotate_around_n(Vec3f dest, Vec3f v, Vec3f n, s16 r);` `Vec3fp vec3f_rotate_around_n(OUT Vec3f dest, Vec3f v, Vec3f n, s16 r);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4434,7 +4434,7 @@ Projects the 3D floating-point vector `v` onto another 3D floating-point vector
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_project(Vec3f dest, Vec3f v, Vec3f onto);` `Vec3fp vec3f_project(OUT Vec3f dest, Vec3f v, Vec3f onto);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4461,7 +4461,7 @@ Scales the 3D floating-point vector `v` by the vector `scale`, then rotates it b
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_transform(Vec3f dest, Vec3f v, Vec3f translation, Vec3s rotation, Vec3f scale);` `Vec3fp vec3f_transform(OUT Vec3f dest, Vec3f v, Vec3f translation, Vec3s rotation, Vec3f scale);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4515,7 +4515,7 @@ Positions the point `to` at a given `dist`, `pitch`, and `yaw` relative to the p
- None - None
### C Prototype ### C Prototype
`void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw);` `void vec3f_set_dist_and_angle(Vec3f from, OUT Vec3f to, f32 dist, s16 pitch, s16 yaw);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4541,7 +4541,7 @@ Determines a vector that is perpendicular (normal) to the plane defined by three
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f b, Vec3f c);` `Vec3fp find_vector_perpendicular_to_plane(OUT Vec3f dest, Vec3f a, Vec3f b, Vec3f c);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4567,7 +4567,7 @@ Adjusts the 4x4 floating-point matrix `mtx` so that it represents a viewing tran
- None - None
### C Prototype ### C Prototype
`void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll);` `void mtxf_lookat(OUT Mat4 mtx, Vec3f from, Vec3f to, s16 roll);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4592,7 +4592,7 @@ Rotates `dest` according to the angles in `rotate` using ZXY order, and then tra
- None - None
### C Prototype ### C Prototype
`void mtxf_rotate_zxy_and_translate(Mat4 dest, Vec3f translate, Vec3s rotate);` `void mtxf_rotate_zxy_and_translate(OUT Mat4 dest, Vec3f translate, Vec3s rotate);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4617,7 +4617,7 @@ Rotates `dest` using angles in XYZ order, and then translates it by the 3D float
- None - None
### C Prototype ### C Prototype
`void mtxf_rotate_xyz_and_translate(Mat4 dest, Vec3f b, Vec3s c);` `void mtxf_rotate_xyz_and_translate(OUT Mat4 dest, Vec3f b, Vec3s c);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4643,7 +4643,7 @@ Transforms a 4x4 floating-point matrix `mtx` into a "billboard" oriented toward
- None - None
### C Prototype ### C Prototype
`void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle);` `void mtxf_billboard(OUT Mat4 dest, Mat4 mtx, Vec3f position, s16 angle);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4669,7 +4669,7 @@ Creates a "cylindrical billboard" transformation from the 4x4 matrix `mtx` place
- None - None
### C Prototype ### C Prototype
`void mtxf_cylboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle);` `void mtxf_cylboard(OUT Mat4 dest, Mat4 mtx, Vec3f position, s16 angle);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4695,7 +4695,7 @@ Aligns `dest` so that it fits the orientation of a terrain surface defined by it
- None - None
### C Prototype ### C Prototype
`void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw);` `void mtxf_align_terrain_normal(OUT Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4721,7 +4721,7 @@ Aligns `mtx` to fit onto a terrain triangle at `pos`, applying a given `yaw` and
- None - None
### C Prototype ### C Prototype
`void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius);` `void mtxf_align_terrain_triangle(OUT Mat4 mtx, Vec3f pos, s16 yaw, f32 radius);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4746,7 +4746,7 @@ Multiplies two 4x4 floating-point matrices `a` and `b` (in that order), storing
- None - None
### C Prototype ### C Prototype
`void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b);` `void mtxf_mul(OUT Mat4 dest, Mat4 a, Mat4 b);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4758,7 +4758,7 @@ Multiplies two 4x4 floating-point matrices `a` and `b` (in that order), storing
Multiplies the 3D signed-integer vector `b` with the 4x4 floating-point matrix `mtx`, which applies the transformation to the point Multiplies the 3D signed-integer vector `b` with the 4x4 floating-point matrix `mtx`, which applies the transformation to the point
### Lua Example ### Lua Example
`local PointerValue = mtxf_mul_vec3s(mtx, b)` `local Vec3sValue = mtxf_mul_vec3s(mtx, b)`
### Parameters ### Parameters
| Field | Type | | Field | Type |
@ -4767,10 +4767,10 @@ Multiplies the 3D signed-integer vector `b` with the 4x4 floating-point matrix `
| b | [Vec3s](structs.md#Vec3s) | | b | [Vec3s](structs.md#Vec3s) |
### Returns ### Returns
- `Pointer` <`integer`> [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`s16 *mtxf_mul_vec3s(Mat4 mtx, Vec3s b);` `Vec3sp mtxf_mul_vec3s(Mat4 mtx, OUT Vec3s b);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4794,7 +4794,7 @@ Rotates the matrix `mtx` in the XY plane by the given `angle`. Rotating in the X
- None - None
### C Prototype ### C Prototype
`void mtxf_rotate_xy(Mat4 mtx, s16 angle);` `void mtxf_rotate_xy(OUT Mat4 mtx, s16 angle);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4818,7 +4818,7 @@ Inverts the 4x4 floating-point matrix `src` and stores the inverse in `dest`. Ap
- None - None
### C Prototype ### C Prototype
`void mtxf_inverse(Mat4 dest, Mat4 src);` `void mtxf_inverse(OUT Mat4 dest, Mat4 src);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4843,7 +4843,7 @@ Extracts the position (translation component) from the transformation matrix `ob
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx);` `Vec3fp get_pos_from_transform_mtx(OUT Vec3f dest, Mat4 objMtx, Mat4 camMtx);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -4994,7 +4994,7 @@ Sets the 4x4 floating-point matrix `mtx` to all zeros. Unless you really need th
- None - None
### C Prototype ### C Prototype
`void mtxf_zero(Mat4 mtx);` `void mtxf_zero(OUT Mat4 mtx);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5018,7 +5018,7 @@ Copies the 4x4 floating-point matrix `src` into `dest`. After this operation, `d
- None - None
### C Prototype ### C Prototype
`void mtxf_copy(Mat4 dest, Mat4 src);` `void mtxf_copy(OUT Mat4 dest, Mat4 src);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5041,7 +5041,7 @@ Sets the 4x4 floating-point matrix `mtx` to the identity matrix. The identity ma
- None - None
### C Prototype ### C Prototype
`void mtxf_identity(Mat4 mtx);` `void mtxf_identity(OUT Mat4 mtx);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5050,7 +5050,7 @@ Sets the 4x4 floating-point matrix `mtx` to the identity matrix. The identity ma
## [mtxf_translate](#mtxf_translate) ## [mtxf_translate](#mtxf_translate)
### Description ### Description
Applies a translation to the 4x4 floating-point matrix `dest` by adding the coordinates in the 3D floating-point vector `b`. This shifts any transformed point by `b` Sets the 4x4 floating-point matrix `dest` to the translation matrix decribed by the 3D floating-point vector `b`. This matrix is used to shift any transformed point by `b`
### Lua Example ### Lua Example
`mtxf_translate(dest, b)` `mtxf_translate(dest, b)`
@ -5065,7 +5065,7 @@ Applies a translation to the 4x4 floating-point matrix `dest` by adding the coor
- None - None
### C Prototype ### C Prototype
`void mtxf_translate(Mat4 dest, Vec3f b);` `void mtxf_translate(OUT Mat4 dest, Vec3f b);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5090,7 +5090,7 @@ Scales the 4x4 floating-point matrix `mtx` by the scaling factors found in the 3
- None - None
### C Prototype ### C Prototype
`void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s);` `void mtxf_scale_vec3f(OUT Mat4 dest, Mat4 mtx, Vec3f s);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5119,7 +5119,7 @@ Sets the components of the 3D floating-point vector `v` to 0
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_zero(Vec3f v);` `Vec3fp vec3f_zero(OUT Vec3f v);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5143,7 +5143,7 @@ Copies the contents of a 3D floating-point vector (`src`) into another 3D floati
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_copy(Vec3f dest, Vec3f src);` `Vec3fp vec3f_copy(OUT Vec3f dest, Vec3f src);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5169,7 +5169,7 @@ Sets the values of the 3D floating-point vector `dest` to the given x, y, and z
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_set(Vec3f dest, f32 x, f32 y, f32 z);` `Vec3fp vec3f_set(OUT Vec3f dest, f32 x, f32 y, f32 z);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5193,7 +5193,7 @@ Adds the components of the 3D floating-point vector `a` to `dest`
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_add(Vec3f dest, Vec3f a);` `Vec3fp vec3f_add(OUT Vec3f dest, Vec3f a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5218,7 +5218,7 @@ Adds the components of two 3D floating-point vectors `a` and `b` and stores the
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_sum(Vec3f dest, Vec3f a, Vec3f b);` `Vec3fp vec3f_sum(OUT Vec3f dest, Vec3f a, Vec3f b);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5242,7 +5242,7 @@ Subtracts the components of the 3D floating-point vector `a` from `dest`
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_sub(Vec3f dest, Vec3f a);` `Vec3fp vec3f_sub(OUT Vec3f dest, Vec3f a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5267,7 +5267,7 @@ Subtracts the components of the 3D floating-point vector `b` from the components
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_dif(Vec3f dest, Vec3f a, Vec3f b);` `Vec3fp vec3f_dif(OUT Vec3f dest, Vec3f a, Vec3f b);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5291,7 +5291,7 @@ Multiplies each component of the 3D floating-point vector `dest` by the scalar v
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_mul(Vec3f dest, f32 a);` `Vec3fp vec3f_mul(OUT Vec3f dest, f32 a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5315,7 +5315,7 @@ Multiplies the components of the 3D floating-point vector `dest` with the compon
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_mult(Vec3f dest, Vec3f a);` `Vec3fp vec3f_mult(OUT Vec3f dest, Vec3f a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5340,7 +5340,7 @@ Multiplies the components of two 3D floating-point vectors `a` and `b` and store
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_prod(Vec3f dest, Vec3f a, Vec3f b);` `Vec3fp vec3f_prod(OUT Vec3f dest, Vec3f a, Vec3f b);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5364,7 +5364,7 @@ Divides each component of the 3D floating-point vector `dest` by the scalar valu
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_div(Vec3f dest, f32 a);` `Vec3fp vec3f_div(OUT Vec3f dest, f32 a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5410,7 +5410,7 @@ Normalizes the 3D floating-point vector `v` so that its length (magnitude) becom
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_normalize(Vec3f v);` `Vec3fp vec3f_normalize(OUT Vec3f v);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5434,7 +5434,7 @@ Sets the length (magnitude) of 3D floating-point vector `v`, while retaining its
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_set_magnitude(Vec3f v, f32 mag);` `Vec3fp vec3f_set_magnitude(OUT Vec3f v, f32 mag);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5483,7 +5483,7 @@ Computes the cross product of two 3D floating-point vectors `a` and `b` and stor
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_cross(Vec3f dest, Vec3f a, Vec3f b);` `Vec3fp vec3f_cross(OUT Vec3f dest, Vec3f a, Vec3f b);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5510,7 +5510,7 @@ Takes two 3D floating-point vectors `vecA` and `vecB`, multiplies them by `sclA`
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3f_combine(Vec3f dest, Vec3f vecA, Vec3f vecB, f32 sclA, f32 sclB);` `Vec3fp vec3f_combine(OUT Vec3f dest, Vec3f vecA, Vec3f vecB, f32 sclA, f32 sclB);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5605,7 +5605,7 @@ Converts a 3D floating-point vector `a` into a 3D integer vector and stores the
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3f_to_vec3i(Vec3i dest, Vec3f a);` `Vec3ip vec3f_to_vec3i(OUT Vec3i dest, Vec3f a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5629,7 +5629,7 @@ Converts a 3D floating-point vector `a` into a 3D short integer vector and store
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3f_to_vec3s(Vec3s dest, Vec3f a);` `Vec3sp vec3f_to_vec3s(OUT Vec3s dest, Vec3f a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5658,7 +5658,7 @@ Sets the components of the 3D integer vector `v` to 0
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3i_zero(Vec3i v);` `Vec3ip vec3i_zero(OUT Vec3i v);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5682,7 +5682,7 @@ Copies the contents of a 3D integer vector (`src`) into another 3D integer vecto
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3i_copy(Vec3i dest, Vec3i src);` `Vec3ip vec3i_copy(OUT Vec3i dest, Vec3i src);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5708,7 +5708,7 @@ Sets the values of the 3D integer vector `dest` to the given x, y, and z values
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3i_set(Vec3i dest, s32 x, s32 y, s32 z);` `Vec3ip vec3i_set(OUT Vec3i dest, s32 x, s32 y, s32 z);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5732,7 +5732,7 @@ Adds the components of the 3D integer vector `a` to `dest`
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3i_add(Vec3i dest, Vec3i a);` `Vec3ip vec3i_add(OUT Vec3i dest, Vec3i a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5757,7 +5757,7 @@ Adds the components of two 3D integer vectors `a` and `b` and stores the result
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3i_sum(Vec3i dest, Vec3i a, Vec3i b);` `Vec3ip vec3i_sum(OUT Vec3i dest, Vec3i a, Vec3i b);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5781,7 +5781,7 @@ Subtracts the components of the 3D integer vector `a` from `dest`
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3i_sub(Vec3i dest, Vec3i a);` `Vec3ip vec3i_sub(OUT Vec3i dest, Vec3i a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5806,7 +5806,7 @@ Subtracts the components of the 3D integer vector `b` from the components of `a`
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3i_dif(Vec3i dest, Vec3i a, Vec3i b);` `Vec3ip vec3i_dif(OUT Vec3i dest, Vec3i a, Vec3i b);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5830,7 +5830,7 @@ Multiplies each component of the 3D integer vector `dest` by the scalar value `a
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3i_mul(Vec3i dest, f32 a);` `Vec3ip vec3i_mul(OUT Vec3i dest, f32 a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5854,7 +5854,7 @@ Multiplies the components of the 3D integer vector `dest` with the components of
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3i_mult(Vec3i dest, Vec3i a);` `Vec3ip vec3i_mult(OUT Vec3i dest, Vec3i a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5879,7 +5879,7 @@ Multiplies the components of two 3D integer vectors `a` and `b` and stores the r
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3i_prod(Vec3i dest, Vec3i a, Vec3i b);` `Vec3ip vec3i_prod(OUT Vec3i dest, Vec3i a, Vec3i b);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5903,7 +5903,7 @@ Divides each component of the 3D integer vector `dest` by the scalar value `a`
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3i_div(Vec3i dest, f32 a);` `Vec3ip vec3i_div(OUT Vec3i dest, f32 a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5949,7 +5949,7 @@ Normalizes the 3D integer vector `v` so that its length (magnitude) becomes 1, w
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3i_normalize(Vec3i v);` `Vec3ip vec3i_normalize(OUT Vec3i v);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -5973,7 +5973,7 @@ Sets the length (magnitude) of 3D integer vector `v`, while retaining its direct
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3i_set_magnitude(Vec3i v, f32 mag);` `Vec3ip vec3i_set_magnitude(OUT Vec3i v, f32 mag);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6022,7 +6022,7 @@ Computes the cross product of two 3D integer vectors `a` and `b` and stores the
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3i_cross(Vec3i dest, Vec3i a, Vec3i b);` `Vec3ip vec3i_cross(OUT Vec3i dest, Vec3i a, Vec3i b);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6049,7 +6049,7 @@ Takes two 3D integer vectors `vecA` and `vecB`, multiplies them by `sclA` and `s
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3i_combine(Vec3i dest, Vec3i vecA, Vec3i vecB, f32 sclA, f32 sclB);` `Vec3ip vec3i_combine(OUT Vec3i dest, Vec3i vecA, Vec3i vecB, f32 sclA, f32 sclB);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6144,7 +6144,7 @@ Converts a 3D integer vector `a` into a 3D floating-point vector and stores the
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3i_to_vec3f(Vec3f dest, Vec3i a);` `Vec3fp vec3i_to_vec3f(OUT Vec3f dest, Vec3i a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6168,7 +6168,7 @@ Converts a 3D integer vector `a` into a 3D short integer vector and stores the r
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3i_to_vec3s(Vec3s dest, Vec3i a);` `Vec3sp vec3i_to_vec3s(OUT Vec3s dest, Vec3i a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6197,7 +6197,7 @@ Sets the components of the 3D short integer vector `v` to 0
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3s_zero(Vec3s v);` `Vec3sp vec3s_zero(OUT Vec3s v);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6221,7 +6221,7 @@ Copies the contents of a 3D short integer vector (`src`) into another 3D short i
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3s_copy(Vec3s dest, Vec3s src);` `Vec3sp vec3s_copy(OUT Vec3s dest, Vec3s src);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6247,7 +6247,7 @@ Sets the values of the 3D short integer vector `dest` to the given x, y, and z v
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3s_set(Vec3s dest, s16 x, s16 y, s16 z);` `Vec3sp vec3s_set(OUT Vec3s dest, s16 x, s16 y, s16 z);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6271,7 +6271,7 @@ Adds the components of the 3D short integer vector `a` to `dest`
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3s_add(Vec3s dest, Vec3s a);` `Vec3sp vec3s_add(OUT Vec3s dest, Vec3s a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6296,7 +6296,7 @@ Adds the components of two 3D short integer vectors `a` and `b` and stores the r
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3s_sum(Vec3s dest, Vec3s a, Vec3s b);` `Vec3sp vec3s_sum(OUT Vec3s dest, Vec3s a, Vec3s b);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6320,7 +6320,7 @@ Subtracts the components of the 3D short integer vector `a` from `dest`
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3s_sub(Vec3s dest, Vec3s a);` `Vec3sp vec3s_sub(OUT Vec3s dest, Vec3s a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6345,7 +6345,7 @@ Subtracts the components of the 3D short integer vector `b` from the components
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3s_dif(Vec3s dest, Vec3s a, Vec3s b);` `Vec3sp vec3s_dif(OUT Vec3s dest, Vec3s a, Vec3s b);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6369,7 +6369,7 @@ Multiplies each component of the 3D short integer vector `dest` by the scalar va
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3s_mul(Vec3s dest, f32 a);` `Vec3sp vec3s_mul(OUT Vec3s dest, f32 a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6393,7 +6393,7 @@ Multiplies the components of the 3D short integer vector `dest` with the compone
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3s_mult(Vec3s dest, Vec3s a);` `Vec3sp vec3s_mult(OUT Vec3s dest, Vec3s a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6418,7 +6418,7 @@ Multiplies the components of two 3D short integer vectors `a` and `b` and stores
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3s_prod(Vec3s dest, Vec3s a, Vec3s b);` `Vec3sp vec3s_prod(OUT Vec3s dest, Vec3s a, Vec3s b);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6442,7 +6442,7 @@ Divides each component of the 3D short integer vector `dest` by the scalar value
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3s_div(Vec3s dest, f32 a);` `Vec3sp vec3s_div(OUT Vec3s dest, f32 a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6488,7 +6488,7 @@ Normalizes the 3D short integer vector `v` so that its length (magnitude) become
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3s_normalize(Vec3s v);` `Vec3sp vec3s_normalize(OUT Vec3s v);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6512,7 +6512,7 @@ Sets the length (magnitude) of 3D short integer vector `v`, while retaining its
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3s_set_magnitude(Vec3s v, f32 mag);` `Vec3sp vec3s_set_magnitude(OUT Vec3s v, f32 mag);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6561,7 +6561,7 @@ Computes the cross product of two 3D short integer vectors `a` and `b` and store
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3s_cross(Vec3s dest, Vec3s a, Vec3s b);` `Vec3sp vec3s_cross(OUT Vec3s dest, Vec3s a, Vec3s b);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6588,7 +6588,7 @@ Takes two 3D short integer vectors `vecA` and `vecB`, multiplies them by `sclA`
[Vec3s](structs.md#Vec3s) [Vec3s](structs.md#Vec3s)
### C Prototype ### C Prototype
`Vec3sp vec3s_combine(Vec3s dest, Vec3s vecA, Vec3s vecB, f32 sclA, f32 sclB);` `Vec3sp vec3s_combine(OUT Vec3s dest, Vec3s vecA, Vec3s vecB, f32 sclA, f32 sclB);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6683,7 +6683,7 @@ Converts a 3D short integer vector `a` into a 3D floating-point vector and store
[Vec3f](structs.md#Vec3f) [Vec3f](structs.md#Vec3f)
### C Prototype ### C Prototype
`Vec3fp vec3s_to_vec3f(Vec3f dest, Vec3s a);` `Vec3fp vec3s_to_vec3f(OUT Vec3f dest, Vec3s a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -6707,7 +6707,7 @@ Converts a 3D short integer vector `a` into a 3D integer vector and stores the r
[Vec3i](structs.md#Vec3i) [Vec3i](structs.md#Vec3i)
### C Prototype ### C Prototype
`Vec3ip vec3s_to_vec3i(Vec3i dest, Vec3s a);` `Vec3ip vec3s_to_vec3i(OUT Vec3i dest, Vec3s a);`
[:arrow_up_small:](#) [:arrow_up_small:](#)

View file

@ -214,7 +214,7 @@ Linearly interpolates `res` between `a` and `b` with `delta`
- None - None
### C Prototype ### C Prototype
`void delta_interpolate_vec3f(Vec3f res, Vec3f a, Vec3f b, f32 delta);` `void delta_interpolate_vec3f(OUT Vec3f res, Vec3f a, Vec3f b, f32 delta);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -240,7 +240,7 @@ Linearly interpolates `res` between `a` and `b` with `delta`
- None - None
### C Prototype ### C Prototype
`void delta_interpolate_vec3s(Vec3s res, Vec3s a, Vec3s b, f32 delta);` `void delta_interpolate_vec3s(OUT Vec3s res, Vec3s a, Vec3s b, f32 delta);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -1615,7 +1615,7 @@ Finds any wall collisions and returns what the displacement vector would be.
- `integer` - `integer`
### C Prototype ### C Prototype
`s8 obj_find_wall_displacement(Vec3f dist, f32 x, f32 y, f32 z, f32 radius);` `s8 obj_find_wall_displacement(OUT Vec3f dist, f32 x, f32 y, f32 z, f32 radius);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -2929,7 +2929,7 @@ Overrides the current room Mario is in. Set to -1 to reset override
- None - None
### C Prototype ### C Prototype
`void obj_apply_scale_to_matrix(struct Object *obj, Mat4 dst, Mat4 src);` `void obj_apply_scale_to_matrix(struct Object *obj, OUT Mat4 dst, Mat4 src);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -2951,7 +2951,7 @@ Overrides the current room Mario is in. Set to -1 to reset override
- None - None
### C Prototype ### C Prototype
`void create_transformation_from_matrices(Mat4 a0, Mat4 a1, Mat4 a2);` `void create_transformation_from_matrices(OUT Mat4 a0, Mat4 a1, Mat4 a2);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -3625,7 +3625,7 @@ Multiplies a vector by a matrix of the form: `| ? ? ? 0 |` `| ? ? ? 0 |` `| ? ?
- None - None
### C Prototype ### C Prototype
`void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v);` `void linear_mtxf_mul_vec3f(Mat4 m, OUT Vec3f dst, Vec3f v);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -3650,7 +3650,7 @@ Multiplies a vector by the transpose of a matrix of the form: `| ? ? ? 0 |` `| ?
- None - None
### C Prototype ### C Prototype
`void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v);` `void linear_mtxf_transpose_mul_vec3f(Mat4 m, OUT Vec3f dst, Vec3f v);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -8077,7 +8077,7 @@ Retrieves the current position of Mario's cap, if it is on the ground in the cur
- `integer` - `integer`
### C Prototype ### C Prototype
`s32 save_file_get_cap_pos(Vec3s capPos);` `s32 save_file_get_cap_pos(OUT Vec3s capPos);`
[:arrow_up_small:](#) [:arrow_up_small:](#)

View file

@ -4284,7 +4284,7 @@ Retrieves the animated part position associated to `animPart` from the MarioStat
- `boolean` - `boolean`
### C Prototype ### C Prototype
`bool get_mario_anim_part_pos(struct MarioState *m, u32 animPart, Vec3f pos);` `bool get_mario_anim_part_pos(struct MarioState *m, u32 animPart, OUT Vec3f pos);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -7350,7 +7350,7 @@ Gets the closest point of the triangle to `src` and returns it in `out`.
- None - None
### C Prototype ### C Prototype
`void closest_point_to_triangle(struct Surface* surf, Vec3f src, Vec3f out);` `void closest_point_to_triangle(struct Surface* surf, Vec3f src, OUT Vec3f out);`
[:arrow_up_small:](#) [:arrow_up_small:](#)

View file

@ -51,7 +51,6 @@
- [spawn_wind_particles](functions-2.md#spawn_wind_particles) - [spawn_wind_particles](functions-2.md#spawn_wind_particles)
- [check_if_moving_over_floor](functions-2.md#check_if_moving_over_floor) - [check_if_moving_over_floor](functions-2.md#check_if_moving_over_floor)
- [arc_to_goal_pos](functions-2.md#arc_to_goal_pos) - [arc_to_goal_pos](functions-2.md#arc_to_goal_pos)
- [vec3f_copy_2](functions-2.md#vec3f_copy_2)
- [tox_box_move](functions-2.md#tox_box_move) - [tox_box_move](functions-2.md#tox_box_move)
- [play_penguin_walking_sound](functions-2.md#play_penguin_walking_sound) - [play_penguin_walking_sound](functions-2.md#play_penguin_walking_sound)
- [update_angle_from_move_flags](functions-2.md#update_angle_from_move_flags) - [update_angle_from_move_flags](functions-2.md#update_angle_from_move_flags)
@ -654,6 +653,10 @@
- [select_mario_cam_mode](functions-3.md#select_mario_cam_mode) - [select_mario_cam_mode](functions-3.md#select_mario_cam_mode)
- [object_pos_to_vec3f](functions-3.md#object_pos_to_vec3f) - [object_pos_to_vec3f](functions-3.md#object_pos_to_vec3f)
- [vec3f_to_object_pos](functions-3.md#vec3f_to_object_pos) - [vec3f_to_object_pos](functions-3.md#vec3f_to_object_pos)
- [object_face_angle_to_vec3s](functions-3.md#object_face_angle_to_vec3s)
- [vec3s_to_object_face_angle](functions-3.md#vec3s_to_object_face_angle)
- [object_move_angle_to_vec3s](functions-3.md#object_move_angle_to_vec3s)
- [vec3s_to_object_move_angle](functions-3.md#vec3s_to_object_move_angle)
- [cam_select_alt_mode](functions-3.md#cam_select_alt_mode) - [cam_select_alt_mode](functions-3.md#cam_select_alt_mode)
- [set_cam_angle](functions-3.md#set_cam_angle) - [set_cam_angle](functions-3.md#set_cam_angle)
- [set_handheld_shake](functions-3.md#set_handheld_shake) - [set_handheld_shake](functions-3.md#set_handheld_shake)

View file

@ -40,6 +40,10 @@ struct Controller
OSContPad *controllerData; OSContPad *controllerData;
}; };
// A macro to tell autogen which function parameters are modified during the function call and should be pushed again
// Only works with Vec3, Mat4 and Color types
#define OUT
typedef f32 Vec2f[2]; // X, Y typedef f32 Vec2f[2]; // X, Y
typedef s16 Vec2s[2]; typedef s16 Vec2s[2];
typedef s32 Vec2i[2]; typedef s32 Vec2i[2];

View file

@ -17,7 +17,7 @@ static inline void color_set(Color color, u8 r, u8 g, u8 b) {
color[2] = b; color[2] = b;
} }
void le_calculate_vertex_lighting(Vtx_t* v, Color out) { void le_calculate_vertex_lighting(Vtx_t* v, OUT Color out) {
if (sLights == NULL) { return; } if (sLights == NULL) { return; }
#ifdef LE_TOTAL_WEIGHTED_LIGHTING #ifdef LE_TOTAL_WEIGHTED_LIGHTING
@ -56,7 +56,7 @@ void le_calculate_vertex_lighting(Vtx_t* v, Color out) {
#endif #endif
} }
void le_calculate_lighting_color(Vec3f pos, Color out, f32 lightIntensityScalar) { void le_calculate_lighting_color(Vec3f pos, OUT Color out, f32 lightIntensityScalar) {
if (sLights == NULL) { return; } if (sLights == NULL) { return; }
#ifdef LE_TOTAL_WEIGHTED_LIGHTING #ifdef LE_TOTAL_WEIGHTED_LIGHTING
@ -95,7 +95,7 @@ void le_calculate_lighting_color(Vec3f pos, Color out, f32 lightIntensityScalar)
#endif #endif
} }
void le_calculate_lighting_dir(Vec3f pos, Vec3f out) { void le_calculate_lighting_dir(Vec3f pos, OUT Vec3f out) {
if (sLights == NULL) { return; } if (sLights == NULL) { return; }
Vec3f lightingDir = { 0, 0, 0 }; Vec3f lightingDir = { 0, 0, 0 };

View file

@ -15,11 +15,11 @@ struct LELight
f32 intensity; f32 intensity;
}; };
void le_calculate_vertex_lighting(Vtx_t* v, Color out); void le_calculate_vertex_lighting(Vtx_t* v, OUT Color out);
/* |description|Calculates the lighting with `lightIntensityScalar` at a position and outputs the color in `out`|descriptionEnd|*/ /* |description|Calculates the lighting with `lightIntensityScalar` at a position and outputs the color in `out`|descriptionEnd|*/
void le_calculate_lighting_color(Vec3f pos, Color out, f32 lightIntensityScalar); void le_calculate_lighting_color(Vec3f pos, OUT Color out, f32 lightIntensityScalar);
/* |description|Calculates the lighting direction from a position and outputs the result in `out`|descriptionEnd| */ /* |description|Calculates the lighting direction from a position and outputs the result in `out`|descriptionEnd| */
void le_calculate_lighting_dir(Vec3f pos, Vec3f out); void le_calculate_lighting_dir(Vec3f pos, OUT Vec3f out);
/* |description|Adds a lighting engine point light at `x`, `y`, `z` with color `r`, `g`, `b` and `radius` with `intensity`|descriptionEnd| */ /* |description|Adds a lighting engine point light at `x`, `y`, `z` with color `r`, `g`, `b` and `radius` with `intensity`|descriptionEnd| */
s32 le_add_light(f32 x, f32 y, f32 z, u8 r, u8 g, u8 b, f32 radius, f32 intensity); s32 le_add_light(f32 x, f32 y, f32 z, u8 r, u8 g, u8 b, f32 radius, f32 intensity);
/* |description|Removes a lighting engine point light corresponding to `id`|descriptionEnd| */ /* |description|Removes a lighting engine point light corresponding to `id`|descriptionEnd| */

View file

@ -133,7 +133,7 @@ OPTIMIZE_O3 f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec) {
* [0, 0, 0, 0, 1, 2, ... n-1, n, n, n, n] * [0, 0, 0, 0, 1, 2, ... n-1, n, n, n, n]
* TODO: verify the classification of the spline / figure out how polynomials were computed * TODO: verify the classification of the spline / figure out how polynomials were computed
*/ */
OPTIMIZE_O3 void spline_get_weights(struct MarioState* m, Vec4f result, f32 t, UNUSED s32 c) { OPTIMIZE_O3 void spline_get_weights(struct MarioState* m, OUT Vec4f result, f32 t, UNUSED s32 c) {
if (!m) { return; } if (!m) { return; }
f32 tinv = 1 - t; f32 tinv = 1 - t;
f32 tinv2 = tinv * tinv; f32 tinv2 = tinv * tinv;
@ -195,7 +195,7 @@ OPTIMIZE_O3 void anim_spline_init(struct MarioState* m, Vec4s *keyFrames) {
* anim_spline_init should be called before polling for vectors. * anim_spline_init should be called before polling for vectors.
* Returns TRUE when the last point is reached, FALSE otherwise. * Returns TRUE when the last point is reached, FALSE otherwise.
*/ */
OPTIMIZE_O3 s32 anim_spline_poll(struct MarioState* m, Vec3f result) { OPTIMIZE_O3 s32 anim_spline_poll(struct MarioState* m, OUT Vec3f result) {
if (!m) { return 0; } if (!m) { return 0; }
Vec4f weights = { 0 }; Vec4f weights = { 0 };
s32 i; s32 i;
@ -245,7 +245,7 @@ Vec3f gVec3fOne = { 1.0f, 1.0f, 1.0f };
* Returns a vector rotated around the z axis, then the x axis, then the y * Returns a vector rotated around the z axis, then the x axis, then the y
* axis. * axis.
*/ */
OPTIMIZE_O3 Vec3fp vec3f_rotate_zxy(Vec3f dest, Vec3s rotate) { OPTIMIZE_O3 Vec3fp vec3f_rotate_zxy(OUT Vec3f dest, Vec3s rotate) {
Vec3f v = { dest[0], dest[1], dest[2] }; Vec3f v = { dest[0], dest[1], dest[2] };
f32 sx = sins(rotate[0]); f32 sx = sins(rotate[0]);
@ -270,7 +270,7 @@ OPTIMIZE_O3 Vec3fp vec3f_rotate_zxy(Vec3f dest, Vec3s rotate) {
// Rodrigues' formula // Rodrigues' formula
// dest = v * cos(r) + (n x v) * sin(r) + n * (n . v) * (1 - cos(r)) // dest = v * cos(r) + (n x v) * sin(r) + n * (n . v) * (1 - cos(r))
OPTIMIZE_O3 Vec3fp vec3f_rotate_around_n(Vec3f dest, Vec3f v, Vec3f n, s16 r) { OPTIMIZE_O3 Vec3fp vec3f_rotate_around_n(OUT Vec3f dest, Vec3f v, Vec3f n, s16 r) {
Vec3f nvCross; Vec3f nvCross;
vec3f_cross(nvCross, n, v); vec3f_cross(nvCross, n, v);
f32 nvDot = vec3f_dot(n, v); f32 nvDot = vec3f_dot(n, v);
@ -282,7 +282,7 @@ OPTIMIZE_O3 Vec3fp vec3f_rotate_around_n(Vec3f dest, Vec3f v, Vec3f n, s16 r) {
return dest; return dest;
} }
OPTIMIZE_O3 Vec3fp vec3f_project(Vec3f dest, Vec3f v, Vec3f onto) { OPTIMIZE_O3 Vec3fp vec3f_project(OUT Vec3f dest, Vec3f v, Vec3f onto) {
f32 numerator = vec3f_dot(v, onto); f32 numerator = vec3f_dot(v, onto);
f32 denominator = vec3f_dot(onto, onto); f32 denominator = vec3f_dot(onto, onto);
if (denominator == 0) { if (denominator == 0) {
@ -294,7 +294,7 @@ OPTIMIZE_O3 Vec3fp vec3f_project(Vec3f dest, Vec3f v, Vec3f onto) {
return dest; return dest;
} }
OPTIMIZE_O3 Vec3fp vec3f_transform(Vec3f dest, Vec3f v, Vec3f translation, Vec3s rotation, Vec3f scale) { OPTIMIZE_O3 Vec3fp vec3f_transform(OUT Vec3f dest, Vec3f v, Vec3f translation, Vec3s rotation, Vec3f scale) {
vec3f_copy(dest, v); vec3f_copy(dest, v);
// scale // scale
@ -330,7 +330,7 @@ OPTIMIZE_O3 void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *
* Construct the 'to' point which is distance 'dist' away from the 'from' position, * Construct the 'to' point which is distance 'dist' away from the 'from' position,
* and has the angles pitch and yaw. * and has the angles pitch and yaw.
*/ */
OPTIMIZE_O3 void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw) { OPTIMIZE_O3 void vec3f_set_dist_and_angle(Vec3f from, OUT Vec3f to, f32 dist, s16 pitch, s16 yaw) {
to[0] = from[0] + dist * coss(pitch) * sins(yaw); to[0] = from[0] + dist * coss(pitch) * sins(yaw);
to[1] = from[1] + dist * sins(pitch); to[1] = from[1] + dist * sins(pitch);
to[2] = from[2] + dist * coss(pitch) * coss(yaw); to[2] = from[2] + dist * coss(pitch) * coss(yaw);
@ -341,7 +341,7 @@ OPTIMIZE_O3 void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pi
* It is similar to vec3f_cross, but it calculates the vectors (c-b) and (b-a) * It is similar to vec3f_cross, but it calculates the vectors (c-b) and (b-a)
* at the same time. * at the same time.
*/ */
OPTIMIZE_O3 Vec3fp find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f b, Vec3f c) { OPTIMIZE_O3 Vec3fp find_vector_perpendicular_to_plane(OUT Vec3f dest, Vec3f a, Vec3f b, Vec3f c) {
dest[0] = (b[1] - a[1]) * (c[2] - b[2]) - (c[1] - b[1]) * (b[2] - a[2]); dest[0] = (b[1] - a[1]) * (c[2] - b[2]) - (c[1] - b[1]) * (b[2] - a[2]);
dest[1] = (b[2] - a[2]) * (c[0] - b[0]) - (c[2] - b[2]) * (b[0] - a[0]); dest[1] = (b[2] - a[2]) * (c[0] - b[0]) - (c[2] - b[2]) * (b[0] - a[0]);
dest[2] = (b[0] - a[0]) * (c[1] - b[1]) - (c[0] - b[0]) * (b[1] - a[1]); dest[2] = (b[0] - a[0]) * (c[1] - b[1]) - (c[0] - b[0]) * (b[1] - a[1]);
@ -388,7 +388,7 @@ Mat4 gMat4Zero = {
* at the position 'to'. The up-vector is assumed to be (0, 1, 0), but the 'roll' * at the position 'to'. The up-vector is assumed to be (0, 1, 0), but the 'roll'
* angle allows a bank rotation of the camera. * angle allows a bank rotation of the camera.
*/ */
OPTIMIZE_O3 void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll) { OPTIMIZE_O3 void mtxf_lookat(OUT Mat4 mtx, Vec3f from, Vec3f to, s16 roll) {
Vec3f forward, right, up; Vec3f forward, right, up;
f32 sinRoll, cosRoll; f32 sinRoll, cosRoll;
f32 dx, dz, xzDist; f32 dx, dz, xzDist;
@ -456,7 +456,7 @@ OPTIMIZE_O3 void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll) {
* Build a matrix that rotates around the z axis, then the x axis, then the y * Build a matrix that rotates around the z axis, then the x axis, then the y
* axis, and then translates. * axis, and then translates.
*/ */
OPTIMIZE_O3 void mtxf_rotate_zxy_and_translate(Mat4 dest, Vec3f translate, Vec3s rotate) { OPTIMIZE_O3 void mtxf_rotate_zxy_and_translate(OUT Mat4 dest, Vec3f translate, Vec3s rotate) {
f32 sx = sins(rotate[0]); f32 sx = sins(rotate[0]);
f32 cx = coss(rotate[0]); f32 cx = coss(rotate[0]);
@ -489,7 +489,7 @@ OPTIMIZE_O3 void mtxf_rotate_zxy_and_translate(Mat4 dest, Vec3f translate, Vec3s
* Build a matrix that rotates around the x axis, then the y axis, then the z * Build a matrix that rotates around the x axis, then the y axis, then the z
* axis, and then translates. * axis, and then translates.
*/ */
OPTIMIZE_O3 void mtxf_rotate_xyz_and_translate(Mat4 dest, Vec3f b, Vec3s c) { OPTIMIZE_O3 void mtxf_rotate_xyz_and_translate(OUT Mat4 dest, Vec3f b, Vec3s c) {
f32 sx = sins(c[0]); f32 sx = sins(c[0]);
f32 cx = coss(c[0]); f32 cx = coss(c[0]);
@ -526,7 +526,7 @@ OPTIMIZE_O3 void mtxf_rotate_xyz_and_translate(Mat4 dest, Vec3f b, Vec3s c) {
* 'position' is the position of the object in the world * 'position' is the position of the object in the world
* 'angle' rotates the object while still facing the camera. * 'angle' rotates the object while still facing the camera.
*/ */
OPTIMIZE_O3 void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle) { OPTIMIZE_O3 void mtxf_billboard(OUT Mat4 dest, Mat4 mtx, Vec3f position, s16 angle) {
dest[0][0] = coss(angle); dest[0][0] = coss(angle);
dest[0][1] = sins(angle); dest[0][1] = sins(angle);
dest[0][2] = 0; dest[0][2] = 0;
@ -549,7 +549,7 @@ OPTIMIZE_O3 void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle)
} }
// straight up mtxf_billboard but minus the dest[1][n] lines. transform for cylindrical billboards // straight up mtxf_billboard but minus the dest[1][n] lines. transform for cylindrical billboards
OPTIMIZE_O3 void mtxf_cylboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle) { OPTIMIZE_O3 void mtxf_cylboard(OUT Mat4 dest, Mat4 mtx, Vec3f position, s16 angle) {
dest[0][0] = coss(angle); dest[0][0] = coss(angle);
dest[0][1] = sins(angle); dest[0][1] = sins(angle);
dest[0][2] = 0; dest[0][2] = 0;
@ -578,7 +578,7 @@ OPTIMIZE_O3 void mtxf_cylboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle) {
* 'yaw' is the angle which it should face * 'yaw' is the angle which it should face
* 'pos' is the object's position in the world * 'pos' is the object's position in the world
*/ */
OPTIMIZE_O3 void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw) { OPTIMIZE_O3 void mtxf_align_terrain_normal(OUT Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw) {
Vec3f lateralDir; Vec3f lateralDir;
Vec3f leftDir; Vec3f leftDir;
Vec3f forwardDir; Vec3f forwardDir;
@ -621,7 +621,7 @@ OPTIMIZE_O3 void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s1
* 'pos' is the object's position in the world * 'pos' is the object's position in the world
* 'radius' is the distance from each triangle vertex to the center * 'radius' is the distance from each triangle vertex to the center
*/ */
OPTIMIZE_O3 void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius) { OPTIMIZE_O3 void mtxf_align_terrain_triangle(OUT Mat4 mtx, Vec3f pos, s16 yaw, f32 radius) {
struct Surface *sp74; struct Surface *sp74;
Vec3f point0; Vec3f point0;
Vec3f point1; Vec3f point1;
@ -692,7 +692,7 @@ OPTIMIZE_O3 void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 r
* The resulting matrix represents first applying transformation b and * The resulting matrix represents first applying transformation b and
* then a. * then a.
*/ */
OPTIMIZE_O3 void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b) { OPTIMIZE_O3 void mtxf_mul(OUT Mat4 dest, Mat4 a, Mat4 b) {
Mat4 tmp; Mat4 tmp;
for (s32 i = 0; i < 4; i++) { for (s32 i = 0; i < 4; i++) {
for (s32 j = 0; j < 4; j++) { for (s32 j = 0; j < 4; j++) {
@ -710,7 +710,7 @@ OPTIMIZE_O3 void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b) {
* to the point. Note that the bottom row is assumed to be [0, 0, 0, 1], which is * to the point. Note that the bottom row is assumed to be [0, 0, 0, 1], which is
* true for transformation matrices if the translation has a w component of 1. * true for transformation matrices if the translation has a w component of 1.
*/ */
OPTIMIZE_O3 s16 *mtxf_mul_vec3s(Mat4 mtx, Vec3s b) { OPTIMIZE_O3 Vec3sp mtxf_mul_vec3s(Mat4 mtx, OUT Vec3s b) {
f32 x = b[0]; f32 x = b[0];
f32 y = b[1]; f32 y = b[1];
f32 z = b[2]; f32 z = b[2];
@ -725,7 +725,7 @@ OPTIMIZE_O3 s16 *mtxf_mul_vec3s(Mat4 mtx, Vec3s b) {
/** /**
* Set 'mtx' to a transformation matrix that rotates around the z axis. * Set 'mtx' to a transformation matrix that rotates around the z axis.
*/ */
OPTIMIZE_O3 void mtxf_rotate_xy(Mat4 mtx, s16 angle) { OPTIMIZE_O3 void mtxf_rotate_xy(OUT Mat4 mtx, s16 angle) {
mtxf_identity(mtx); mtxf_identity(mtx);
mtx[0][0] = coss(angle); mtx[0][0] = coss(angle);
mtx[0][1] = sins(angle); mtx[0][1] = sins(angle);
@ -746,7 +746,7 @@ OPTIMIZE_O3 void mtxf_rotate_xy(Mat4 mtx, s16 angle) {
* furthermore, this is currently only used to get the inverse of the camera transform * furthermore, this is currently only used to get the inverse of the camera transform
* because that is always orthonormal, the determinant will never be 0, so that check is removed * because that is always orthonormal, the determinant will never be 0, so that check is removed
*/ */
OPTIMIZE_O3 void mtxf_inverse(Mat4 dest, Mat4 src) { OPTIMIZE_O3 void mtxf_inverse(OUT Mat4 dest, Mat4 src) {
Mat4 buf; Mat4 buf;
// calculating the determinant has been reduced since the check is removed // calculating the determinant has been reduced since the check is removed
@ -789,7 +789,7 @@ OPTIMIZE_O3 void mtxf_inverse(Mat4 dest, Mat4 src) {
* objMtx back from screen orientation to world orientation, and then subtracting * objMtx back from screen orientation to world orientation, and then subtracting
* the camera position. * the camera position.
*/ */
OPTIMIZE_O3 Vec3fp get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx) { OPTIMIZE_O3 Vec3fp get_pos_from_transform_mtx(OUT Vec3f dest, Mat4 objMtx, Mat4 camMtx) {
f32 camX = camMtx[3][0] * camMtx[0][0] + camMtx[3][1] * camMtx[0][1] + camMtx[3][2] * camMtx[0][2]; f32 camX = camMtx[3][0] * camMtx[0][0] + camMtx[3][1] * camMtx[0][1] + camMtx[3][2] * camMtx[0][2];
f32 camY = camMtx[3][0] * camMtx[1][0] + camMtx[3][1] * camMtx[1][1] + camMtx[3][2] * camMtx[1][2]; f32 camY = camMtx[3][0] * camMtx[1][0] + camMtx[3][1] * camMtx[1][1] + camMtx[3][2] * camMtx[1][2];
f32 camZ = camMtx[3][0] * camMtx[2][0] + camMtx[3][1] * camMtx[2][1] + camMtx[3][2] * camMtx[2][2]; f32 camZ = camMtx[3][0] * camMtx[2][0] + camMtx[3][1] * camMtx[2][1] + camMtx[3][2] * camMtx[2][2];

View file

@ -131,7 +131,7 @@ OPTIMIZE_O3 f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec);
/* |description| /* |description|
Computes spline interpolation weights for a given parameter `t` and stores these weights in `result`. This is used in spline-based animations to find intermediate positions between keyframes Computes spline interpolation weights for a given parameter `t` and stores these weights in `result`. This is used in spline-based animations to find intermediate positions between keyframes
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 void spline_get_weights(struct MarioState* m, Vec4f result, f32 t, UNUSED s32 c); OPTIMIZE_O3 void spline_get_weights(struct MarioState* m, OUT Vec4f result, f32 t, UNUSED s32 c);
/* |description| /* |description|
Initializes a spline-based animation for the `MarioState` structure `m` using the provided array of 3D signed-integer vectors `keyFrames`. This sets up the animation so that it can be advanced by polling Initializes a spline-based animation for the `MarioState` structure `m` using the provided array of 3D signed-integer vectors `keyFrames`. This sets up the animation so that it can be advanced by polling
@ -141,7 +141,7 @@ OPTIMIZE_O3 void anim_spline_init(struct MarioState* m, Vec4s *keyFrames);
/* |description| /* |description|
Advances the spline-based animation associated with `m` and stores the current interpolated position in `result`. It returns the animation's status, allowing the caller to determine if the animation is ongoing or has completed Advances the spline-based animation associated with `m` and stores the current interpolated position in `result`. It returns the animation's status, allowing the caller to determine if the animation is ongoing or has completed
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 s32 anim_spline_poll(struct MarioState* m, Vec3f result); OPTIMIZE_O3 s32 anim_spline_poll(struct MarioState* m, OUT Vec3f result);
/////////// ///////////
// Vec3f // // Vec3f //
@ -152,22 +152,22 @@ OPTIMIZE_O3 s32 anim_spline_poll(struct MarioState* m, Vec3f result);
/* |description| /* |description|
Rotates the 3D floating-point vector `v` by the angles specified in the 3D signed-integer vector `rotate`, applying the rotations in the order Z, then X, then Y. The rotated vector replaces `v` Rotates the 3D floating-point vector `v` by the angles specified in the 3D signed-integer vector `rotate`, applying the rotations in the order Z, then X, then Y. The rotated vector replaces `v`
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 Vec3fp vec3f_rotate_zxy(Vec3f v, Vec3s rotate); OPTIMIZE_O3 Vec3fp vec3f_rotate_zxy(OUT Vec3f v, Vec3s rotate);
/* |description| /* |description|
Rotates the 3D floating-point vector `v` around the vector `n`, given a rotation `r` (in sm64 angle units), and stores the result in `dest` Rotates the 3D floating-point vector `v` around the vector `n`, given a rotation `r` (in sm64 angle units), and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 Vec3fp vec3f_rotate_around_n(Vec3f dest, Vec3f v, Vec3f n, s16 r); OPTIMIZE_O3 Vec3fp vec3f_rotate_around_n(OUT Vec3f dest, Vec3f v, Vec3f n, s16 r);
/* |description| /* |description|
Projects the 3D floating-point vector `v` onto another 3D floating-point vector `onto`. The resulting projection, stored in `dest`, represents how much of `v` lies along the direction of `onto` Projects the 3D floating-point vector `v` onto another 3D floating-point vector `onto`. The resulting projection, stored in `dest`, represents how much of `v` lies along the direction of `onto`
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 Vec3fp vec3f_project(Vec3f dest, Vec3f v, Vec3f onto); OPTIMIZE_O3 Vec3fp vec3f_project(OUT Vec3f dest, Vec3f v, Vec3f onto);
/* |description| /* |description|
Scales the 3D floating-point vector `v` by the vector `scale`, then rotates it by the rotation vector `rotation`, and finally translates it by the vector `translation`. The resulting vector is stored in `dest` Scales the 3D floating-point vector `v` by the vector `scale`, then rotates it by the rotation vector `rotation`, and finally translates it by the vector `translation`. The resulting vector is stored in `dest`
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 Vec3fp vec3f_transform(Vec3f dest, Vec3f v, Vec3f translation, Vec3s rotation, Vec3f scale); OPTIMIZE_O3 Vec3fp vec3f_transform(OUT Vec3f dest, Vec3f v, Vec3f translation, Vec3s rotation, Vec3f scale);
/* |description| /* |description|
Calculates the distance between two points in 3D space (`from` and `to`), as well as the pitch and yaw angles that describe the direction from `from` to `to`. The results are stored in `dist`, `pitch`, and `yaw` Calculates the distance between two points in 3D space (`from` and `to`), as well as the pitch and yaw angles that describe the direction from `from` to `to`. The results are stored in `dist`, `pitch`, and `yaw`
@ -177,12 +177,12 @@ OPTIMIZE_O3 void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *
/* |description| /* |description|
Positions the point `to` at a given `dist`, `pitch`, and `yaw` relative to the point `from`. This can be used to place objects around a reference point at specific angles and distances Positions the point `to` at a given `dist`, `pitch`, and `yaw` relative to the point `from`. This can be used to place objects around a reference point at specific angles and distances
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw); OPTIMIZE_O3 void vec3f_set_dist_and_angle(Vec3f from, OUT Vec3f to, f32 dist, s16 pitch, s16 yaw);
/* |description| /* |description|
Determines a vector that is perpendicular (normal) to the plane defined by three given 3D floating-point points `a`, `b`, and `c`. The resulting perpendicular vector is stored in `dest` Determines a vector that is perpendicular (normal) to the plane defined by three given 3D floating-point points `a`, `b`, and `c`. The resulting perpendicular vector is stored in `dest`
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 Vec3fp find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f b, Vec3f c); OPTIMIZE_O3 Vec3fp find_vector_perpendicular_to_plane(OUT Vec3f dest, Vec3f a, Vec3f b, Vec3f c);
/////////// ///////////
// Vec3i // // Vec3i //
@ -205,62 +205,62 @@ OPTIMIZE_O3 Vec3fp find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f
/* |description| /* |description|
Adjusts the 4x4 floating-point matrix `mtx` so that it represents a viewing transformation looking from the point `from` toward the point `to`, with a given roll angle. This creates a view matrix oriented toward `to` Adjusts the 4x4 floating-point matrix `mtx` so that it represents a viewing transformation looking from the point `from` toward the point `to`, with a given roll angle. This creates a view matrix oriented toward `to`
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll); OPTIMIZE_O3 void mtxf_lookat(OUT Mat4 mtx, Vec3f from, Vec3f to, s16 roll);
/* |description| /* |description|
Rotates `dest` according to the angles in `rotate` using ZXY order, and then translates it by the 3D floating-point vector `translate`. This effectively positions and orients `dest` in 3D space Rotates `dest` according to the angles in `rotate` using ZXY order, and then translates it by the 3D floating-point vector `translate`. This effectively positions and orients `dest` in 3D space
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 void mtxf_rotate_zxy_and_translate(Mat4 dest, Vec3f translate, Vec3s rotate); OPTIMIZE_O3 void mtxf_rotate_zxy_and_translate(OUT Mat4 dest, Vec3f translate, Vec3s rotate);
/* |description| /* |description|
Rotates `dest` using angles in XYZ order, and then translates it by the 3D floating-point vector `b` and applies the rotations described by `c`. This sets up `dest` with a specific orientation and position in space Rotates `dest` using angles in XYZ order, and then translates it by the 3D floating-point vector `b` and applies the rotations described by `c`. This sets up `dest` with a specific orientation and position in space
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 void mtxf_rotate_xyz_and_translate(Mat4 dest, Vec3f b, Vec3s c); OPTIMIZE_O3 void mtxf_rotate_xyz_and_translate(OUT Mat4 dest, Vec3f b, Vec3s c);
/* |description| /* |description|
Transforms a 4x4 floating-point matrix `mtx` into a "billboard" oriented toward the camera or a given direction. The billboard is placed at `position` and rotated by `angle`. This is useful for objects that should always face the viewer Transforms a 4x4 floating-point matrix `mtx` into a "billboard" oriented toward the camera or a given direction. The billboard is placed at `position` and rotated by `angle`. This is useful for objects that should always face the viewer
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle); OPTIMIZE_O3 void mtxf_billboard(OUT Mat4 dest, Mat4 mtx, Vec3f position, s16 angle);
/* |description| /* |description|
Creates a "cylindrical billboard" transformation from the 4x4 matrix `mtx` placed at `position` with a given `angle`. Unlike a full billboard, this might allow rotation around one axis while still facing the viewer on others Creates a "cylindrical billboard" transformation from the 4x4 matrix `mtx` placed at `position` with a given `angle`. Unlike a full billboard, this might allow rotation around one axis while still facing the viewer on others
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 void mtxf_cylboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle); OPTIMIZE_O3 void mtxf_cylboard(OUT Mat4 dest, Mat4 mtx, Vec3f position, s16 angle);
/* |description| /* |description|
Aligns `dest` so that it fits the orientation of a terrain surface defined by its normal vector `upDir`. The transformation is positioned at `pos` and oriented with a given `yaw`. This is often used to make objects sit naturally on uneven ground Aligns `dest` so that it fits the orientation of a terrain surface defined by its normal vector `upDir`. The transformation is positioned at `pos` and oriented with a given `yaw`. This is often used to make objects sit naturally on uneven ground
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw); OPTIMIZE_O3 void mtxf_align_terrain_normal(OUT Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw);
/* |description| /* |description|
Aligns `mtx` to fit onto a terrain triangle at `pos`, applying a given `yaw` and scaling by `radius`. This helps position objects so they match the orientation of the terrain's surface Aligns `mtx` to fit onto a terrain triangle at `pos`, applying a given `yaw` and scaling by `radius`. This helps position objects so they match the orientation of the terrain's surface
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius); OPTIMIZE_O3 void mtxf_align_terrain_triangle(OUT Mat4 mtx, Vec3f pos, s16 yaw, f32 radius);
/* |description| /* |description|
Multiplies two 4x4 floating-point matrices `a` and `b` (in that order), storing the product in `dest`. This can be used for combining multiple transformations into one Multiplies two 4x4 floating-point matrices `a` and `b` (in that order), storing the product in `dest`. This can be used for combining multiple transformations into one
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b); OPTIMIZE_O3 void mtxf_mul(OUT Mat4 dest, Mat4 a, Mat4 b);
/* |description| /* |description|
Multiplies the 3D signed-integer vector `b` with the 4x4 floating-point matrix `mtx`, which applies the transformation to the point Multiplies the 3D signed-integer vector `b` with the 4x4 floating-point matrix `mtx`, which applies the transformation to the point
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 s16 *mtxf_mul_vec3s(Mat4 mtx, Vec3s b); OPTIMIZE_O3 Vec3sp mtxf_mul_vec3s(Mat4 mtx, OUT Vec3s b);
/* |description| /* |description|
Rotates the matrix `mtx` in the XY plane by the given `angle`. Rotating in the XY plane typically means pivoting around the Z axis Rotates the matrix `mtx` in the XY plane by the given `angle`. Rotating in the XY plane typically means pivoting around the Z axis
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 void mtxf_rotate_xy(Mat4 mtx, s16 angle); OPTIMIZE_O3 void mtxf_rotate_xy(OUT Mat4 mtx, s16 angle);
/* |description| /* |description|
Inverts the 4x4 floating-point matrix `src` and stores the inverse in `dest`. Applying the inverse transformation undoes whatever `src` did, returning points back to their original coordinate space Inverts the 4x4 floating-point matrix `src` and stores the inverse in `dest`. Applying the inverse transformation undoes whatever `src` did, returning points back to their original coordinate space
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 void mtxf_inverse(Mat4 dest, Mat4 src); OPTIMIZE_O3 void mtxf_inverse(OUT Mat4 dest, Mat4 src);
/* |description| /* |description|
Extracts the position (translation component) from the transformation matrix `objMtx` relative to the coordinate system defined by `camMtx` and stores that 3D position in `dest`. This can be used to get the object's coordinates in camera space Extracts the position (translation component) from the transformation matrix `objMtx` relative to the coordinate system defined by `camMtx` and stores that 3D position in `dest`. This can be used to get the object's coordinates in camera space
|descriptionEnd| */ |descriptionEnd| */
OPTIMIZE_O3 Vec3fp get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx); OPTIMIZE_O3 Vec3fp get_pos_from_transform_mtx(OUT Vec3f dest, Mat4 objMtx, Mat4 camMtx);
#endif // MATH_UTIL_H #endif // MATH_UTIL_H

View file

@ -14,28 +14,28 @@ optimizations and bug reports.
Sets the 4x4 floating-point matrix `mtx` to all zeros. Sets the 4x4 floating-point matrix `mtx` to all zeros.
Unless you really need this-It's reccomended to use mtxf_identity instead. Unless you really need this-It's reccomended to use mtxf_identity instead.
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 void mtxf_zero(Mat4 mtx) { INLINE OPTIMIZE_O3 void mtxf_zero(OUT Mat4 mtx) {
memset(mtx, 0, sizeof(Mat4)); memset(mtx, 0, sizeof(Mat4));
} }
/* |description| /* |description|
Copies the 4x4 floating-point matrix `src` into `dest`. After this operation, `dest` contains the same matrix values as `src` Copies the 4x4 floating-point matrix `src` into `dest`. After this operation, `dest` contains the same matrix values as `src`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 void mtxf_copy(Mat4 dest, Mat4 src) { INLINE OPTIMIZE_O3 void mtxf_copy(OUT Mat4 dest, Mat4 src) {
memcpy(dest, src, sizeof(Mat4)); memcpy(dest, src, sizeof(Mat4));
} }
/* |description| /* |description|
Sets the 4x4 floating-point matrix `mtx` to the identity matrix. The identity matrix leaves points unchanged when they are transformed by it which is useful for matrix math Sets the 4x4 floating-point matrix `mtx` to the identity matrix. The identity matrix leaves points unchanged when they are transformed by it which is useful for matrix math
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 void mtxf_identity(Mat4 mtx) { INLINE OPTIMIZE_O3 void mtxf_identity(OUT Mat4 mtx) {
mtxf_copy(mtx, gMat4Identity); mtxf_copy(mtx, gMat4Identity);
} }
/* |description| /* |description|
Applies a translation to the 4x4 floating-point matrix `dest` by adding the coordinates in the 3D floating-point vector `b`. This shifts any transformed point by `b` Sets the 4x4 floating-point matrix `dest` to the translation matrix decribed by the 3D floating-point vector `b`. This matrix is used to shift any transformed point by `b`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 void mtxf_translate(Mat4 dest, Vec3f b) { INLINE OPTIMIZE_O3 void mtxf_translate(OUT Mat4 dest, Vec3f b) {
mtxf_identity(dest); mtxf_identity(dest);
vec3f_copy(dest[3], b); vec3f_copy(dest[3], b);
} }
@ -43,7 +43,7 @@ INLINE OPTIMIZE_O3 void mtxf_translate(Mat4 dest, Vec3f b) {
/* |description| /* |description|
Scales the 4x4 floating-point matrix `mtx` by the scaling factors found in the 3D floating-point vector `s`, and stores the result in `dest`. This enlarges or shrinks objects in 3D space Scales the 4x4 floating-point matrix `mtx` by the scaling factors found in the 3D floating-point vector `s`, and stores the result in `dest`. This enlarges or shrinks objects in 3D space
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s) { INLINE OPTIMIZE_O3 void mtxf_scale_vec3f(OUT Mat4 dest, Mat4 mtx, Vec3f s) {
mtxf_copy(dest, mtx); mtxf_copy(dest, mtx);
vec3f_mul(dest[0], s[0]); vec3f_mul(dest[0], s[0]);
vec3f_mul(dest[1], s[1]); vec3f_mul(dest[1], s[1]);

View file

@ -3,7 +3,7 @@
/* |description| /* |description|
Sets the components of the 3D {{desc}} vector `v` to 0 Sets the components of the 3D {{desc}} vector `v` to 0
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_zero(Vec3{{suffix}} v) { INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_zero(OUT Vec3{{suffix}} v) {
memset(v, 0, sizeof(Vec3{{suffix}})); memset(v, 0, sizeof(Vec3{{suffix}}));
return v; return v;
} }
@ -11,7 +11,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_zero(Vec3{{suffix}} v) {
/* |description| /* |description|
Copies the contents of a 3D {{desc}} vector (`src`) into another 3D {{desc}} vector (`dest`) Copies the contents of a 3D {{desc}} vector (`src`) into another 3D {{desc}} vector (`dest`)
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_copy(Vec3{{suffix}} dest, Vec3{{suffix}} src) { INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_copy(OUT Vec3{{suffix}} dest, Vec3{{suffix}} src) {
dest[0] = src[0]; dest[0] = src[0];
dest[1] = src[1]; dest[1] = src[1];
dest[2] = src[2]; dest[2] = src[2];
@ -21,7 +21,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_copy(Vec3{{suffix}} dest, Vec3
/* |description| /* |description|
Sets the values of the 3D {{desc}} vector `dest` to the given x, y, and z values Sets the values of the 3D {{desc}} vector `dest` to the given x, y, and z values
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_set(Vec3{{suffix}} dest, {{type}} x, {{type}} y, {{type}} z) { INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_set(OUT Vec3{{suffix}} dest, {{type}} x, {{type}} y, {{type}} z) {
dest[0] = x; dest[0] = x;
dest[1] = y; dest[1] = y;
dest[2] = z; dest[2] = z;
@ -31,7 +31,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_set(Vec3{{suffix}} dest, {{typ
/* |description| /* |description|
Adds the components of the 3D {{desc}} vector `a` to `dest` Adds the components of the 3D {{desc}} vector `a` to `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_add(Vec3{{suffix}} dest, Vec3{{suffix}} a) { INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_add(OUT Vec3{{suffix}} dest, Vec3{{suffix}} a) {
dest[0] += a[0]; dest[0] += a[0];
dest[1] += a[1]; dest[1] += a[1];
dest[2] += a[2]; dest[2] += a[2];
@ -41,7 +41,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_add(Vec3{{suffix}} dest, Vec3{
/* |description| /* |description|
Adds the components of two 3D {{desc}} vectors `a` and `b` and stores the result in `dest` Adds the components of two 3D {{desc}} vectors `a` and `b` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_sum(Vec3{{suffix}} dest, Vec3{{suffix}} a, Vec3{{suffix}} b) { INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_sum(OUT Vec3{{suffix}} dest, Vec3{{suffix}} a, Vec3{{suffix}} b) {
dest[0] = a[0] + b[0]; dest[0] = a[0] + b[0];
dest[1] = a[1] + b[1]; dest[1] = a[1] + b[1];
dest[2] = a[2] + b[2]; dest[2] = a[2] + b[2];
@ -51,7 +51,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_sum(Vec3{{suffix}} dest, Vec3{
/* |description| /* |description|
Subtracts the components of the 3D {{desc}} vector `a` from `dest` Subtracts the components of the 3D {{desc}} vector `a` from `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_sub(Vec3{{suffix}} dest, Vec3{{suffix}} a) { INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_sub(OUT Vec3{{suffix}} dest, Vec3{{suffix}} a) {
dest[0] -= a[0]; dest[0] -= a[0];
dest[1] -= a[1]; dest[1] -= a[1];
dest[2] -= a[2]; dest[2] -= a[2];
@ -61,7 +61,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_sub(Vec3{{suffix}} dest, Vec3{
/* |description| /* |description|
Subtracts the components of the 3D {{desc}} vector `b` from the components of `a` and stores the result in `dest` Subtracts the components of the 3D {{desc}} vector `b` from the components of `a` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_dif(Vec3{{suffix}} dest, Vec3{{suffix}} a, Vec3{{suffix}} b) { INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_dif(OUT Vec3{{suffix}} dest, Vec3{{suffix}} a, Vec3{{suffix}} b) {
dest[0] = a[0] - b[0]; dest[0] = a[0] - b[0];
dest[1] = a[1] - b[1]; dest[1] = a[1] - b[1];
dest[2] = a[2] - b[2]; dest[2] = a[2] - b[2];
@ -71,7 +71,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_dif(Vec3{{suffix}} dest, Vec3{
/* |description| /* |description|
Multiplies each component of the 3D {{desc}} vector `dest` by the scalar value `a` Multiplies each component of the 3D {{desc}} vector `dest` by the scalar value `a`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_mul(Vec3{{suffix}} dest, f32 a) { INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_mul(OUT Vec3{{suffix}} dest, f32 a) {
dest[0] *= a; dest[0] *= a;
dest[1] *= a; dest[1] *= a;
dest[2] *= a; dest[2] *= a;
@ -81,7 +81,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_mul(Vec3{{suffix}} dest, f32 a
/* |description| /* |description|
Multiplies the components of the 3D {{desc}} vector `dest` with the components of `a` Multiplies the components of the 3D {{desc}} vector `dest` with the components of `a`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_mult(Vec3{{suffix}} dest, Vec3{{suffix}} a) { INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_mult(OUT Vec3{{suffix}} dest, Vec3{{suffix}} a) {
dest[0] *= a[0]; dest[0] *= a[0];
dest[1] *= a[1]; dest[1] *= a[1];
dest[2] *= a[2]; dest[2] *= a[2];
@ -91,7 +91,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_mult(Vec3{{suffix}} dest, Vec3
/* |description| /* |description|
Multiplies the components of two 3D {{desc}} vectors `a` and `b` and stores the result in `dest` Multiplies the components of two 3D {{desc}} vectors `a` and `b` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_prod(Vec3{{suffix}} dest, Vec3{{suffix}} a, Vec3{{suffix}} b) { INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_prod(OUT Vec3{{suffix}} dest, Vec3{{suffix}} a, Vec3{{suffix}} b) {
dest[0] = a[0] * b[0]; dest[0] = a[0] * b[0];
dest[1] = a[1] * b[1]; dest[1] = a[1] * b[1];
dest[2] = a[2] * b[2]; dest[2] = a[2] * b[2];
@ -101,7 +101,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_prod(Vec3{{suffix}} dest, Vec3
/* |description| /* |description|
Divides each component of the 3D {{desc}} vector `dest` by the scalar value `a` Divides each component of the 3D {{desc}} vector `dest` by the scalar value `a`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_div(Vec3{{suffix}} dest, f32 a) { INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_div(OUT Vec3{{suffix}} dest, f32 a) {
if (a == 0) { return dest; } if (a == 0) { return dest; }
dest[0] /= a; dest[0] /= a;
dest[1] /= a; dest[1] /= a;
@ -119,7 +119,7 @@ INLINE OPTIMIZE_O3 f32 vec3{{suffix}}_length(Vec3{{suffix}} a) {
/* |description| /* |description|
Normalizes the 3D {{desc}} vector `v` so that its length (magnitude) becomes 1, while retaining its direction Normalizes the 3D {{desc}} vector `v` so that its length (magnitude) becomes 1, while retaining its direction
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_normalize(Vec3{{suffix}} v) { INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_normalize(OUT Vec3{{suffix}} v) {
f32 mag = vec3{{suffix}}_length(v); f32 mag = vec3{{suffix}}_length(v);
vec3{{suffix}}_div(v, mag); vec3{{suffix}}_div(v, mag);
return v; return v;
@ -128,7 +128,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_normalize(Vec3{{suffix}} v) {
/* |description| /* |description|
Sets the length (magnitude) of 3D {{desc}} vector `v`, while retaining its direction Sets the length (magnitude) of 3D {{desc}} vector `v`, while retaining its direction
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_set_magnitude(Vec3{{suffix}} v, f32 mag) { INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_set_magnitude(OUT Vec3{{suffix}} v, f32 mag) {
vec3{{suffix}}_normalize(v); vec3{{suffix}}_normalize(v);
vec3{{suffix}}_mul(v, mag); vec3{{suffix}}_mul(v, mag);
return v; return v;
@ -144,7 +144,7 @@ INLINE OPTIMIZE_O3 f32 vec3{{suffix}}_dot(Vec3{{suffix}} a, Vec3{{suffix}} b) {
/* |description| /* |description|
Computes the cross product of two 3D {{desc}} vectors `a` and `b` and stores the result in `dest` Computes the cross product of two 3D {{desc}} vectors `a` and `b` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_cross(Vec3{{suffix}} dest, Vec3{{suffix}} a, Vec3{{suffix}} b) { INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_cross(OUT Vec3{{suffix}} dest, Vec3{{suffix}} a, Vec3{{suffix}} b) {
dest[0] = a[1] * b[2] - b[1] * a[2]; dest[0] = a[1] * b[2] - b[1] * a[2];
dest[1] = a[2] * b[0] - b[2] * a[0]; dest[1] = a[2] * b[0] - b[2] * a[0];
dest[2] = a[0] * b[1] - b[0] * a[1]; dest[2] = a[0] * b[1] - b[0] * a[1];
@ -154,7 +154,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_cross(Vec3{{suffix}} dest, Vec
/* |description| /* |description|
Takes two 3D {{desc}} vectors `vecA` and `vecB`, multiplies them by `sclA` and `sclB` respectively, adds the scaled vectors together and stores the result in `dest` Takes two 3D {{desc}} vectors `vecA` and `vecB`, multiplies them by `sclA` and `sclB` respectively, adds the scaled vectors together and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_combine(Vec3{{suffix}} dest, Vec3{{suffix}} vecA, Vec3{{suffix}} vecB, f32 sclA, f32 sclB) { INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_combine(OUT Vec3{{suffix}} dest, Vec3{{suffix}} vecA, Vec3{{suffix}} vecB, f32 sclA, f32 sclB) {
dest[0] = vecA[0] * sclA + vecB[0] * sclB; dest[0] = vecA[0] * sclA + vecB[0] * sclB;
dest[1] = vecA[1] * sclA + vecB[1] * sclB; dest[1] = vecA[1] * sclA + vecB[1] * sclB;
dest[2] = vecA[2] * sclA + vecB[2] * sclB; dest[2] = vecA[2] * sclA + vecB[2] * sclB;

View file

@ -6,7 +6,7 @@
/* |description| /* |description|
Sets the components of the 3D floating-point vector `v` to 0 Sets the components of the 3D floating-point vector `v` to 0
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3f_zero(Vec3f v) { INLINE OPTIMIZE_O3 Vec3fp vec3f_zero(OUT Vec3f v) {
memset(v, 0, sizeof(Vec3f)); memset(v, 0, sizeof(Vec3f));
return v; return v;
} }
@ -14,7 +14,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_zero(Vec3f v) {
/* |description| /* |description|
Copies the contents of a 3D floating-point vector (`src`) into another 3D floating-point vector (`dest`) Copies the contents of a 3D floating-point vector (`src`) into another 3D floating-point vector (`dest`)
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3f_copy(Vec3f dest, Vec3f src) { INLINE OPTIMIZE_O3 Vec3fp vec3f_copy(OUT Vec3f dest, Vec3f src) {
dest[0] = src[0]; dest[0] = src[0];
dest[1] = src[1]; dest[1] = src[1];
dest[2] = src[2]; dest[2] = src[2];
@ -24,7 +24,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_copy(Vec3f dest, Vec3f src) {
/* |description| /* |description|
Sets the values of the 3D floating-point vector `dest` to the given x, y, and z values Sets the values of the 3D floating-point vector `dest` to the given x, y, and z values
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3f_set(Vec3f dest, f32 x, f32 y, f32 z) { INLINE OPTIMIZE_O3 Vec3fp vec3f_set(OUT Vec3f dest, f32 x, f32 y, f32 z) {
dest[0] = x; dest[0] = x;
dest[1] = y; dest[1] = y;
dest[2] = z; dest[2] = z;
@ -34,7 +34,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_set(Vec3f dest, f32 x, f32 y, f32 z) {
/* |description| /* |description|
Adds the components of the 3D floating-point vector `a` to `dest` Adds the components of the 3D floating-point vector `a` to `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3f_add(Vec3f dest, Vec3f a) { INLINE OPTIMIZE_O3 Vec3fp vec3f_add(OUT Vec3f dest, Vec3f a) {
dest[0] += a[0]; dest[0] += a[0];
dest[1] += a[1]; dest[1] += a[1];
dest[2] += a[2]; dest[2] += a[2];
@ -44,7 +44,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_add(Vec3f dest, Vec3f a) {
/* |description| /* |description|
Adds the components of two 3D floating-point vectors `a` and `b` and stores the result in `dest` Adds the components of two 3D floating-point vectors `a` and `b` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3f_sum(Vec3f dest, Vec3f a, Vec3f b) { INLINE OPTIMIZE_O3 Vec3fp vec3f_sum(OUT Vec3f dest, Vec3f a, Vec3f b) {
dest[0] = a[0] + b[0]; dest[0] = a[0] + b[0];
dest[1] = a[1] + b[1]; dest[1] = a[1] + b[1];
dest[2] = a[2] + b[2]; dest[2] = a[2] + b[2];
@ -54,7 +54,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_sum(Vec3f dest, Vec3f a, Vec3f b) {
/* |description| /* |description|
Subtracts the components of the 3D floating-point vector `a` from `dest` Subtracts the components of the 3D floating-point vector `a` from `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3f_sub(Vec3f dest, Vec3f a) { INLINE OPTIMIZE_O3 Vec3fp vec3f_sub(OUT Vec3f dest, Vec3f a) {
dest[0] -= a[0]; dest[0] -= a[0];
dest[1] -= a[1]; dest[1] -= a[1];
dest[2] -= a[2]; dest[2] -= a[2];
@ -64,7 +64,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_sub(Vec3f dest, Vec3f a) {
/* |description| /* |description|
Subtracts the components of the 3D floating-point vector `b` from the components of `a` and stores the result in `dest` Subtracts the components of the 3D floating-point vector `b` from the components of `a` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3f_dif(Vec3f dest, Vec3f a, Vec3f b) { INLINE OPTIMIZE_O3 Vec3fp vec3f_dif(OUT Vec3f dest, Vec3f a, Vec3f b) {
dest[0] = a[0] - b[0]; dest[0] = a[0] - b[0];
dest[1] = a[1] - b[1]; dest[1] = a[1] - b[1];
dest[2] = a[2] - b[2]; dest[2] = a[2] - b[2];
@ -74,7 +74,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_dif(Vec3f dest, Vec3f a, Vec3f b) {
/* |description| /* |description|
Multiplies each component of the 3D floating-point vector `dest` by the scalar value `a` Multiplies each component of the 3D floating-point vector `dest` by the scalar value `a`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3f_mul(Vec3f dest, f32 a) { INLINE OPTIMIZE_O3 Vec3fp vec3f_mul(OUT Vec3f dest, f32 a) {
dest[0] *= a; dest[0] *= a;
dest[1] *= a; dest[1] *= a;
dest[2] *= a; dest[2] *= a;
@ -84,7 +84,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_mul(Vec3f dest, f32 a) {
/* |description| /* |description|
Multiplies the components of the 3D floating-point vector `dest` with the components of `a` Multiplies the components of the 3D floating-point vector `dest` with the components of `a`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3f_mult(Vec3f dest, Vec3f a) { INLINE OPTIMIZE_O3 Vec3fp vec3f_mult(OUT Vec3f dest, Vec3f a) {
dest[0] *= a[0]; dest[0] *= a[0];
dest[1] *= a[1]; dest[1] *= a[1];
dest[2] *= a[2]; dest[2] *= a[2];
@ -94,7 +94,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_mult(Vec3f dest, Vec3f a) {
/* |description| /* |description|
Multiplies the components of two 3D floating-point vectors `a` and `b` and stores the result in `dest` Multiplies the components of two 3D floating-point vectors `a` and `b` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3f_prod(Vec3f dest, Vec3f a, Vec3f b) { INLINE OPTIMIZE_O3 Vec3fp vec3f_prod(OUT Vec3f dest, Vec3f a, Vec3f b) {
dest[0] = a[0] * b[0]; dest[0] = a[0] * b[0];
dest[1] = a[1] * b[1]; dest[1] = a[1] * b[1];
dest[2] = a[2] * b[2]; dest[2] = a[2] * b[2];
@ -104,7 +104,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_prod(Vec3f dest, Vec3f a, Vec3f b) {
/* |description| /* |description|
Divides each component of the 3D floating-point vector `dest` by the scalar value `a` Divides each component of the 3D floating-point vector `dest` by the scalar value `a`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3f_div(Vec3f dest, f32 a) { INLINE OPTIMIZE_O3 Vec3fp vec3f_div(OUT Vec3f dest, f32 a) {
if (a == 0) { return dest; } if (a == 0) { return dest; }
dest[0] /= a; dest[0] /= a;
dest[1] /= a; dest[1] /= a;
@ -122,7 +122,7 @@ INLINE OPTIMIZE_O3 f32 vec3f_length(Vec3f a) {
/* |description| /* |description|
Normalizes the 3D floating-point vector `v` so that its length (magnitude) becomes 1, while retaining its direction Normalizes the 3D floating-point vector `v` so that its length (magnitude) becomes 1, while retaining its direction
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3f_normalize(Vec3f v) { INLINE OPTIMIZE_O3 Vec3fp vec3f_normalize(OUT Vec3f v) {
f32 mag = vec3f_length(v); f32 mag = vec3f_length(v);
vec3f_div(v, mag); vec3f_div(v, mag);
return v; return v;
@ -131,7 +131,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_normalize(Vec3f v) {
/* |description| /* |description|
Sets the length (magnitude) of 3D floating-point vector `v`, while retaining its direction Sets the length (magnitude) of 3D floating-point vector `v`, while retaining its direction
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3f_set_magnitude(Vec3f v, f32 mag) { INLINE OPTIMIZE_O3 Vec3fp vec3f_set_magnitude(OUT Vec3f v, f32 mag) {
vec3f_normalize(v); vec3f_normalize(v);
vec3f_mul(v, mag); vec3f_mul(v, mag);
return v; return v;
@ -147,7 +147,7 @@ INLINE OPTIMIZE_O3 f32 vec3f_dot(Vec3f a, Vec3f b) {
/* |description| /* |description|
Computes the cross product of two 3D floating-point vectors `a` and `b` and stores the result in `dest` Computes the cross product of two 3D floating-point vectors `a` and `b` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3f_cross(Vec3f dest, Vec3f a, Vec3f b) { INLINE OPTIMIZE_O3 Vec3fp vec3f_cross(OUT Vec3f dest, Vec3f a, Vec3f b) {
dest[0] = a[1] * b[2] - b[1] * a[2]; dest[0] = a[1] * b[2] - b[1] * a[2];
dest[1] = a[2] * b[0] - b[2] * a[0]; dest[1] = a[2] * b[0] - b[2] * a[0];
dest[2] = a[0] * b[1] - b[0] * a[1]; dest[2] = a[0] * b[1] - b[0] * a[1];
@ -157,7 +157,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_cross(Vec3f dest, Vec3f a, Vec3f b) {
/* |description| /* |description|
Takes two 3D floating-point vectors `vecA` and `vecB`, multiplies them by `sclA` and `sclB` respectively, adds the scaled vectors together and stores the result in `dest` Takes two 3D floating-point vectors `vecA` and `vecB`, multiplies them by `sclA` and `sclB` respectively, adds the scaled vectors together and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3f_combine(Vec3f dest, Vec3f vecA, Vec3f vecB, f32 sclA, f32 sclB) { INLINE OPTIMIZE_O3 Vec3fp vec3f_combine(OUT Vec3f dest, Vec3f vecA, Vec3f vecB, f32 sclA, f32 sclB) {
dest[0] = vecA[0] * sclA + vecB[0] * sclB; dest[0] = vecA[0] * sclA + vecB[0] * sclB;
dest[1] = vecA[1] * sclA + vecB[1] * sclB; dest[1] = vecA[1] * sclA + vecB[1] * sclB;
dest[2] = vecA[2] * sclA + vecB[2] * sclB; dest[2] = vecA[2] * sclA + vecB[2] * sclB;
@ -191,7 +191,7 @@ INLINE OPTIMIZE_O3 bool vec3f_is_zero(Vec3f v) {
/* |description| /* |description|
Converts a 3D floating-point vector `a` into a 3D integer vector and stores the result in `dest` Converts a 3D floating-point vector `a` into a 3D integer vector and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3f_to_vec3i(Vec3i dest, Vec3f a) { INLINE OPTIMIZE_O3 Vec3ip vec3f_to_vec3i(OUT Vec3i dest, Vec3f a) {
dest[0] = a[0] + ((a[0] > 0) ? 0.5f : -0.5f); dest[0] = a[0] + ((a[0] > 0) ? 0.5f : -0.5f);
dest[1] = a[1] + ((a[1] > 0) ? 0.5f : -0.5f); dest[1] = a[1] + ((a[1] > 0) ? 0.5f : -0.5f);
dest[2] = a[2] + ((a[2] > 0) ? 0.5f : -0.5f); dest[2] = a[2] + ((a[2] > 0) ? 0.5f : -0.5f);
@ -201,7 +201,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3f_to_vec3i(Vec3i dest, Vec3f a) {
/* |description| /* |description|
Converts a 3D floating-point vector `a` into a 3D short integer vector and stores the result in `dest` Converts a 3D floating-point vector `a` into a 3D short integer vector and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3f_to_vec3s(Vec3s dest, Vec3f a) { INLINE OPTIMIZE_O3 Vec3sp vec3f_to_vec3s(OUT Vec3s dest, Vec3f a) {
dest[0] = a[0] + ((a[0] > 0) ? 0.5f : -0.5f); dest[0] = a[0] + ((a[0] > 0) ? 0.5f : -0.5f);
dest[1] = a[1] + ((a[1] > 0) ? 0.5f : -0.5f); dest[1] = a[1] + ((a[1] > 0) ? 0.5f : -0.5f);
dest[2] = a[2] + ((a[2] > 0) ? 0.5f : -0.5f); dest[2] = a[2] + ((a[2] > 0) ? 0.5f : -0.5f);

View file

@ -6,7 +6,7 @@
/* |description| /* |description|
Sets the components of the 3D integer vector `v` to 0 Sets the components of the 3D integer vector `v` to 0
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3i_zero(Vec3i v) { INLINE OPTIMIZE_O3 Vec3ip vec3i_zero(OUT Vec3i v) {
memset(v, 0, sizeof(Vec3i)); memset(v, 0, sizeof(Vec3i));
return v; return v;
} }
@ -14,7 +14,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_zero(Vec3i v) {
/* |description| /* |description|
Copies the contents of a 3D integer vector (`src`) into another 3D integer vector (`dest`) Copies the contents of a 3D integer vector (`src`) into another 3D integer vector (`dest`)
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3i_copy(Vec3i dest, Vec3i src) { INLINE OPTIMIZE_O3 Vec3ip vec3i_copy(OUT Vec3i dest, Vec3i src) {
dest[0] = src[0]; dest[0] = src[0];
dest[1] = src[1]; dest[1] = src[1];
dest[2] = src[2]; dest[2] = src[2];
@ -24,7 +24,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_copy(Vec3i dest, Vec3i src) {
/* |description| /* |description|
Sets the values of the 3D integer vector `dest` to the given x, y, and z values Sets the values of the 3D integer vector `dest` to the given x, y, and z values
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3i_set(Vec3i dest, s32 x, s32 y, s32 z) { INLINE OPTIMIZE_O3 Vec3ip vec3i_set(OUT Vec3i dest, s32 x, s32 y, s32 z) {
dest[0] = x; dest[0] = x;
dest[1] = y; dest[1] = y;
dest[2] = z; dest[2] = z;
@ -34,7 +34,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_set(Vec3i dest, s32 x, s32 y, s32 z) {
/* |description| /* |description|
Adds the components of the 3D integer vector `a` to `dest` Adds the components of the 3D integer vector `a` to `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3i_add(Vec3i dest, Vec3i a) { INLINE OPTIMIZE_O3 Vec3ip vec3i_add(OUT Vec3i dest, Vec3i a) {
dest[0] += a[0]; dest[0] += a[0];
dest[1] += a[1]; dest[1] += a[1];
dest[2] += a[2]; dest[2] += a[2];
@ -44,7 +44,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_add(Vec3i dest, Vec3i a) {
/* |description| /* |description|
Adds the components of two 3D integer vectors `a` and `b` and stores the result in `dest` Adds the components of two 3D integer vectors `a` and `b` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3i_sum(Vec3i dest, Vec3i a, Vec3i b) { INLINE OPTIMIZE_O3 Vec3ip vec3i_sum(OUT Vec3i dest, Vec3i a, Vec3i b) {
dest[0] = a[0] + b[0]; dest[0] = a[0] + b[0];
dest[1] = a[1] + b[1]; dest[1] = a[1] + b[1];
dest[2] = a[2] + b[2]; dest[2] = a[2] + b[2];
@ -54,7 +54,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_sum(Vec3i dest, Vec3i a, Vec3i b) {
/* |description| /* |description|
Subtracts the components of the 3D integer vector `a` from `dest` Subtracts the components of the 3D integer vector `a` from `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3i_sub(Vec3i dest, Vec3i a) { INLINE OPTIMIZE_O3 Vec3ip vec3i_sub(OUT Vec3i dest, Vec3i a) {
dest[0] -= a[0]; dest[0] -= a[0];
dest[1] -= a[1]; dest[1] -= a[1];
dest[2] -= a[2]; dest[2] -= a[2];
@ -64,7 +64,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_sub(Vec3i dest, Vec3i a) {
/* |description| /* |description|
Subtracts the components of the 3D integer vector `b` from the components of `a` and stores the result in `dest` Subtracts the components of the 3D integer vector `b` from the components of `a` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3i_dif(Vec3i dest, Vec3i a, Vec3i b) { INLINE OPTIMIZE_O3 Vec3ip vec3i_dif(OUT Vec3i dest, Vec3i a, Vec3i b) {
dest[0] = a[0] - b[0]; dest[0] = a[0] - b[0];
dest[1] = a[1] - b[1]; dest[1] = a[1] - b[1];
dest[2] = a[2] - b[2]; dest[2] = a[2] - b[2];
@ -74,7 +74,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_dif(Vec3i dest, Vec3i a, Vec3i b) {
/* |description| /* |description|
Multiplies each component of the 3D integer vector `dest` by the scalar value `a` Multiplies each component of the 3D integer vector `dest` by the scalar value `a`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3i_mul(Vec3i dest, f32 a) { INLINE OPTIMIZE_O3 Vec3ip vec3i_mul(OUT Vec3i dest, f32 a) {
dest[0] *= a; dest[0] *= a;
dest[1] *= a; dest[1] *= a;
dest[2] *= a; dest[2] *= a;
@ -84,7 +84,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_mul(Vec3i dest, f32 a) {
/* |description| /* |description|
Multiplies the components of the 3D integer vector `dest` with the components of `a` Multiplies the components of the 3D integer vector `dest` with the components of `a`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3i_mult(Vec3i dest, Vec3i a) { INLINE OPTIMIZE_O3 Vec3ip vec3i_mult(OUT Vec3i dest, Vec3i a) {
dest[0] *= a[0]; dest[0] *= a[0];
dest[1] *= a[1]; dest[1] *= a[1];
dest[2] *= a[2]; dest[2] *= a[2];
@ -94,7 +94,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_mult(Vec3i dest, Vec3i a) {
/* |description| /* |description|
Multiplies the components of two 3D integer vectors `a` and `b` and stores the result in `dest` Multiplies the components of two 3D integer vectors `a` and `b` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3i_prod(Vec3i dest, Vec3i a, Vec3i b) { INLINE OPTIMIZE_O3 Vec3ip vec3i_prod(OUT Vec3i dest, Vec3i a, Vec3i b) {
dest[0] = a[0] * b[0]; dest[0] = a[0] * b[0];
dest[1] = a[1] * b[1]; dest[1] = a[1] * b[1];
dest[2] = a[2] * b[2]; dest[2] = a[2] * b[2];
@ -104,7 +104,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_prod(Vec3i dest, Vec3i a, Vec3i b) {
/* |description| /* |description|
Divides each component of the 3D integer vector `dest` by the scalar value `a` Divides each component of the 3D integer vector `dest` by the scalar value `a`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3i_div(Vec3i dest, f32 a) { INLINE OPTIMIZE_O3 Vec3ip vec3i_div(OUT Vec3i dest, f32 a) {
if (a == 0) { return dest; } if (a == 0) { return dest; }
dest[0] /= a; dest[0] /= a;
dest[1] /= a; dest[1] /= a;
@ -122,7 +122,7 @@ INLINE OPTIMIZE_O3 f32 vec3i_length(Vec3i a) {
/* |description| /* |description|
Normalizes the 3D integer vector `v` so that its length (magnitude) becomes 1, while retaining its direction Normalizes the 3D integer vector `v` so that its length (magnitude) becomes 1, while retaining its direction
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3i_normalize(Vec3i v) { INLINE OPTIMIZE_O3 Vec3ip vec3i_normalize(OUT Vec3i v) {
f32 mag = vec3i_length(v); f32 mag = vec3i_length(v);
vec3i_div(v, mag); vec3i_div(v, mag);
return v; return v;
@ -131,7 +131,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_normalize(Vec3i v) {
/* |description| /* |description|
Sets the length (magnitude) of 3D integer vector `v`, while retaining its direction Sets the length (magnitude) of 3D integer vector `v`, while retaining its direction
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3i_set_magnitude(Vec3i v, f32 mag) { INLINE OPTIMIZE_O3 Vec3ip vec3i_set_magnitude(OUT Vec3i v, f32 mag) {
vec3i_normalize(v); vec3i_normalize(v);
vec3i_mul(v, mag); vec3i_mul(v, mag);
return v; return v;
@ -147,7 +147,7 @@ INLINE OPTIMIZE_O3 f32 vec3i_dot(Vec3i a, Vec3i b) {
/* |description| /* |description|
Computes the cross product of two 3D integer vectors `a` and `b` and stores the result in `dest` Computes the cross product of two 3D integer vectors `a` and `b` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3i_cross(Vec3i dest, Vec3i a, Vec3i b) { INLINE OPTIMIZE_O3 Vec3ip vec3i_cross(OUT Vec3i dest, Vec3i a, Vec3i b) {
dest[0] = a[1] * b[2] - b[1] * a[2]; dest[0] = a[1] * b[2] - b[1] * a[2];
dest[1] = a[2] * b[0] - b[2] * a[0]; dest[1] = a[2] * b[0] - b[2] * a[0];
dest[2] = a[0] * b[1] - b[0] * a[1]; dest[2] = a[0] * b[1] - b[0] * a[1];
@ -157,7 +157,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_cross(Vec3i dest, Vec3i a, Vec3i b) {
/* |description| /* |description|
Takes two 3D integer vectors `vecA` and `vecB`, multiplies them by `sclA` and `sclB` respectively, adds the scaled vectors together and stores the result in `dest` Takes two 3D integer vectors `vecA` and `vecB`, multiplies them by `sclA` and `sclB` respectively, adds the scaled vectors together and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3i_combine(Vec3i dest, Vec3i vecA, Vec3i vecB, f32 sclA, f32 sclB) { INLINE OPTIMIZE_O3 Vec3ip vec3i_combine(OUT Vec3i dest, Vec3i vecA, Vec3i vecB, f32 sclA, f32 sclB) {
dest[0] = vecA[0] * sclA + vecB[0] * sclB; dest[0] = vecA[0] * sclA + vecB[0] * sclB;
dest[1] = vecA[1] * sclA + vecB[1] * sclB; dest[1] = vecA[1] * sclA + vecB[1] * sclB;
dest[2] = vecA[2] * sclA + vecB[2] * sclB; dest[2] = vecA[2] * sclA + vecB[2] * sclB;
@ -191,7 +191,7 @@ INLINE OPTIMIZE_O3 bool vec3i_is_zero(Vec3i v) {
/* |description| /* |description|
Converts a 3D integer vector `a` into a 3D floating-point vector and stores the result in `dest` Converts a 3D integer vector `a` into a 3D floating-point vector and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3i_to_vec3f(Vec3f dest, Vec3i a) { INLINE OPTIMIZE_O3 Vec3fp vec3i_to_vec3f(OUT Vec3f dest, Vec3i a) {
dest[0] = a[0]; dest[0] = a[0];
dest[1] = a[1]; dest[1] = a[1];
dest[2] = a[2]; dest[2] = a[2];
@ -201,7 +201,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3i_to_vec3f(Vec3f dest, Vec3i a) {
/* |description| /* |description|
Converts a 3D integer vector `a` into a 3D short integer vector and stores the result in `dest` Converts a 3D integer vector `a` into a 3D short integer vector and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3i_to_vec3s(Vec3s dest, Vec3i a) { INLINE OPTIMIZE_O3 Vec3sp vec3i_to_vec3s(OUT Vec3s dest, Vec3i a) {
dest[0] = a[0]; dest[0] = a[0];
dest[1] = a[1]; dest[1] = a[1];
dest[2] = a[2]; dest[2] = a[2];

View file

@ -6,7 +6,7 @@
/* |description| /* |description|
Sets the components of the 3D short integer vector `v` to 0 Sets the components of the 3D short integer vector `v` to 0
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3s_zero(Vec3s v) { INLINE OPTIMIZE_O3 Vec3sp vec3s_zero(OUT Vec3s v) {
memset(v, 0, sizeof(Vec3s)); memset(v, 0, sizeof(Vec3s));
return v; return v;
} }
@ -14,7 +14,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_zero(Vec3s v) {
/* |description| /* |description|
Copies the contents of a 3D short integer vector (`src`) into another 3D short integer vector (`dest`) Copies the contents of a 3D short integer vector (`src`) into another 3D short integer vector (`dest`)
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3s_copy(Vec3s dest, Vec3s src) { INLINE OPTIMIZE_O3 Vec3sp vec3s_copy(OUT Vec3s dest, Vec3s src) {
dest[0] = src[0]; dest[0] = src[0];
dest[1] = src[1]; dest[1] = src[1];
dest[2] = src[2]; dest[2] = src[2];
@ -24,7 +24,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_copy(Vec3s dest, Vec3s src) {
/* |description| /* |description|
Sets the values of the 3D short integer vector `dest` to the given x, y, and z values Sets the values of the 3D short integer vector `dest` to the given x, y, and z values
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3s_set(Vec3s dest, s16 x, s16 y, s16 z) { INLINE OPTIMIZE_O3 Vec3sp vec3s_set(OUT Vec3s dest, s16 x, s16 y, s16 z) {
dest[0] = x; dest[0] = x;
dest[1] = y; dest[1] = y;
dest[2] = z; dest[2] = z;
@ -34,7 +34,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_set(Vec3s dest, s16 x, s16 y, s16 z) {
/* |description| /* |description|
Adds the components of the 3D short integer vector `a` to `dest` Adds the components of the 3D short integer vector `a` to `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3s_add(Vec3s dest, Vec3s a) { INLINE OPTIMIZE_O3 Vec3sp vec3s_add(OUT Vec3s dest, Vec3s a) {
dest[0] += a[0]; dest[0] += a[0];
dest[1] += a[1]; dest[1] += a[1];
dest[2] += a[2]; dest[2] += a[2];
@ -44,7 +44,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_add(Vec3s dest, Vec3s a) {
/* |description| /* |description|
Adds the components of two 3D short integer vectors `a` and `b` and stores the result in `dest` Adds the components of two 3D short integer vectors `a` and `b` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3s_sum(Vec3s dest, Vec3s a, Vec3s b) { INLINE OPTIMIZE_O3 Vec3sp vec3s_sum(OUT Vec3s dest, Vec3s a, Vec3s b) {
dest[0] = a[0] + b[0]; dest[0] = a[0] + b[0];
dest[1] = a[1] + b[1]; dest[1] = a[1] + b[1];
dest[2] = a[2] + b[2]; dest[2] = a[2] + b[2];
@ -54,7 +54,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_sum(Vec3s dest, Vec3s a, Vec3s b) {
/* |description| /* |description|
Subtracts the components of the 3D short integer vector `a` from `dest` Subtracts the components of the 3D short integer vector `a` from `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3s_sub(Vec3s dest, Vec3s a) { INLINE OPTIMIZE_O3 Vec3sp vec3s_sub(OUT Vec3s dest, Vec3s a) {
dest[0] -= a[0]; dest[0] -= a[0];
dest[1] -= a[1]; dest[1] -= a[1];
dest[2] -= a[2]; dest[2] -= a[2];
@ -64,7 +64,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_sub(Vec3s dest, Vec3s a) {
/* |description| /* |description|
Subtracts the components of the 3D short integer vector `b` from the components of `a` and stores the result in `dest` Subtracts the components of the 3D short integer vector `b` from the components of `a` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3s_dif(Vec3s dest, Vec3s a, Vec3s b) { INLINE OPTIMIZE_O3 Vec3sp vec3s_dif(OUT Vec3s dest, Vec3s a, Vec3s b) {
dest[0] = a[0] - b[0]; dest[0] = a[0] - b[0];
dest[1] = a[1] - b[1]; dest[1] = a[1] - b[1];
dest[2] = a[2] - b[2]; dest[2] = a[2] - b[2];
@ -74,7 +74,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_dif(Vec3s dest, Vec3s a, Vec3s b) {
/* |description| /* |description|
Multiplies each component of the 3D short integer vector `dest` by the scalar value `a` Multiplies each component of the 3D short integer vector `dest` by the scalar value `a`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3s_mul(Vec3s dest, f32 a) { INLINE OPTIMIZE_O3 Vec3sp vec3s_mul(OUT Vec3s dest, f32 a) {
dest[0] *= a; dest[0] *= a;
dest[1] *= a; dest[1] *= a;
dest[2] *= a; dest[2] *= a;
@ -84,7 +84,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_mul(Vec3s dest, f32 a) {
/* |description| /* |description|
Multiplies the components of the 3D short integer vector `dest` with the components of `a` Multiplies the components of the 3D short integer vector `dest` with the components of `a`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3s_mult(Vec3s dest, Vec3s a) { INLINE OPTIMIZE_O3 Vec3sp vec3s_mult(OUT Vec3s dest, Vec3s a) {
dest[0] *= a[0]; dest[0] *= a[0];
dest[1] *= a[1]; dest[1] *= a[1];
dest[2] *= a[2]; dest[2] *= a[2];
@ -94,7 +94,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_mult(Vec3s dest, Vec3s a) {
/* |description| /* |description|
Multiplies the components of two 3D short integer vectors `a` and `b` and stores the result in `dest` Multiplies the components of two 3D short integer vectors `a` and `b` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3s_prod(Vec3s dest, Vec3s a, Vec3s b) { INLINE OPTIMIZE_O3 Vec3sp vec3s_prod(OUT Vec3s dest, Vec3s a, Vec3s b) {
dest[0] = a[0] * b[0]; dest[0] = a[0] * b[0];
dest[1] = a[1] * b[1]; dest[1] = a[1] * b[1];
dest[2] = a[2] * b[2]; dest[2] = a[2] * b[2];
@ -104,7 +104,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_prod(Vec3s dest, Vec3s a, Vec3s b) {
/* |description| /* |description|
Divides each component of the 3D short integer vector `dest` by the scalar value `a` Divides each component of the 3D short integer vector `dest` by the scalar value `a`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3s_div(Vec3s dest, f32 a) { INLINE OPTIMIZE_O3 Vec3sp vec3s_div(OUT Vec3s dest, f32 a) {
if (a == 0) { return dest; } if (a == 0) { return dest; }
dest[0] /= a; dest[0] /= a;
dest[1] /= a; dest[1] /= a;
@ -122,7 +122,7 @@ INLINE OPTIMIZE_O3 f32 vec3s_length(Vec3s a) {
/* |description| /* |description|
Normalizes the 3D short integer vector `v` so that its length (magnitude) becomes 1, while retaining its direction Normalizes the 3D short integer vector `v` so that its length (magnitude) becomes 1, while retaining its direction
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3s_normalize(Vec3s v) { INLINE OPTIMIZE_O3 Vec3sp vec3s_normalize(OUT Vec3s v) {
f32 mag = vec3s_length(v); f32 mag = vec3s_length(v);
vec3s_div(v, mag); vec3s_div(v, mag);
return v; return v;
@ -131,7 +131,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_normalize(Vec3s v) {
/* |description| /* |description|
Sets the length (magnitude) of 3D short integer vector `v`, while retaining its direction Sets the length (magnitude) of 3D short integer vector `v`, while retaining its direction
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3s_set_magnitude(Vec3s v, f32 mag) { INLINE OPTIMIZE_O3 Vec3sp vec3s_set_magnitude(OUT Vec3s v, f32 mag) {
vec3s_normalize(v); vec3s_normalize(v);
vec3s_mul(v, mag); vec3s_mul(v, mag);
return v; return v;
@ -147,7 +147,7 @@ INLINE OPTIMIZE_O3 f32 vec3s_dot(Vec3s a, Vec3s b) {
/* |description| /* |description|
Computes the cross product of two 3D short integer vectors `a` and `b` and stores the result in `dest` Computes the cross product of two 3D short integer vectors `a` and `b` and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3s_cross(Vec3s dest, Vec3s a, Vec3s b) { INLINE OPTIMIZE_O3 Vec3sp vec3s_cross(OUT Vec3s dest, Vec3s a, Vec3s b) {
dest[0] = a[1] * b[2] - b[1] * a[2]; dest[0] = a[1] * b[2] - b[1] * a[2];
dest[1] = a[2] * b[0] - b[2] * a[0]; dest[1] = a[2] * b[0] - b[2] * a[0];
dest[2] = a[0] * b[1] - b[0] * a[1]; dest[2] = a[0] * b[1] - b[0] * a[1];
@ -157,7 +157,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_cross(Vec3s dest, Vec3s a, Vec3s b) {
/* |description| /* |description|
Takes two 3D short integer vectors `vecA` and `vecB`, multiplies them by `sclA` and `sclB` respectively, adds the scaled vectors together and stores the result in `dest` Takes two 3D short integer vectors `vecA` and `vecB`, multiplies them by `sclA` and `sclB` respectively, adds the scaled vectors together and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3sp vec3s_combine(Vec3s dest, Vec3s vecA, Vec3s vecB, f32 sclA, f32 sclB) { INLINE OPTIMIZE_O3 Vec3sp vec3s_combine(OUT Vec3s dest, Vec3s vecA, Vec3s vecB, f32 sclA, f32 sclB) {
dest[0] = vecA[0] * sclA + vecB[0] * sclB; dest[0] = vecA[0] * sclA + vecB[0] * sclB;
dest[1] = vecA[1] * sclA + vecB[1] * sclB; dest[1] = vecA[1] * sclA + vecB[1] * sclB;
dest[2] = vecA[2] * sclA + vecB[2] * sclB; dest[2] = vecA[2] * sclA + vecB[2] * sclB;
@ -191,7 +191,7 @@ INLINE OPTIMIZE_O3 bool vec3s_is_zero(Vec3s v) {
/* |description| /* |description|
Converts a 3D short integer vector `a` into a 3D floating-point vector and stores the result in `dest` Converts a 3D short integer vector `a` into a 3D floating-point vector and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3fp vec3s_to_vec3f(Vec3f dest, Vec3s a) { INLINE OPTIMIZE_O3 Vec3fp vec3s_to_vec3f(OUT Vec3f dest, Vec3s a) {
dest[0] = a[0]; dest[0] = a[0];
dest[1] = a[1]; dest[1] = a[1];
dest[2] = a[2]; dest[2] = a[2];
@ -201,7 +201,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3s_to_vec3f(Vec3f dest, Vec3s a) {
/* |description| /* |description|
Converts a 3D short integer vector `a` into a 3D integer vector and stores the result in `dest` Converts a 3D short integer vector `a` into a 3D integer vector and stores the result in `dest`
|descriptionEnd| */ |descriptionEnd| */
INLINE OPTIMIZE_O3 Vec3ip vec3s_to_vec3i(Vec3i dest, Vec3s a) { INLINE OPTIMIZE_O3 Vec3ip vec3s_to_vec3i(OUT Vec3i dest, Vec3s a) {
dest[0] = a[0]; dest[0] = a[0];
dest[1] = a[1]; dest[1] = a[1];
dest[2] = a[2]; dest[2] = a[2];

View file

@ -25,7 +25,7 @@ void set_find_wall_direction(Vec3f dir, bool active, bool airborne) {
gFindWallDirectionAirborne = airborne; gFindWallDirectionAirborne = airborne;
} }
void closest_point_to_triangle(struct Surface* surf, Vec3f src, Vec3f out) { void closest_point_to_triangle(struct Surface* surf, Vec3f src, OUT Vec3f out) {
Vec3f v1; vec3s_to_vec3f(v1, surf->vertex1); Vec3f v1; vec3s_to_vec3f(v1, surf->vertex1);
Vec3f v2; vec3s_to_vec3f(v2, surf->vertex2); Vec3f v2; vec3s_to_vec3f(v2, surf->vertex2);
Vec3f v3; vec3s_to_vec3f(v3, surf->vertex3); Vec3f v3; vec3s_to_vec3f(v3, surf->vertex3);

View file

@ -87,6 +87,6 @@ void set_find_wall_direction(Vec3f dir, bool active, bool airborne);
/* |description| /* |description|
Gets the closest point of the triangle to `src` and returns it in `out`. Gets the closest point of the triangle to `src` and returns it in `out`.
|descriptionEnd| */ |descriptionEnd| */
void closest_point_to_triangle(struct Surface* surf, Vec3f src, Vec3f out); void closest_point_to_triangle(struct Surface* surf, Vec3f src, OUT Vec3f out);
#endif // SURFACE_COLLISION_H #endif // SURFACE_COLLISION_H

View file

@ -204,15 +204,6 @@ void spawn_sparkle_particles(s32 n, s32 a1, s32 a2, s32 r) {
#include "behaviors/bullet_bill.inc.c" #include "behaviors/bullet_bill.inc.c"
#include "behaviors/bowser.inc.c" #include "behaviors/bowser.inc.c"
#include "behaviors/blue_fish.inc.c" #include "behaviors/blue_fish.inc.c"
// Not in behavior file, duplicate of vec3f_copy except without bad return.
// Used in a few behavior files.
void vec3f_copy_2(Vec3f dest, Vec3f src) {
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
}
#include "behaviors/checkerboard_platform.inc.c" #include "behaviors/checkerboard_platform.inc.c"
#include "behaviors/ddd_warp.inc.c" #include "behaviors/ddd_warp.inc.c"
#include "behaviors/water_pillar.inc.c" #include "behaviors/water_pillar.inc.c"

View file

@ -21,8 +21,6 @@ void spawn_wind_particles(s16 pitch, s16 yaw);
s32 check_if_moving_over_floor(f32 a0, f32 a1); s32 check_if_moving_over_floor(f32 a0, f32 a1);
/* |description|Calculates the time it takes for the current object to follow an arc from `pos` to `goal`|descriptionEnd| */ /* |description|Calculates the time it takes for the current object to follow an arc from `pos` to `goal`|descriptionEnd| */
s32 arc_to_goal_pos(Vec3f goal, Vec3f pos, f32 yVel, f32 gravity); s32 arc_to_goal_pos(Vec3f goal, Vec3f pos, f32 yVel, f32 gravity);
/* |description|Duplicate of vec3f_copy except without bad return|descriptionEnd| */
void vec3f_copy_2(Vec3f dest, Vec3f src);
/* |description|Moves Tox Box|descriptionEnd| */ /* |description|Moves Tox Box|descriptionEnd| */
void tox_box_move(f32 forwardVel, f32 a1, s16 deltaPitch, s16 deltaRoll); void tox_box_move(f32 forwardVel, f32 a1, s16 deltaPitch, s16 deltaRoll);
/* |description|Plays the penguin walking sound|descriptionEnd| */ /* |description|Plays the penguin walking sound|descriptionEnd| */

View file

@ -1612,7 +1612,7 @@ void falling_bowser_plat_act_2(void) {
if ((o->oTimer & 1) == 0 && o->oTimer < 14 && BHV_ARR_CHECK(D_8032F698, o->oBehParams2ndByte, struct Struct8032F698)) { if ((o->oTimer & 1) == 0 && o->oTimer < 14 && BHV_ARR_CHECK(D_8032F698, o->oBehParams2ndByte, struct Struct8032F698)) {
sp22 = D_8032F698[o->oBehParams2ndByte].unk3 + (gDebugInfo[4][1] << 8); sp22 = D_8032F698[o->oBehParams2ndByte].unk3 + (gDebugInfo[4][1] << 8);
sp1C = -(o->oTimer / 2) * 290 + 1740; sp1C = -(o->oTimer / 2) * 290 + 1740;
vec3f_copy_2(sp24, &o->oPosX); vec3f_copy(sp24, &o->oPosX);
o->oPosX = D_8032F698[o->oBehParams2ndByte].unk1 + sins(sp22 + 5296) * sp1C; o->oPosX = D_8032F698[o->oBehParams2ndByte].unk1 + sins(sp22 + 5296) * sp1C;
o->oPosZ = D_8032F698[o->oBehParams2ndByte].unk2 + coss(sp22 + 5296) * sp1C; o->oPosZ = D_8032F698[o->oBehParams2ndByte].unk2 + coss(sp22 + 5296) * sp1C;
o->oPosY = 307.0f; o->oPosY = 307.0f;
@ -1620,7 +1620,7 @@ void falling_bowser_plat_act_2(void) {
o->oPosX = D_8032F698[o->oBehParams2ndByte].unk1 + sins(sp22 - 5296) * sp1C; o->oPosX = D_8032F698[o->oBehParams2ndByte].unk1 + sins(sp22 - 5296) * sp1C;
o->oPosZ = D_8032F698[o->oBehParams2ndByte].unk2 + coss(sp22 - 5296) * sp1C; o->oPosZ = D_8032F698[o->oBehParams2ndByte].unk2 + coss(sp22 - 5296) * sp1C;
spawn_mist_particles_variable(4, 0, 100); spawn_mist_particles_variable(4, 0, 100);
vec3f_copy_2(&o->oPosX, sp24); vec3f_copy(&o->oPosX, sp24);
} }
cur_obj_move_using_fvel_and_gravity(); cur_obj_move_using_fvel_and_gravity();
if (o->oTimer > 300) if (o->oTimer > 300)

View file

@ -25,7 +25,7 @@ void bhv_checkerboard_elevator_group_init(void) {
if (sp2C == NULL) { continue; } if (sp2C == NULL) { continue; }
sp2C->oCheckerBoardPlatformUnk1AC = D_8032F754[sp34].unk2; sp2C->oCheckerBoardPlatformUnk1AC = D_8032F754[sp34].unk2;
sp2C->oTimer = 0; sp2C->oTimer = 0;
vec3f_copy_2(sp2C->header.gfx.scale, D_8032F754[sp34].unk1); vec3f_copy(sp2C->header.gfx.scale, D_8032F754[sp34].unk1);
} }
} }

View file

@ -28,11 +28,11 @@ void bhv_sl_snowman_wind_loop(void) {
o->oDistanceToMario = 0; o->oDistanceToMario = 0;
// Check if Mario is within 1000 units of the center of the bridge, and ready to speak. // Check if Mario is within 1000 units of the center of the bridge, and ready to speak.
vec3f_copy_2(tempPos, &o->oPosX); vec3f_copy(tempPos, &o->oPosX);
obj_set_pos(o, 1100, 3328, 1164); // Position is in the middle of the ice bridge obj_set_pos(o, 1100, 3328, 1164); // Position is in the middle of the ice bridge
if (cur_obj_can_mario_activate_textbox(&gMarioStates[0], 1000.0f, 30.0f, 0x7FFF)) if (cur_obj_can_mario_activate_textbox(&gMarioStates[0], 1000.0f, 30.0f, 0x7FFF))
o->oSubAction++; o->oSubAction++;
vec3f_copy_2(&o->oPosX, tempPos); vec3f_copy(&o->oPosX, tempPos);
// Mario has come close, begin dialog. // Mario has come close, begin dialog.
} else if (o->oSubAction == SL_SNOWMAN_WIND_ACT_TALKING) { } else if (o->oSubAction == SL_SNOWMAN_WIND_ACT_TALKING) {

View file

@ -160,14 +160,14 @@ void king_whomp_on_ground(void) {
if (o->oHealth == 0) if (o->oHealth == 0)
o->oAction = 8; o->oAction = 8;
else { else {
vec3f_copy_2(pos, &o->oPosX); vec3f_copy(pos, &o->oPosX);
if (player) { if (player) {
vec3f_copy_2(&o->oPosX, &player->oPosX); vec3f_copy(&o->oPosX, &player->oPosX);
} }
spawn_mist_particles_variable(0, 0, 100.0f); spawn_mist_particles_variable(0, 0, 100.0f);
spawn_triangle_break_particles(20, 138, 3.0f, 4); spawn_triangle_break_particles(20, 138, 3.0f, 4);
cur_obj_shake_screen(SHAKE_POS_SMALL); cur_obj_shake_screen(SHAKE_POS_SMALL);
vec3f_copy_2(&o->oPosX, pos); vec3f_copy(&o->oPosX, pos);
} }
o->oSubAction++; o->oSubAction++;
} }

View file

@ -3788,7 +3788,7 @@ void stub_camera_2(UNUSED struct Camera *c) {
void stub_camera_3(UNUSED struct Camera *c) { void stub_camera_3(UNUSED struct Camera *c) {
} }
void object_pos_to_vec3f(Vec3f dst, struct Object *o) { void object_pos_to_vec3f(OUT Vec3f dst, struct Object *o) {
if (!dst || !o) { return; } if (!dst || !o) { return; }
dst[0] = o->oPosX; dst[0] = o->oPosX;
dst[1] = o->oPosY; dst[1] = o->oPosY;
@ -3802,13 +3802,34 @@ void vec3f_to_object_pos(struct Object *o, Vec3f src) {
o->oPosZ = src[2]; o->oPosZ = src[2];
} }
void unused_object_angle_to_vec3s(Vec3s dst, struct Object *o) { void object_face_angle_to_vec3s(OUT Vec3s dst, struct Object *o) {
if (!dst || !o) { return; }
dst[0] = o->oFaceAnglePitch;
dst[1] = o->oFaceAngleYaw;
dst[2] = o->oFaceAngleRoll;
}
void vec3s_to_object_face_angle(struct Object *o, Vec3s src) {
if (!o || !src) { return; }
o->oFaceAnglePitch = src[0];
o->oFaceAngleYaw = src[1];
o->oFaceAngleRoll = src[2];
}
void object_move_angle_to_vec3s(OUT Vec3s dst, struct Object *o) {
if (!dst || !o) { return; } if (!dst || !o) { return; }
dst[0] = o->oMoveAnglePitch; dst[0] = o->oMoveAnglePitch;
dst[1] = o->oMoveAngleYaw; dst[1] = o->oMoveAngleYaw;
dst[2] = o->oMoveAngleRoll; dst[2] = o->oMoveAngleRoll;
} }
void vec3s_to_object_move_angle(struct Object *o, Vec3s src) {
if (!o || !src) { return; }
o->oMoveAnglePitch = src[0];
o->oMoveAngleYaw = src[1];
o->oMoveAngleRoll = src[2];
}
/** /**
* Produces values using a cubic b-spline curve. Basically Q is the used output, * Produces values using a cubic b-spline curve. Basically Q is the used output,
* u is a value between 0 and 1 that represents the position along the spline, * u is a value between 0 and 1 that represents the position along the spline,
@ -4040,7 +4061,7 @@ void set_handheld_shake(u8 mode) {
* This function must be called every frame in order to actually apply the effect, since the effect's * This function must be called every frame in order to actually apply the effect, since the effect's
* mag and inc are set to 0 every frame at the end of this function. * mag and inc are set to 0 every frame at the end of this function.
*/ */
void shake_camera_handheld(Vec3f pos, Vec3f focus) { void shake_camera_handheld(Vec3f pos, OUT Vec3f focus) {
s32 i; s32 i;
Vec3f shakeOffset; Vec3f shakeOffset;
Vec3f shakeSpline[4]; Vec3f shakeSpline[4];
@ -4165,7 +4186,7 @@ s32 update_camera_hud_status(struct Camera *c) {
* *
* @return the number of collisions found * @return the number of collisions found
*/ */
s32 collide_with_walls(Vec3f pos, f32 offsetY, f32 radius) { s32 collide_with_walls(OUT Vec3f pos, f32 offsetY, f32 radius) {
struct WallCollisionData collisionData; struct WallCollisionData collisionData;
struct Surface *wall = NULL; struct Surface *wall = NULL;
f32 normX; f32 normX;
@ -4216,7 +4237,7 @@ s32 vec3f_compare(Vec3f pos, f32 posX, f32 posY, f32 posZ) {
return equal; return equal;
} }
s32 clamp_pitch(Vec3f from, Vec3f to, s16 maxPitch, s16 minPitch) { s32 clamp_pitch(Vec3f from, OUT Vec3f to, s16 maxPitch, s16 minPitch) {
s32 outOfRange = 0; s32 outOfRange = 0;
s16 pitch; s16 pitch;
s16 yaw; s16 yaw;
@ -4332,7 +4353,7 @@ s32 approach_s16_asymptotic(s16 current, s16 target, s16 divisor) {
* Applies the approach_f32_asymptotic_bool function to each of the X, Y, & Z components of the given * Applies the approach_f32_asymptotic_bool function to each of the X, Y, & Z components of the given
* vector. * vector.
*/ */
void approach_vec3f_asymptotic(Vec3f current, Vec3f target, f32 xMul, f32 yMul, f32 zMul) { void approach_vec3f_asymptotic(OUT Vec3f current, Vec3f target, f32 xMul, f32 yMul, f32 zMul) {
approach_f32_asymptotic_bool(&current[0], target[0], xMul); approach_f32_asymptotic_bool(&current[0], target[0], xMul);
approach_f32_asymptotic_bool(&current[1], target[1], yMul); approach_f32_asymptotic_bool(&current[1], target[1], yMul);
approach_f32_asymptotic_bool(&current[2], target[2], zMul); approach_f32_asymptotic_bool(&current[2], target[2], zMul);
@ -4342,7 +4363,7 @@ void approach_vec3f_asymptotic(Vec3f current, Vec3f target, f32 xMul, f32 yMul,
* Applies the set_or_approach_f32_asymptotic_bool function to each of the X, Y, & Z components of the * Applies the set_or_approach_f32_asymptotic_bool function to each of the X, Y, & Z components of the
* given vector. * given vector.
*/ */
void set_or_approach_vec3f_asymptotic(Vec3f dst, Vec3f goal, f32 xMul, f32 yMul, f32 zMul) { void set_or_approach_vec3f_asymptotic(OUT Vec3f dst, Vec3f goal, f32 xMul, f32 yMul, f32 zMul) {
set_or_approach_f32_asymptotic(&dst[0], goal[0], xMul); set_or_approach_f32_asymptotic(&dst[0], goal[0], xMul);
set_or_approach_f32_asymptotic(&dst[1], goal[1], yMul); set_or_approach_f32_asymptotic(&dst[1], goal[1], yMul);
set_or_approach_f32_asymptotic(&dst[2], goal[2], zMul); set_or_approach_f32_asymptotic(&dst[2], goal[2], zMul);
@ -4352,7 +4373,7 @@ void set_or_approach_vec3f_asymptotic(Vec3f dst, Vec3f goal, f32 xMul, f32 yMul,
* Applies the approach_s32_asymptotic function to each of the X, Y, & Z components of the given * Applies the approach_s32_asymptotic function to each of the X, Y, & Z components of the given
* vector. * vector.
*/ */
void approach_vec3s_asymptotic(Vec3s current, Vec3s target, s16 xMul, s16 yMul, s16 zMul) { void approach_vec3s_asymptotic(OUT Vec3s current, Vec3s target, s16 xMul, s16 yMul, s16 zMul) {
approach_s16_asymptotic_bool(&current[0], target[0], xMul); approach_s16_asymptotic_bool(&current[0], target[0], xMul);
approach_s16_asymptotic_bool(&current[1], target[1], yMul); approach_s16_asymptotic_bool(&current[1], target[1], yMul);
approach_s16_asymptotic_bool(&current[2], target[2], zMul); approach_s16_asymptotic_bool(&current[2], target[2], zMul);
@ -4490,7 +4511,7 @@ f32 camera_approach_f32_symmetric(f32 current, f32 target, f32 increment) {
* Generate a vector with all three values about zero. The * Generate a vector with all three values about zero. The
* three ranges determine how wide the range about zero. * three ranges determine how wide the range about zero.
*/ */
void random_vec3s(Vec3s dst, s16 xRange, s16 yRange, s16 zRange) { void random_vec3s(OUT Vec3s dst, s16 xRange, s16 yRange, s16 zRange) {
f32 randomFloat; f32 randomFloat;
UNUSED u8 unused[4]; UNUSED u8 unused[4];
f32 tempXRange; f32 tempXRange;
@ -4557,7 +4578,7 @@ s16 reduce_by_dist_from_camera(s16 value, f32 maxDist, f32 posX, f32 posY, f32 p
return result; return result;
} }
s32 clamp_positions_and_find_yaw(Vec3f pos, Vec3f origin, f32 xMax, f32 xMin, f32 zMax, f32 zMin) { s32 clamp_positions_and_find_yaw(OUT Vec3f pos, Vec3f origin, f32 xMax, f32 xMin, f32 zMax, f32 zMin) {
s16 yaw = gCamera->nextYaw; s16 yaw = gCamera->nextYaw;
if (pos[0] >= xMax) { if (pos[0] >= xMax) {
@ -4737,7 +4758,7 @@ s32 is_mario_behind_surface(UNUSED struct Camera *c, struct Surface *surf) {
* Calculates the distance between two points and sets a vector to a point * Calculates the distance between two points and sets a vector to a point
* scaled along a line between them. Typically, somewhere in the middle. * scaled along a line between them. Typically, somewhere in the middle.
*/ */
void scale_along_line(Vec3f dst, Vec3f from, Vec3f to, f32 scale) { void scale_along_line(OUT Vec3f dst, Vec3f from, Vec3f to, f32 scale) {
Vec3f tempVec; Vec3f tempVec;
tempVec[0] = (to[0] - from[0]) * scale + from[0]; tempVec[0] = (to[0] - from[0]) * scale + from[0];
@ -4823,7 +4844,7 @@ f32 calc_hor_dist(Vec3f a, Vec3f b) {
/** /**
* Rotates a vector in the horizontal plane and copies it to a new vector. * Rotates a vector in the horizontal plane and copies it to a new vector.
*/ */
void rotate_in_xz(Vec3f dst, Vec3f src, s16 yaw) { void rotate_in_xz(OUT Vec3f dst, Vec3f src, s16 yaw) {
Vec3f tempVec; Vec3f tempVec;
vec3f_copy(tempVec, src); vec3f_copy(tempVec, src);
@ -4838,7 +4859,7 @@ void rotate_in_xz(Vec3f dst, Vec3f src, s16 yaw) {
* Note: This function also flips the Z axis, so +Z moves forward, not backward like it would in world * Note: This function also flips the Z axis, so +Z moves forward, not backward like it would in world
* space. If possible, use vec3f_set_dist_and_angle() * space. If possible, use vec3f_set_dist_and_angle()
*/ */
void rotate_in_yz(Vec3f dst, Vec3f src, s16 pitch) { void rotate_in_yz(OUT Vec3f dst, Vec3f src, s16 pitch) {
Vec3f tempVec; Vec3f tempVec;
vec3f_copy(tempVec, src); vec3f_copy(tempVec, src);
@ -4932,7 +4953,7 @@ void increment_shake_offset(s16 *offset, s16 increment) {
/** /**
* Apply a vertical shake to the camera by adjusting its pitch * Apply a vertical shake to the camera by adjusting its pitch
*/ */
void shake_camera_pitch(Vec3f pos, Vec3f focus) { void shake_camera_pitch(Vec3f pos, OUT Vec3f focus) {
f32 dist; f32 dist;
s16 pitch; s16 pitch;
s16 yaw; s16 yaw;
@ -4952,7 +4973,7 @@ void shake_camera_pitch(Vec3f pos, Vec3f focus) {
/** /**
* Apply a horizontal shake to the camera by adjusting its yaw * Apply a horizontal shake to the camera by adjusting its yaw
*/ */
void shake_camera_yaw(Vec3f pos, Vec3f focus) { void shake_camera_yaw(Vec3f pos, OUT Vec3f focus) {
f32 dist; f32 dist;
s16 pitch; s16 pitch;
s16 yaw; s16 yaw;
@ -5599,7 +5620,7 @@ static void unused_set_pos_rel_mario(struct Camera *c, f32 leftRight, f32 yOff,
* *
* @warning Flips the Z axis, so that relative to `rotation`, -Z moves forwards and +Z moves backwards. * @warning Flips the Z axis, so that relative to `rotation`, -Z moves forwards and +Z moves backwards.
*/ */
void offset_rotated(Vec3f dst, Vec3f from, Vec3f to, Vec3s rotation) { void offset_rotated(OUT Vec3f dst, Vec3f from, Vec3f to, Vec3s rotation) {
Vec3f unusedCopy; Vec3f unusedCopy;
Vec3f pitchRotated; Vec3f pitchRotated;
@ -5653,7 +5674,7 @@ void determine_pushing_or_pulling_door(s16 *rotation) {
* *
* @return Lakitu's next yaw, which is the same as the yaw passed in if no transition happened * @return Lakitu's next yaw, which is the same as the yaw passed in if no transition happened
*/ */
s16 next_lakitu_state(Vec3f newPos, Vec3f newFoc, Vec3f curPos, Vec3f curFoc, s16 next_lakitu_state(OUT Vec3f newPos, OUT Vec3f newFoc, Vec3f curPos, Vec3f curFoc,
Vec3f oldPos, Vec3f oldFoc, s16 yaw) { Vec3f oldPos, Vec3f oldFoc, s16 yaw) {
s16 yawVelocity; s16 yawVelocity;
s16 pitchVelocity; s16 pitchVelocity;
@ -7043,7 +7064,7 @@ s16 camera_course_processing(struct Camera *c) {
* Move `pos` between the nearest floor and ceiling * Move `pos` between the nearest floor and ceiling
* @param lastGood unused, passed as the last position the camera was in * @param lastGood unused, passed as the last position the camera was in
*/ */
void resolve_geometry_collisions(Vec3f pos, UNUSED Vec3f lastGood) { void resolve_geometry_collisions(OUT Vec3f pos, UNUSED Vec3f lastGood) {
f32 ceilY, floorY; f32 ceilY, floorY;
struct Surface *surf; struct Surface *surf;

View file

@ -788,7 +788,7 @@ void stub_camera_3(UNUSED struct Camera *c);
Converts an object's position to a `Vec3f` format. Converts an object's position to a `Vec3f` format.
Useful for aligning object behaviors or interactions with the camera system Useful for aligning object behaviors or interactions with the camera system
|descriptionEnd| */ |descriptionEnd| */
void object_pos_to_vec3f(Vec3f dst, struct Object *o); void object_pos_to_vec3f(OUT Vec3f dst, struct Object *o);
/* |description| /* |description|
Converts a `Vec3f` position to an object's internal format. Converts a `Vec3f` position to an object's internal format.
@ -796,6 +796,26 @@ Useful for syncing 3D positions between objects and the game world
|descriptionEnd| */ |descriptionEnd| */
void vec3f_to_object_pos(struct Object *o, Vec3f src); void vec3f_to_object_pos(struct Object *o, Vec3f src);
/* |description|
Converts an object's face angle to a `Vec3s` format
|descriptionEnd| */
void object_face_angle_to_vec3s(OUT Vec3s dst, struct Object *o);
/* |description|
Converts a `Vec3s` angle to an object's face angle internal format
|descriptionEnd| */
void vec3s_to_object_face_angle(struct Object *o, Vec3s src);
/* |description|
Converts an object's move angle to a `Vec3s` format
|descriptionEnd| */
void object_move_angle_to_vec3s(OUT Vec3s dst, struct Object *o);
/* |description|
Converts a `Vec3s` angle to an object's move angle internal format
|descriptionEnd| */
void vec3s_to_object_move_angle(struct Object *o, Vec3s src);
s32 move_point_along_spline(Vec3f p, struct CutsceneSplinePoint spline[], s16 *splineSegment, f32 *progress); s32 move_point_along_spline(Vec3f p, struct CutsceneSplinePoint spline[], s16 *splineSegment, f32 *progress);
/* |description| /* |description|
@ -820,7 +840,7 @@ void set_handheld_shake(u8 mode);
Activates a handheld camera shake effect. Activates a handheld camera shake effect.
Calculates positional and focus adjustments to simulate manual movement Calculates positional and focus adjustments to simulate manual movement
|descriptionEnd| */ |descriptionEnd| */
void shake_camera_handheld(Vec3f pos, Vec3f focus); void shake_camera_handheld(Vec3f pos, OUT Vec3f focus);
/* |description| /* |description|
Determines which C-buttons are currently pressed by the player. Determines which C-buttons are currently pressed by the player.
@ -834,13 +854,13 @@ s32 update_camera_hud_status(struct Camera *c);
Checks for collisions between the camera and level geometry. Checks for collisions between the camera and level geometry.
Adjusts the camera's position to avoid clipping into walls or obstacles Adjusts the camera's position to avoid clipping into walls or obstacles
|descriptionEnd| */ |descriptionEnd| */
s32 collide_with_walls(Vec3f pos, f32 offsetY, f32 radius); s32 collide_with_walls(OUT Vec3f pos, f32 offsetY, f32 radius);
/* |description| /* |description|
Clamps the camera's pitch angle between a maximum and minimum value. Clamps the camera's pitch angle between a maximum and minimum value.
Prevents over-rotation and maintains a consistent viewing angle Prevents over-rotation and maintains a consistent viewing angle
|descriptionEnd| */ |descriptionEnd| */
s32 clamp_pitch(Vec3f from, Vec3f to, s16 maxPitch, s16 minPitch); s32 clamp_pitch(Vec3f from, OUT Vec3f to, s16 maxPitch, s16 minPitch);
/* |description| /* |description|
Checks if a position is within 100 units of Mario's current position. Checks if a position is within 100 units of Mario's current position.
@ -886,13 +906,13 @@ s32 approach_s16_asymptotic(s16 current, s16 target, s16 divisor);
Smoothly transitions a 3D vector (`current`) towards a target vector (`target`) using asymptotic scaling. Smoothly transitions a 3D vector (`current`) towards a target vector (`target`) using asymptotic scaling.
Scaling values (the `Mul` variables) for x, y, and z axes determine the speed of adjustment for each component Scaling values (the `Mul` variables) for x, y, and z axes determine the speed of adjustment for each component
|descriptionEnd| */ |descriptionEnd| */
void approach_vec3f_asymptotic(Vec3f current, Vec3f target, f32 xMul, f32 yMul, f32 zMul); void approach_vec3f_asymptotic(OUT Vec3f current, Vec3f target, f32 xMul, f32 yMul, f32 zMul);
/* |description| /* |description|
Smoothly transitions a 3D vector (`current`) toward a target vector (`goal`) using asymptotic scaling. Smoothly transitions a 3D vector (`current`) toward a target vector (`goal`) using asymptotic scaling.
Allows gradual or instantaneous alignment of 3D positions. Scaling values (the `Mul` variables) for x, y, and z axes determine the speed of adjustment for each component Allows gradual or instantaneous alignment of 3D positions. Scaling values (the `Mul` variables) for x, y, and z axes determine the speed of adjustment for each component
|descriptionEnd| */ |descriptionEnd| */
void set_or_approach_vec3f_asymptotic(Vec3f dst, Vec3f goal, f32 xMul, f32 yMul, f32 zMul); void set_or_approach_vec3f_asymptotic(OUT Vec3f dst, Vec3f goal, f32 xMul, f32 yMul, f32 zMul);
/* |description| /* |description|
Adjusts a signed 16-bit integer (`current`) towards a target (`target`) symmetrically with a fixed increment (`increment`). Adjusts a signed 16-bit integer (`current`) towards a target (`target`) symmetrically with a fixed increment (`increment`).
@ -922,13 +942,13 @@ f32 camera_approach_f32_symmetric(f32 value, f32 target, f32 increment);
Generates a random 3D vector with short integer components. Generates a random 3D vector with short integer components.
Useful for randomized offsets or environmental effects Useful for randomized offsets or environmental effects
|descriptionEnd| */ |descriptionEnd| */
void random_vec3s(Vec3s dst, s16 xRange, s16 yRange, s16 zRange); void random_vec3s(OUT Vec3s dst, s16 xRange, s16 yRange, s16 zRange);
/* |description| /* |description|
Clamps a position within specified X and Z bounds and calculates the yaw angle from the origin. Clamps a position within specified X and Z bounds and calculates the yaw angle from the origin.
Prevents the camera from moving outside of the designated area Prevents the camera from moving outside of the designated area
|descriptionEnd| */ |descriptionEnd| */
s32 clamp_positions_and_find_yaw(Vec3f pos, Vec3f origin, f32 xMax, f32 xMin, f32 zMax, f32 zMin); s32 clamp_positions_and_find_yaw(OUT Vec3f pos, Vec3f origin, f32 xMax, f32 xMin, f32 zMax, f32 zMin);
/* |description| /* |description|
Determines if a range is obstructed by a surface relative to the camera. Determines if a range is obstructed by a surface relative to the camera.
@ -941,7 +961,7 @@ Scales a point along a line between two 3D points (`from` and `to`).
The scaling factor determines how far along the line the resulting point will be. The scaling factor determines how far along the line the resulting point will be.
The result is stored in the destination vector (`dest`) The result is stored in the destination vector (`dest`)
|descriptionEnd| */ |descriptionEnd| */
void scale_along_line(Vec3f dest, Vec3f from, Vec3f to, f32 scale); void scale_along_line(OUT Vec3f dest, Vec3f from, Vec3f to, f32 scale);
/* |description| /* |description|
Calculates the pitch angle (rotation around the X-axis) from one 3D point (`from`) to another (`to`). Calculates the pitch angle (rotation around the X-axis) from one 3D point (`from`) to another (`to`).
@ -980,14 +1000,14 @@ Rotates a vector around the XZ-plane by a specified yaw angle.
The result is stored in the destination vector (`dst`). The result is stored in the destination vector (`dst`).
Useful for rotating camera positions or object coordinates horizontally Useful for rotating camera positions or object coordinates horizontally
|descriptionEnd| */ |descriptionEnd| */
void rotate_in_xz(Vec3f dst, Vec3f src, s16 yaw); void rotate_in_xz(OUT Vec3f dst, Vec3f src, s16 yaw);
/* |description| /* |description|
Rotates a vector around the YZ-plane by a specified pitch angle. Rotates a vector around the YZ-plane by a specified pitch angle.
The result is stored in the destination vector (`dst`). The result is stored in the destination vector (`dst`).
Useful for vertical camera rotations or object transformations Useful for vertical camera rotations or object transformations
|descriptionEnd| */ |descriptionEnd| */
void rotate_in_yz(Vec3f dst, Vec3f src, s16 pitch); void rotate_in_yz(OUT Vec3f dst, Vec3f src, s16 pitch);
/* |description| /* |description|
Applies a pitch-based shake effect to the camera. Applies a pitch-based shake effect to the camera.
@ -1018,13 +1038,13 @@ void set_pitch_shake_from_point(s16 mag, s16 decay, s16 inc, f32 maxDist, f32 po
Activates a pitch-based shake effect. Activates a pitch-based shake effect.
Adds vertical vibrational movement to the camera's behavior Adds vertical vibrational movement to the camera's behavior
|descriptionEnd| */ |descriptionEnd| */
void shake_camera_pitch(Vec3f pos, Vec3f focus); void shake_camera_pitch(Vec3f pos, OUT Vec3f focus);
/* |description| /* |description|
Activates a yaw-based shake effect. Activates a yaw-based shake effect.
Adds horizontal vibrational movement to the camera's behavior Adds horizontal vibrational movement to the camera's behavior
|descriptionEnd| */ |descriptionEnd| */
void shake_camera_yaw(Vec3f pos, Vec3f focus); void shake_camera_yaw(Vec3f pos, OUT Vec3f focus);
/* |description| /* |description|
Applies a roll-based shake effect to the camera. Applies a roll-based shake effect to the camera.
@ -1138,13 +1158,13 @@ void approach_camera_height(struct Camera *c, f32 goal, f32 inc);
Offsets a vector by rotating it in 3D space relative to a reference position. Offsets a vector by rotating it in 3D space relative to a reference position.
This is useful for creating radial effects or dynamic transformations This is useful for creating radial effects or dynamic transformations
|descriptionEnd| */ |descriptionEnd| */
void offset_rotated(Vec3f dst, Vec3f from, Vec3f to, Vec3s rotation); void offset_rotated(OUT Vec3f dst, Vec3f from, Vec3f to, Vec3s rotation);
/* |description| /* |description|
Transitions the camera to the next Lakitu state, updating position and focus. Transitions the camera to the next Lakitu state, updating position and focus.
This function handles smooth transitions between different gameplay scenarios This function handles smooth transitions between different gameplay scenarios
|descriptionEnd| */ |descriptionEnd| */
s16 next_lakitu_state(Vec3f newPos, Vec3f newFoc, Vec3f curPos, Vec3f curFoc, Vec3f oldPos, Vec3f oldFoc, s16 yaw); s16 next_lakitu_state(OUT Vec3f newPos, OUT Vec3f newFoc, Vec3f curPos, Vec3f curFoc, Vec3f oldPos, Vec3f oldFoc, s16 yaw);
/* |description|Set the fixed camera base pos depending on the current level area|descriptionEnd| */ /* |description|Set the fixed camera base pos depending on the current level area|descriptionEnd| */
void set_fixed_cam_axis_sa_lobby(UNUSED s16 preset); void set_fixed_cam_axis_sa_lobby(UNUSED s16 preset);
@ -1158,7 +1178,7 @@ s16 camera_course_processing(struct Camera *c);
Resolves collisions between the camera and level geometry. Resolves collisions between the camera and level geometry.
Adjusts the camera's position to prevent clipping or intersecting with objects Adjusts the camera's position to prevent clipping or intersecting with objects
|descriptionEnd| */ |descriptionEnd| */
void resolve_geometry_collisions(Vec3f pos, UNUSED Vec3f lastGood); void resolve_geometry_collisions(OUT Vec3f pos, UNUSED Vec3f lastGood);
/* |description| /* |description|
Rotates the camera to avoid walls or other obstructions. Rotates the camera to avoid walls or other obstructions.

View file

@ -200,7 +200,7 @@ s32 is_anim_past_frame(struct MarioState *m, s16 animFrame) {
* Rotates the animation's translation into the global coordinate system * Rotates the animation's translation into the global coordinate system
* and returns the animation's flags. * and returns the animation's flags.
*/ */
s16 find_mario_anim_flags_and_translation(struct Object *obj, s32 yaw, Vec3s translation) { s16 find_mario_anim_flags_and_translation(struct Object *obj, s32 yaw, OUT Vec3s translation) {
if (!obj) { return 0; } if (!obj) { return 0; }
f32 dx; f32 dx;
f32 dz; f32 dz;
@ -618,7 +618,7 @@ u32 mario_get_terrain_sound_addend(struct MarioState *m) {
/** /**
* Collides with walls and returns the most recent wall. * Collides with walls and returns the most recent wall.
*/ */
struct Surface *resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius) { struct Surface *resolve_and_return_wall_collisions(OUT Vec3f pos, f32 offset, f32 radius) {
struct WallCollisionData collisionData; struct WallCollisionData collisionData;
struct Surface *wall = NULL; struct Surface *wall = NULL;
@ -643,7 +643,7 @@ struct Surface *resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 ra
/** /**
* Collides with walls and returns the wall collision data. * 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) { void resolve_and_return_wall_collisions_data(OUT Vec3f pos, f32 offset, f32 radius, struct WallCollisionData* collisionData) {
if (!collisionData || !pos) { return; } if (!collisionData || !pos) { return; }
collisionData->x = pos[0]; collisionData->x = pos[0];

View file

@ -58,7 +58,7 @@ s32 is_anim_past_frame(struct MarioState *m, s16 animFrame);
Retrieves the current animation flags and calculates the translation for Mario's animation, rotating it into the global coordinate system based on `yaw`. Retrieves the current animation flags and calculates the translation for Mario's animation, rotating it into the global coordinate system based on `yaw`.
Useful for determining positional offsets from animations (e.g., stepping forward in a walk animation) and applying them to Mario's position Useful for determining positional offsets from animations (e.g., stepping forward in a walk animation) and applying them to Mario's position
|descriptionEnd| */ |descriptionEnd| */
s16 find_mario_anim_flags_and_translation(struct Object *o, s32 yaw, Vec3s translation); s16 find_mario_anim_flags_and_translation(struct Object *o, s32 yaw, OUT Vec3s translation);
/* |description| /* |description|
Applies the translation from Mario's current animation to his world position. Considers animation flags (horizontal/vertical translation) Applies the translation from Mario's current animation to his world position. Considers animation flags (horizontal/vertical translation)
@ -166,12 +166,12 @@ u32 mario_get_terrain_sound_addend(struct MarioState *m);
Checks for and resolves wall collisions at a given position `pos`, returning the last wall encountered. Primarily used to prevent Mario from going through walls. Checks for and resolves wall collisions at a given position `pos`, returning the last wall encountered. Primarily used to prevent Mario from going through walls.
Useful for collision detection when updating Mario's movement or adjusting his position Useful for collision detection when updating Mario's movement or adjusting his position
|descriptionEnd| */ |descriptionEnd| */
struct Surface *resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius); struct Surface *resolve_and_return_wall_collisions(OUT Vec3f pos, f32 offset, f32 radius);
/* |description| /* |description|
Similar to `resolve_and_return_wall_collisions` but also returns detailed collision data (`WallCollisionData`). This can handle multiple walls and store them for further checks Similar to `resolve_and_return_wall_collisions` but also returns detailed collision data (`WallCollisionData`). This can handle multiple walls and store them for further checks
|descriptionEnd| */ |descriptionEnd| */
void resolve_and_return_wall_collisions_data(Vec3f pos, f32 offset, f32 radius, struct WallCollisionData* collisionData); void resolve_and_return_wall_collisions_data(OUT Vec3f pos, f32 offset, f32 radius, struct WallCollisionData* collisionData);
f32 vec3f_find_ceil(Vec3f pos, f32 height, struct Surface **ceil); f32 vec3f_find_ceil(Vec3f pos, f32 height, struct Surface **ceil);
f32 vec3f_mario_ceil(Vec3f pos, f32 height, struct Surface **ceil); f32 vec3f_mario_ceil(Vec3f pos, f32 height, struct Surface **ceil);

View file

@ -344,7 +344,7 @@ s32 act_top_of_pole(struct MarioState *m) {
/* |description| /* |description|
Performs a single step of movement while Mario is hanging from a ceiling. It handles wall collisions and checks the floor and ceiling to determine if Mario remains hanging, leaves the ceiling, or hits it Performs a single step of movement while Mario is hanging from a ceiling. It handles wall collisions and checks the floor and ceiling to determine if Mario remains hanging, leaves the ceiling, or hits it
|descriptionEnd| */ |descriptionEnd| */
s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos) { s32 perform_hanging_step(struct MarioState *m, OUT Vec3f nextPos) {
if (!m) { return 0; } if (!m) { return 0; }
UNUSED s32 unused; UNUSED s32 unused;
struct Surface *ceil; struct Surface *ceil;

View file

@ -85,7 +85,7 @@ static f32 get_buoyancy(struct MarioState *m) {
} }
/* |description|Performs a full water movement step where ceilings, floors, and walls are handled. Generally, you should use `perform_water_step` for the full step functionality|descriptionEnd| */ /* |description|Performs a full water movement step where ceilings, floors, and walls are handled. Generally, you should use `perform_water_step` for the full step functionality|descriptionEnd| */
u32 perform_water_full_step(struct MarioState *m, Vec3f nextPos) { u32 perform_water_full_step(struct MarioState *m, OUT Vec3f nextPos) {
if (!m) { return 0; } if (!m) { return 0; }
struct WallCollisionData wcd = { 0 }; struct WallCollisionData wcd = { 0 };
struct Surface *ceil; struct Surface *ceil;
@ -136,7 +136,7 @@ u32 perform_water_full_step(struct MarioState *m, Vec3f nextPos) {
} }
/* |description|Calculates a water current and outputs it in `step`|descriptionEnd| */ /* |description|Calculates a water current and outputs it in `step`|descriptionEnd| */
void apply_water_current(struct MarioState *m, Vec3f step) { void apply_water_current(struct MarioState *m, OUT Vec3f step) {
if (!m) { return; } if (!m) { return; }
s32 i; s32 i;
f32 whirlpoolRadius = 2000.0f; f32 whirlpoolRadius = 2000.0f;

View file

@ -760,7 +760,7 @@ s8 obj_check_if_facing_toward_angle(u32 base, u32 goal, s16 range) {
} }
/* |description|Finds any wall collisions and returns what the displacement vector would be.|descriptionEnd| */ /* |description|Finds any wall collisions and returns what the displacement vector would be.|descriptionEnd| */
s8 obj_find_wall_displacement(Vec3f dist, f32 x, f32 y, f32 z, f32 radius) { s8 obj_find_wall_displacement(OUT Vec3f dist, f32 x, f32 y, f32 z, f32 radius) {
struct WallCollisionData hitbox; struct WallCollisionData hitbox;
UNUSED u8 filler[0x20]; UNUSED u8 filler[0x20];

View file

@ -273,7 +273,7 @@ void obj_update_pos_from_parent_transformation(Mat4 a0, struct Object *a1) {
a1->oPosZ = spC * a0[0][2] + sp8 * a0[1][2] + sp4 * a0[2][2] + a0[3][2]; a1->oPosZ = spC * a0[0][2] + sp8 * a0[1][2] + sp4 * a0[2][2] + a0[3][2];
} }
void obj_apply_scale_to_matrix(struct Object *obj, Mat4 dst, Mat4 src) { void obj_apply_scale_to_matrix(struct Object *obj, OUT Mat4 dst, Mat4 src) {
if (obj == NULL) { return; } if (obj == NULL) { return; }
dst[0][0] = src[0][0] * obj->header.gfx.scale[0]; dst[0][0] = src[0][0] * obj->header.gfx.scale[0];
dst[1][0] = src[1][0] * obj->header.gfx.scale[1]; dst[1][0] = src[1][0] * obj->header.gfx.scale[1];
@ -296,7 +296,7 @@ void obj_apply_scale_to_matrix(struct Object *obj, Mat4 dst, Mat4 src) {
dst[3][3] = src[3][3]; dst[3][3] = src[3][3];
} }
void create_transformation_from_matrices(Mat4 a0, Mat4 a1, Mat4 a2) { void create_transformation_from_matrices(OUT Mat4 a0, Mat4 a1, Mat4 a2) {
f32 spC, sp8, sp4; f32 spC, sp8, sp4;
spC = a2[3][0] * a2[0][0] + a2[3][1] * a2[0][1] + a2[3][2] * a2[0][2]; spC = a2[3][0] * a2[0][0] + a2[3][1] * a2[0][1] + a2[3][2] * a2[0][2];
@ -825,7 +825,7 @@ Multiplies a vector by a matrix of the form:
`| 0 0 0 1 |` `| 0 0 0 1 |`
i.e. a matrix representing a linear transformation over 3 space i.e. a matrix representing a linear transformation over 3 space
|descriptionEnd| */ |descriptionEnd| */
void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v) { void linear_mtxf_mul_vec3f(Mat4 m, OUT Vec3f dst, Vec3f v) {
s32 i; s32 i;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
dst[i] = m[0][i] * v[0] + m[1][i] * v[1] + m[2][i] * v[2]; dst[i] = m[0][i] * v[0] + m[1][i] * v[1] + m[2][i] * v[2];
@ -840,7 +840,7 @@ Multiplies a vector by the transpose of a matrix of the form:
`| 0 0 0 1 |` `| 0 0 0 1 |`
i.e. a matrix representing a linear transformation over 3 space i.e. a matrix representing a linear transformation over 3 space
|descriptionEnd| */ |descriptionEnd| */
void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v) { void linear_mtxf_transpose_mul_vec3f(Mat4 m, OUT Vec3f dst, Vec3f v) {
s32 i; s32 i;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
dst[i] = m[i][0] * v[0] + m[i][1] * v[1] + m[i][2] * v[2]; dst[i] = m[i][0] * v[0] + m[i][1] * v[1] + m[i][2] * v[2];

View file

@ -73,8 +73,8 @@ Gfx *geo_switch_area(s32 callContext, struct GraphNode *node);
#endif #endif
Gfx *geo_choose_area_ext(s32 callContext, UNUSED struct GraphNode *node, Mat4 mtx); Gfx *geo_choose_area_ext(s32 callContext, UNUSED struct GraphNode *node, Mat4 mtx);
void obj_update_pos_from_parent_transformation(Mat4 a0, struct Object *a1); void obj_update_pos_from_parent_transformation(Mat4 a0, struct Object *a1);
void obj_apply_scale_to_matrix(struct Object *obj, Mat4 dst, Mat4 src); void obj_apply_scale_to_matrix(struct Object *obj, OUT Mat4 dst, Mat4 src);
void create_transformation_from_matrices(Mat4 a0, Mat4 a1, Mat4 a2); void create_transformation_from_matrices(OUT Mat4 a0, Mat4 a1, Mat4 a2);
void obj_set_held_state(struct Object *obj, const BehaviorScript *heldBehavior); void obj_set_held_state(struct Object *obj, const BehaviorScript *heldBehavior);
f32 lateral_dist_between_objects(struct Object *obj1, struct Object *obj2); f32 lateral_dist_between_objects(struct Object *obj1, struct Object *obj2);
f32 dist_between_objects(struct Object *obj1, struct Object *obj2); f32 dist_between_objects(struct Object *obj1, struct Object *obj2);
@ -119,8 +119,8 @@ void obj_copy_pos_and_angle(struct Object *dst, struct Object *src);
void obj_copy_pos(struct Object *dst, struct Object *src); void obj_copy_pos(struct Object *dst, struct Object *src);
void obj_copy_angle(struct Object *dst, struct Object *src); void obj_copy_angle(struct Object *dst, struct Object *src);
void obj_set_gfx_pos_from_pos(struct Object *obj); void obj_set_gfx_pos_from_pos(struct Object *obj);
void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v); void linear_mtxf_mul_vec3f(Mat4 m, OUT Vec3f dst, Vec3f v);
void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v); void linear_mtxf_transpose_mul_vec3f(Mat4 m, OUT Vec3f dst, Vec3f v);
void obj_apply_scale_to_transform(struct Object *obj); void obj_apply_scale_to_transform(struct Object *obj);
void obj_copy_scale(struct Object *dst, struct Object *src); void obj_copy_scale(struct Object *dst, struct Object *src);
void obj_scale_xyz(struct Object* obj, f32 xScale, f32 yScale, f32 zScale); void obj_scale_xyz(struct Object* obj, f32 xScale, f32 yScale, f32 zScale);

View file

@ -43,8 +43,6 @@ extern f32 gOverrideFar;
void geo_process_node_and_siblings(struct GraphNode *firstNode); void geo_process_node_and_siblings(struct GraphNode *firstNode);
void geo_process_root(struct GraphNodeRoot *node, Vp *b, Vp *c, s32 clearColor); void geo_process_root(struct GraphNodeRoot *node, Vp *b, Vp *c, s32 clearColor);
void interpolate_vectors(Vec3f res, Vec3f a, Vec3f b);
void interpolate_vectors_s16(Vec3s res, Vec3s a, Vec3s b);
struct ShadowInterp { struct ShadowInterp {
Gfx* gfx; Gfx* gfx;

View file

@ -791,7 +791,7 @@ void save_file_set_cap_pos(s16 x, s16 y, s16 z) {
save_file_set_flags(SAVE_FLAG_CAP_ON_GROUND); save_file_set_flags(SAVE_FLAG_CAP_ON_GROUND);
} }
s32 save_file_get_cap_pos(Vec3s capPos) { s32 save_file_get_cap_pos(OUT Vec3s capPos) {
if (INVALID_FILE_INDEX(gCurrSaveFileNum - 1)) { return 0; } if (INVALID_FILE_INDEX(gCurrSaveFileNum - 1)) { return 0; }
if (INVALID_SRC_SLOT(gSaveFileUsingBackupSlot)) { return 0; } if (INVALID_SRC_SLOT(gSaveFileUsingBackupSlot)) { return 0; }
struct SaveFile *saveFile = &gSaveBuffer.files[gCurrSaveFileNum - 1][gSaveFileUsingBackupSlot]; struct SaveFile *saveFile = &gSaveBuffer.files[gCurrSaveFileNum - 1][gSaveFileUsingBackupSlot];

View file

@ -248,7 +248,7 @@ void save_file_set_cap_pos(s16 x, s16 y, s16 z);
Retrieves the current position of Mario's cap, if it is on the ground in the current level and area. The position is stored in the provided `capPos` parameter. Retrieves the current position of Mario's cap, if it is on the ground in the current level and area. The position is stored in the provided `capPos` parameter.
Useful for tracking the cap's location after it has been dropped or lost Useful for tracking the cap's location after it has been dropped or lost
|descriptionEnd| */ |descriptionEnd| */
s32 save_file_get_cap_pos(Vec3s capPos); s32 save_file_get_cap_pos(OUT Vec3s capPos);
void save_file_set_sound_mode(u16 mode); void save_file_set_sound_mode(u16 mode);

View file

@ -646,7 +646,7 @@ f32 djui_hud_get_fov_coeff() {
return (fovDefault / fovCurrent) * 1.13f; return (fovDefault / fovCurrent) * 1.13f;
} }
bool djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out) { bool djui_hud_world_pos_to_screen_pos(Vec3f pos, OUT Vec3f out) {
if (!gCamera) { return false; } if (!gCamera) { return false; }
hud_rotate_and_translate_vec3f(pos, &gCamera->mtx, out); hud_rotate_and_translate_vec3f(pos, &gCamera->mtx, out);
if (out[2] >= 0.0f) { if (out[2] >= 0.0f) {

View file

@ -131,7 +131,7 @@ f32 get_current_fov();
/* |description|Gets the camera FOV coefficient|descriptionEnd| */ /* |description|Gets the camera FOV coefficient|descriptionEnd| */
f32 djui_hud_get_fov_coeff(); f32 djui_hud_get_fov_coeff();
/* |description|Converts a world position to screen position|descriptionEnd| */ /* |description|Converts a world position to screen position|descriptionEnd| */
bool djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out); bool djui_hud_world_pos_to_screen_pos(Vec3f pos, OUT Vec3f out);
/* |description|Checks if the DJUI pause menu is created|descriptionEnd| */ /* |description|Checks if the DJUI pause menu is created|descriptionEnd| */
bool djui_hud_is_pause_menu_created(void); bool djui_hud_is_pause_menu_created(void);

View file

@ -603,7 +603,7 @@ static void import_texture(int tile) {
//printf("Time diff: %d\n", t1 - t0); //printf("Time diff: %d\n", t1 - t0);
} }
static void OPTIMIZE_O3 gfx_transposed_matrix_mul(Vec3f res, const Vec3f a, const Mat4 b) { static void OPTIMIZE_O3 gfx_transposed_matrix_mul(OUT Vec3f res, const Vec3f a, const Mat4 b) {
res[0] = a[0] * b[0][0] + a[1] * b[0][1] + a[2] * b[0][2]; res[0] = a[0] * b[0][0] + a[1] * b[0][1] + a[2] * b[0][2];
res[1] = a[0] * b[1][0] + a[1] * b[1][1] + a[2] * b[1][2]; res[1] = a[0] * b[1][0] + a[1] * b[1][1] + a[2] * b[1][2];
res[2] = a[0] * b[2][0] + a[1] * b[2][1] + a[2] * b[2][2]; res[2] = a[0] * b[2][0] + a[1] * b[2][1] + a[2] * b[2][2];

View file

@ -54,7 +54,7 @@ char gSmluaConstants[] = ""
"-- sound --\n" "-- sound --\n"
"-----------\n" "-----------\n"
"--- @type Vec3f\n" "--- @type Vec3f\n"
"gGlobalSoundSource = { x = 0, y = 0, z = 0 }\n" "gGlobalSoundSource = create_read_only_table({ x = 0, y = 0, z = 0 })\n"
"--- @param bank number\n" "--- @param bank number\n"
"--- @param soundID number\n" "--- @param soundID number\n"
"--- @param priority number\n" "--- @param priority number\n"

File diff suppressed because it is too large Load diff

View file

@ -34,7 +34,7 @@ void network_player_color_to_palette(struct NetworkPlayer *np, enum PlayerPart p
np->overridePalette = np->palette; np->overridePalette = np->palette;
} }
void network_player_palette_to_color(struct NetworkPlayer *np, enum PlayerPart part, Color out) { void network_player_palette_to_color(struct NetworkPlayer *np, enum PlayerPart part, OUT Color out) {
LOG_LUA_LINE_WARNING("[LUA] network_player_palette_to_color() is deprecated! Use network_player_get_palette_color() or network_player_get_override_palette_color() instead."); LOG_LUA_LINE_WARNING("[LUA] network_player_palette_to_color() is deprecated! Use network_player_get_palette_color() or network_player_get_override_palette_color() instead.");
if (np == NULL || !(part < PLAYER_PART_MAX && part >= 0)) { if (np == NULL || !(part < PLAYER_PART_MAX && part >= 0)) {
if (np == NULL) { // output config palette instead if np is NULL if (np == NULL) { // output config palette instead if np is NULL

View file

@ -13,4 +13,4 @@ void audio_stream_set_speed(struct ModAudio* audio, f32 initial_freq, f32 speed,
/* |description|[DEPRECATED: Use `network_player_set_override_palette_color` instead]|descriptionEnd| */ /* |description|[DEPRECATED: Use `network_player_set_override_palette_color` instead]|descriptionEnd| */
void network_player_color_to_palette(struct NetworkPlayer *np, enum PlayerPart part, Color color); void network_player_color_to_palette(struct NetworkPlayer *np, enum PlayerPart part, Color color);
/* |description|[DEPRECATED: Use `network_player_get_palette_color` or `network_player_get_override_palette_color` instead]|descriptionEnd| */ /* |description|[DEPRECATED: Use `network_player_get_palette_color` or `network_player_get_override_palette_color` instead]|descriptionEnd| */
void network_player_palette_to_color(struct NetworkPlayer *np, enum PlayerPart part, Color out); void network_player_palette_to_color(struct NetworkPlayer *np, enum PlayerPart part, OUT Color out);

View file

@ -322,7 +322,7 @@ f32 get_hand_foot_pos_z(struct MarioState* m, u8 index) {
return m->marioBodyState->animPartsPos[sHandFootToAnimParts[index]][2]; return m->marioBodyState->animPartsPos[sHandFootToAnimParts[index]][2];
} }
bool get_mario_anim_part_pos(struct MarioState *m, u32 animPart, Vec3f pos) { bool get_mario_anim_part_pos(struct MarioState *m, u32 animPart, OUT Vec3f pos) {
if (!m) { return false; } if (!m) { return false; }
if (animPart >= MARIO_ANIM_PART_MAX) { return false; } if (animPart >= MARIO_ANIM_PART_MAX) { return false; }
vec3f_copy(pos, m->marioBodyState->animPartsPos[animPart]); vec3f_copy(pos, m->marioBodyState->animPartsPos[animPart]);

View file

@ -136,7 +136,7 @@ f32 get_hand_foot_pos_z(struct MarioState* m, u8 index);
/* |description| /* |description|
Retrieves the animated part position associated to `animPart` from the MarioState `m` and stores it into `pos`. Returns `true` on success or `false` on failure Retrieves the animated part position associated to `animPart` from the MarioState `m` and stores it into `pos`. Returns `true` on success or `false` on failure
|descriptionEnd| */ |descriptionEnd| */
bool get_mario_anim_part_pos(struct MarioState *m, u32 animPart, Vec3f pos); bool get_mario_anim_part_pos(struct MarioState *m, u32 animPart, OUT Vec3f pos);
/* |description|Gets the current save file number (1-indexed)|descriptionEnd| */ /* |description|Gets the current save file number (1-indexed)|descriptionEnd| */
s16 get_current_save_file_num(void); s16 get_current_save_file_num(void);

View file

@ -135,14 +135,14 @@ s32 delta_interpolate_s32(s32 a, s32 b, f32 delta) {
return a * (1.0f - delta) + b * delta; return a * (1.0f - delta) + b * delta;
} }
void delta_interpolate_vec3f(Vec3f res, Vec3f a, Vec3f b, f32 delta) { void delta_interpolate_vec3f(OUT Vec3f res, Vec3f a, Vec3f b, f32 delta) {
f32 antiDelta = 1.0f - delta; f32 antiDelta = 1.0f - delta;
res[0] = ((a[0] * antiDelta) + (b[0] * delta)); res[0] = ((a[0] * antiDelta) + (b[0] * delta));
res[1] = ((a[1] * antiDelta) + (b[1] * delta)); res[1] = ((a[1] * antiDelta) + (b[1] * delta));
res[2] = ((a[2] * antiDelta) + (b[2] * delta)); res[2] = ((a[2] * antiDelta) + (b[2] * delta));
} }
void delta_interpolate_vec3s(Vec3s res, Vec3s a, Vec3s b, f32 delta) { void delta_interpolate_vec3s(OUT Vec3s res, Vec3s a, Vec3s b, f32 delta) {
f32 antiDelta = 1.0f - delta; f32 antiDelta = 1.0f - delta;
res[0] = ((a[0] * antiDelta) + (b[0] * delta)); res[0] = ((a[0] * antiDelta) + (b[0] * delta));
res[1] = ((a[1] * antiDelta) + (b[1] * delta)); res[1] = ((a[1] * antiDelta) + (b[1] * delta));

View file

@ -26,9 +26,9 @@ f32 delta_interpolate_f32(f32 a, f32 b, f32 delta);
/* |description|Linearly interpolates between `a` and `b` with `delta`|descriptionEnd| */ /* |description|Linearly interpolates between `a` and `b` with `delta`|descriptionEnd| */
s32 delta_interpolate_s32(s32 a, s32 b, f32 delta); s32 delta_interpolate_s32(s32 a, s32 b, f32 delta);
/* |description|Linearly interpolates `res` between `a` and `b` with `delta`|descriptionEnd| */ /* |description|Linearly interpolates `res` between `a` and `b` with `delta`|descriptionEnd| */
void delta_interpolate_vec3f(Vec3f res, Vec3f a, Vec3f b, f32 delta); void delta_interpolate_vec3f(OUT Vec3f res, Vec3f a, Vec3f b, f32 delta);
/* |description|Linearly interpolates `res` between `a` and `b` with `delta`|descriptionEnd| */ /* |description|Linearly interpolates `res` between `a` and `b` with `delta`|descriptionEnd| */
void delta_interpolate_vec3s(Vec3s res, Vec3s a, Vec3s b, f32 delta); void delta_interpolate_vec3s(OUT Vec3s res, Vec3s a, Vec3s b, f32 delta);
void delta_interpolate_normal(s8* res, s8* a, s8* b, f32 delta); void delta_interpolate_normal(s8* res, s8* a, s8* b, f32 delta);
void delta_interpolate_rgba(u8* res, u8* a, u8* b, f32 delta); void delta_interpolate_rgba(u8* res, u8* a, u8* b, f32 delta);
void delta_interpolate_mtx(Mtx* out, Mtx* a, Mtx* b, f32 delta); void delta_interpolate_mtx(Mtx* out, Mtx* a, Mtx* b, f32 delta);