diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index 6e3941a99..78bb2c99a 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -902,8 +902,9 @@ def build_param(fid, param, i): def build_param_after(param, i): ptype = param['type'] 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)) else: return '' @@ -997,9 +998,12 @@ def build_function(function, do_extern): i += 1 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: - 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' @@ -1099,6 +1103,11 @@ def process_function(fname, line, description): for param_str in params_str.split(','): param = {} 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: param['type'] = normalize_type(param_str) param['identifier'] = 'arg%d' % param_index diff --git a/autogen/gen_math.py b/autogen/gen_math.py index db411a975..98da45c1a 100644 --- a/autogen/gen_math.py +++ b/autogen/gen_math.py @@ -5,7 +5,7 @@ VEC3X_TO_VEC3Y = """ /* |description| Converts a 3D {{desc}} vector `a` into a 3D {{desc_2}} vector and stores the result in `dest` |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[1] = a[1]{{rounding_1}}; dest[2] = a[2]{{rounding_2}}; diff --git a/autogen/lua_constants/built-in.lua b/autogen/lua_constants/built-in.lua index f3fe72d83..d02329b10 100644 --- a/autogen/lua_constants/built-in.lua +++ b/autogen/lua_constants/built-in.lua @@ -61,7 +61,7 @@ end ----------- --- @type Vec3f -gGlobalSoundSource = { x = 0, y = 0, z = 0 } +gGlobalSoundSource = create_read_only_table({ x = 0, y = 0, z = 0 }) --- @param bank number --- @param soundID number diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 4eee966ed..fce83c791 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -63,7 +63,7 @@ end ----------- --- @type Vec3f -gGlobalSoundSource = { x = 0, y = 0, z = 0 } +gGlobalSoundSource = create_read_only_table({ x = 0, y = 0, z = 0 }) --- @param bank number --- @param soundID number diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index ea71d83b3..4dba7ed0f 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -109,13 +109,6 @@ function arc_to_goal_pos(goal, pos, yVel, gravity) -- ... 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 a1 number --- @param deltaPitch integer @@ -3144,6 +3137,34 @@ function vec3f_to_object_pos(o, src) -- ... 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 --- @return integer --- 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 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 function mtxf_mul_vec3s(mtx, b) -- ... @@ -6583,7 +6604,7 @@ end --- @param dest Mat4 --- @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) -- ... end diff --git a/docs/lua/functions-2.md b/docs/lua/functions-2.md index e8e622753..fcdba108c 100644 --- a/docs/lua/functions-2.md +++ b/docs/lua/functions-2.md @@ -205,30 +205,6 @@ Calculates the time it takes for the current object to follow an arc from `pos`
-## [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:](#) - -
- ## [tox_box_move](#tox_box_move) ### Description diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md index e74eb3d08..651ec0b62 100644 --- a/docs/lua/functions-3.md +++ b/docs/lua/functions-3.md @@ -537,7 +537,7 @@ Converts an object's position to a `Vec3f` format. Useful for aligning object be - None ### 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:](#) @@ -567,6 +567,102 @@ Converts a `Vec3f` position to an object's internal format. Useful for syncing 3
+## [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:](#) + +
+ +## [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:](#) + +
+ +## [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:](#) + +
+ +## [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:](#) + +
+ ## [cam_select_alt_mode](#cam_select_alt_mode) ### Description @@ -654,7 +750,7 @@ Activates a handheld camera shake effect. Calculates positional and focus adjust - None ### C Prototype -`void shake_camera_handheld(Vec3f pos, Vec3f focus);` +`void shake_camera_handheld(Vec3f pos, OUT Vec3f focus);` [:arrow_up_small:](#) @@ -704,7 +800,7 @@ Checks for collisions between the camera and level geometry. Adjusts the camera' - `integer` ### 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:](#) @@ -730,7 +826,7 @@ Clamps the camera's pitch angle between a maximum and minimum value. Prevents ov - `integer` ### 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:](#) @@ -907,7 +1003,7 @@ Smoothly transitions a 3D vector (`current`) towards a target vector (`target`) - None ### 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:](#) @@ -934,7 +1030,7 @@ Smoothly transitions a 3D vector (`current`) toward a target vector (`goal`) usi - None ### 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:](#) @@ -1060,7 +1156,7 @@ Generates a random 3D vector with short integer components. Useful for randomize - None ### 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:](#) @@ -1088,7 +1184,7 @@ Clamps a position within specified X and Z bounds and calculates the yaw angle f - `integer` ### 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:](#) @@ -1141,7 +1237,7 @@ Scales a point along a line between two 3D points (`from` and `to`). The scaling - None ### 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:](#) @@ -1288,7 +1384,7 @@ Rotates a vector around the XZ-plane by a specified yaw angle. The result is sto - None ### 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:](#) @@ -1313,7 +1409,7 @@ Rotates a vector around the YZ-plane by a specified pitch angle. The result is s - None ### 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:](#) @@ -1441,7 +1537,7 @@ Activates a pitch-based shake effect. Adds vertical vibrational movement to the - None ### C Prototype -`void shake_camera_pitch(Vec3f pos, Vec3f focus);` +`void shake_camera_pitch(Vec3f pos, OUT Vec3f focus);` [:arrow_up_small:](#) @@ -1465,7 +1561,7 @@ Activates a yaw-based shake effect. Adds horizontal vibrational movement to the - None ### C Prototype -`void shake_camera_yaw(Vec3f pos, Vec3f focus);` +`void shake_camera_yaw(Vec3f pos, OUT Vec3f focus);` [:arrow_up_small:](#) @@ -1894,7 +1990,7 @@ Offsets a vector by rotating it in 3D space relative to a reference position. Th - None ### 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:](#) @@ -1923,7 +2019,7 @@ Transitions the camera to the next Lakitu state, updating position and focus. Th - `integer` ### 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:](#) @@ -1993,7 +2089,7 @@ Resolves collisions between the camera and level geometry. Adjusts the camera's - None ### C Prototype -`void resolve_geometry_collisions(Vec3f pos, UNUSED Vec3f lastGood);` +`void resolve_geometry_collisions(OUT Vec3f pos, UNUSED Vec3f lastGood);` [:arrow_up_small:](#) @@ -3366,7 +3462,7 @@ Converts a world position to screen position - `boolean` ### 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:](#) @@ -6432,7 +6528,7 @@ Calculates the lighting with `lightIntensityScalar` at a position and outputs th - None ### 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:](#) @@ -6456,7 +6552,7 @@ Calculates the lighting direction from a position and outputs the result in `out - None ### C Prototype -`void le_calculate_lighting_dir(Vec3f pos, Vec3f out);` +`void le_calculate_lighting_dir(Vec3f pos, OUT Vec3f out);` [:arrow_up_small:](#) diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md index 72de5afc3..e21c1fa09 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -222,7 +222,7 @@ Retrieves the current animation flags and calculates the translation for Mario's - `integer` ### 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:](#) @@ -697,7 +697,7 @@ Checks for and resolves wall collisions at a given position `pos`, returning the [Surface](structs.md#Surface) ### 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:](#) @@ -723,7 +723,7 @@ Similar to `resolve_and_return_wall_collisions` but also returns detailed collis - None ### 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:](#) @@ -1872,7 +1872,7 @@ Performs a single step of movement while Mario is hanging from a ceiling. It han - `integer` ### C Prototype -`s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos);` +`s32 perform_hanging_step(struct MarioState *m, OUT Vec3f nextPos);` [:arrow_up_small:](#) @@ -3620,7 +3620,7 @@ Performs a full water movement step where ceilings, floors, and walls are handle - `integer` ### 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:](#) @@ -3644,7 +3644,7 @@ Calculates a water current and outputs it in `step` - None ### C Prototype -`void apply_water_current(struct MarioState *m, Vec3f step);` +`void apply_water_current(struct MarioState *m, OUT Vec3f step);` [:arrow_up_small:](#) @@ -4311,7 +4311,7 @@ Computes spline interpolation weights for a given parameter `t` and stores these - None ### 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:](#) @@ -4359,7 +4359,7 @@ Advances the spline-based animation associated with `m` and stores the current i - `integer` ### C Prototype -`s32 anim_spline_poll(struct MarioState* m, Vec3f result);` +`s32 anim_spline_poll(struct MarioState* m, OUT Vec3f result);` [: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) ### C Prototype -`Vec3fp vec3f_rotate_zxy(Vec3f v, Vec3s rotate);` +`Vec3fp vec3f_rotate_zxy(OUT Vec3f v, Vec3s rotate);` [: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) ### 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:](#) @@ -4434,7 +4434,7 @@ Projects the 3D floating-point vector `v` onto another 3D floating-point vector [Vec3f](structs.md#Vec3f) ### C Prototype -`Vec3fp vec3f_project(Vec3f dest, Vec3f v, Vec3f onto);` +`Vec3fp vec3f_project(OUT Vec3f dest, Vec3f v, Vec3f onto);` [: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) ### 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:](#) @@ -4515,7 +4515,7 @@ Positions the point `to` at a given `dist`, `pitch`, and `yaw` relative to the p - None ### 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:](#) @@ -4541,7 +4541,7 @@ Determines a vector that is perpendicular (normal) to the plane defined by three [Vec3f](structs.md#Vec3f) ### 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:](#) @@ -4567,7 +4567,7 @@ Adjusts the 4x4 floating-point matrix `mtx` so that it represents a viewing tran - None ### 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:](#) @@ -4592,7 +4592,7 @@ Rotates `dest` according to the angles in `rotate` using ZXY order, and then tra - None ### 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:](#) @@ -4617,7 +4617,7 @@ Rotates `dest` using angles in XYZ order, and then translates it by the 3D float - None ### 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:](#) @@ -4643,7 +4643,7 @@ Transforms a 4x4 floating-point matrix `mtx` into a "billboard" oriented toward - None ### 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:](#) @@ -4669,7 +4669,7 @@ Creates a "cylindrical billboard" transformation from the 4x4 matrix `mtx` place - None ### 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:](#) @@ -4695,7 +4695,7 @@ Aligns `dest` so that it fits the orientation of a terrain surface defined by it - None ### 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:](#) @@ -4721,7 +4721,7 @@ Aligns `mtx` to fit onto a terrain triangle at `pos`, applying a given `yaw` and - None ### 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:](#) @@ -4746,7 +4746,7 @@ Multiplies two 4x4 floating-point matrices `a` and `b` (in that order), storing - None ### C Prototype -`void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b);` +`void mtxf_mul(OUT Mat4 dest, Mat4 a, Mat4 b);` [: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 ### Lua Example -`local PointerValue = mtxf_mul_vec3s(mtx, b)` +`local Vec3sValue = mtxf_mul_vec3s(mtx, b)` ### Parameters | Field | Type | @@ -4767,10 +4767,10 @@ Multiplies the 3D signed-integer vector `b` with the 4x4 floating-point matrix ` | b | [Vec3s](structs.md#Vec3s) | ### Returns -- `Pointer` <`integer`> +[Vec3s](structs.md#Vec3s) ### C Prototype -`s16 *mtxf_mul_vec3s(Mat4 mtx, Vec3s b);` +`Vec3sp mtxf_mul_vec3s(Mat4 mtx, OUT Vec3s b);` [:arrow_up_small:](#) @@ -4794,7 +4794,7 @@ Rotates the matrix `mtx` in the XY plane by the given `angle`. Rotating in the X - None ### C Prototype -`void mtxf_rotate_xy(Mat4 mtx, s16 angle);` +`void mtxf_rotate_xy(OUT Mat4 mtx, s16 angle);` [:arrow_up_small:](#) @@ -4818,7 +4818,7 @@ Inverts the 4x4 floating-point matrix `src` and stores the inverse in `dest`. Ap - None ### C Prototype -`void mtxf_inverse(Mat4 dest, Mat4 src);` +`void mtxf_inverse(OUT Mat4 dest, Mat4 src);` [:arrow_up_small:](#) @@ -4843,7 +4843,7 @@ Extracts the position (translation component) from the transformation matrix `ob [Vec3f](structs.md#Vec3f) ### 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:](#) @@ -4994,7 +4994,7 @@ Sets the 4x4 floating-point matrix `mtx` to all zeros. Unless you really need th - None ### C Prototype -`void mtxf_zero(Mat4 mtx);` +`void mtxf_zero(OUT Mat4 mtx);` [:arrow_up_small:](#) @@ -5018,7 +5018,7 @@ Copies the 4x4 floating-point matrix `src` into `dest`. After this operation, `d - None ### C Prototype -`void mtxf_copy(Mat4 dest, Mat4 src);` +`void mtxf_copy(OUT Mat4 dest, Mat4 src);` [:arrow_up_small:](#) @@ -5041,7 +5041,7 @@ Sets the 4x4 floating-point matrix `mtx` to the identity matrix. The identity ma - None ### C Prototype -`void mtxf_identity(Mat4 mtx);` +`void mtxf_identity(OUT Mat4 mtx);` [: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) ### 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 `mtxf_translate(dest, b)` @@ -5065,7 +5065,7 @@ Applies a translation to the 4x4 floating-point matrix `dest` by adding the coor - None ### C Prototype -`void mtxf_translate(Mat4 dest, Vec3f b);` +`void mtxf_translate(OUT Mat4 dest, Vec3f b);` [:arrow_up_small:](#) @@ -5090,7 +5090,7 @@ Scales the 4x4 floating-point matrix `mtx` by the scaling factors found in the 3 - None ### 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:](#) @@ -5119,7 +5119,7 @@ Sets the components of the 3D floating-point vector `v` to 0 [Vec3f](structs.md#Vec3f) ### C Prototype -`Vec3fp vec3f_zero(Vec3f v);` +`Vec3fp vec3f_zero(OUT Vec3f v);` [: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) ### C Prototype -`Vec3fp vec3f_copy(Vec3f dest, Vec3f src);` +`Vec3fp vec3f_copy(OUT Vec3f dest, Vec3f src);` [: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) ### 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:](#) @@ -5193,7 +5193,7 @@ Adds the components of the 3D floating-point vector `a` to `dest` [Vec3f](structs.md#Vec3f) ### C Prototype -`Vec3fp vec3f_add(Vec3f dest, Vec3f a);` +`Vec3fp vec3f_add(OUT Vec3f dest, Vec3f a);` [: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) ### C Prototype -`Vec3fp vec3f_sum(Vec3f dest, Vec3f a, Vec3f b);` +`Vec3fp vec3f_sum(OUT Vec3f dest, Vec3f a, Vec3f b);` [:arrow_up_small:](#) @@ -5242,7 +5242,7 @@ Subtracts the components of the 3D floating-point vector `a` from `dest` [Vec3f](structs.md#Vec3f) ### C Prototype -`Vec3fp vec3f_sub(Vec3f dest, Vec3f a);` +`Vec3fp vec3f_sub(OUT Vec3f dest, Vec3f a);` [:arrow_up_small:](#) @@ -5267,7 +5267,7 @@ Subtracts the components of the 3D floating-point vector `b` from the components [Vec3f](structs.md#Vec3f) ### C Prototype -`Vec3fp vec3f_dif(Vec3f dest, Vec3f a, Vec3f b);` +`Vec3fp vec3f_dif(OUT Vec3f dest, Vec3f a, Vec3f b);` [: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) ### C Prototype -`Vec3fp vec3f_mul(Vec3f dest, f32 a);` +`Vec3fp vec3f_mul(OUT Vec3f dest, f32 a);` [:arrow_up_small:](#) @@ -5315,7 +5315,7 @@ Multiplies the components of the 3D floating-point vector `dest` with the compon [Vec3f](structs.md#Vec3f) ### C Prototype -`Vec3fp vec3f_mult(Vec3f dest, Vec3f a);` +`Vec3fp vec3f_mult(OUT Vec3f dest, Vec3f a);` [: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) ### C Prototype -`Vec3fp vec3f_prod(Vec3f dest, Vec3f a, Vec3f b);` +`Vec3fp vec3f_prod(OUT Vec3f dest, Vec3f a, Vec3f b);` [: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) ### C Prototype -`Vec3fp vec3f_div(Vec3f dest, f32 a);` +`Vec3fp vec3f_div(OUT Vec3f dest, f32 a);` [:arrow_up_small:](#) @@ -5410,7 +5410,7 @@ Normalizes the 3D floating-point vector `v` so that its length (magnitude) becom [Vec3f](structs.md#Vec3f) ### C Prototype -`Vec3fp vec3f_normalize(Vec3f v);` +`Vec3fp vec3f_normalize(OUT Vec3f v);` [:arrow_up_small:](#) @@ -5434,7 +5434,7 @@ Sets the length (magnitude) of 3D floating-point vector `v`, while retaining its [Vec3f](structs.md#Vec3f) ### C Prototype -`Vec3fp vec3f_set_magnitude(Vec3f v, f32 mag);` +`Vec3fp vec3f_set_magnitude(OUT Vec3f v, f32 mag);` [: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) ### C Prototype -`Vec3fp vec3f_cross(Vec3f dest, Vec3f a, Vec3f b);` +`Vec3fp vec3f_cross(OUT Vec3f dest, Vec3f a, Vec3f b);` [:arrow_up_small:](#) @@ -5510,7 +5510,7 @@ Takes two 3D floating-point vectors `vecA` and `vecB`, multiplies them by `sclA` [Vec3f](structs.md#Vec3f) ### 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:](#) @@ -5605,7 +5605,7 @@ Converts a 3D floating-point vector `a` into a 3D integer vector and stores the [Vec3i](structs.md#Vec3i) ### C Prototype -`Vec3ip vec3f_to_vec3i(Vec3i dest, Vec3f a);` +`Vec3ip vec3f_to_vec3i(OUT Vec3i dest, Vec3f a);` [: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) ### C Prototype -`Vec3sp vec3f_to_vec3s(Vec3s dest, Vec3f a);` +`Vec3sp vec3f_to_vec3s(OUT Vec3s dest, Vec3f a);` [:arrow_up_small:](#) @@ -5658,7 +5658,7 @@ Sets the components of the 3D integer vector `v` to 0 [Vec3i](structs.md#Vec3i) ### C Prototype -`Vec3ip vec3i_zero(Vec3i v);` +`Vec3ip vec3i_zero(OUT Vec3i v);` [: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) ### C Prototype -`Vec3ip vec3i_copy(Vec3i dest, Vec3i src);` +`Vec3ip vec3i_copy(OUT Vec3i dest, Vec3i src);` [: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) ### 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:](#) @@ -5732,7 +5732,7 @@ Adds the components of the 3D integer vector `a` to `dest` [Vec3i](structs.md#Vec3i) ### C Prototype -`Vec3ip vec3i_add(Vec3i dest, Vec3i a);` +`Vec3ip vec3i_add(OUT Vec3i dest, Vec3i a);` [: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) ### C Prototype -`Vec3ip vec3i_sum(Vec3i dest, Vec3i a, Vec3i b);` +`Vec3ip vec3i_sum(OUT Vec3i dest, Vec3i a, Vec3i b);` [:arrow_up_small:](#) @@ -5781,7 +5781,7 @@ Subtracts the components of the 3D integer vector `a` from `dest` [Vec3i](structs.md#Vec3i) ### C Prototype -`Vec3ip vec3i_sub(Vec3i dest, Vec3i a);` +`Vec3ip vec3i_sub(OUT Vec3i dest, Vec3i a);` [: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) ### C Prototype -`Vec3ip vec3i_dif(Vec3i dest, Vec3i a, Vec3i b);` +`Vec3ip vec3i_dif(OUT Vec3i dest, Vec3i a, Vec3i b);` [: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) ### C Prototype -`Vec3ip vec3i_mul(Vec3i dest, f32 a);` +`Vec3ip vec3i_mul(OUT Vec3i dest, f32 a);` [:arrow_up_small:](#) @@ -5854,7 +5854,7 @@ Multiplies the components of the 3D integer vector `dest` with the components of [Vec3i](structs.md#Vec3i) ### C Prototype -`Vec3ip vec3i_mult(Vec3i dest, Vec3i a);` +`Vec3ip vec3i_mult(OUT Vec3i dest, Vec3i a);` [: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) ### C Prototype -`Vec3ip vec3i_prod(Vec3i dest, Vec3i a, Vec3i b);` +`Vec3ip vec3i_prod(OUT Vec3i dest, Vec3i a, Vec3i b);` [: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) ### C Prototype -`Vec3ip vec3i_div(Vec3i dest, f32 a);` +`Vec3ip vec3i_div(OUT Vec3i dest, f32 a);` [: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) ### C Prototype -`Vec3ip vec3i_normalize(Vec3i v);` +`Vec3ip vec3i_normalize(OUT Vec3i v);` [:arrow_up_small:](#) @@ -5973,7 +5973,7 @@ Sets the length (magnitude) of 3D integer vector `v`, while retaining its direct [Vec3i](structs.md#Vec3i) ### C Prototype -`Vec3ip vec3i_set_magnitude(Vec3i v, f32 mag);` +`Vec3ip vec3i_set_magnitude(OUT Vec3i v, f32 mag);` [: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) ### C Prototype -`Vec3ip vec3i_cross(Vec3i dest, Vec3i a, Vec3i b);` +`Vec3ip vec3i_cross(OUT Vec3i dest, Vec3i a, Vec3i b);` [: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) ### 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:](#) @@ -6144,7 +6144,7 @@ Converts a 3D integer vector `a` into a 3D floating-point vector and stores the [Vec3f](structs.md#Vec3f) ### C Prototype -`Vec3fp vec3i_to_vec3f(Vec3f dest, Vec3i a);` +`Vec3fp vec3i_to_vec3f(OUT Vec3f dest, Vec3i a);` [: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) ### C Prototype -`Vec3sp vec3i_to_vec3s(Vec3s dest, Vec3i a);` +`Vec3sp vec3i_to_vec3s(OUT Vec3s dest, Vec3i a);` [:arrow_up_small:](#) @@ -6197,7 +6197,7 @@ Sets the components of the 3D short integer vector `v` to 0 [Vec3s](structs.md#Vec3s) ### C Prototype -`Vec3sp vec3s_zero(Vec3s v);` +`Vec3sp vec3s_zero(OUT Vec3s v);` [: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) ### C Prototype -`Vec3sp vec3s_copy(Vec3s dest, Vec3s src);` +`Vec3sp vec3s_copy(OUT Vec3s dest, Vec3s src);` [: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) ### 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:](#) @@ -6271,7 +6271,7 @@ Adds the components of the 3D short integer vector `a` to `dest` [Vec3s](structs.md#Vec3s) ### C Prototype -`Vec3sp vec3s_add(Vec3s dest, Vec3s a);` +`Vec3sp vec3s_add(OUT Vec3s dest, Vec3s a);` [: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) ### C Prototype -`Vec3sp vec3s_sum(Vec3s dest, Vec3s a, Vec3s b);` +`Vec3sp vec3s_sum(OUT Vec3s dest, Vec3s a, Vec3s b);` [:arrow_up_small:](#) @@ -6320,7 +6320,7 @@ Subtracts the components of the 3D short integer vector `a` from `dest` [Vec3s](structs.md#Vec3s) ### C Prototype -`Vec3sp vec3s_sub(Vec3s dest, Vec3s a);` +`Vec3sp vec3s_sub(OUT Vec3s dest, Vec3s a);` [:arrow_up_small:](#) @@ -6345,7 +6345,7 @@ Subtracts the components of the 3D short integer vector `b` from the components [Vec3s](structs.md#Vec3s) ### C Prototype -`Vec3sp vec3s_dif(Vec3s dest, Vec3s a, Vec3s b);` +`Vec3sp vec3s_dif(OUT Vec3s dest, Vec3s a, Vec3s b);` [: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) ### C Prototype -`Vec3sp vec3s_mul(Vec3s dest, f32 a);` +`Vec3sp vec3s_mul(OUT Vec3s dest, f32 a);` [:arrow_up_small:](#) @@ -6393,7 +6393,7 @@ Multiplies the components of the 3D short integer vector `dest` with the compone [Vec3s](structs.md#Vec3s) ### C Prototype -`Vec3sp vec3s_mult(Vec3s dest, Vec3s a);` +`Vec3sp vec3s_mult(OUT Vec3s dest, Vec3s a);` [: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) ### C Prototype -`Vec3sp vec3s_prod(Vec3s dest, Vec3s a, Vec3s b);` +`Vec3sp vec3s_prod(OUT Vec3s dest, Vec3s a, Vec3s b);` [: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) ### C Prototype -`Vec3sp vec3s_div(Vec3s dest, f32 a);` +`Vec3sp vec3s_div(OUT Vec3s dest, f32 a);` [:arrow_up_small:](#) @@ -6488,7 +6488,7 @@ Normalizes the 3D short integer vector `v` so that its length (magnitude) become [Vec3s](structs.md#Vec3s) ### C Prototype -`Vec3sp vec3s_normalize(Vec3s v);` +`Vec3sp vec3s_normalize(OUT Vec3s v);` [:arrow_up_small:](#) @@ -6512,7 +6512,7 @@ Sets the length (magnitude) of 3D short integer vector `v`, while retaining its [Vec3s](structs.md#Vec3s) ### C Prototype -`Vec3sp vec3s_set_magnitude(Vec3s v, f32 mag);` +`Vec3sp vec3s_set_magnitude(OUT Vec3s v, f32 mag);` [: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) ### C Prototype -`Vec3sp vec3s_cross(Vec3s dest, Vec3s a, Vec3s b);` +`Vec3sp vec3s_cross(OUT Vec3s dest, Vec3s a, Vec3s b);` [:arrow_up_small:](#) @@ -6588,7 +6588,7 @@ Takes two 3D short integer vectors `vecA` and `vecB`, multiplies them by `sclA` [Vec3s](structs.md#Vec3s) ### 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:](#) @@ -6683,7 +6683,7 @@ Converts a 3D short integer vector `a` into a 3D floating-point vector and store [Vec3f](structs.md#Vec3f) ### C Prototype -`Vec3fp vec3s_to_vec3f(Vec3f dest, Vec3s a);` +`Vec3fp vec3s_to_vec3f(OUT Vec3f dest, Vec3s a);` [: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) ### C Prototype -`Vec3ip vec3s_to_vec3i(Vec3i dest, Vec3s a);` +`Vec3ip vec3s_to_vec3i(OUT Vec3i dest, Vec3s a);` [:arrow_up_small:](#) diff --git a/docs/lua/functions-5.md b/docs/lua/functions-5.md index f2a39d725..c83e04386 100644 --- a/docs/lua/functions-5.md +++ b/docs/lua/functions-5.md @@ -214,7 +214,7 @@ Linearly interpolates `res` between `a` and `b` with `delta` - None ### 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:](#) @@ -240,7 +240,7 @@ Linearly interpolates `res` between `a` and `b` with `delta` - None ### 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:](#) @@ -1615,7 +1615,7 @@ Finds any wall collisions and returns what the displacement vector would be. - `integer` ### 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:](#) @@ -2929,7 +2929,7 @@ Overrides the current room Mario is in. Set to -1 to reset override - None ### 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:](#) @@ -2951,7 +2951,7 @@ Overrides the current room Mario is in. Set to -1 to reset override - None ### 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:](#) @@ -3625,7 +3625,7 @@ Multiplies a vector by a matrix of the form: `| ? ? ? 0 |` `| ? ? ? 0 |` `| ? ? - None ### 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:](#) @@ -3650,7 +3650,7 @@ Multiplies a vector by the transpose of a matrix of the form: `| ? ? ? 0 |` `| ? - None ### 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:](#) @@ -8077,7 +8077,7 @@ Retrieves the current position of Mario's cap, if it is on the ground in the cur - `integer` ### C Prototype -`s32 save_file_get_cap_pos(Vec3s capPos);` +`s32 save_file_get_cap_pos(OUT Vec3s capPos);` [:arrow_up_small:](#) diff --git a/docs/lua/functions-6.md b/docs/lua/functions-6.md index 81ec58fe7..7fb4b0148 100644 --- a/docs/lua/functions-6.md +++ b/docs/lua/functions-6.md @@ -4284,7 +4284,7 @@ Retrieves the animated part position associated to `animPart` from the MarioStat - `boolean` ### 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:](#) @@ -7350,7 +7350,7 @@ Gets the closest point of the triangle to `src` and returns it in `out`. - None ### 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:](#) diff --git a/docs/lua/functions.md b/docs/lua/functions.md index cbcc0f899..d6f5ac591 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -51,7 +51,6 @@ - [spawn_wind_particles](functions-2.md#spawn_wind_particles) - [check_if_moving_over_floor](functions-2.md#check_if_moving_over_floor) - [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) - [play_penguin_walking_sound](functions-2.md#play_penguin_walking_sound) - [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) - [object_pos_to_vec3f](functions-3.md#object_pos_to_vec3f) - [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) - [set_cam_angle](functions-3.md#set_cam_angle) - [set_handheld_shake](functions-3.md#set_handheld_shake) diff --git a/include/types.h b/include/types.h index 5995ba5b9..a891f6cda 100644 --- a/include/types.h +++ b/include/types.h @@ -40,6 +40,10 @@ struct Controller 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 s16 Vec2s[2]; typedef s32 Vec2i[2]; diff --git a/src/engine/lighting_engine.c b/src/engine/lighting_engine.c index 9384e43de..9c3af3f10 100644 --- a/src/engine/lighting_engine.c +++ b/src/engine/lighting_engine.c @@ -17,7 +17,7 @@ static inline void color_set(Color color, u8 r, u8 g, u8 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; } #ifdef LE_TOTAL_WEIGHTED_LIGHTING @@ -56,7 +56,7 @@ void le_calculate_vertex_lighting(Vtx_t* v, Color out) { #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; } #ifdef LE_TOTAL_WEIGHTED_LIGHTING @@ -95,7 +95,7 @@ void le_calculate_lighting_color(Vec3f pos, Color out, f32 lightIntensityScalar) #endif } -void le_calculate_lighting_dir(Vec3f pos, Vec3f out) { +void le_calculate_lighting_dir(Vec3f pos, OUT Vec3f out) { if (sLights == NULL) { return; } Vec3f lightingDir = { 0, 0, 0 }; diff --git a/src/engine/lighting_engine.h b/src/engine/lighting_engine.h index d0a99dc9e..72540cc31 100644 --- a/src/engine/lighting_engine.h +++ b/src/engine/lighting_engine.h @@ -15,11 +15,11 @@ struct LELight 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|*/ -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| */ -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| */ 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| */ diff --git a/src/engine/math_util.c b/src/engine/math_util.c index 7fe0d038c..0cb6231c6 100644 --- a/src/engine/math_util.c +++ b/src/engine/math_util.c @@ -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] * 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; } f32 tinv = 1 - t; 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. * 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; } Vec4f weights = { 0 }; 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 * 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] }; f32 sx = sins(rotate[0]); @@ -270,7 +270,7 @@ OPTIMIZE_O3 Vec3fp vec3f_rotate_zxy(Vec3f dest, Vec3s rotate) { // Rodrigues' formula // 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_cross(nvCross, 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; } -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 denominator = vec3f_dot(onto, onto); if (denominator == 0) { @@ -294,7 +294,7 @@ OPTIMIZE_O3 Vec3fp vec3f_project(Vec3f dest, Vec3f v, Vec3f onto) { 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); // 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, * 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[1] = from[1] + dist * sins(pitch); 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) * 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[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]); @@ -388,7 +388,7 @@ Mat4 gMat4Zero = { * 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. */ -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; f32 sinRoll, cosRoll; 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 * 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 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 * 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 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 * '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][1] = sins(angle); 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 -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][1] = sins(angle); 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 * '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 leftDir; 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 * '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; Vec3f point0; 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 * 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; for (s32 i = 0; i < 4; i++) { 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 * 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 y = b[1]; 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. */ -OPTIMIZE_O3 void mtxf_rotate_xy(Mat4 mtx, s16 angle) { +OPTIMIZE_O3 void mtxf_rotate_xy(OUT Mat4 mtx, s16 angle) { mtxf_identity(mtx); mtx[0][0] = coss(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 * 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; // 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 * 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 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]; diff --git a/src/engine/math_util.h b/src/engine/math_util.h index 0289367d6..838fa58ce 100644 --- a/src/engine/math_util.h +++ b/src/engine/math_util.h @@ -131,7 +131,7 @@ OPTIMIZE_O3 f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec); /* |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 |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| 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| 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| */ -OPTIMIZE_O3 s32 anim_spline_poll(struct MarioState* m, Vec3f result); +OPTIMIZE_O3 s32 anim_spline_poll(struct MarioState* m, OUT Vec3f result); /////////// // Vec3f // @@ -152,22 +152,22 @@ OPTIMIZE_O3 s32 anim_spline_poll(struct MarioState* m, Vec3f result); /* |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` |descriptionEnd| */ -OPTIMIZE_O3 Vec3fp vec3f_rotate_zxy(Vec3f v, Vec3s rotate); +OPTIMIZE_O3 Vec3fp vec3f_rotate_zxy(OUT Vec3f v, Vec3s rotate); /* |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` |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| 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| */ -OPTIMIZE_O3 Vec3fp vec3f_project(Vec3f dest, Vec3f v, Vec3f onto); +OPTIMIZE_O3 Vec3fp vec3f_project(OUT Vec3f dest, Vec3f v, Vec3f onto); /* |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` |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| 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| 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| */ -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| 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| */ -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 // @@ -205,62 +205,62 @@ OPTIMIZE_O3 Vec3fp find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f /* |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` |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| 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| */ -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| 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| */ -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| 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| */ -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| 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| */ -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| 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| */ -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| 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| */ -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| 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| */ -OPTIMIZE_O3 void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b); +OPTIMIZE_O3 void mtxf_mul(OUT Mat4 dest, Mat4 a, Mat4 b); /* |description| Multiplies the 3D signed-integer vector `b` with the 4x4 floating-point matrix `mtx`, which applies the transformation to the point |descriptionEnd| */ -OPTIMIZE_O3 s16 *mtxf_mul_vec3s(Mat4 mtx, Vec3s b); +OPTIMIZE_O3 Vec3sp mtxf_mul_vec3s(Mat4 mtx, OUT Vec3s b); /* |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 |descriptionEnd| */ -OPTIMIZE_O3 void mtxf_rotate_xy(Mat4 mtx, s16 angle); +OPTIMIZE_O3 void mtxf_rotate_xy(OUT Mat4 mtx, s16 angle); /* |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 |descriptionEnd| */ -OPTIMIZE_O3 void mtxf_inverse(Mat4 dest, Mat4 src); +OPTIMIZE_O3 void mtxf_inverse(OUT Mat4 dest, Mat4 src); /* |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 |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 diff --git a/src/engine/math_util_mat4.inl b/src/engine/math_util_mat4.inl index b2088e474..f1fe8faef 100644 --- a/src/engine/math_util_mat4.inl +++ b/src/engine/math_util_mat4.inl @@ -14,28 +14,28 @@ optimizations and bug reports. Sets the 4x4 floating-point matrix `mtx` to all zeros. Unless you really need this-It's reccomended to use mtxf_identity instead. |descriptionEnd| */ -INLINE OPTIMIZE_O3 void mtxf_zero(Mat4 mtx) { +INLINE OPTIMIZE_O3 void mtxf_zero(OUT Mat4 mtx) { memset(mtx, 0, sizeof(Mat4)); } /* |description| Copies the 4x4 floating-point matrix `src` into `dest`. After this operation, `dest` contains the same matrix values as `src` |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)); } /* |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 |descriptionEnd| */ -INLINE OPTIMIZE_O3 void mtxf_identity(Mat4 mtx) { +INLINE OPTIMIZE_O3 void mtxf_identity(OUT Mat4 mtx) { mtxf_copy(mtx, gMat4Identity); } /* |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| */ -INLINE OPTIMIZE_O3 void mtxf_translate(Mat4 dest, Vec3f b) { +INLINE OPTIMIZE_O3 void mtxf_translate(OUT Mat4 dest, Vec3f b) { mtxf_identity(dest); vec3f_copy(dest[3], b); } @@ -43,7 +43,7 @@ INLINE OPTIMIZE_O3 void mtxf_translate(Mat4 dest, Vec3f b) { /* |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 |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); vec3f_mul(dest[0], s[0]); vec3f_mul(dest[1], s[1]); diff --git a/src/engine/math_util_vec3.tmpl b/src/engine/math_util_vec3.tmpl index 083a8ae6a..e111079e1 100644 --- a/src/engine/math_util_vec3.tmpl +++ b/src/engine/math_util_vec3.tmpl @@ -3,7 +3,7 @@ /* |description| Sets the components of the 3D {{desc}} vector `v` to 0 |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}})); return v; } @@ -11,7 +11,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_zero(Vec3{{suffix}} v) { /* |description| Copies the contents of a 3D {{desc}} vector (`src`) into another 3D {{desc}} vector (`dest`) |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[1] = src[1]; dest[2] = src[2]; @@ -21,7 +21,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_copy(Vec3{{suffix}} dest, Vec3 /* |description| Sets the values of the 3D {{desc}} vector `dest` to the given x, y, and z values |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[1] = y; dest[2] = z; @@ -31,7 +31,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_set(Vec3{{suffix}} dest, {{typ /* |description| Adds the components of the 3D {{desc}} vector `a` to `dest` |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[1] += a[1]; dest[2] += a[2]; @@ -41,7 +41,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_add(Vec3{{suffix}} dest, Vec3{ /* |description| Adds the components of two 3D {{desc}} vectors `a` and `b` and stores the result in `dest` |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[1] = a[1] + b[1]; dest[2] = a[2] + b[2]; @@ -51,7 +51,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_sum(Vec3{{suffix}} dest, Vec3{ /* |description| Subtracts the components of the 3D {{desc}} vector `a` from `dest` |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[1] -= a[1]; dest[2] -= a[2]; @@ -61,7 +61,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_sub(Vec3{{suffix}} dest, Vec3{ /* |description| Subtracts the components of the 3D {{desc}} vector `b` from the components of `a` and stores the result in `dest` |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[1] = a[1] - b[1]; dest[2] = a[2] - b[2]; @@ -71,7 +71,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_dif(Vec3{{suffix}} dest, Vec3{ /* |description| Multiplies each component of the 3D {{desc}} vector `dest` by the scalar value `a` |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[1] *= a; dest[2] *= a; @@ -81,7 +81,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_mul(Vec3{{suffix}} dest, f32 a /* |description| Multiplies the components of the 3D {{desc}} vector `dest` with the components of `a` |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[1] *= a[1]; dest[2] *= a[2]; @@ -91,7 +91,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_mult(Vec3{{suffix}} dest, Vec3 /* |description| Multiplies the components of two 3D {{desc}} vectors `a` and `b` and stores the result in `dest` |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[1] = a[1] * b[1]; dest[2] = a[2] * b[2]; @@ -101,7 +101,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_prod(Vec3{{suffix}} dest, Vec3 /* |description| Divides each component of the 3D {{desc}} vector `dest` by the scalar value `a` |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; } dest[0] /= a; dest[1] /= a; @@ -119,7 +119,7 @@ INLINE OPTIMIZE_O3 f32 vec3{{suffix}}_length(Vec3{{suffix}} a) { /* |description| Normalizes the 3D {{desc}} vector `v` so that its length (magnitude) becomes 1, while retaining its direction |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); vec3{{suffix}}_div(v, mag); return v; @@ -128,7 +128,7 @@ INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_normalize(Vec3{{suffix}} v) { /* |description| Sets the length (magnitude) of 3D {{desc}} vector `v`, while retaining its direction |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}}_mul(v, mag); return v; @@ -144,7 +144,7 @@ INLINE OPTIMIZE_O3 f32 vec3{{suffix}}_dot(Vec3{{suffix}} a, Vec3{{suffix}} b) { /* |description| Computes the cross product of two 3D {{desc}} vectors `a` and `b` and stores the result in `dest` |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[1] = a[2] * b[0] - b[2] * a[0]; 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| 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| */ -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[1] = vecA[1] * sclA + vecB[1] * sclB; dest[2] = vecA[2] * sclA + vecB[2] * sclB; diff --git a/src/engine/math_util_vec3f.inl b/src/engine/math_util_vec3f.inl index d6b4bacf6..5756cb0d4 100644 --- a/src/engine/math_util_vec3f.inl +++ b/src/engine/math_util_vec3f.inl @@ -6,7 +6,7 @@ /* |description| Sets the components of the 3D floating-point vector `v` to 0 |descriptionEnd| */ -INLINE OPTIMIZE_O3 Vec3fp vec3f_zero(Vec3f v) { +INLINE OPTIMIZE_O3 Vec3fp vec3f_zero(OUT Vec3f v) { memset(v, 0, sizeof(Vec3f)); return v; } @@ -14,7 +14,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_zero(Vec3f v) { /* |description| Copies the contents of a 3D floating-point vector (`src`) into another 3D floating-point vector (`dest`) |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[1] = src[1]; dest[2] = src[2]; @@ -24,7 +24,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_copy(Vec3f dest, Vec3f src) { /* |description| Sets the values of the 3D floating-point vector `dest` to the given x, y, and z values |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[1] = y; dest[2] = z; @@ -34,7 +34,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_set(Vec3f dest, f32 x, f32 y, f32 z) { /* |description| Adds the components of the 3D floating-point vector `a` to `dest` |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[1] += a[1]; dest[2] += a[2]; @@ -44,7 +44,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_add(Vec3f dest, Vec3f a) { /* |description| Adds the components of two 3D floating-point vectors `a` and `b` and stores the result in `dest` |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[1] = a[1] + b[1]; dest[2] = a[2] + b[2]; @@ -54,7 +54,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_sum(Vec3f dest, Vec3f a, Vec3f b) { /* |description| Subtracts the components of the 3D floating-point vector `a` from `dest` |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[1] -= a[1]; dest[2] -= a[2]; @@ -64,7 +64,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_sub(Vec3f dest, Vec3f a) { /* |description| Subtracts the components of the 3D floating-point vector `b` from the components of `a` and stores the result in `dest` |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[1] = a[1] - b[1]; dest[2] = a[2] - b[2]; @@ -74,7 +74,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_dif(Vec3f dest, Vec3f a, Vec3f b) { /* |description| Multiplies each component of the 3D floating-point vector `dest` by the scalar value `a` |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[1] *= a; dest[2] *= a; @@ -84,7 +84,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_mul(Vec3f dest, f32 a) { /* |description| Multiplies the components of the 3D floating-point vector `dest` with the components of `a` |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[1] *= a[1]; dest[2] *= a[2]; @@ -94,7 +94,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_mult(Vec3f dest, Vec3f a) { /* |description| Multiplies the components of two 3D floating-point vectors `a` and `b` and stores the result in `dest` |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[1] = a[1] * b[1]; dest[2] = a[2] * b[2]; @@ -104,7 +104,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_prod(Vec3f dest, Vec3f a, Vec3f b) { /* |description| Divides each component of the 3D floating-point vector `dest` by the scalar value `a` |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; } dest[0] /= a; dest[1] /= a; @@ -122,7 +122,7 @@ INLINE OPTIMIZE_O3 f32 vec3f_length(Vec3f a) { /* |description| Normalizes the 3D floating-point vector `v` so that its length (magnitude) becomes 1, while retaining its direction |descriptionEnd| */ -INLINE OPTIMIZE_O3 Vec3fp vec3f_normalize(Vec3f v) { +INLINE OPTIMIZE_O3 Vec3fp vec3f_normalize(OUT Vec3f v) { f32 mag = vec3f_length(v); vec3f_div(v, mag); return v; @@ -131,7 +131,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3f_normalize(Vec3f v) { /* |description| Sets the length (magnitude) of 3D floating-point vector `v`, while retaining its direction |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_mul(v, mag); return v; @@ -147,7 +147,7 @@ INLINE OPTIMIZE_O3 f32 vec3f_dot(Vec3f a, Vec3f b) { /* |description| Computes the cross product of two 3D floating-point vectors `a` and `b` and stores the result in `dest` |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[1] = a[2] * b[0] - b[2] * a[0]; 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| 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| */ -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[1] = vecA[1] * sclA + vecB[1] * sclB; dest[2] = vecA[2] * sclA + vecB[2] * sclB; @@ -191,7 +191,7 @@ INLINE OPTIMIZE_O3 bool vec3f_is_zero(Vec3f v) { /* |description| Converts a 3D floating-point vector `a` into a 3D integer vector and stores the result in `dest` |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[1] = a[1] + ((a[1] > 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| Converts a 3D floating-point vector `a` into a 3D short integer vector and stores the result in `dest` |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[1] = a[1] + ((a[1] > 0) ? 0.5f : -0.5f); dest[2] = a[2] + ((a[2] > 0) ? 0.5f : -0.5f); diff --git a/src/engine/math_util_vec3i.inl b/src/engine/math_util_vec3i.inl index 607f7137c..b7de7da32 100644 --- a/src/engine/math_util_vec3i.inl +++ b/src/engine/math_util_vec3i.inl @@ -6,7 +6,7 @@ /* |description| Sets the components of the 3D integer vector `v` to 0 |descriptionEnd| */ -INLINE OPTIMIZE_O3 Vec3ip vec3i_zero(Vec3i v) { +INLINE OPTIMIZE_O3 Vec3ip vec3i_zero(OUT Vec3i v) { memset(v, 0, sizeof(Vec3i)); return v; } @@ -14,7 +14,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_zero(Vec3i v) { /* |description| Copies the contents of a 3D integer vector (`src`) into another 3D integer vector (`dest`) |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[1] = src[1]; dest[2] = src[2]; @@ -24,7 +24,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_copy(Vec3i dest, Vec3i src) { /* |description| Sets the values of the 3D integer vector `dest` to the given x, y, and z values |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[1] = y; dest[2] = z; @@ -34,7 +34,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_set(Vec3i dest, s32 x, s32 y, s32 z) { /* |description| Adds the components of the 3D integer vector `a` to `dest` |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[1] += a[1]; dest[2] += a[2]; @@ -44,7 +44,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_add(Vec3i dest, Vec3i a) { /* |description| Adds the components of two 3D integer vectors `a` and `b` and stores the result in `dest` |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[1] = a[1] + b[1]; dest[2] = a[2] + b[2]; @@ -54,7 +54,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_sum(Vec3i dest, Vec3i a, Vec3i b) { /* |description| Subtracts the components of the 3D integer vector `a` from `dest` |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[1] -= a[1]; dest[2] -= a[2]; @@ -64,7 +64,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_sub(Vec3i dest, Vec3i a) { /* |description| Subtracts the components of the 3D integer vector `b` from the components of `a` and stores the result in `dest` |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[1] = a[1] - b[1]; dest[2] = a[2] - b[2]; @@ -74,7 +74,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_dif(Vec3i dest, Vec3i a, Vec3i b) { /* |description| Multiplies each component of the 3D integer vector `dest` by the scalar value `a` |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[1] *= a; dest[2] *= a; @@ -84,7 +84,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_mul(Vec3i dest, f32 a) { /* |description| Multiplies the components of the 3D integer vector `dest` with the components of `a` |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[1] *= a[1]; dest[2] *= a[2]; @@ -94,7 +94,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_mult(Vec3i dest, Vec3i a) { /* |description| Multiplies the components of two 3D integer vectors `a` and `b` and stores the result in `dest` |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[1] = a[1] * b[1]; dest[2] = a[2] * b[2]; @@ -104,7 +104,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_prod(Vec3i dest, Vec3i a, Vec3i b) { /* |description| Divides each component of the 3D integer vector `dest` by the scalar value `a` |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; } dest[0] /= a; dest[1] /= a; @@ -122,7 +122,7 @@ INLINE OPTIMIZE_O3 f32 vec3i_length(Vec3i a) { /* |description| Normalizes the 3D integer vector `v` so that its length (magnitude) becomes 1, while retaining its direction |descriptionEnd| */ -INLINE OPTIMIZE_O3 Vec3ip vec3i_normalize(Vec3i v) { +INLINE OPTIMIZE_O3 Vec3ip vec3i_normalize(OUT Vec3i v) { f32 mag = vec3i_length(v); vec3i_div(v, mag); return v; @@ -131,7 +131,7 @@ INLINE OPTIMIZE_O3 Vec3ip vec3i_normalize(Vec3i v) { /* |description| Sets the length (magnitude) of 3D integer vector `v`, while retaining its direction |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_mul(v, mag); return v; @@ -147,7 +147,7 @@ INLINE OPTIMIZE_O3 f32 vec3i_dot(Vec3i a, Vec3i b) { /* |description| Computes the cross product of two 3D integer vectors `a` and `b` and stores the result in `dest` |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[1] = a[2] * b[0] - b[2] * a[0]; 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| 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| */ -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[1] = vecA[1] * sclA + vecB[1] * sclB; dest[2] = vecA[2] * sclA + vecB[2] * sclB; @@ -191,7 +191,7 @@ INLINE OPTIMIZE_O3 bool vec3i_is_zero(Vec3i v) { /* |description| Converts a 3D integer vector `a` into a 3D floating-point vector and stores the result in `dest` |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[1] = a[1]; dest[2] = a[2]; @@ -201,7 +201,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3i_to_vec3f(Vec3f dest, Vec3i a) { /* |description| Converts a 3D integer vector `a` into a 3D short integer vector and stores the result in `dest` |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[1] = a[1]; dest[2] = a[2]; diff --git a/src/engine/math_util_vec3s.inl b/src/engine/math_util_vec3s.inl index 28406a7ae..392d87eb2 100644 --- a/src/engine/math_util_vec3s.inl +++ b/src/engine/math_util_vec3s.inl @@ -6,7 +6,7 @@ /* |description| Sets the components of the 3D short integer vector `v` to 0 |descriptionEnd| */ -INLINE OPTIMIZE_O3 Vec3sp vec3s_zero(Vec3s v) { +INLINE OPTIMIZE_O3 Vec3sp vec3s_zero(OUT Vec3s v) { memset(v, 0, sizeof(Vec3s)); return v; } @@ -14,7 +14,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_zero(Vec3s v) { /* |description| Copies the contents of a 3D short integer vector (`src`) into another 3D short integer vector (`dest`) |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[1] = src[1]; dest[2] = src[2]; @@ -24,7 +24,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_copy(Vec3s dest, Vec3s src) { /* |description| Sets the values of the 3D short integer vector `dest` to the given x, y, and z values |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[1] = y; dest[2] = z; @@ -34,7 +34,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_set(Vec3s dest, s16 x, s16 y, s16 z) { /* |description| Adds the components of the 3D short integer vector `a` to `dest` |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[1] += a[1]; dest[2] += a[2]; @@ -44,7 +44,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_add(Vec3s dest, Vec3s a) { /* |description| Adds the components of two 3D short integer vectors `a` and `b` and stores the result in `dest` |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[1] = a[1] + b[1]; dest[2] = a[2] + b[2]; @@ -54,7 +54,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_sum(Vec3s dest, Vec3s a, Vec3s b) { /* |description| Subtracts the components of the 3D short integer vector `a` from `dest` |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[1] -= a[1]; dest[2] -= a[2]; @@ -64,7 +64,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_sub(Vec3s dest, Vec3s a) { /* |description| Subtracts the components of the 3D short integer vector `b` from the components of `a` and stores the result in `dest` |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[1] = a[1] - b[1]; dest[2] = a[2] - b[2]; @@ -74,7 +74,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_dif(Vec3s dest, Vec3s a, Vec3s b) { /* |description| Multiplies each component of the 3D short integer vector `dest` by the scalar value `a` |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[1] *= a; dest[2] *= a; @@ -84,7 +84,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_mul(Vec3s dest, f32 a) { /* |description| Multiplies the components of the 3D short integer vector `dest` with the components of `a` |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[1] *= a[1]; dest[2] *= a[2]; @@ -94,7 +94,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_mult(Vec3s dest, Vec3s a) { /* |description| Multiplies the components of two 3D short integer vectors `a` and `b` and stores the result in `dest` |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[1] = a[1] * b[1]; dest[2] = a[2] * b[2]; @@ -104,7 +104,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_prod(Vec3s dest, Vec3s a, Vec3s b) { /* |description| Divides each component of the 3D short integer vector `dest` by the scalar value `a` |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; } dest[0] /= a; dest[1] /= a; @@ -122,7 +122,7 @@ INLINE OPTIMIZE_O3 f32 vec3s_length(Vec3s a) { /* |description| Normalizes the 3D short integer vector `v` so that its length (magnitude) becomes 1, while retaining its direction |descriptionEnd| */ -INLINE OPTIMIZE_O3 Vec3sp vec3s_normalize(Vec3s v) { +INLINE OPTIMIZE_O3 Vec3sp vec3s_normalize(OUT Vec3s v) { f32 mag = vec3s_length(v); vec3s_div(v, mag); return v; @@ -131,7 +131,7 @@ INLINE OPTIMIZE_O3 Vec3sp vec3s_normalize(Vec3s v) { /* |description| Sets the length (magnitude) of 3D short integer vector `v`, while retaining its direction |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_mul(v, mag); return v; @@ -147,7 +147,7 @@ INLINE OPTIMIZE_O3 f32 vec3s_dot(Vec3s a, Vec3s b) { /* |description| Computes the cross product of two 3D short integer vectors `a` and `b` and stores the result in `dest` |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[1] = a[2] * b[0] - b[2] * a[0]; 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| 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| */ -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[1] = vecA[1] * sclA + vecB[1] * sclB; dest[2] = vecA[2] * sclA + vecB[2] * sclB; @@ -191,7 +191,7 @@ INLINE OPTIMIZE_O3 bool vec3s_is_zero(Vec3s v) { /* |description| Converts a 3D short integer vector `a` into a 3D floating-point vector and stores the result in `dest` |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[1] = a[1]; dest[2] = a[2]; @@ -201,7 +201,7 @@ INLINE OPTIMIZE_O3 Vec3fp vec3s_to_vec3f(Vec3f dest, Vec3s a) { /* |description| Converts a 3D short integer vector `a` into a 3D integer vector and stores the result in `dest` |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[1] = a[1]; dest[2] = a[2]; diff --git a/src/engine/surface_collision.c b/src/engine/surface_collision.c index ae30de925..7061380bd 100644 --- a/src/engine/surface_collision.c +++ b/src/engine/surface_collision.c @@ -25,7 +25,7 @@ void set_find_wall_direction(Vec3f dir, bool active, bool 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 v2; vec3s_to_vec3f(v2, surf->vertex2); Vec3f v3; vec3s_to_vec3f(v3, surf->vertex3); diff --git a/src/engine/surface_collision.h b/src/engine/surface_collision.h index 94a576ff1..d954b847b 100644 --- a/src/engine/surface_collision.h +++ b/src/engine/surface_collision.h @@ -87,6 +87,6 @@ void set_find_wall_direction(Vec3f dir, bool active, bool airborne); /* |description| Gets the closest point of the triangle to `src` and returns it in `out`. |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 diff --git a/src/game/behavior_actions.c b/src/game/behavior_actions.c index e4e6c987f..e6c358df8 100644 --- a/src/game/behavior_actions.c +++ b/src/game/behavior_actions.c @@ -204,15 +204,6 @@ void spawn_sparkle_particles(s32 n, s32 a1, s32 a2, s32 r) { #include "behaviors/bullet_bill.inc.c" #include "behaviors/bowser.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/ddd_warp.inc.c" #include "behaviors/water_pillar.inc.c" diff --git a/src/game/behavior_actions.h b/src/game/behavior_actions.h index 968da5949..43af97809 100644 --- a/src/game/behavior_actions.h +++ b/src/game/behavior_actions.h @@ -21,8 +21,6 @@ void spawn_wind_particles(s16 pitch, s16 yaw); 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| */ 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| */ void tox_box_move(f32 forwardVel, f32 a1, s16 deltaPitch, s16 deltaRoll); /* |description|Plays the penguin walking sound|descriptionEnd| */ diff --git a/src/game/behaviors/bowser.inc.c b/src/game/behaviors/bowser.inc.c index 0537a90f9..754af163a 100644 --- a/src/game/behaviors/bowser.inc.c +++ b/src/game/behaviors/bowser.inc.c @@ -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)) { sp22 = D_8032F698[o->oBehParams2ndByte].unk3 + (gDebugInfo[4][1] << 8); 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->oPosZ = D_8032F698[o->oBehParams2ndByte].unk2 + coss(sp22 + 5296) * sp1C; 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->oPosZ = D_8032F698[o->oBehParams2ndByte].unk2 + coss(sp22 - 5296) * sp1C; 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(); if (o->oTimer > 300) diff --git a/src/game/behaviors/checkerboard_platform.inc.c b/src/game/behaviors/checkerboard_platform.inc.c index ab0f6f116..355b7bbd9 100644 --- a/src/game/behaviors/checkerboard_platform.inc.c +++ b/src/game/behaviors/checkerboard_platform.inc.c @@ -25,7 +25,7 @@ void bhv_checkerboard_elevator_group_init(void) { if (sp2C == NULL) { continue; } sp2C->oCheckerBoardPlatformUnk1AC = D_8032F754[sp34].unk2; sp2C->oTimer = 0; - vec3f_copy_2(sp2C->header.gfx.scale, D_8032F754[sp34].unk1); + vec3f_copy(sp2C->header.gfx.scale, D_8032F754[sp34].unk1); } } diff --git a/src/game/behaviors/sl_snowman_wind.inc.c b/src/game/behaviors/sl_snowman_wind.inc.c index 3af531658..baa7bb9ea 100644 --- a/src/game/behaviors/sl_snowman_wind.inc.c +++ b/src/game/behaviors/sl_snowman_wind.inc.c @@ -28,11 +28,11 @@ void bhv_sl_snowman_wind_loop(void) { o->oDistanceToMario = 0; // 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 if (cur_obj_can_mario_activate_textbox(&gMarioStates[0], 1000.0f, 30.0f, 0x7FFF)) o->oSubAction++; - vec3f_copy_2(&o->oPosX, tempPos); + vec3f_copy(&o->oPosX, tempPos); // Mario has come close, begin dialog. } else if (o->oSubAction == SL_SNOWMAN_WIND_ACT_TALKING) { diff --git a/src/game/behaviors/whomp.inc.c b/src/game/behaviors/whomp.inc.c index 75abccbed..3c8f89790 100644 --- a/src/game/behaviors/whomp.inc.c +++ b/src/game/behaviors/whomp.inc.c @@ -160,14 +160,14 @@ void king_whomp_on_ground(void) { if (o->oHealth == 0) o->oAction = 8; else { - vec3f_copy_2(pos, &o->oPosX); + vec3f_copy(pos, &o->oPosX); if (player) { - vec3f_copy_2(&o->oPosX, &player->oPosX); + vec3f_copy(&o->oPosX, &player->oPosX); } spawn_mist_particles_variable(0, 0, 100.0f); spawn_triangle_break_particles(20, 138, 3.0f, 4); cur_obj_shake_screen(SHAKE_POS_SMALL); - vec3f_copy_2(&o->oPosX, pos); + vec3f_copy(&o->oPosX, pos); } o->oSubAction++; } diff --git a/src/game/camera.c b/src/game/camera.c index ab6fcc60d..525d62f6e 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -3788,7 +3788,7 @@ void stub_camera_2(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; } dst[0] = o->oPosX; dst[1] = o->oPosY; @@ -3802,13 +3802,34 @@ void vec3f_to_object_pos(struct Object *o, Vec3f src) { 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; } dst[0] = o->oMoveAnglePitch; dst[1] = o->oMoveAngleYaw; 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, * 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 * 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; Vec3f shakeOffset; Vec3f shakeSpline[4]; @@ -4165,7 +4186,7 @@ s32 update_camera_hud_status(struct Camera *c) { * * @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 Surface *wall = NULL; f32 normX; @@ -4216,7 +4237,7 @@ s32 vec3f_compare(Vec3f pos, f32 posX, f32 posY, f32 posZ) { 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; s16 pitch; 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 * 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(¤t[0], target[0], xMul); approach_f32_asymptotic_bool(¤t[1], target[1], yMul); approach_f32_asymptotic_bool(¤t[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 * 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[1], goal[1], yMul); 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 * 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(¤t[0], target[0], xMul); approach_s16_asymptotic_bool(¤t[1], target[1], yMul); approach_s16_asymptotic_bool(¤t[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 * 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; UNUSED u8 unused[4]; f32 tempXRange; @@ -4557,7 +4578,7 @@ s16 reduce_by_dist_from_camera(s16 value, f32 maxDist, f32 posX, f32 posY, f32 p 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; 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 * 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; 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. */ -void rotate_in_xz(Vec3f dst, Vec3f src, s16 yaw) { +void rotate_in_xz(OUT Vec3f dst, Vec3f src, s16 yaw) { Vec3f tempVec; 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 * 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_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 */ -void shake_camera_pitch(Vec3f pos, Vec3f focus) { +void shake_camera_pitch(Vec3f pos, OUT Vec3f focus) { f32 dist; s16 pitch; 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 */ -void shake_camera_yaw(Vec3f pos, Vec3f focus) { +void shake_camera_yaw(Vec3f pos, OUT Vec3f focus) { f32 dist; s16 pitch; 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. */ -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 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 */ -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) { s16 yawVelocity; s16 pitchVelocity; @@ -7043,7 +7064,7 @@ s16 camera_course_processing(struct Camera *c) { * Move `pos` between the nearest floor and ceiling * @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; struct Surface *surf; diff --git a/src/game/camera.h b/src/game/camera.h index 6c7efa2dd..bf611d1d3 100644 --- a/src/game/camera.h +++ b/src/game/camera.h @@ -788,7 +788,7 @@ void stub_camera_3(UNUSED struct Camera *c); Converts an object's position to a `Vec3f` format. Useful for aligning object behaviors or interactions with the camera system |descriptionEnd| */ -void object_pos_to_vec3f(Vec3f dst, struct Object *o); +void object_pos_to_vec3f(OUT Vec3f dst, struct Object *o); /* |description| 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| */ 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); /* |description| @@ -820,7 +840,7 @@ void set_handheld_shake(u8 mode); Activates a handheld camera shake effect. Calculates positional and focus adjustments to simulate manual movement |descriptionEnd| */ -void shake_camera_handheld(Vec3f pos, Vec3f focus); +void shake_camera_handheld(Vec3f pos, OUT Vec3f focus); /* |description| 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. Adjusts the camera's position to avoid clipping into walls or obstacles |descriptionEnd| */ -s32 collide_with_walls(Vec3f pos, f32 offsetY, f32 radius); +s32 collide_with_walls(OUT Vec3f pos, f32 offsetY, f32 radius); /* |description| Clamps the camera's pitch angle between a maximum and minimum value. Prevents over-rotation and maintains a consistent viewing angle |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| 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. Scaling values (the `Mul` variables) for x, y, and z axes determine the speed of adjustment for each component |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| 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 |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| 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. Useful for randomized offsets or environmental effects |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| 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 |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| 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 result is stored in the destination vector (`dest`) |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| 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`). Useful for rotating camera positions or object coordinates horizontally |descriptionEnd| */ -void rotate_in_xz(Vec3f dst, Vec3f src, s16 yaw); +void rotate_in_xz(OUT Vec3f dst, Vec3f src, s16 yaw); /* |description| Rotates a vector around the YZ-plane by a specified pitch angle. The result is stored in the destination vector (`dst`). Useful for vertical camera rotations or object transformations |descriptionEnd| */ -void rotate_in_yz(Vec3f dst, Vec3f src, s16 pitch); +void rotate_in_yz(OUT Vec3f dst, Vec3f src, s16 pitch); /* |description| 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. Adds vertical vibrational movement to the camera's behavior |descriptionEnd| */ -void shake_camera_pitch(Vec3f pos, Vec3f focus); +void shake_camera_pitch(Vec3f pos, OUT Vec3f focus); /* |description| Activates a yaw-based shake effect. Adds horizontal vibrational movement to the camera's behavior |descriptionEnd| */ -void shake_camera_yaw(Vec3f pos, Vec3f focus); +void shake_camera_yaw(Vec3f pos, OUT Vec3f focus); /* |description| 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. This is useful for creating radial effects or dynamic transformations |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| Transitions the camera to the next Lakitu state, updating position and focus. This function handles smooth transitions between different gameplay scenarios |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| */ 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. Adjusts the camera's position to prevent clipping or intersecting with objects |descriptionEnd| */ -void resolve_geometry_collisions(Vec3f pos, UNUSED Vec3f lastGood); +void resolve_geometry_collisions(OUT Vec3f pos, UNUSED Vec3f lastGood); /* |description| Rotates the camera to avoid walls or other obstructions. diff --git a/src/game/mario.c b/src/game/mario.c index c2dcb9a73..9c42ffc36 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -200,7 +200,7 @@ s32 is_anim_past_frame(struct MarioState *m, s16 animFrame) { * Rotates the animation's translation into the global coordinate system * 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; } f32 dx; f32 dz; @@ -618,7 +618,7 @@ u32 mario_get_terrain_sound_addend(struct MarioState *m) { /** * 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 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. */ -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; } collisionData->x = pos[0]; diff --git a/src/game/mario.h b/src/game/mario.h index 56fd6ec34..e0e4656cf 100644 --- a/src/game/mario.h +++ b/src/game/mario.h @@ -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`. Useful for determining positional offsets from animations (e.g., stepping forward in a walk animation) and applying them to Mario's position |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| 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. Useful for collision detection when updating Mario's movement or adjusting his position |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| 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| */ -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_mario_ceil(Vec3f pos, f32 height, struct Surface **ceil); diff --git a/src/game/mario_actions_automatic.c b/src/game/mario_actions_automatic.c index 8c32fd92c..64a1566d3 100644 --- a/src/game/mario_actions_automatic.c +++ b/src/game/mario_actions_automatic.c @@ -344,7 +344,7 @@ s32 act_top_of_pole(struct MarioState *m) { /* |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 |descriptionEnd| */ -s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos) { +s32 perform_hanging_step(struct MarioState *m, OUT Vec3f nextPos) { if (!m) { return 0; } UNUSED s32 unused; struct Surface *ceil; diff --git a/src/game/mario_actions_submerged.c b/src/game/mario_actions_submerged.c index d344627ab..dfe323559 100644 --- a/src/game/mario_actions_submerged.c +++ b/src/game/mario_actions_submerged.c @@ -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| */ -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; } struct WallCollisionData wcd = { 0 }; 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| */ -void apply_water_current(struct MarioState *m, Vec3f step) { +void apply_water_current(struct MarioState *m, OUT Vec3f step) { if (!m) { return; } s32 i; f32 whirlpoolRadius = 2000.0f; diff --git a/src/game/obj_behaviors.c b/src/game/obj_behaviors.c index 8337e5c71..fc223d8dd 100644 --- a/src/game/obj_behaviors.c +++ b/src/game/obj_behaviors.c @@ -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| */ -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; UNUSED u8 filler[0x20]; diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index a1008cdbe..f95018748 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -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]; } -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; } dst[0][0] = src[0][0] * obj->header.gfx.scale[0]; 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]; } -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; 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 |` i.e. a matrix representing a linear transformation over 3 space |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; for (i = 0; i < 3; i++) { 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 |` i.e. a matrix representing a linear transformation over 3 space |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; for (i = 0; i < 3; i++) { dst[i] = m[i][0] * v[0] + m[i][1] * v[1] + m[i][2] * v[2]; diff --git a/src/game/object_helpers.h b/src/game/object_helpers.h index 6298ad44c..9e4a32df0 100644 --- a/src/game/object_helpers.h +++ b/src/game/object_helpers.h @@ -73,8 +73,8 @@ Gfx *geo_switch_area(s32 callContext, struct GraphNode *node); #endif 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_apply_scale_to_matrix(struct Object *obj, Mat4 dst, Mat4 src); -void create_transformation_from_matrices(Mat4 a0, Mat4 a1, Mat4 a2); +void obj_apply_scale_to_matrix(struct Object *obj, OUT Mat4 dst, Mat4 src); +void create_transformation_from_matrices(OUT Mat4 a0, Mat4 a1, Mat4 a2); void obj_set_held_state(struct Object *obj, const BehaviorScript *heldBehavior); f32 lateral_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_angle(struct Object *dst, struct Object *src); void obj_set_gfx_pos_from_pos(struct Object *obj); -void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v); -void linear_mtxf_transpose_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, OUT Vec3f dst, Vec3f v); void obj_apply_scale_to_transform(struct Object *obj); void obj_copy_scale(struct Object *dst, struct Object *src); void obj_scale_xyz(struct Object* obj, f32 xScale, f32 yScale, f32 zScale); diff --git a/src/game/rendering_graph_node.h b/src/game/rendering_graph_node.h index 76183200c..ce059fa74 100644 --- a/src/game/rendering_graph_node.h +++ b/src/game/rendering_graph_node.h @@ -43,8 +43,6 @@ extern f32 gOverrideFar; void geo_process_node_and_siblings(struct GraphNode *firstNode); 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 { Gfx* gfx; diff --git a/src/game/save_file.c b/src/game/save_file.c index b4769c738..c62ae378c 100644 --- a/src/game/save_file.c +++ b/src/game/save_file.c @@ -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); } -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_SRC_SLOT(gSaveFileUsingBackupSlot)) { return 0; } struct SaveFile *saveFile = &gSaveBuffer.files[gCurrSaveFileNum - 1][gSaveFileUsingBackupSlot]; diff --git a/src/game/save_file.h b/src/game/save_file.h index fe53d4574..4f15a5f31 100644 --- a/src/game/save_file.h +++ b/src/game/save_file.h @@ -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. Useful for tracking the cap's location after it has been dropped or lost |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); diff --git a/src/pc/djui/djui_hud_utils.c b/src/pc/djui/djui_hud_utils.c index 5e4d92b98..6500fa269 100644 --- a/src/pc/djui/djui_hud_utils.c +++ b/src/pc/djui/djui_hud_utils.c @@ -646,7 +646,7 @@ f32 djui_hud_get_fov_coeff() { 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; } hud_rotate_and_translate_vec3f(pos, &gCamera->mtx, out); if (out[2] >= 0.0f) { diff --git a/src/pc/djui/djui_hud_utils.h b/src/pc/djui/djui_hud_utils.h index e4093f1b1..47bd8ff69 100644 --- a/src/pc/djui/djui_hud_utils.h +++ b/src/pc/djui/djui_hud_utils.h @@ -131,7 +131,7 @@ f32 get_current_fov(); /* |description|Gets the camera FOV coefficient|descriptionEnd| */ f32 djui_hud_get_fov_coeff(); /* |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| */ bool djui_hud_is_pause_menu_created(void); diff --git a/src/pc/gfx/gfx_pc.c b/src/pc/gfx/gfx_pc.c index 2c616b444..b669aed99 100644 --- a/src/pc/gfx/gfx_pc.c +++ b/src/pc/gfx/gfx_pc.c @@ -603,7 +603,7 @@ static void import_texture(int tile) { //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[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]; diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index 6890dd1f3..fd4bdec2c 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -54,7 +54,7 @@ char gSmluaConstants[] = "" "-- sound --\n" "-----------\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 soundID number\n" "--- @param priority number\n" diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index bd3802b87..d50f037c6 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -521,37 +521,6 @@ int smlua_func_arc_to_goal_pos(lua_State* L) { lua_pushinteger(L, arc_to_goal_pos(goal, pos, yVel, gravity)); - smlua_push_vec3f(goal, 1); - - smlua_push_vec3f(pos, 2); - - return 1; -} - -int smlua_func_vec3f_copy_2(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "vec3f_copy_2", 2, top); - return 0; - } - - - Vec3f dest; - smlua_get_vec3f(dest, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "vec3f_copy_2"); return 0; } - - Vec3f src; - smlua_get_vec3f(src, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3f_copy_2"); return 0; } - - vec3f_copy_2(dest, src); - - smlua_push_vec3f(dest, 1); - - smlua_push_vec3f(src, 2); - return 1; } @@ -9629,8 +9598,6 @@ int smlua_func_geo_move_mario_part_from_parent(lua_State* L) { smlua_push_object(L, LOT_GFX, geo_move_mario_part_from_parent(run, node, mtx), NULL); - smlua_push_mat4(mtx, 3); - return 1; } */ @@ -9679,8 +9646,6 @@ int smlua_func_geo_update_body_rot_from_parent(lua_State* L) { smlua_push_object(L, LOT_GFX, geo_update_body_rot_from_parent(run, node, mtx), NULL); - smlua_push_mat4(mtx, 3); - return 1; } */ @@ -9752,8 +9717,6 @@ int smlua_func_geo_update_held_mario_pos(lua_State* L) { smlua_push_object(L, LOT_GFX, geo_update_held_mario_pos(run, node, mtx), NULL); - smlua_push_mat4(mtx, 3); - return 1; } */ @@ -10336,7 +10299,93 @@ int smlua_func_vec3f_to_object_pos(lua_State* L) { vec3f_to_object_pos(o, src); - smlua_push_vec3f(src, 2); + return 1; +} + +int smlua_func_object_face_angle_to_vec3s(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "object_face_angle_to_vec3s", 2, top); + return 0; + } + + + Vec3s dst; + smlua_get_vec3s(dst, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "object_face_angle_to_vec3s"); return 0; } + struct Object* o = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "object_face_angle_to_vec3s"); return 0; } + + object_face_angle_to_vec3s(dst, o); + + smlua_push_vec3s(dst, 1); + + return 1; +} + +int smlua_func_vec3s_to_object_face_angle(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "vec3s_to_object_face_angle", 2, top); + return 0; + } + + struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "vec3s_to_object_face_angle"); return 0; } + + Vec3s src; + smlua_get_vec3s(src, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3s_to_object_face_angle"); return 0; } + + vec3s_to_object_face_angle(o, src); + + return 1; +} + +int smlua_func_object_move_angle_to_vec3s(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "object_move_angle_to_vec3s", 2, top); + return 0; + } + + + Vec3s dst; + smlua_get_vec3s(dst, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "object_move_angle_to_vec3s"); return 0; } + struct Object* o = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "object_move_angle_to_vec3s"); return 0; } + + object_move_angle_to_vec3s(dst, o); + + smlua_push_vec3s(dst, 1); + + return 1; +} + +int smlua_func_vec3s_to_object_move_angle(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "vec3s_to_object_move_angle", 2, top); + return 0; + } + + struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "vec3s_to_object_move_angle"); return 0; } + + Vec3s src; + smlua_get_vec3s(src, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3s_to_object_move_angle"); return 0; } + + vec3s_to_object_move_angle(o, src); return 1; } @@ -10412,8 +10461,6 @@ int smlua_func_shake_camera_handheld(lua_State* L) { shake_camera_handheld(pos, focus); - smlua_push_vec3f(pos, 1); - smlua_push_vec3f(focus, 2); return 1; @@ -10489,8 +10536,6 @@ int smlua_func_clamp_pitch(lua_State* L) { lua_pushinteger(L, clamp_pitch(from, to, maxPitch, minPitch)); - smlua_push_vec3f(from, 1); - smlua_push_vec3f(to, 2); return 1; @@ -10650,8 +10695,6 @@ int smlua_func_approach_vec3f_asymptotic(lua_State* L) { smlua_push_vec3f(current, 1); - smlua_push_vec3f(target, 2); - return 1; } @@ -10683,8 +10726,6 @@ int smlua_func_set_or_approach_vec3f_asymptotic(lua_State* L) { smlua_push_vec3f(dst, 1); - smlua_push_vec3f(goal, 2); - return 1; } @@ -10829,8 +10870,6 @@ int smlua_func_clamp_positions_and_find_yaw(lua_State* L) { smlua_push_vec3f(pos, 1); - smlua_push_vec3f(origin, 2); - return 1; } @@ -10860,10 +10899,6 @@ int smlua_func_is_range_behind_surface(lua_State* L) { lua_pushinteger(L, is_range_behind_surface(from, to, surf, range, surfType)); - smlua_push_vec3f(from, 1); - - smlua_push_vec3f(to, 2); - return 1; } @@ -10895,10 +10930,6 @@ int smlua_func_scale_along_line(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3f(from, 2); - - smlua_push_vec3f(to, 3); - return 1; } @@ -10922,10 +10953,6 @@ int smlua_func_calculate_pitch(lua_State* L) { lua_pushinteger(L, calculate_pitch(from, to)); - smlua_push_vec3f(from, 1); - - smlua_push_vec3f(to, 2); - return 1; } @@ -10949,10 +10976,6 @@ int smlua_func_calculate_yaw(lua_State* L) { lua_pushinteger(L, calculate_yaw(from, to)); - smlua_push_vec3f(from, 1); - - smlua_push_vec3f(to, 2); - return 1; } @@ -10980,10 +11003,6 @@ int smlua_func_calculate_angles(lua_State* L) { calculate_angles(from, to, pitch, yaw); - smlua_push_vec3f(from, 1); - - smlua_push_vec3f(to, 2); - return 1; } @@ -11007,10 +11026,6 @@ int smlua_func_calc_abs_dist(lua_State* L) { lua_pushnumber(L, calc_abs_dist(a, b)); - smlua_push_vec3f(a, 1); - - smlua_push_vec3f(b, 2); - return 1; } @@ -11034,10 +11049,6 @@ int smlua_func_calc_hor_dist(lua_State* L) { lua_pushnumber(L, calc_hor_dist(a, b)); - smlua_push_vec3f(a, 1); - - smlua_push_vec3f(b, 2); - return 1; } @@ -11065,8 +11076,6 @@ int smlua_func_rotate_in_xz(lua_State* L) { smlua_push_vec3f(dst, 1); - smlua_push_vec3f(src, 2); - return 1; } @@ -11094,8 +11103,6 @@ int smlua_func_rotate_in_yz(lua_State* L) { smlua_push_vec3f(dst, 1); - smlua_push_vec3f(src, 2); - return 1; } @@ -11211,8 +11218,6 @@ int smlua_func_shake_camera_pitch(lua_State* L) { shake_camera_pitch(pos, focus); - smlua_push_vec3f(pos, 1); - smlua_push_vec3f(focus, 2); return 1; @@ -11238,8 +11243,6 @@ int smlua_func_shake_camera_yaw(lua_State* L) { shake_camera_yaw(pos, focus); - smlua_push_vec3f(pos, 1); - smlua_push_vec3f(focus, 2); return 1; @@ -11577,12 +11580,6 @@ int smlua_func_offset_rotated(lua_State* L) { smlua_push_vec3f(dst, 1); - smlua_push_vec3f(from, 2); - - smlua_push_vec3f(to, 3); - - smlua_push_vec3s(rotation, 4); - return 1; } @@ -11628,14 +11625,6 @@ int smlua_func_next_lakitu_state(lua_State* L) { smlua_push_vec3f(newFoc, 2); - smlua_push_vec3f(curPos, 3); - - smlua_push_vec3f(curFoc, 4); - - smlua_push_vec3f(oldPos, 5); - - smlua_push_vec3f(oldFoc, 6); - return 1; } @@ -11695,8 +11684,6 @@ int smlua_func_resolve_geometry_collisions(lua_State* L) { smlua_push_vec3f(pos, 1); - smlua_push_vec3f(lastGood, 2); - return 1; } @@ -11722,8 +11709,6 @@ int smlua_func_rotate_camera_around_walls(lua_State* L) { lua_pushinteger(L, rotate_camera_around_walls(c, cPos, avoidYaw, yawRange)); - smlua_push_vec3f(cPos, 2); - return 1; } @@ -11985,8 +11970,6 @@ int smlua_func_obj_rotate_towards_point(lua_State* L) { obj_rotate_towards_point(o, point, pitchOff, yawOff, pitchDiv, yawDiv); - smlua_push_vec3f(point, 2); - return 1; } @@ -12831,8 +12814,6 @@ int smlua_func_djui_hud_world_pos_to_screen_pos(lua_State* L) { lua_pushboolean(L, djui_hud_world_pos_to_screen_pos(pos, out)); - smlua_push_vec3f(pos, 1); - smlua_push_vec3f(out, 2); return 1; @@ -12957,8 +12938,6 @@ int smlua_func_play_sound(lua_State* L) { play_sound(soundBits, pos); - smlua_push_vec3f(pos, 2); - return 1; } @@ -12982,8 +12961,6 @@ int smlua_func_play_sound_with_freq_scale(lua_State* L) { play_sound_with_freq_scale(soundBits, pos, freqScale); - smlua_push_vec3f(pos, 2); - return 1; } @@ -13102,8 +13079,6 @@ int smlua_func_stop_sound(lua_State* L) { stop_sound(soundBits, pos); - smlua_push_vec3f(pos, 2); - return 1; } @@ -13123,8 +13098,6 @@ int smlua_func_stop_sounds_from_source(lua_State* L) { stop_sounds_from_source(pos); - smlua_push_vec3f(pos, 1); - return 1; } @@ -15228,8 +15201,6 @@ int smlua_func_le_calculate_lighting_color(lua_State* L) { le_calculate_lighting_color(pos, out, lightIntensityScalar); - smlua_push_vec3f(pos, 1); - smlua_push_color(out, 2); return 1; @@ -15255,8 +15226,6 @@ int smlua_func_le_calculate_lighting_dir(lua_State* L) { le_calculate_lighting_dir(pos, out); - smlua_push_vec3f(pos, 1); - smlua_push_vec3f(out, 2); return 1; @@ -16033,8 +16002,6 @@ int smlua_func_vec3f_find_ceil(lua_State* L) { lua_pushnumber(L, vec3f_find_ceil(pos, height, ceil)); - smlua_push_vec3f(pos, 1); - return 1; } */ @@ -16060,8 +16027,6 @@ int smlua_func_vec3f_mario_ceil(lua_State* L) { lua_pushnumber(L, vec3f_mario_ceil(pos, height, ceil)); - smlua_push_vec3f(pos, 1); - return 1; } */ @@ -16978,7 +16943,7 @@ int smlua_func_perform_hanging_step(lua_State* L) { smlua_get_vec3f(nextPos, 2); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "perform_hanging_step"); return 0; } - extern s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos); + extern s32 perform_hanging_step(struct MarioState *m, OUT Vec3f nextPos); lua_pushinteger(L, perform_hanging_step(m, nextPos)); smlua_push_vec3f(nextPos, 2); @@ -17899,8 +17864,6 @@ int smlua_func_push_or_sidle_wall(lua_State* L) { extern void push_or_sidle_wall(struct MarioState *m, Vec3f startPos); push_or_sidle_wall(m, startPos); - smlua_push_vec3f(startPos, 2); - return 1; } @@ -18458,7 +18421,7 @@ int smlua_func_perform_water_full_step(lua_State* L) { smlua_get_vec3f(nextPos, 2); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "perform_water_full_step"); return 0; } - extern u32 perform_water_full_step(struct MarioState *m, Vec3f nextPos); + extern u32 perform_water_full_step(struct MarioState *m, OUT Vec3f nextPos); lua_pushinteger(L, perform_water_full_step(m, nextPos)); smlua_push_vec3f(nextPos, 2); @@ -18482,7 +18445,7 @@ int smlua_func_apply_water_current(lua_State* L) { smlua_get_vec3f(step, 2); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "apply_water_current"); return 0; } - extern void apply_water_current(struct MarioState *m, Vec3f step); + extern void apply_water_current(struct MarioState *m, OUT Vec3f step); apply_water_current(m, step); smlua_push_vec3f(step, 2); @@ -19079,8 +19042,6 @@ int smlua_func_vec3f_rotate_zxy(lua_State* L) { smlua_push_vec3f(v, 1); - smlua_push_vec3s(rotate, 2); - lua_settop(L, 1); return 1; } @@ -19113,10 +19074,6 @@ int smlua_func_vec3f_rotate_around_n(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3f(v, 2); - - smlua_push_vec3f(n, 3); - lua_settop(L, 1); return 1; } @@ -19147,10 +19104,6 @@ int smlua_func_vec3f_project(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3f(v, 2); - - smlua_push_vec3f(onto, 3); - lua_settop(L, 1); return 1; } @@ -19189,14 +19142,6 @@ int smlua_func_vec3f_transform(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3f(v, 2); - - smlua_push_vec3f(translation, 3); - - smlua_push_vec3s(rotation, 4); - - smlua_push_vec3f(scale, 5); - lua_settop(L, 1); return 1; } @@ -19227,10 +19172,6 @@ int smlua_func_vec3f_get_dist_and_angle(lua_State* L) { vec3f_get_dist_and_angle(from, to, dist, pitch, yaw); - smlua_push_vec3f(from, 1); - - smlua_push_vec3f(to, 2); - return 1; } @@ -19260,8 +19201,6 @@ int smlua_func_vec3f_set_dist_and_angle(lua_State* L) { vec3f_set_dist_and_angle(from, to, dist, pitch, yaw); - smlua_push_vec3f(from, 1); - smlua_push_vec3f(to, 2); return 1; @@ -19297,12 +19236,6 @@ int smlua_func_find_vector_perpendicular_to_plane(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3f(a, 2); - - smlua_push_vec3f(b, 3); - - smlua_push_vec3f(c, 4); - lua_settop(L, 1); return 1; } @@ -19335,10 +19268,6 @@ int smlua_func_mtxf_lookat(lua_State* L) { smlua_push_mat4(mtx, 1); - smlua_push_vec3f(from, 2); - - smlua_push_vec3f(to, 3); - return 1; } @@ -19368,10 +19297,6 @@ int smlua_func_mtxf_rotate_zxy_and_translate(lua_State* L) { smlua_push_mat4(dest, 1); - smlua_push_vec3f(translate, 2); - - smlua_push_vec3s(rotate, 3); - return 1; } @@ -19401,10 +19326,6 @@ int smlua_func_mtxf_rotate_xyz_and_translate(lua_State* L) { smlua_push_mat4(dest, 1); - smlua_push_vec3f(b, 2); - - smlua_push_vec3s(c, 3); - return 1; } @@ -19436,10 +19357,6 @@ int smlua_func_mtxf_billboard(lua_State* L) { smlua_push_mat4(dest, 1); - smlua_push_mat4(mtx, 2); - - smlua_push_vec3f(position, 3); - return 1; } @@ -19471,10 +19388,6 @@ int smlua_func_mtxf_cylboard(lua_State* L) { smlua_push_mat4(dest, 1); - smlua_push_mat4(mtx, 2); - - smlua_push_vec3f(position, 3); - return 1; } @@ -19506,10 +19419,6 @@ int smlua_func_mtxf_align_terrain_normal(lua_State* L) { smlua_push_mat4(dest, 1); - smlua_push_vec3f(upDir, 2); - - smlua_push_vec3f(pos, 3); - return 1; } @@ -19539,8 +19448,6 @@ int smlua_func_mtxf_align_terrain_triangle(lua_State* L) { smlua_push_mat4(mtx, 1); - smlua_push_vec3f(pos, 2); - return 1; } @@ -19570,10 +19477,6 @@ int smlua_func_mtxf_mul(lua_State* L) { smlua_push_mat4(dest, 1); - smlua_push_mat4(a, 2); - - smlua_push_mat4(b, 3); - return 1; } @@ -19595,12 +19498,11 @@ int smlua_func_mtxf_mul_vec3s(lua_State* L) { smlua_get_vec3s(b, 2); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "mtxf_mul_vec3s"); return 0; } - smlua_push_pointer(L, LVT_S16_P, (void*)mtxf_mul_vec3s(mtx, b), NULL); - - smlua_push_mat4(mtx, 1); + mtxf_mul_vec3s(mtx, b); smlua_push_vec3s(b, 2); + lua_settop(L, 2); return 1; } @@ -19649,8 +19551,6 @@ int smlua_func_mtxf_inverse(lua_State* L) { smlua_push_mat4(dest, 1); - smlua_push_mat4(src, 2); - return 1; } @@ -19680,10 +19580,6 @@ int smlua_func_get_pos_from_transform_mtx(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_mat4(objMtx, 2); - - smlua_push_mat4(camMtx, 3); - lua_settop(L, 1); return 1; } @@ -19826,8 +19722,6 @@ int smlua_func_mtxf_copy(lua_State* L) { smlua_push_mat4(dest, 1); - smlua_push_mat4(src, 2); - return 1; } @@ -19874,8 +19768,6 @@ int smlua_func_mtxf_translate(lua_State* L) { smlua_push_mat4(dest, 1); - smlua_push_vec3f(b, 2); - return 1; } @@ -19905,10 +19797,6 @@ int smlua_func_mtxf_scale_vec3f(lua_State* L) { smlua_push_mat4(dest, 1); - smlua_push_mat4(mtx, 2); - - smlua_push_vec3f(s, 3); - return 1; } @@ -19931,8 +19819,6 @@ int smlua_func_mtxf_to_mtx(lua_State* L) { mtxf_to_mtx(dest, src); - smlua_push_mat4(src, 2); - return 1; } */ @@ -19985,8 +19871,6 @@ int smlua_func_vec3f_copy(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3f(src, 2); - lua_settop(L, 1); return 1; } @@ -20041,8 +19925,6 @@ int smlua_func_vec3f_add(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3f(a, 2); - lua_settop(L, 1); return 1; } @@ -20073,10 +19955,6 @@ int smlua_func_vec3f_sum(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3f(a, 2); - - smlua_push_vec3f(b, 3); - lua_settop(L, 1); return 1; } @@ -20103,8 +19981,6 @@ int smlua_func_vec3f_sub(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3f(a, 2); - lua_settop(L, 1); return 1; } @@ -20135,10 +20011,6 @@ int smlua_func_vec3f_dif(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3f(a, 2); - - smlua_push_vec3f(b, 3); - lua_settop(L, 1); return 1; } @@ -20189,8 +20061,6 @@ int smlua_func_vec3f_mult(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3f(a, 2); - lua_settop(L, 1); return 1; } @@ -20221,10 +20091,6 @@ int smlua_func_vec3f_prod(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3f(a, 2); - - smlua_push_vec3f(b, 3); - lua_settop(L, 1); return 1; } @@ -20269,8 +20135,6 @@ int smlua_func_vec3f_length(lua_State* L) { lua_pushnumber(L, vec3f_length(a)); - smlua_push_vec3f(a, 1); - return 1; } @@ -20340,10 +20204,6 @@ int smlua_func_vec3f_dot(lua_State* L) { lua_pushnumber(L, vec3f_dot(a, b)); - smlua_push_vec3f(a, 1); - - smlua_push_vec3f(b, 2); - return 1; } @@ -20373,10 +20233,6 @@ int smlua_func_vec3f_cross(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3f(a, 2); - - smlua_push_vec3f(b, 3); - lua_settop(L, 1); return 1; } @@ -20411,10 +20267,6 @@ int smlua_func_vec3f_combine(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3f(vecA, 2); - - smlua_push_vec3f(vecB, 3); - lua_settop(L, 1); return 1; } @@ -20439,10 +20291,6 @@ int smlua_func_vec3f_dist(lua_State* L) { lua_pushnumber(L, vec3f_dist(v1, v2)); - smlua_push_vec3f(v1, 1); - - smlua_push_vec3f(v2, 2); - return 1; } @@ -20466,10 +20314,6 @@ int smlua_func_vec3f_hdist(lua_State* L) { lua_pushnumber(L, vec3f_hdist(v1, v2)); - smlua_push_vec3f(v1, 1); - - smlua_push_vec3f(v2, 2); - return 1; } @@ -20489,8 +20333,6 @@ int smlua_func_vec3f_is_zero(lua_State* L) { lua_pushboolean(L, vec3f_is_zero(v)); - smlua_push_vec3f(v, 1); - return 1; } @@ -20516,8 +20358,6 @@ int smlua_func_vec3f_to_vec3i(lua_State* L) { smlua_push_vec3i(dest, 1); - smlua_push_vec3f(a, 2); - lua_settop(L, 1); return 1; } @@ -20544,8 +20384,6 @@ int smlua_func_vec3f_to_vec3s(lua_State* L) { smlua_push_vec3s(dest, 1); - smlua_push_vec3f(a, 2); - lua_settop(L, 1); return 1; } @@ -20598,8 +20436,6 @@ int smlua_func_vec3i_copy(lua_State* L) { smlua_push_vec3i(dest, 1); - smlua_push_vec3i(src, 2); - lua_settop(L, 1); return 1; } @@ -20654,8 +20490,6 @@ int smlua_func_vec3i_add(lua_State* L) { smlua_push_vec3i(dest, 1); - smlua_push_vec3i(a, 2); - lua_settop(L, 1); return 1; } @@ -20686,10 +20520,6 @@ int smlua_func_vec3i_sum(lua_State* L) { smlua_push_vec3i(dest, 1); - smlua_push_vec3i(a, 2); - - smlua_push_vec3i(b, 3); - lua_settop(L, 1); return 1; } @@ -20716,8 +20546,6 @@ int smlua_func_vec3i_sub(lua_State* L) { smlua_push_vec3i(dest, 1); - smlua_push_vec3i(a, 2); - lua_settop(L, 1); return 1; } @@ -20748,10 +20576,6 @@ int smlua_func_vec3i_dif(lua_State* L) { smlua_push_vec3i(dest, 1); - smlua_push_vec3i(a, 2); - - smlua_push_vec3i(b, 3); - lua_settop(L, 1); return 1; } @@ -20802,8 +20626,6 @@ int smlua_func_vec3i_mult(lua_State* L) { smlua_push_vec3i(dest, 1); - smlua_push_vec3i(a, 2); - lua_settop(L, 1); return 1; } @@ -20834,10 +20656,6 @@ int smlua_func_vec3i_prod(lua_State* L) { smlua_push_vec3i(dest, 1); - smlua_push_vec3i(a, 2); - - smlua_push_vec3i(b, 3); - lua_settop(L, 1); return 1; } @@ -20882,8 +20700,6 @@ int smlua_func_vec3i_length(lua_State* L) { lua_pushnumber(L, vec3i_length(a)); - smlua_push_vec3i(a, 1); - return 1; } @@ -20953,10 +20769,6 @@ int smlua_func_vec3i_dot(lua_State* L) { lua_pushnumber(L, vec3i_dot(a, b)); - smlua_push_vec3i(a, 1); - - smlua_push_vec3i(b, 2); - return 1; } @@ -20986,10 +20798,6 @@ int smlua_func_vec3i_cross(lua_State* L) { smlua_push_vec3i(dest, 1); - smlua_push_vec3i(a, 2); - - smlua_push_vec3i(b, 3); - lua_settop(L, 1); return 1; } @@ -21024,10 +20832,6 @@ int smlua_func_vec3i_combine(lua_State* L) { smlua_push_vec3i(dest, 1); - smlua_push_vec3i(vecA, 2); - - smlua_push_vec3i(vecB, 3); - lua_settop(L, 1); return 1; } @@ -21052,10 +20856,6 @@ int smlua_func_vec3i_dist(lua_State* L) { lua_pushnumber(L, vec3i_dist(v1, v2)); - smlua_push_vec3i(v1, 1); - - smlua_push_vec3i(v2, 2); - return 1; } @@ -21079,10 +20879,6 @@ int smlua_func_vec3i_hdist(lua_State* L) { lua_pushnumber(L, vec3i_hdist(v1, v2)); - smlua_push_vec3i(v1, 1); - - smlua_push_vec3i(v2, 2); - return 1; } @@ -21102,8 +20898,6 @@ int smlua_func_vec3i_is_zero(lua_State* L) { lua_pushboolean(L, vec3i_is_zero(v)); - smlua_push_vec3i(v, 1); - return 1; } @@ -21129,8 +20923,6 @@ int smlua_func_vec3i_to_vec3f(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3i(a, 2); - lua_settop(L, 1); return 1; } @@ -21157,8 +20949,6 @@ int smlua_func_vec3i_to_vec3s(lua_State* L) { smlua_push_vec3s(dest, 1); - smlua_push_vec3i(a, 2); - lua_settop(L, 1); return 1; } @@ -21211,8 +21001,6 @@ int smlua_func_vec3s_copy(lua_State* L) { smlua_push_vec3s(dest, 1); - smlua_push_vec3s(src, 2); - lua_settop(L, 1); return 1; } @@ -21267,8 +21055,6 @@ int smlua_func_vec3s_add(lua_State* L) { smlua_push_vec3s(dest, 1); - smlua_push_vec3s(a, 2); - lua_settop(L, 1); return 1; } @@ -21299,10 +21085,6 @@ int smlua_func_vec3s_sum(lua_State* L) { smlua_push_vec3s(dest, 1); - smlua_push_vec3s(a, 2); - - smlua_push_vec3s(b, 3); - lua_settop(L, 1); return 1; } @@ -21329,8 +21111,6 @@ int smlua_func_vec3s_sub(lua_State* L) { smlua_push_vec3s(dest, 1); - smlua_push_vec3s(a, 2); - lua_settop(L, 1); return 1; } @@ -21361,10 +21141,6 @@ int smlua_func_vec3s_dif(lua_State* L) { smlua_push_vec3s(dest, 1); - smlua_push_vec3s(a, 2); - - smlua_push_vec3s(b, 3); - lua_settop(L, 1); return 1; } @@ -21415,8 +21191,6 @@ int smlua_func_vec3s_mult(lua_State* L) { smlua_push_vec3s(dest, 1); - smlua_push_vec3s(a, 2); - lua_settop(L, 1); return 1; } @@ -21447,10 +21221,6 @@ int smlua_func_vec3s_prod(lua_State* L) { smlua_push_vec3s(dest, 1); - smlua_push_vec3s(a, 2); - - smlua_push_vec3s(b, 3); - lua_settop(L, 1); return 1; } @@ -21495,8 +21265,6 @@ int smlua_func_vec3s_length(lua_State* L) { lua_pushnumber(L, vec3s_length(a)); - smlua_push_vec3s(a, 1); - return 1; } @@ -21566,10 +21334,6 @@ int smlua_func_vec3s_dot(lua_State* L) { lua_pushnumber(L, vec3s_dot(a, b)); - smlua_push_vec3s(a, 1); - - smlua_push_vec3s(b, 2); - return 1; } @@ -21599,10 +21363,6 @@ int smlua_func_vec3s_cross(lua_State* L) { smlua_push_vec3s(dest, 1); - smlua_push_vec3s(a, 2); - - smlua_push_vec3s(b, 3); - lua_settop(L, 1); return 1; } @@ -21637,10 +21397,6 @@ int smlua_func_vec3s_combine(lua_State* L) { smlua_push_vec3s(dest, 1); - smlua_push_vec3s(vecA, 2); - - smlua_push_vec3s(vecB, 3); - lua_settop(L, 1); return 1; } @@ -21665,10 +21421,6 @@ int smlua_func_vec3s_dist(lua_State* L) { lua_pushnumber(L, vec3s_dist(v1, v2)); - smlua_push_vec3s(v1, 1); - - smlua_push_vec3s(v2, 2); - return 1; } @@ -21692,10 +21444,6 @@ int smlua_func_vec3s_hdist(lua_State* L) { lua_pushnumber(L, vec3s_hdist(v1, v2)); - smlua_push_vec3s(v1, 1); - - smlua_push_vec3s(v2, 2); - return 1; } @@ -21715,8 +21463,6 @@ int smlua_func_vec3s_is_zero(lua_State* L) { lua_pushboolean(L, vec3s_is_zero(v)); - smlua_push_vec3s(v, 1); - return 1; } @@ -21742,8 +21488,6 @@ int smlua_func_vec3s_to_vec3f(lua_State* L) { smlua_push_vec3f(dest, 1); - smlua_push_vec3s(a, 2); - lua_settop(L, 1); return 1; } @@ -21770,8 +21514,6 @@ int smlua_func_vec3s_to_vec3i(lua_State* L) { smlua_push_vec3i(dest, 1); - smlua_push_vec3s(a, 2); - lua_settop(L, 1); return 1; } @@ -21950,10 +21692,6 @@ int smlua_func_delta_interpolate_vec3f(lua_State* L) { smlua_push_vec3f(res, 1); - smlua_push_vec3f(a, 2); - - smlua_push_vec3f(b, 3); - return 1; } @@ -21985,10 +21723,6 @@ int smlua_func_delta_interpolate_vec3s(lua_State* L) { smlua_push_vec3s(res, 1); - smlua_push_vec3s(a, 2); - - smlua_push_vec3s(b, 3); - return 1; } @@ -22356,8 +22090,6 @@ int smlua_func_network_player_set_override_palette_color(lua_State* L) { network_player_set_override_palette_color(np, part, color); - smlua_push_color(color, 3); - return 1; } @@ -23176,7 +22908,7 @@ int smlua_func_obj_find_wall_displacement(lua_State* L) { f32 radius = smlua_to_number(L, 5); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "obj_find_wall_displacement"); return 0; } - extern s8 obj_find_wall_displacement(Vec3f dist, f32 x, f32 y, f32 z, f32 radius); + extern s8 obj_find_wall_displacement(OUT Vec3f dist, f32 x, f32 y, f32 z, f32 radius); lua_pushinteger(L, obj_find_wall_displacement(dist, x, y, z, radius)); smlua_push_vec3f(dist, 1); @@ -24276,8 +24008,6 @@ int smlua_func_geo_update_projectile_pos_from_parent(lua_State* L) { extern Gfx *geo_update_projectile_pos_from_parent(s32 callContext, UNUSED struct GraphNode *node, Mat4 mtx); smlua_push_object(L, LOT_GFX, geo_update_projectile_pos_from_parent(callContext, node, mtx), NULL); - smlua_push_mat4(mtx, 3); - return 1; } */ @@ -24390,8 +24120,6 @@ int smlua_func_geo_choose_area_ext(lua_State* L) { extern Gfx *geo_choose_area_ext(UNUSED s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); smlua_push_object(L, LOT_GFX, geo_choose_area_ext(callContext, node, mtx), NULL); - smlua_push_mat4(mtx, 3); - return 1; } */ @@ -24415,8 +24143,6 @@ int smlua_func_obj_update_pos_from_parent_transformation(lua_State* L) { extern void obj_update_pos_from_parent_transformation(Mat4 a0, struct Object *a1); obj_update_pos_from_parent_transformation(a0, a1); - smlua_push_mat4(a0, 1); - return 1; } @@ -24440,13 +24166,11 @@ int smlua_func_obj_apply_scale_to_matrix(lua_State* L) { smlua_get_mat4(src, 3); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "obj_apply_scale_to_matrix"); return 0; } - extern void obj_apply_scale_to_matrix(struct Object *obj, Mat4 dst, Mat4 src); + extern void obj_apply_scale_to_matrix(struct Object *obj, OUT Mat4 dst, Mat4 src); obj_apply_scale_to_matrix(obj, dst, src); smlua_push_mat4(dst, 2); - smlua_push_mat4(src, 3); - return 1; } @@ -24472,15 +24196,11 @@ int smlua_func_create_transformation_from_matrices(lua_State* L) { smlua_get_mat4(a2, 3); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "create_transformation_from_matrices"); return 0; } - extern void create_transformation_from_matrices(Mat4 a0, Mat4 a1, Mat4 a2); + extern void create_transformation_from_matrices(OUT Mat4 a0, Mat4 a1, Mat4 a2); create_transformation_from_matrices(a0, a1, a2); smlua_push_mat4(a0, 1); - smlua_push_mat4(a1, 2); - - smlua_push_mat4(a2, 3); - return 1; } @@ -25146,15 +24866,11 @@ int smlua_func_linear_mtxf_mul_vec3f(lua_State* L) { smlua_get_vec3f(v, 3); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "linear_mtxf_mul_vec3f"); return 0; } - extern void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v); + extern void linear_mtxf_mul_vec3f(Mat4 m, OUT Vec3f dst, Vec3f v); linear_mtxf_mul_vec3f(m, dst, v); - smlua_push_mat4(m, 1); - smlua_push_vec3f(dst, 2); - smlua_push_vec3f(v, 3); - return 1; } @@ -25180,15 +24896,11 @@ int smlua_func_linear_mtxf_transpose_mul_vec3f(lua_State* L) { smlua_get_vec3f(v, 3); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "linear_mtxf_transpose_mul_vec3f"); return 0; } - extern void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v); + extern void linear_mtxf_transpose_mul_vec3f(Mat4 m, OUT Vec3f dst, Vec3f v); linear_mtxf_transpose_mul_vec3f(m, dst, v); - smlua_push_mat4(m, 1); - smlua_push_vec3f(dst, 2); - smlua_push_vec3f(v, 3); - return 1; } @@ -28166,8 +27878,6 @@ int smlua_func_geo_offset_klepto_held_object(lua_State* L) { extern Gfx *geo_offset_klepto_held_object(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); smlua_push_object(L, LOT_GFX, geo_offset_klepto_held_object(callContext, node, mtx), NULL); - smlua_push_mat4(mtx, 3); - return 1; } */ @@ -29869,8 +29579,6 @@ int smlua_func_audio_sample_play(lua_State* L) { audio_sample_play(audio, position, volume); - smlua_push_vec3f(position, 2); - return 1; } @@ -30954,8 +30662,6 @@ int smlua_func_network_player_color_to_palette(lua_State* L) { network_player_color_to_palette(np, part, color); - smlua_push_color(color, 3); - return 1; } @@ -35061,12 +34767,6 @@ int smlua_func_find_surface_on_ray(lua_State* L) { find_surface_on_ray(orig, dir, hit_surface, hit_pos, precision); - smlua_push_vec3f(orig, 1); - - smlua_push_vec3f(dir, 2); - - smlua_push_vec3f(hit_pos, 4); - return 1; } */ @@ -35091,8 +34791,6 @@ int smlua_func_set_find_wall_direction(lua_State* L) { set_find_wall_direction(dir, active, airborne); - smlua_push_vec3f(dir, 1); - return 1; } @@ -35118,8 +34816,6 @@ int smlua_func_closest_point_to_triangle(lua_State* L) { closest_point_to_triangle(surf, src, out); - smlua_push_vec3f(src, 2); - smlua_push_vec3f(out, 3); return 1; @@ -35257,7 +34953,6 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "spawn_wind_particles", smlua_func_spawn_wind_particles); smlua_bind_function(L, "check_if_moving_over_floor", smlua_func_check_if_moving_over_floor); smlua_bind_function(L, "arc_to_goal_pos", smlua_func_arc_to_goal_pos); - smlua_bind_function(L, "vec3f_copy_2", smlua_func_vec3f_copy_2); smlua_bind_function(L, "tox_box_move", smlua_func_tox_box_move); smlua_bind_function(L, "play_penguin_walking_sound", smlua_func_play_penguin_walking_sound); smlua_bind_function(L, "update_angle_from_move_flags", smlua_func_update_angle_from_move_flags); @@ -35866,6 +35561,10 @@ void smlua_bind_functions_autogen(void) { //smlua_bind_function(L, "geo_camera_main", smlua_func_geo_camera_main); <--- UNIMPLEMENTED smlua_bind_function(L, "object_pos_to_vec3f", smlua_func_object_pos_to_vec3f); smlua_bind_function(L, "vec3f_to_object_pos", smlua_func_vec3f_to_object_pos); + smlua_bind_function(L, "object_face_angle_to_vec3s", smlua_func_object_face_angle_to_vec3s); + smlua_bind_function(L, "vec3s_to_object_face_angle", smlua_func_vec3s_to_object_face_angle); + smlua_bind_function(L, "object_move_angle_to_vec3s", smlua_func_object_move_angle_to_vec3s); + smlua_bind_function(L, "vec3s_to_object_move_angle", smlua_func_vec3s_to_object_move_angle); smlua_bind_function(L, "cam_select_alt_mode", smlua_func_cam_select_alt_mode); smlua_bind_function(L, "set_cam_angle", smlua_func_set_cam_angle); smlua_bind_function(L, "set_handheld_shake", smlua_func_set_handheld_shake); diff --git a/src/pc/lua/utils/smlua_deprecated.c b/src/pc/lua/utils/smlua_deprecated.c index 7734a1cb6..fdd998e18 100644 --- a/src/pc/lua/utils/smlua_deprecated.c +++ b/src/pc/lua/utils/smlua_deprecated.c @@ -34,7 +34,7 @@ void network_player_color_to_palette(struct NetworkPlayer *np, enum PlayerPart p 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."); if (np == NULL || !(part < PLAYER_PART_MAX && part >= 0)) { if (np == NULL) { // output config palette instead if np is NULL diff --git a/src/pc/lua/utils/smlua_deprecated.h b/src/pc/lua/utils/smlua_deprecated.h index 0137ac257..82314f7d6 100644 --- a/src/pc/lua/utils/smlua_deprecated.h +++ b/src/pc/lua/utils/smlua_deprecated.h @@ -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| */ 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| */ -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); diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index b5b083529..b3f2d4452 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -322,7 +322,7 @@ f32 get_hand_foot_pos_z(struct MarioState* m, u8 index) { 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 (animPart >= MARIO_ANIM_PART_MAX) { return false; } vec3f_copy(pos, m->marioBodyState->animPartsPos[animPart]); diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index 71f791065..c7e3d0712 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -136,7 +136,7 @@ f32 get_hand_foot_pos_z(struct MarioState* m, u8 index); /* |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 |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| */ s16 get_current_save_file_num(void); diff --git a/src/pc/utils/misc.c b/src/pc/utils/misc.c index b1d4c49f0..df98e8f17 100644 --- a/src/pc/utils/misc.c +++ b/src/pc/utils/misc.c @@ -135,14 +135,14 @@ s32 delta_interpolate_s32(s32 a, s32 b, f32 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; res[0] = ((a[0] * antiDelta) + (b[0] * delta)); res[1] = ((a[1] * antiDelta) + (b[1] * 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; res[0] = ((a[0] * antiDelta) + (b[0] * delta)); res[1] = ((a[1] * antiDelta) + (b[1] * delta)); diff --git a/src/pc/utils/misc.h b/src/pc/utils/misc.h index 1fc426ade..98dff7be7 100644 --- a/src/pc/utils/misc.h +++ b/src/pc/utils/misc.h @@ -26,9 +26,9 @@ f32 delta_interpolate_f32(f32 a, f32 b, f32 delta); /* |description|Linearly interpolates between `a` and `b` with `delta`|descriptionEnd| */ s32 delta_interpolate_s32(s32 a, s32 b, f32 delta); /* |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| */ -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_rgba(u8* res, u8* a, u8* b, f32 delta); void delta_interpolate_mtx(Mtx* out, Mtx* a, Mtx* b, f32 delta);