More math improvements (#820)
* More math improvements * more math functions * stack check * added error message when trying to modify read-only table; fix gSmluaConstants printed to console
This commit is contained in:
parent
dea7247d9f
commit
69e129805e
@ -233,7 +233,10 @@ def translate_type_to_lua(ptype):
|
||||
ptype = ptype.split(' ')[1].replace('*', '')
|
||||
return ptype, 'structs.md#%s' % ptype
|
||||
|
||||
if 'Vec3' in ptype:
|
||||
if ptype in VECP_TYPES:
|
||||
return VECP_TYPES[ptype], 'structs.md#%s' % VECP_TYPES[ptype]
|
||||
|
||||
if ptype in VEC_TYPES:
|
||||
return ptype, 'structs.md#%s' % ptype
|
||||
|
||||
if ptype.startswith('enum '):
|
||||
@ -267,7 +270,7 @@ def translate_type_to_lua(ptype):
|
||||
|
||||
if ptype.count('*') == 1 and '???' not in translate_type_to_lvt(ptype):
|
||||
ptype = ptype.replace('const', '').replace('*', '').strip()
|
||||
s = '`Pointer` <%s>' % translate_type_to_lua(ptype)[0]
|
||||
s = '`Pointer` <`%s`>' % translate_type_to_lua(ptype)[0].replace('`', '').strip()
|
||||
return s, None
|
||||
|
||||
if not ptype.startswith('`'):
|
||||
|
@ -1,5 +1,6 @@
|
||||
from common import *
|
||||
from extract_constants import *
|
||||
from vec_types import *
|
||||
import sys
|
||||
|
||||
in_filename = 'autogen/lua_constants/built-in.lua'
|
||||
@ -365,12 +366,30 @@ def build_files(processed_files):
|
||||
|
||||
return s
|
||||
|
||||
def build_vec_type_constant(type_name, vec_type, constant, values):
|
||||
txt = 'g%s%s = create_read_only_table({' % (type_name, constant)
|
||||
txt += ','.join([
|
||||
'%s=%s' % (lua_field, str(values[i]))
|
||||
for i, lua_field in enumerate(vec_type["fields_mapping"])
|
||||
])
|
||||
txt += '})'
|
||||
return txt
|
||||
|
||||
def build_to_c(built_files):
|
||||
txt = ''
|
||||
|
||||
# Built-in and deprecated
|
||||
for filename in [in_filename, deprecated_filename]:
|
||||
with open(get_path(filename), 'r') as f:
|
||||
for line in f.readlines():
|
||||
txt += line.strip() + '\n'
|
||||
|
||||
# Vec types constants
|
||||
for type_name, vec_type in VEC_TYPES.items():
|
||||
for constant, values in vec_type.get("constants", {}).items():
|
||||
txt += build_vec_type_constant(type_name, vec_type, constant, values) + '\n'
|
||||
|
||||
# Source files
|
||||
txt += '\n' + built_files
|
||||
|
||||
while ('\n\n' in txt):
|
||||
@ -505,6 +524,14 @@ def build_to_def(processed_files):
|
||||
s += f.read()
|
||||
s += '\n'
|
||||
|
||||
s += '\n\n-------------------------\n'
|
||||
s += '-- vec types constants --\n'
|
||||
s += '-------------------------\n\n'
|
||||
for type_name, vec_type in VEC_TYPES.items():
|
||||
for constant, values in vec_type.get("constants", {}).items():
|
||||
s += '--- @type %s\n' % (type_name)
|
||||
s += build_vec_type_constant(type_name, vec_type, constant, values) + '\n\n'
|
||||
|
||||
for file in processed_files:
|
||||
constants = file['constants']
|
||||
skip_constant = False
|
||||
|
@ -921,6 +921,9 @@ def build_call(function):
|
||||
elif ftype == 'void *':
|
||||
return ' %s;\n' % ccall
|
||||
|
||||
if ftype in VECP_TYPES:
|
||||
return ' %s;\n' % ccall
|
||||
|
||||
flot = translate_type_to_lot(ftype)
|
||||
|
||||
lfunc = 'UNIMPLEMENTED -->'
|
||||
@ -994,6 +997,10 @@ def build_function(function, do_extern):
|
||||
i += 1
|
||||
s += '\n'
|
||||
|
||||
# To allow chaining vector functions calls, return the table corresponding to `dest` parameter
|
||||
if function['type'] in VECP_TYPES:
|
||||
s += ' lua_settop(L, 1);\n'
|
||||
|
||||
s += ' return 1;\n}\n'
|
||||
|
||||
if fid in override_function_version_excludes:
|
||||
@ -1442,6 +1449,9 @@ def def_files(processed_files):
|
||||
for def_pointer in def_pointers:
|
||||
s += '--- @alias %s %s\n' % (def_pointer, def_pointer[8:])
|
||||
|
||||
for vecp_type, vec_type in VECP_TYPES.items():
|
||||
s += '--- @alias %s %s\n' % (vecp_type, vec_type)
|
||||
|
||||
with open(get_path(out_filename_defs), 'w', encoding='utf-8', newline='\n') as out:
|
||||
out.write(s)
|
||||
|
||||
|
@ -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 {{type_2}} *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}}(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}};
|
||||
@ -24,7 +24,6 @@ def vec3_write_conversion_functions(generated: str, curr_template: dict, templat
|
||||
.replace("{{desc}}", curr_template["desc"]) \
|
||||
.replace("{{suffix}}", curr_template["suffix"]) \
|
||||
.replace("{{desc_2}}", template["desc"]) \
|
||||
.replace("{{type_2}}", template["type"]) \
|
||||
.replace("{{suffix_2}}", template["suffix"])
|
||||
|
||||
for i in range(size):
|
||||
|
@ -21,12 +21,47 @@ _ReadOnlyTable = {
|
||||
end
|
||||
}
|
||||
|
||||
-----------
|
||||
-- table --
|
||||
-----------
|
||||
|
||||
--- Creates a shallow copy of table `t`
|
||||
--- @param t table
|
||||
--- @return table
|
||||
function table.copy(t)
|
||||
return table_copy(t)
|
||||
end
|
||||
|
||||
--- Creates a deep copy of table `t`
|
||||
--- @param t table
|
||||
--- @return table
|
||||
function table.deepcopy(t)
|
||||
return table_deepcopy(t)
|
||||
end
|
||||
|
||||
--- Utility function to create a read-only table
|
||||
--- @param data table
|
||||
--- @return table
|
||||
function create_read_only_table(data)
|
||||
local t = {}
|
||||
local mt = {
|
||||
__index = data,
|
||||
__newindex = function(_, k, _)
|
||||
error('Attempting to modify key `' .. k .. '` of read-only table')
|
||||
end,
|
||||
__call = function() return table_copy(data) end,
|
||||
__metatable = false
|
||||
}
|
||||
setmetatable(t, mt)
|
||||
return t
|
||||
end
|
||||
|
||||
-----------
|
||||
-- sound --
|
||||
-----------
|
||||
|
||||
--- @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
|
||||
@ -167,6 +202,48 @@ function math.hypot(a, b)
|
||||
return __math_sqrt(a * a + b * b)
|
||||
end
|
||||
|
||||
--- @param x number
|
||||
--- @return number
|
||||
--- Returns 1 if `x` is positive or zero, -1 otherwise
|
||||
function math.sign(x)
|
||||
return x >= 0 and 1 or -1
|
||||
end
|
||||
|
||||
--- @param x number
|
||||
--- @return number
|
||||
--- Returns 1 if `x` is positive, 0 if it is zero, -1 otherwise
|
||||
function math.sign0(x)
|
||||
return x ~= 0 and (x > 0 and 1 or -1) or 0
|
||||
end
|
||||
|
||||
--- @param t number
|
||||
--- @param a number
|
||||
--- @param b number
|
||||
--- @return number
|
||||
--- Linearly interpolates `t` between `a` and `b`
|
||||
function math.lerp(t, a, b)
|
||||
return a + (b - a) * t
|
||||
end
|
||||
|
||||
--- @param x number
|
||||
--- @param a number
|
||||
--- @param b number
|
||||
--- @return number
|
||||
--- Determines where `x` linearly lies between `a` and `b`. It's the inverse of `math.lerp`
|
||||
function math.invlerp(x, a, b)
|
||||
return (x - a) / (b - a)
|
||||
end
|
||||
|
||||
--- @param x number
|
||||
--- @param a number
|
||||
--- @param b number
|
||||
--- @param c number
|
||||
--- @param d number
|
||||
--- @return number
|
||||
--- Linearly remaps `x` from the source range `[a, b]` to the destination range `[c, d]`
|
||||
function math.remap(x, a, b, c, d)
|
||||
return c + (d - c) * ((x - a) / (b - a))
|
||||
end
|
||||
|
||||
-----------------
|
||||
-- legacy font --
|
||||
|
@ -23,12 +23,47 @@ _ReadOnlyTable = {
|
||||
end
|
||||
}
|
||||
|
||||
-----------
|
||||
-- table --
|
||||
-----------
|
||||
|
||||
--- Creates a shallow copy of table `t`
|
||||
--- @param t table
|
||||
--- @return table
|
||||
function table.copy(t)
|
||||
return table_copy(t)
|
||||
end
|
||||
|
||||
--- Creates a deep copy of table `t`
|
||||
--- @param t table
|
||||
--- @return table
|
||||
function table.deepcopy(t)
|
||||
return table_deepcopy(t)
|
||||
end
|
||||
|
||||
--- Utility function to create a read-only table
|
||||
--- @param data table
|
||||
--- @return table
|
||||
function create_read_only_table(data)
|
||||
local t = {}
|
||||
local mt = {
|
||||
__index = data,
|
||||
__newindex = function(_, k, _)
|
||||
error('Attempting to modify key `' .. k .. '` of read-only table')
|
||||
end,
|
||||
__call = function() return table_copy(data) end,
|
||||
__metatable = false
|
||||
}
|
||||
setmetatable(t, mt)
|
||||
return t
|
||||
end
|
||||
|
||||
-----------
|
||||
-- sound --
|
||||
-----------
|
||||
|
||||
--- @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
|
||||
@ -169,6 +204,48 @@ function math.hypot(a, b)
|
||||
return __math_sqrt(a * a + b * b)
|
||||
end
|
||||
|
||||
--- @param x number
|
||||
--- @return number
|
||||
--- Returns 1 if `x` is positive or zero, -1 otherwise
|
||||
function math.sign(x)
|
||||
return x >= 0 and 1 or -1
|
||||
end
|
||||
|
||||
--- @param x number
|
||||
--- @return number
|
||||
--- Returns 1 if `x` is positive, 0 if it is zero, -1 otherwise
|
||||
function math.sign0(x)
|
||||
return x ~= 0 and (x > 0 and 1 or -1) or 0
|
||||
end
|
||||
|
||||
--- @param t number
|
||||
--- @param a number
|
||||
--- @param b number
|
||||
--- @return number
|
||||
--- Linearly interpolates `t` between `a` and `b`
|
||||
function math.lerp(t, a, b)
|
||||
return a + (b - a) * t
|
||||
end
|
||||
|
||||
--- @param x number
|
||||
--- @param a number
|
||||
--- @param b number
|
||||
--- @return number
|
||||
--- Determines where `x` linearly lies between `a` and `b`. It's the inverse of `math.lerp`
|
||||
function math.invlerp(x, a, b)
|
||||
return (x - a) / (b - a)
|
||||
end
|
||||
|
||||
--- @param x number
|
||||
--- @param a number
|
||||
--- @param b number
|
||||
--- @param c number
|
||||
--- @param d number
|
||||
--- @return number
|
||||
--- Linearly remaps `x` from the source range `[a, b]` to the destination range `[c, d]`
|
||||
function math.remap(x, a, b, c, d)
|
||||
return c + (d - c) * ((x - a) / (b - a))
|
||||
end
|
||||
|
||||
-----------------
|
||||
-- legacy font --
|
||||
@ -177,6 +254,84 @@ end
|
||||
--- @type integer
|
||||
FONT_TINY = -1
|
||||
|
||||
|
||||
-------------------------
|
||||
-- vec types constants --
|
||||
-------------------------
|
||||
|
||||
--- @type Vec2f
|
||||
gVec2fZero = create_read_only_table({x=0,y=0})
|
||||
|
||||
--- @type Vec2f
|
||||
gVec2fOne = create_read_only_table({x=1,y=1})
|
||||
|
||||
--- @type Vec3f
|
||||
gVec3fZero = create_read_only_table({x=0,y=0,z=0})
|
||||
|
||||
--- @type Vec3f
|
||||
gVec3fOne = create_read_only_table({x=1,y=1,z=1})
|
||||
|
||||
--- @type Vec3f
|
||||
gVec3fX = create_read_only_table({x=1,y=0,z=0})
|
||||
|
||||
--- @type Vec3f
|
||||
gVec3fY = create_read_only_table({x=0,y=1,z=0})
|
||||
|
||||
--- @type Vec3f
|
||||
gVec3fZ = create_read_only_table({x=0,y=0,z=1})
|
||||
|
||||
--- @type Vec4f
|
||||
gVec4fZero = create_read_only_table({x=0,y=0,z=0,w=0})
|
||||
|
||||
--- @type Vec4f
|
||||
gVec4fOne = create_read_only_table({x=1,y=1,z=1,w=1})
|
||||
|
||||
--- @type Vec2i
|
||||
gVec2iZero = create_read_only_table({x=0,y=0})
|
||||
|
||||
--- @type Vec2i
|
||||
gVec2iOne = create_read_only_table({x=1,y=1})
|
||||
|
||||
--- @type Vec3i
|
||||
gVec3iZero = create_read_only_table({x=0,y=0,z=0})
|
||||
|
||||
--- @type Vec3i
|
||||
gVec3iOne = create_read_only_table({x=1,y=1,z=1})
|
||||
|
||||
--- @type Vec4i
|
||||
gVec4iZero = create_read_only_table({x=0,y=0,z=0,w=0})
|
||||
|
||||
--- @type Vec4i
|
||||
gVec4iOne = create_read_only_table({x=1,y=1,z=1,w=1})
|
||||
|
||||
--- @type Vec2s
|
||||
gVec2sZero = create_read_only_table({x=0,y=0})
|
||||
|
||||
--- @type Vec2s
|
||||
gVec2sOne = create_read_only_table({x=1,y=1})
|
||||
|
||||
--- @type Vec3s
|
||||
gVec3sZero = create_read_only_table({x=0,y=0,z=0})
|
||||
|
||||
--- @type Vec3s
|
||||
gVec3sOne = create_read_only_table({x=1,y=1,z=1})
|
||||
|
||||
--- @type Vec4s
|
||||
gVec4sZero = create_read_only_table({x=0,y=0,z=0,w=0})
|
||||
|
||||
--- @type Vec4s
|
||||
gVec4sOne = create_read_only_table({x=1,y=1,z=1,w=1})
|
||||
|
||||
--- @type Mat4
|
||||
gMat4Zero = create_read_only_table({m00=0,m01=0,m02=0,m03=0,m10=0,m11=0,m12=0,m13=0,m20=0,m21=0,m22=0,m23=0,m30=0,m31=0,m32=0,m33=0})
|
||||
|
||||
--- @type Mat4
|
||||
gMat4Identity = create_read_only_table({m00=1,m01=0,m02=0,m03=0,m10=0,m11=1,m12=0,m13=0,m20=0,m21=0,m22=1,m23=0,m30=0,m31=0,m32=0,m33=1})
|
||||
|
||||
--- @type Mat4
|
||||
gMat4Fullscreen = create_read_only_table({m00=0.00625,m01=0,m02=0,m03=0,m10=0,m11=0.008333333333333333,m12=0,m13=0,m20=0,m21=0,m22=-1,m23=0,m30=-1,m31=-1,m32=-1,m33=1})
|
||||
|
||||
|
||||
--- @type integer
|
||||
INSTANT_WARP_INDEX_START = 0x00
|
||||
|
||||
|
@ -6360,7 +6360,7 @@ end
|
||||
|
||||
--- @param v Vec3f
|
||||
--- @param rotate Vec3s
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- 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`
|
||||
function vec3f_rotate_zxy(v, rotate)
|
||||
-- ...
|
||||
@ -6370,7 +6370,7 @@ end
|
||||
--- @param v Vec3f
|
||||
--- @param n Vec3f
|
||||
--- @param r integer
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- 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`
|
||||
function vec3f_rotate_around_n(dest, v, n, r)
|
||||
-- ...
|
||||
@ -6379,7 +6379,7 @@ end
|
||||
--- @param dest Vec3f
|
||||
--- @param v Vec3f
|
||||
--- @param onto Vec3f
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- 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`
|
||||
function vec3f_project(dest, v, onto)
|
||||
-- ...
|
||||
@ -6390,7 +6390,7 @@ end
|
||||
--- @param translation Vec3f
|
||||
--- @param rotation Vec3s
|
||||
--- @param scale Vec3f
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- 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`
|
||||
function vec3f_transform(dest, v, translation, rotation, scale)
|
||||
-- ...
|
||||
@ -6420,7 +6420,7 @@ end
|
||||
--- @param a Vec3f
|
||||
--- @param b Vec3f
|
||||
--- @param c Vec3f
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- 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`
|
||||
function find_vector_perpendicular_to_plane(dest, a, b, c)
|
||||
-- ...
|
||||
@ -6498,7 +6498,7 @@ end
|
||||
--- @param mtx Mat4
|
||||
--- @param b Vec3s
|
||||
--- @return Pointer_integer
|
||||
--- Multiplies the 4x4 floating-point matrix `mtx` by a 3D signed-integer vector `b`, potentially interpreting `b` as angles or translations depending on usage, and modifies `mtx` accordingly
|
||||
--- 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)
|
||||
-- ...
|
||||
end
|
||||
@ -6520,7 +6520,7 @@ end
|
||||
--- @param dest Vec3f
|
||||
--- @param objMtx Mat4
|
||||
--- @param camMtx Mat4
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- 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
|
||||
function get_pos_from_transform_mtx(dest, objMtx, camMtx)
|
||||
-- ...
|
||||
@ -6597,7 +6597,7 @@ function mtxf_scale_vec3f(dest, mtx, s)
|
||||
end
|
||||
|
||||
--- @param v Vec3f
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- Sets the components of the 3D floating-point vector `v` to 0
|
||||
function vec3f_zero(v)
|
||||
-- ...
|
||||
@ -6605,7 +6605,7 @@ end
|
||||
|
||||
--- @param dest Vec3f
|
||||
--- @param src Vec3f
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- Copies the contents of a 3D floating-point vector (`src`) into another 3D floating-point vector (`dest`)
|
||||
function vec3f_copy(dest, src)
|
||||
-- ...
|
||||
@ -6615,7 +6615,7 @@ end
|
||||
--- @param x number
|
||||
--- @param y number
|
||||
--- @param z number
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- Sets the values of the 3D floating-point vector `dest` to the given x, y, and z values
|
||||
function vec3f_set(dest, x, y, z)
|
||||
-- ...
|
||||
@ -6623,7 +6623,7 @@ end
|
||||
|
||||
--- @param dest Vec3f
|
||||
--- @param a Vec3f
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- Adds the components of the 3D floating-point vector `a` to `dest`
|
||||
function vec3f_add(dest, a)
|
||||
-- ...
|
||||
@ -6632,7 +6632,7 @@ end
|
||||
--- @param dest Vec3f
|
||||
--- @param a Vec3f
|
||||
--- @param b Vec3f
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- Adds the components of two 3D floating-point vectors `a` and `b` and stores the result in `dest`
|
||||
function vec3f_sum(dest, a, b)
|
||||
-- ...
|
||||
@ -6640,7 +6640,7 @@ end
|
||||
|
||||
--- @param dest Vec3f
|
||||
--- @param a Vec3f
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- Subtracts the components of the 3D floating-point vector `a` from `dest`
|
||||
function vec3f_sub(dest, a)
|
||||
-- ...
|
||||
@ -6649,7 +6649,7 @@ end
|
||||
--- @param dest Vec3f
|
||||
--- @param a Vec3f
|
||||
--- @param b Vec3f
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- Subtracts the components of the 3D floating-point vector `b` from the components of `a` and stores the result in `dest`
|
||||
function vec3f_dif(dest, a, b)
|
||||
-- ...
|
||||
@ -6657,15 +6657,32 @@ end
|
||||
|
||||
--- @param dest Vec3f
|
||||
--- @param a number
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- Multiplies each component of the 3D floating-point vector `dest` by the scalar value `a`
|
||||
function vec3f_mul(dest, a)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param dest Vec3f
|
||||
--- @param a Vec3f
|
||||
--- @return Vec3f
|
||||
--- Multiplies the components of the 3D floating-point vector `dest` with the components of `a`
|
||||
function vec3f_mult(dest, a)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param dest Vec3f
|
||||
--- @param a Vec3f
|
||||
--- @param b Vec3f
|
||||
--- @return Vec3f
|
||||
--- Multiplies the components of two 3D floating-point vectors `a` and `b` and stores the result in `dest`
|
||||
function vec3f_prod(dest, a, b)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param dest Vec3f
|
||||
--- @param a number
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- Divides each component of the 3D floating-point vector `dest` by the scalar value `a`
|
||||
function vec3f_div(dest, a)
|
||||
-- ...
|
||||
@ -6679,7 +6696,7 @@ function vec3f_length(a)
|
||||
end
|
||||
|
||||
--- @param v Vec3f
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- Normalizes the 3D floating-point vector `v` so that its length (magnitude) becomes 1, while retaining its direction
|
||||
function vec3f_normalize(v)
|
||||
-- ...
|
||||
@ -6687,7 +6704,7 @@ end
|
||||
|
||||
--- @param v Vec3f
|
||||
--- @param mag number
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- Sets the length (magnitude) of 3D floating-point vector `v`, while retaining its direction
|
||||
function vec3f_set_magnitude(v, mag)
|
||||
-- ...
|
||||
@ -6704,7 +6721,7 @@ end
|
||||
--- @param dest Vec3f
|
||||
--- @param a Vec3f
|
||||
--- @param b Vec3f
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- Computes the cross product of two 3D floating-point vectors `a` and `b` and stores the result in `dest`
|
||||
function vec3f_cross(dest, a, b)
|
||||
-- ...
|
||||
@ -6715,7 +6732,7 @@ end
|
||||
--- @param vecB Vec3f
|
||||
--- @param sclA number
|
||||
--- @param sclB number
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- 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`
|
||||
function vec3f_combine(dest, vecA, vecB, sclA, sclB)
|
||||
-- ...
|
||||
@ -6746,7 +6763,7 @@ end
|
||||
|
||||
--- @param dest Vec3i
|
||||
--- @param a Vec3f
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3i
|
||||
--- Converts a 3D floating-point vector `a` into a 3D integer vector and stores the result in `dest`
|
||||
function vec3f_to_vec3i(dest, a)
|
||||
-- ...
|
||||
@ -6754,14 +6771,14 @@ end
|
||||
|
||||
--- @param dest Vec3s
|
||||
--- @param a Vec3f
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3s
|
||||
--- Converts a 3D floating-point vector `a` into a 3D short integer vector and stores the result in `dest`
|
||||
function vec3f_to_vec3s(dest, a)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param v Vec3i
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3i
|
||||
--- Sets the components of the 3D integer vector `v` to 0
|
||||
function vec3i_zero(v)
|
||||
-- ...
|
||||
@ -6769,7 +6786,7 @@ end
|
||||
|
||||
--- @param dest Vec3i
|
||||
--- @param src Vec3i
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3i
|
||||
--- Copies the contents of a 3D integer vector (`src`) into another 3D integer vector (`dest`)
|
||||
function vec3i_copy(dest, src)
|
||||
-- ...
|
||||
@ -6779,7 +6796,7 @@ end
|
||||
--- @param x integer
|
||||
--- @param y integer
|
||||
--- @param z integer
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3i
|
||||
--- Sets the values of the 3D integer vector `dest` to the given x, y, and z values
|
||||
function vec3i_set(dest, x, y, z)
|
||||
-- ...
|
||||
@ -6787,7 +6804,7 @@ end
|
||||
|
||||
--- @param dest Vec3i
|
||||
--- @param a Vec3i
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3i
|
||||
--- Adds the components of the 3D integer vector `a` to `dest`
|
||||
function vec3i_add(dest, a)
|
||||
-- ...
|
||||
@ -6796,7 +6813,7 @@ end
|
||||
--- @param dest Vec3i
|
||||
--- @param a Vec3i
|
||||
--- @param b Vec3i
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3i
|
||||
--- Adds the components of two 3D integer vectors `a` and `b` and stores the result in `dest`
|
||||
function vec3i_sum(dest, a, b)
|
||||
-- ...
|
||||
@ -6804,7 +6821,7 @@ end
|
||||
|
||||
--- @param dest Vec3i
|
||||
--- @param a Vec3i
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3i
|
||||
--- Subtracts the components of the 3D integer vector `a` from `dest`
|
||||
function vec3i_sub(dest, a)
|
||||
-- ...
|
||||
@ -6813,7 +6830,7 @@ end
|
||||
--- @param dest Vec3i
|
||||
--- @param a Vec3i
|
||||
--- @param b Vec3i
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3i
|
||||
--- Subtracts the components of the 3D integer vector `b` from the components of `a` and stores the result in `dest`
|
||||
function vec3i_dif(dest, a, b)
|
||||
-- ...
|
||||
@ -6821,15 +6838,32 @@ end
|
||||
|
||||
--- @param dest Vec3i
|
||||
--- @param a number
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3i
|
||||
--- Multiplies each component of the 3D integer vector `dest` by the scalar value `a`
|
||||
function vec3i_mul(dest, a)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param dest Vec3i
|
||||
--- @param a Vec3i
|
||||
--- @return Vec3i
|
||||
--- Multiplies the components of the 3D integer vector `dest` with the components of `a`
|
||||
function vec3i_mult(dest, a)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param dest Vec3i
|
||||
--- @param a Vec3i
|
||||
--- @param b Vec3i
|
||||
--- @return Vec3i
|
||||
--- Multiplies the components of two 3D integer vectors `a` and `b` and stores the result in `dest`
|
||||
function vec3i_prod(dest, a, b)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param dest Vec3i
|
||||
--- @param a number
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3i
|
||||
--- Divides each component of the 3D integer vector `dest` by the scalar value `a`
|
||||
function vec3i_div(dest, a)
|
||||
-- ...
|
||||
@ -6843,7 +6877,7 @@ function vec3i_length(a)
|
||||
end
|
||||
|
||||
--- @param v Vec3i
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3i
|
||||
--- Normalizes the 3D integer vector `v` so that its length (magnitude) becomes 1, while retaining its direction
|
||||
function vec3i_normalize(v)
|
||||
-- ...
|
||||
@ -6851,7 +6885,7 @@ end
|
||||
|
||||
--- @param v Vec3i
|
||||
--- @param mag number
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3i
|
||||
--- Sets the length (magnitude) of 3D integer vector `v`, while retaining its direction
|
||||
function vec3i_set_magnitude(v, mag)
|
||||
-- ...
|
||||
@ -6868,7 +6902,7 @@ end
|
||||
--- @param dest Vec3i
|
||||
--- @param a Vec3i
|
||||
--- @param b Vec3i
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3i
|
||||
--- Computes the cross product of two 3D integer vectors `a` and `b` and stores the result in `dest`
|
||||
function vec3i_cross(dest, a, b)
|
||||
-- ...
|
||||
@ -6879,7 +6913,7 @@ end
|
||||
--- @param vecB Vec3i
|
||||
--- @param sclA number
|
||||
--- @param sclB number
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3i
|
||||
--- 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`
|
||||
function vec3i_combine(dest, vecA, vecB, sclA, sclB)
|
||||
-- ...
|
||||
@ -6910,7 +6944,7 @@ end
|
||||
|
||||
--- @param dest Vec3f
|
||||
--- @param a Vec3i
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- Converts a 3D integer vector `a` into a 3D floating-point vector and stores the result in `dest`
|
||||
function vec3i_to_vec3f(dest, a)
|
||||
-- ...
|
||||
@ -6918,14 +6952,14 @@ end
|
||||
|
||||
--- @param dest Vec3s
|
||||
--- @param a Vec3i
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3s
|
||||
--- Converts a 3D integer vector `a` into a 3D short integer vector and stores the result in `dest`
|
||||
function vec3i_to_vec3s(dest, a)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param v Vec3s
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3s
|
||||
--- Sets the components of the 3D short integer vector `v` to 0
|
||||
function vec3s_zero(v)
|
||||
-- ...
|
||||
@ -6933,7 +6967,7 @@ end
|
||||
|
||||
--- @param dest Vec3s
|
||||
--- @param src Vec3s
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3s
|
||||
--- Copies the contents of a 3D short integer vector (`src`) into another 3D short integer vector (`dest`)
|
||||
function vec3s_copy(dest, src)
|
||||
-- ...
|
||||
@ -6943,7 +6977,7 @@ end
|
||||
--- @param x integer
|
||||
--- @param y integer
|
||||
--- @param z integer
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3s
|
||||
--- Sets the values of the 3D short integer vector `dest` to the given x, y, and z values
|
||||
function vec3s_set(dest, x, y, z)
|
||||
-- ...
|
||||
@ -6951,7 +6985,7 @@ end
|
||||
|
||||
--- @param dest Vec3s
|
||||
--- @param a Vec3s
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3s
|
||||
--- Adds the components of the 3D short integer vector `a` to `dest`
|
||||
function vec3s_add(dest, a)
|
||||
-- ...
|
||||
@ -6960,7 +6994,7 @@ end
|
||||
--- @param dest Vec3s
|
||||
--- @param a Vec3s
|
||||
--- @param b Vec3s
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3s
|
||||
--- Adds the components of two 3D short integer vectors `a` and `b` and stores the result in `dest`
|
||||
function vec3s_sum(dest, a, b)
|
||||
-- ...
|
||||
@ -6968,7 +7002,7 @@ end
|
||||
|
||||
--- @param dest Vec3s
|
||||
--- @param a Vec3s
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3s
|
||||
--- Subtracts the components of the 3D short integer vector `a` from `dest`
|
||||
function vec3s_sub(dest, a)
|
||||
-- ...
|
||||
@ -6977,7 +7011,7 @@ end
|
||||
--- @param dest Vec3s
|
||||
--- @param a Vec3s
|
||||
--- @param b Vec3s
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3s
|
||||
--- Subtracts the components of the 3D short integer vector `b` from the components of `a` and stores the result in `dest`
|
||||
function vec3s_dif(dest, a, b)
|
||||
-- ...
|
||||
@ -6985,15 +7019,32 @@ end
|
||||
|
||||
--- @param dest Vec3s
|
||||
--- @param a number
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3s
|
||||
--- Multiplies each component of the 3D short integer vector `dest` by the scalar value `a`
|
||||
function vec3s_mul(dest, a)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param dest Vec3s
|
||||
--- @param a Vec3s
|
||||
--- @return Vec3s
|
||||
--- Multiplies the components of the 3D short integer vector `dest` with the components of `a`
|
||||
function vec3s_mult(dest, a)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param dest Vec3s
|
||||
--- @param a Vec3s
|
||||
--- @param b Vec3s
|
||||
--- @return Vec3s
|
||||
--- Multiplies the components of two 3D short integer vectors `a` and `b` and stores the result in `dest`
|
||||
function vec3s_prod(dest, a, b)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param dest Vec3s
|
||||
--- @param a number
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3s
|
||||
--- Divides each component of the 3D short integer vector `dest` by the scalar value `a`
|
||||
function vec3s_div(dest, a)
|
||||
-- ...
|
||||
@ -7007,7 +7058,7 @@ function vec3s_length(a)
|
||||
end
|
||||
|
||||
--- @param v Vec3s
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3s
|
||||
--- Normalizes the 3D short integer vector `v` so that its length (magnitude) becomes 1, while retaining its direction
|
||||
function vec3s_normalize(v)
|
||||
-- ...
|
||||
@ -7015,7 +7066,7 @@ end
|
||||
|
||||
--- @param v Vec3s
|
||||
--- @param mag number
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3s
|
||||
--- Sets the length (magnitude) of 3D short integer vector `v`, while retaining its direction
|
||||
function vec3s_set_magnitude(v, mag)
|
||||
-- ...
|
||||
@ -7032,7 +7083,7 @@ end
|
||||
--- @param dest Vec3s
|
||||
--- @param a Vec3s
|
||||
--- @param b Vec3s
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3s
|
||||
--- Computes the cross product of two 3D short integer vectors `a` and `b` and stores the result in `dest`
|
||||
function vec3s_cross(dest, a, b)
|
||||
-- ...
|
||||
@ -7043,7 +7094,7 @@ end
|
||||
--- @param vecB Vec3s
|
||||
--- @param sclA number
|
||||
--- @param sclB number
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3s
|
||||
--- 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`
|
||||
function vec3s_combine(dest, vecA, vecB, sclA, sclB)
|
||||
-- ...
|
||||
@ -7074,7 +7125,7 @@ end
|
||||
|
||||
--- @param dest Vec3f
|
||||
--- @param a Vec3s
|
||||
--- @return Pointer_number
|
||||
--- @return Vec3f
|
||||
--- Converts a 3D short integer vector `a` into a 3D floating-point vector and stores the result in `dest`
|
||||
function vec3s_to_vec3f(dest, a)
|
||||
-- ...
|
||||
@ -7082,7 +7133,7 @@ end
|
||||
|
||||
--- @param dest Vec3i
|
||||
--- @param a Vec3s
|
||||
--- @return Pointer_integer
|
||||
--- @return Vec3i
|
||||
--- Converts a 3D short integer vector `a` into a 3D integer vector and stores the result in `dest`
|
||||
function vec3s_to_vec3i(dest, a)
|
||||
-- ...
|
||||
@ -11693,3 +11744,14 @@ end
|
||||
--- @alias Pointer_Collision Collision
|
||||
--- @alias Pointer_Gfx Gfx
|
||||
--- @alias Pointer_Vtx Vtx
|
||||
--- @alias Vec2fp Vec2f
|
||||
--- @alias Vec3fp Vec3f
|
||||
--- @alias Vec4fp Vec4f
|
||||
--- @alias Vec2ip Vec2i
|
||||
--- @alias Vec3ip Vec3i
|
||||
--- @alias Vec4ip Vec4i
|
||||
--- @alias Vec2sp Vec2s
|
||||
--- @alias Vec3sp Vec3s
|
||||
--- @alias Vec4sp Vec4s
|
||||
--- @alias Mat4p Mat4
|
||||
--- @alias Colorp Color
|
||||
|
@ -6,6 +6,10 @@ VEC_TYPES = {
|
||||
"x": "[0]",
|
||||
"y": "[1]",
|
||||
},
|
||||
"constants": {
|
||||
"Zero": [ 0, 0 ],
|
||||
"One": [ 1, 1 ],
|
||||
},
|
||||
},
|
||||
"Vec3f": {
|
||||
"field_c_type": "f32",
|
||||
@ -15,6 +19,13 @@ VEC_TYPES = {
|
||||
"y": "[1]",
|
||||
"z": "[2]",
|
||||
},
|
||||
"constants": {
|
||||
"Zero": [ 0, 0, 0 ],
|
||||
"One": [ 1, 1, 1 ],
|
||||
"X": [ 1, 0, 0 ],
|
||||
"Y": [ 0, 1, 0 ],
|
||||
"Z": [ 0, 0, 1 ],
|
||||
},
|
||||
},
|
||||
"Vec4f": {
|
||||
"field_c_type": "f32",
|
||||
@ -25,6 +36,10 @@ VEC_TYPES = {
|
||||
"z": "[2]",
|
||||
"w": "[3]",
|
||||
},
|
||||
"constants": {
|
||||
"Zero": [ 0, 0, 0, 0 ],
|
||||
"One": [ 1, 1, 1, 1 ],
|
||||
},
|
||||
},
|
||||
"Vec2i": {
|
||||
"field_c_type": "s32",
|
||||
@ -33,6 +48,10 @@ VEC_TYPES = {
|
||||
"x": "[0]",
|
||||
"y": "[1]",
|
||||
},
|
||||
"constants": {
|
||||
"Zero": [ 0, 0 ],
|
||||
"One": [ 1, 1 ],
|
||||
},
|
||||
},
|
||||
"Vec3i": {
|
||||
"field_c_type": "s32",
|
||||
@ -42,6 +61,10 @@ VEC_TYPES = {
|
||||
"y": "[1]",
|
||||
"z": "[2]",
|
||||
},
|
||||
"constants": {
|
||||
"Zero": [ 0, 0, 0 ],
|
||||
"One": [ 1, 1, 1 ],
|
||||
},
|
||||
},
|
||||
"Vec4i": {
|
||||
"field_c_type": "s32",
|
||||
@ -52,6 +75,10 @@ VEC_TYPES = {
|
||||
"z": "[2]",
|
||||
"w": "[3]",
|
||||
},
|
||||
"constants": {
|
||||
"Zero": [ 0, 0, 0, 0 ],
|
||||
"One": [ 1, 1, 1, 1 ],
|
||||
},
|
||||
},
|
||||
"Vec2s": {
|
||||
"field_c_type": "s16",
|
||||
@ -60,6 +87,10 @@ VEC_TYPES = {
|
||||
"x": "[0]",
|
||||
"y": "[1]",
|
||||
},
|
||||
"constants": {
|
||||
"Zero": [ 0, 0 ],
|
||||
"One": [ 1, 1 ],
|
||||
},
|
||||
},
|
||||
"Vec3s": {
|
||||
"field_c_type": "s16",
|
||||
@ -69,6 +100,10 @@ VEC_TYPES = {
|
||||
"y": "[1]",
|
||||
"z": "[2]",
|
||||
},
|
||||
"constants": {
|
||||
"Zero": [ 0, 0, 0 ],
|
||||
"One": [ 1, 1, 1 ],
|
||||
},
|
||||
},
|
||||
"Vec4s": {
|
||||
"field_c_type": "s16",
|
||||
@ -79,6 +114,10 @@ VEC_TYPES = {
|
||||
"z": "[2]",
|
||||
"w": "[3]",
|
||||
},
|
||||
"constants": {
|
||||
"Zero": [ 0, 0, 0, 0 ],
|
||||
"One": [ 1, 1, 1, 1 ],
|
||||
},
|
||||
},
|
||||
"Mat4": {
|
||||
"field_c_type": "f32",
|
||||
@ -119,6 +158,11 @@ VEC_TYPES = {
|
||||
"o": "[3][2]",
|
||||
"p": "[3][3]",
|
||||
},
|
||||
"constants": {
|
||||
"Zero": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
|
||||
"Identity": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ],
|
||||
"Fullscreen": [ 2.0 / 320.0, 0, 0, 0, 0, 2.0 / 240.0, 0, 0, 0, 0, -1, 0, -1, -1, -1, 1 ]
|
||||
},
|
||||
},
|
||||
"Color": {
|
||||
"field_c_type": "u8",
|
||||
@ -130,3 +174,8 @@ VEC_TYPES = {
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
VECP_TYPES = {
|
||||
vec_type + "p": vec_type
|
||||
for vec_type in VEC_TYPES
|
||||
}
|
||||
|
@ -6425,7 +6425,7 @@ Calculates the lighting with `lightIntensityScalar` at a position and outputs th
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| pos | [Vec3f](structs.md#Vec3f) |
|
||||
| out | `Color` |
|
||||
| out | [Color](structs.md#Color) |
|
||||
| lightIntensityScalar | `number` |
|
||||
|
||||
### Returns
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,6 +5,247 @@
|
||||
[< prev](functions-4.md) | [1](functions.md) | [2](functions-2.md) | [3](functions-3.md) | [4](functions-4.md) | 5 | [6](functions-6.md) | [next >](functions-6.md)]
|
||||
|
||||
|
||||
---
|
||||
# functions from misc.h
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
## [smooth_step](#smooth_step)
|
||||
|
||||
### Description
|
||||
Smoothly steps between `edge0` and `edge1` with `x` as delta
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = smooth_step(edge0, edge1, x)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| edge0 | `number` |
|
||||
| edge1 | `number` |
|
||||
| x | `number` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`float smooth_step(float edge0, float edge1, float x);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [update_all_mario_stars](#update_all_mario_stars)
|
||||
|
||||
### Description
|
||||
Updates every Mario state's star count with the save file total star count
|
||||
|
||||
### Lua Example
|
||||
`update_all_mario_stars()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void update_all_mario_stars(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [clock_elapsed](#clock_elapsed)
|
||||
|
||||
### Description
|
||||
Gets the current clock elapsed time
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = clock_elapsed()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 clock_elapsed(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [clock_elapsed_f64](#clock_elapsed_f64)
|
||||
|
||||
### Description
|
||||
Gets the current clock elapsed time with double precision
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = clock_elapsed_f64()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f64 clock_elapsed_f64(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [clock_elapsed_ticks](#clock_elapsed_ticks)
|
||||
|
||||
### Description
|
||||
Gets the current clock elapsed time in frames
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = clock_elapsed_ticks()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`u32 clock_elapsed_ticks(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [clock_is_date](#clock_is_date)
|
||||
|
||||
### Description
|
||||
Checks whether it is the day given
|
||||
|
||||
### Lua Example
|
||||
`local booleanValue = clock_is_date(month, day)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| month | `integer` |
|
||||
| day | `integer` |
|
||||
|
||||
### Returns
|
||||
- `boolean`
|
||||
|
||||
### C Prototype
|
||||
`bool clock_is_date(u8 month, u8 day);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [delta_interpolate_f32](#delta_interpolate_f32)
|
||||
|
||||
### Description
|
||||
Linearly interpolates between `a` and `b` with `delta`
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = delta_interpolate_f32(a, b, delta)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| a | `number` |
|
||||
| b | `number` |
|
||||
| delta | `number` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 delta_interpolate_f32(f32 a, f32 b, f32 delta);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [delta_interpolate_s32](#delta_interpolate_s32)
|
||||
|
||||
### Description
|
||||
Linearly interpolates between `a` and `b` with `delta`
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = delta_interpolate_s32(a, b, delta)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| a | `integer` |
|
||||
| b | `integer` |
|
||||
| delta | `number` |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`s32 delta_interpolate_s32(s32 a, s32 b, f32 delta);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [delta_interpolate_vec3f](#delta_interpolate_vec3f)
|
||||
|
||||
### Description
|
||||
Linearly interpolates `res` between `a` and `b` with `delta`
|
||||
|
||||
### Lua Example
|
||||
`delta_interpolate_vec3f(res, a, b, delta)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| res | [Vec3f](structs.md#Vec3f) |
|
||||
| a | [Vec3f](structs.md#Vec3f) |
|
||||
| b | [Vec3f](structs.md#Vec3f) |
|
||||
| delta | `number` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void delta_interpolate_vec3f(Vec3f res, Vec3f a, Vec3f b, f32 delta);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [delta_interpolate_vec3s](#delta_interpolate_vec3s)
|
||||
|
||||
### Description
|
||||
Linearly interpolates `res` between `a` and `b` with `delta`
|
||||
|
||||
### Lua Example
|
||||
`delta_interpolate_vec3s(res, a, b, delta)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| res | [Vec3s](structs.md#Vec3s) |
|
||||
| a | [Vec3s](structs.md#Vec3s) |
|
||||
| b | [Vec3s](structs.md#Vec3s) |
|
||||
| delta | `number` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void delta_interpolate_vec3s(Vec3s res, Vec3s a, Vec3s b, f32 delta);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from mod_storage.h
|
||||
|
||||
@ -406,7 +647,7 @@ Sets the `part in `np`'s override color palette`
|
||||
| ----- | ---- |
|
||||
| np | [NetworkPlayer](structs.md#NetworkPlayer) |
|
||||
| part | [enum PlayerPart](constants.md#enum-PlayerPart) |
|
||||
| color | `Color` |
|
||||
| color | [Color](structs.md#Color) |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
@ -2659,7 +2900,7 @@ Overrides the current room Mario is in. Set to -1 to reset override
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| a0 | `Mat4` |
|
||||
| a0 | [Mat4](structs.md#Mat4) |
|
||||
| a1 | [Object](structs.md#Object) |
|
||||
|
||||
### Returns
|
||||
@ -2681,8 +2922,8 @@ Overrides the current room Mario is in. Set to -1 to reset override
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| obj | [Object](structs.md#Object) |
|
||||
| dst | `Mat4` |
|
||||
| src | `Mat4` |
|
||||
| dst | [Mat4](structs.md#Mat4) |
|
||||
| src | [Mat4](structs.md#Mat4) |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
@ -2702,9 +2943,9 @@ Overrides the current room Mario is in. Set to -1 to reset override
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| a0 | `Mat4` |
|
||||
| a1 | `Mat4` |
|
||||
| a2 | `Mat4` |
|
||||
| a0 | [Mat4](structs.md#Mat4) |
|
||||
| a1 | [Mat4](structs.md#Mat4) |
|
||||
| a2 | [Mat4](structs.md#Mat4) |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
@ -3376,7 +3617,7 @@ Multiplies a vector by a matrix of the form: `| ? ? ? 0 |` `| ? ? ? 0 |` `| ? ?
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| m | `Mat4` |
|
||||
| m | [Mat4](structs.md#Mat4) |
|
||||
| dst | [Vec3f](structs.md#Vec3f) |
|
||||
| v | [Vec3f](structs.md#Vec3f) |
|
||||
|
||||
@ -3401,7 +3642,7 @@ Multiplies a vector by the transpose of a matrix of the form: `| ? ? ? 0 |` `| ?
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| m | `Mat4` |
|
||||
| m | [Mat4](structs.md#Mat4) |
|
||||
| dst | [Vec3f](structs.md#Vec3f) |
|
||||
| v | [Vec3f](structs.md#Vec3f) |
|
||||
|
||||
@ -7861,298 +8102,6 @@ Returns the current sound mode (e.g., stereo, mono) stored in the save file. Use
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from seqplayer.h
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
## [sequence_player_get_tempo](#sequence_player_get_tempo)
|
||||
|
||||
### Description
|
||||
Gets the tempo of `player`
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = sequence_player_get_tempo(player)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`u16 sequence_player_get_tempo(u8 player);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_set_tempo](#sequence_player_set_tempo)
|
||||
|
||||
### Description
|
||||
Sets the `tempo` of `player`. Resets when another sequence is played
|
||||
|
||||
### Lua Example
|
||||
`sequence_player_set_tempo(player, tempo)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
| tempo | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void sequence_player_set_tempo(u8 player, u16 tempo);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_get_tempo_acc](#sequence_player_get_tempo_acc)
|
||||
|
||||
### Description
|
||||
Gets the tempoAcc (tempo accumulation) of `player`
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = sequence_player_get_tempo_acc(player)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`u16 sequence_player_get_tempo_acc(u8 player);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_set_tempo_acc](#sequence_player_set_tempo_acc)
|
||||
|
||||
### Description
|
||||
Sets the `tempoAcc` (tempo accumulation) of `player`. Resets when another sequence is played
|
||||
|
||||
### Lua Example
|
||||
`sequence_player_set_tempo_acc(player, tempoAcc)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
| tempoAcc | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void sequence_player_set_tempo_acc(u8 player, u16 tempoAcc);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_get_transposition](#sequence_player_get_transposition)
|
||||
|
||||
### Description
|
||||
Gets the transposition (pitch) of `player`
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = sequence_player_get_transposition(player)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`u16 sequence_player_get_transposition(u8 player);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_set_transposition](#sequence_player_set_transposition)
|
||||
|
||||
### Description
|
||||
Sets the `transposition` (pitch) of `player`. Resets when another sequence is played
|
||||
|
||||
### Lua Example
|
||||
`sequence_player_set_transposition(player, transposition)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
| transposition | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void sequence_player_set_transposition(u8 player, u16 transposition);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_get_volume](#sequence_player_get_volume)
|
||||
|
||||
### Description
|
||||
Gets the volume of `player`
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = sequence_player_get_volume(player)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 sequence_player_get_volume(u8 player);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_get_fade_volume](#sequence_player_get_fade_volume)
|
||||
|
||||
### Description
|
||||
Gets the fade volume of `player`
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = sequence_player_get_fade_volume(player)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 sequence_player_get_fade_volume(u8 player);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_get_mute_volume_scale](#sequence_player_get_mute_volume_scale)
|
||||
|
||||
### Description
|
||||
Gets the mute volume scale of `player`
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = sequence_player_get_mute_volume_scale(player)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 sequence_player_get_mute_volume_scale(u8 player);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from smlua_anim_utils.h
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
## [get_mario_vanilla_animation](#get_mario_vanilla_animation)
|
||||
|
||||
### Description
|
||||
Gets a vanilla mario Animation with `index`
|
||||
|
||||
### Lua Example
|
||||
`local AnimationValue = get_mario_vanilla_animation(index)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| index | `integer` |
|
||||
|
||||
### Returns
|
||||
[Animation](structs.md#Animation)
|
||||
|
||||
### C Prototype
|
||||
`struct Animation *get_mario_vanilla_animation(u16 index);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [smlua_anim_util_set_animation](#smlua_anim_util_set_animation)
|
||||
|
||||
### Description
|
||||
Sets the animation of `obj` to the animation `name` corresponds to
|
||||
|
||||
### Lua Example
|
||||
`smlua_anim_util_set_animation(obj, name)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| obj | [Object](structs.md#Object) |
|
||||
| name | `string` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void smlua_anim_util_set_animation(struct Object *obj, const char *name);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [smlua_anim_util_get_current_animation_name](#smlua_anim_util_get_current_animation_name)
|
||||
|
||||
### Description
|
||||
Gets the name of the current animation playing on `obj`, returns `nil` if there's no name
|
||||
|
||||
### Lua Example
|
||||
`local stringValue = smlua_anim_util_get_current_animation_name(obj)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| obj | [Object](structs.md#Object) |
|
||||
|
||||
### Returns
|
||||
- `string`
|
||||
|
||||
### C Prototype
|
||||
`const char *smlua_anim_util_get_current_animation_name(struct Object *obj);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
---
|
||||
|
||||
|
@ -5,6 +5,298 @@
|
||||
[< prev](functions-5.md) | [1](functions.md) | [2](functions-2.md) | [3](functions-3.md) | [4](functions-4.md) | [5](functions-5.md) | 6]
|
||||
|
||||
|
||||
---
|
||||
# functions from seqplayer.h
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
## [sequence_player_get_tempo](#sequence_player_get_tempo)
|
||||
|
||||
### Description
|
||||
Gets the tempo of `player`
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = sequence_player_get_tempo(player)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`u16 sequence_player_get_tempo(u8 player);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_set_tempo](#sequence_player_set_tempo)
|
||||
|
||||
### Description
|
||||
Sets the `tempo` of `player`. Resets when another sequence is played
|
||||
|
||||
### Lua Example
|
||||
`sequence_player_set_tempo(player, tempo)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
| tempo | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void sequence_player_set_tempo(u8 player, u16 tempo);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_get_tempo_acc](#sequence_player_get_tempo_acc)
|
||||
|
||||
### Description
|
||||
Gets the tempoAcc (tempo accumulation) of `player`
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = sequence_player_get_tempo_acc(player)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`u16 sequence_player_get_tempo_acc(u8 player);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_set_tempo_acc](#sequence_player_set_tempo_acc)
|
||||
|
||||
### Description
|
||||
Sets the `tempoAcc` (tempo accumulation) of `player`. Resets when another sequence is played
|
||||
|
||||
### Lua Example
|
||||
`sequence_player_set_tempo_acc(player, tempoAcc)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
| tempoAcc | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void sequence_player_set_tempo_acc(u8 player, u16 tempoAcc);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_get_transposition](#sequence_player_get_transposition)
|
||||
|
||||
### Description
|
||||
Gets the transposition (pitch) of `player`
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = sequence_player_get_transposition(player)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`u16 sequence_player_get_transposition(u8 player);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_set_transposition](#sequence_player_set_transposition)
|
||||
|
||||
### Description
|
||||
Sets the `transposition` (pitch) of `player`. Resets when another sequence is played
|
||||
|
||||
### Lua Example
|
||||
`sequence_player_set_transposition(player, transposition)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
| transposition | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void sequence_player_set_transposition(u8 player, u16 transposition);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_get_volume](#sequence_player_get_volume)
|
||||
|
||||
### Description
|
||||
Gets the volume of `player`
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = sequence_player_get_volume(player)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 sequence_player_get_volume(u8 player);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_get_fade_volume](#sequence_player_get_fade_volume)
|
||||
|
||||
### Description
|
||||
Gets the fade volume of `player`
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = sequence_player_get_fade_volume(player)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 sequence_player_get_fade_volume(u8 player);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [sequence_player_get_mute_volume_scale](#sequence_player_get_mute_volume_scale)
|
||||
|
||||
### Description
|
||||
Gets the mute volume scale of `player`
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = sequence_player_get_mute_volume_scale(player)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| player | `integer` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 sequence_player_get_mute_volume_scale(u8 player);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from smlua_anim_utils.h
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
## [get_mario_vanilla_animation](#get_mario_vanilla_animation)
|
||||
|
||||
### Description
|
||||
Gets a vanilla mario Animation with `index`
|
||||
|
||||
### Lua Example
|
||||
`local AnimationValue = get_mario_vanilla_animation(index)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| index | `integer` |
|
||||
|
||||
### Returns
|
||||
[Animation](structs.md#Animation)
|
||||
|
||||
### C Prototype
|
||||
`struct Animation *get_mario_vanilla_animation(u16 index);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [smlua_anim_util_set_animation](#smlua_anim_util_set_animation)
|
||||
|
||||
### Description
|
||||
Sets the animation of `obj` to the animation `name` corresponds to
|
||||
|
||||
### Lua Example
|
||||
`smlua_anim_util_set_animation(obj, name)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| obj | [Object](structs.md#Object) |
|
||||
| name | `string` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void smlua_anim_util_set_animation(struct Object *obj, const char *name);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [smlua_anim_util_get_current_animation_name](#smlua_anim_util_get_current_animation_name)
|
||||
|
||||
### Description
|
||||
Gets the name of the current animation playing on `obj`, returns `nil` if there's no name
|
||||
|
||||
### Lua Example
|
||||
`local stringValue = smlua_anim_util_get_current_animation_name(obj)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| obj | [Object](structs.md#Object) |
|
||||
|
||||
### Returns
|
||||
- `string`
|
||||
|
||||
### C Prototype
|
||||
`const char *smlua_anim_util_get_current_animation_name(struct Object *obj);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from smlua_audio_utils.h
|
||||
|
||||
|
@ -1245,6 +1245,8 @@
|
||||
- [vec3f_sub](functions-4.md#vec3f_sub)
|
||||
- [vec3f_dif](functions-4.md#vec3f_dif)
|
||||
- [vec3f_mul](functions-4.md#vec3f_mul)
|
||||
- [vec3f_mult](functions-4.md#vec3f_mult)
|
||||
- [vec3f_prod](functions-4.md#vec3f_prod)
|
||||
- [vec3f_div](functions-4.md#vec3f_div)
|
||||
- [vec3f_length](functions-4.md#vec3f_length)
|
||||
- [vec3f_normalize](functions-4.md#vec3f_normalize)
|
||||
@ -1269,6 +1271,8 @@
|
||||
- [vec3i_sub](functions-4.md#vec3i_sub)
|
||||
- [vec3i_dif](functions-4.md#vec3i_dif)
|
||||
- [vec3i_mul](functions-4.md#vec3i_mul)
|
||||
- [vec3i_mult](functions-4.md#vec3i_mult)
|
||||
- [vec3i_prod](functions-4.md#vec3i_prod)
|
||||
- [vec3i_div](functions-4.md#vec3i_div)
|
||||
- [vec3i_length](functions-4.md#vec3i_length)
|
||||
- [vec3i_normalize](functions-4.md#vec3i_normalize)
|
||||
@ -1293,6 +1297,8 @@
|
||||
- [vec3s_sub](functions-4.md#vec3s_sub)
|
||||
- [vec3s_dif](functions-4.md#vec3s_dif)
|
||||
- [vec3s_mul](functions-4.md#vec3s_mul)
|
||||
- [vec3s_mult](functions-4.md#vec3s_mult)
|
||||
- [vec3s_prod](functions-4.md#vec3s_prod)
|
||||
- [vec3s_div](functions-4.md#vec3s_div)
|
||||
- [vec3s_length](functions-4.md#vec3s_length)
|
||||
- [vec3s_normalize](functions-4.md#vec3s_normalize)
|
||||
@ -1309,16 +1315,16 @@
|
||||
<br />
|
||||
|
||||
- misc.h
|
||||
- [smooth_step](functions-4.md#smooth_step)
|
||||
- [update_all_mario_stars](functions-4.md#update_all_mario_stars)
|
||||
- [clock_elapsed](functions-4.md#clock_elapsed)
|
||||
- [clock_elapsed_f64](functions-4.md#clock_elapsed_f64)
|
||||
- [clock_elapsed_ticks](functions-4.md#clock_elapsed_ticks)
|
||||
- [clock_is_date](functions-4.md#clock_is_date)
|
||||
- [delta_interpolate_f32](functions-4.md#delta_interpolate_f32)
|
||||
- [delta_interpolate_s32](functions-4.md#delta_interpolate_s32)
|
||||
- [delta_interpolate_vec3f](functions-4.md#delta_interpolate_vec3f)
|
||||
- [delta_interpolate_vec3s](functions-4.md#delta_interpolate_vec3s)
|
||||
- [smooth_step](functions-5.md#smooth_step)
|
||||
- [update_all_mario_stars](functions-5.md#update_all_mario_stars)
|
||||
- [clock_elapsed](functions-5.md#clock_elapsed)
|
||||
- [clock_elapsed_f64](functions-5.md#clock_elapsed_f64)
|
||||
- [clock_elapsed_ticks](functions-5.md#clock_elapsed_ticks)
|
||||
- [clock_is_date](functions-5.md#clock_is_date)
|
||||
- [delta_interpolate_f32](functions-5.md#delta_interpolate_f32)
|
||||
- [delta_interpolate_s32](functions-5.md#delta_interpolate_s32)
|
||||
- [delta_interpolate_vec3f](functions-5.md#delta_interpolate_vec3f)
|
||||
- [delta_interpolate_vec3s](functions-5.md#delta_interpolate_vec3s)
|
||||
|
||||
<br />
|
||||
|
||||
@ -1726,22 +1732,22 @@
|
||||
<br />
|
||||
|
||||
- seqplayer.h
|
||||
- [sequence_player_get_tempo](functions-5.md#sequence_player_get_tempo)
|
||||
- [sequence_player_set_tempo](functions-5.md#sequence_player_set_tempo)
|
||||
- [sequence_player_get_tempo_acc](functions-5.md#sequence_player_get_tempo_acc)
|
||||
- [sequence_player_set_tempo_acc](functions-5.md#sequence_player_set_tempo_acc)
|
||||
- [sequence_player_get_transposition](functions-5.md#sequence_player_get_transposition)
|
||||
- [sequence_player_set_transposition](functions-5.md#sequence_player_set_transposition)
|
||||
- [sequence_player_get_volume](functions-5.md#sequence_player_get_volume)
|
||||
- [sequence_player_get_fade_volume](functions-5.md#sequence_player_get_fade_volume)
|
||||
- [sequence_player_get_mute_volume_scale](functions-5.md#sequence_player_get_mute_volume_scale)
|
||||
- [sequence_player_get_tempo](functions-6.md#sequence_player_get_tempo)
|
||||
- [sequence_player_set_tempo](functions-6.md#sequence_player_set_tempo)
|
||||
- [sequence_player_get_tempo_acc](functions-6.md#sequence_player_get_tempo_acc)
|
||||
- [sequence_player_set_tempo_acc](functions-6.md#sequence_player_set_tempo_acc)
|
||||
- [sequence_player_get_transposition](functions-6.md#sequence_player_get_transposition)
|
||||
- [sequence_player_set_transposition](functions-6.md#sequence_player_set_transposition)
|
||||
- [sequence_player_get_volume](functions-6.md#sequence_player_get_volume)
|
||||
- [sequence_player_get_fade_volume](functions-6.md#sequence_player_get_fade_volume)
|
||||
- [sequence_player_get_mute_volume_scale](functions-6.md#sequence_player_get_mute_volume_scale)
|
||||
|
||||
<br />
|
||||
|
||||
- smlua_anim_utils.h
|
||||
- [get_mario_vanilla_animation](functions-5.md#get_mario_vanilla_animation)
|
||||
- [smlua_anim_util_set_animation](functions-5.md#smlua_anim_util_set_animation)
|
||||
- [smlua_anim_util_get_current_animation_name](functions-5.md#smlua_anim_util_get_current_animation_name)
|
||||
- [get_mario_vanilla_animation](functions-6.md#get_mario_vanilla_animation)
|
||||
- [smlua_anim_util_set_animation](functions-6.md#smlua_anim_util_set_animation)
|
||||
- [smlua_anim_util_get_current_animation_name](functions-6.md#smlua_anim_util_get_current_animation_name)
|
||||
|
||||
<br />
|
||||
|
||||
|
@ -408,7 +408,7 @@
|
||||
| filler3C | `Array` <`integer`> | |
|
||||
| focus | [Vec3f](structs.md#Vec3f) | read-only |
|
||||
| mode | `integer` | |
|
||||
| mtx | `Mat4` | read-only |
|
||||
| mtx | [Mat4](structs.md#Mat4) | read-only |
|
||||
| nextYaw | `integer` | |
|
||||
| paletteEditorCap | `boolean` | |
|
||||
| pos | [Vec3f](structs.md#Vec3f) | read-only |
|
||||
@ -1384,7 +1384,7 @@
|
||||
| prevScaleTimestamp | `integer` | read-only |
|
||||
| prevShadowPos | [Vec3f](structs.md#Vec3f) | read-only |
|
||||
| prevShadowPosTimestamp | `integer` | read-only |
|
||||
| prevThrowMatrix | `Mat4` | read-only |
|
||||
| prevThrowMatrix | [Mat4](structs.md#Mat4) | read-only |
|
||||
| prevThrowMatrixTimestamp | `integer` | read-only |
|
||||
| prevTimestamp | `integer` | read-only |
|
||||
| scale | [Vec3f](structs.md#Vec3f) | read-only |
|
||||
@ -2043,7 +2043,7 @@
|
||||
| prevObj | [Object](structs.md#Object) | |
|
||||
| respawnInfoType | `integer` | read-only |
|
||||
| setHome | `integer` | |
|
||||
| transform | `Mat4` | read-only |
|
||||
| transform | [Mat4](structs.md#Mat4) | read-only |
|
||||
| unused1 | `integer` | |
|
||||
| usingObj | [Object](structs.md#Object) | |
|
||||
|
||||
|
@ -50,6 +50,17 @@ typedef f32 Vec4f[4]; // X, Y, Z, W
|
||||
typedef s16 Vec4s[4];
|
||||
typedef s32 Vec4i[4];
|
||||
|
||||
// Pointer types for return values
|
||||
typedef f32 *Vec2fp;
|
||||
typedef s16 *Vec2sp;
|
||||
typedef s32 *Vec2ip;
|
||||
typedef f32 *Vec3fp;
|
||||
typedef s16 *Vec3sp;
|
||||
typedef s32 *Vec3ip;
|
||||
typedef f32 *Vec4fp;
|
||||
typedef s16 *Vec4sp;
|
||||
typedef s32 *Vec4ip;
|
||||
|
||||
typedef f32 Mat4[4][4];
|
||||
|
||||
typedef uintptr_t GeoLayout;
|
||||
|
@ -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 f32 *vec3f_rotate_zxy(Vec3f dest, Vec3s rotate) {
|
||||
OPTIMIZE_O3 Vec3fp vec3f_rotate_zxy(Vec3f dest, Vec3s rotate) {
|
||||
Vec3f v = { dest[0], dest[1], dest[2] };
|
||||
|
||||
f32 sx = sins(rotate[0]);
|
||||
@ -270,7 +270,7 @@ OPTIMIZE_O3 f32 *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 f32 *vec3f_rotate_around_n(Vec3f dest, Vec3f v, Vec3f n, s16 r) {
|
||||
OPTIMIZE_O3 Vec3fp vec3f_rotate_around_n(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 f32 *vec3f_rotate_around_n(Vec3f dest, Vec3f v, Vec3f n, s16 r) {
|
||||
return dest;
|
||||
}
|
||||
|
||||
OPTIMIZE_O3 f32 *vec3f_project(Vec3f dest, Vec3f v, Vec3f onto) {
|
||||
OPTIMIZE_O3 Vec3fp vec3f_project(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 f32 *vec3f_project(Vec3f dest, Vec3f v, Vec3f onto) {
|
||||
return dest;
|
||||
}
|
||||
|
||||
OPTIMIZE_O3 f32 *vec3f_transform(Vec3f dest, Vec3f v, Vec3f translation, Vec3s rotation, Vec3f scale) {
|
||||
OPTIMIZE_O3 Vec3fp vec3f_transform(Vec3f dest, Vec3f v, Vec3f translation, Vec3s rotation, Vec3f scale) {
|
||||
vec3f_copy(dest, v);
|
||||
|
||||
// scale
|
||||
@ -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 f32 *find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f b, Vec3f c) {
|
||||
OPTIMIZE_O3 Vec3fp find_vector_perpendicular_to_plane(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]);
|
||||
@ -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 f32 *get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx) {
|
||||
OPTIMIZE_O3 Vec3fp get_pos_from_transform_mtx(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];
|
||||
|
@ -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 f32 *vec3f_rotate_zxy(Vec3f v, Vec3s rotate);
|
||||
OPTIMIZE_O3 Vec3fp vec3f_rotate_zxy(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 f32 *vec3f_rotate_around_n(Vec3f dest, Vec3f v, Vec3f n, s16 r);
|
||||
OPTIMIZE_O3 Vec3fp vec3f_rotate_around_n(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 f32 *vec3f_project(Vec3f dest, Vec3f v, Vec3f onto);
|
||||
OPTIMIZE_O3 Vec3fp vec3f_project(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 f32 *vec3f_transform(Vec3f dest, Vec3f v, Vec3f translation, Vec3s rotation, Vec3f scale);
|
||||
OPTIMIZE_O3 Vec3fp vec3f_transform(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`
|
||||
@ -182,7 +182,7 @@ OPTIMIZE_O3 void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pi
|
||||
/* |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 f32 *find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f b, Vec3f c);
|
||||
OPTIMIZE_O3 Vec3fp find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f b, Vec3f c);
|
||||
|
||||
///////////
|
||||
// Vec3i //
|
||||
@ -243,7 +243,7 @@ Multiplies two 4x4 floating-point matrices `a` and `b` (in that order), storing
|
||||
OPTIMIZE_O3 void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b);
|
||||
|
||||
/* |description|
|
||||
Multiplies the 4x4 floating-point matrix `mtx` by a 3D signed-integer vector `b`, potentially interpreting `b` as angles or translations depending on usage, and modifies `mtx` accordingly
|
||||
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);
|
||||
|
||||
@ -260,7 +260,7 @@ OPTIMIZE_O3 void mtxf_inverse(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 f32 *get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx);
|
||||
OPTIMIZE_O3 Vec3fp get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx);
|
||||
|
||||
#endif // MATH_UTIL_H
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
/* |description|
|
||||
Sets the components of the 3D {{desc}} vector `v` to 0
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 {{type}} *vec3{{suffix}}_zero(Vec3{{suffix}} v) {
|
||||
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_zero(Vec3{{suffix}} v) {
|
||||
memset(v, 0, sizeof(Vec3{{suffix}}));
|
||||
return v;
|
||||
}
|
||||
@ -11,7 +11,7 @@ INLINE OPTIMIZE_O3 {{type}} *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 {{type}} *vec3{{suffix}}_copy(Vec3{{suffix}} dest, Vec3{{suffix}} src) {
|
||||
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_copy(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 {{type}} *vec3{{suffix}}_copy(Vec3{{suffix}} dest, Vec3{{suff
|
||||
/* |description|
|
||||
Sets the values of the 3D {{desc}} vector `dest` to the given x, y, and z values
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 {{type}} *vec3{{suffix}}_set(Vec3{{suffix}} dest, {{type}} x, {{type}} y, {{type}} z) {
|
||||
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_set(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 {{type}} *vec3{{suffix}}_set(Vec3{{suffix}} dest, {{type}} x,
|
||||
/* |description|
|
||||
Adds the components of the 3D {{desc}} vector `a` to `dest`
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 {{type}} *vec3{{suffix}}_add(Vec3{{suffix}} dest, Vec3{{suffix}} a) {
|
||||
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_add(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 {{type}} *vec3{{suffix}}_add(Vec3{{suffix}} dest, Vec3{{suffi
|
||||
/* |description|
|
||||
Adds the components of two 3D {{desc}} vectors `a` and `b` and stores the result in `dest`
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 {{type}} *vec3{{suffix}}_sum(Vec3{{suffix}} dest, Vec3{{suffix}} a, Vec3{{suffix}} b) {
|
||||
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_sum(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 {{type}} *vec3{{suffix}}_sum(Vec3{{suffix}} dest, Vec3{{suffi
|
||||
/* |description|
|
||||
Subtracts the components of the 3D {{desc}} vector `a` from `dest`
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 {{type}} *vec3{{suffix}}_sub(Vec3{{suffix}} dest, Vec3{{suffix}} a) {
|
||||
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_sub(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 {{type}} *vec3{{suffix}}_sub(Vec3{{suffix}} dest, Vec3{{suffi
|
||||
/* |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 {{type}} *vec3{{suffix}}_dif(Vec3{{suffix}} dest, Vec3{{suffix}} a, Vec3{{suffix}} b) {
|
||||
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_dif(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,17 +71,37 @@ INLINE OPTIMIZE_O3 {{type}} *vec3{{suffix}}_dif(Vec3{{suffix}} dest, Vec3{{suffi
|
||||
/* |description|
|
||||
Multiplies each component of the 3D {{desc}} vector `dest` by the scalar value `a`
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 {{type}} *vec3{{suffix}}_mul(Vec3{{suffix}} dest, f32 a) {
|
||||
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_mul(Vec3{{suffix}} dest, f32 a) {
|
||||
dest[0] *= a;
|
||||
dest[1] *= a;
|
||||
dest[2] *= a;
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* |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) {
|
||||
dest[0] *= a[0];
|
||||
dest[1] *= a[1];
|
||||
dest[2] *= a[2];
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* |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) {
|
||||
dest[0] = a[0] * b[0];
|
||||
dest[1] = a[1] * b[1];
|
||||
dest[2] = a[2] * b[2];
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* |description|
|
||||
Divides each component of the 3D {{desc}} vector `dest` by the scalar value `a`
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 {{type}} *vec3{{suffix}}_div(Vec3{{suffix}} dest, f32 a) {
|
||||
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_div(Vec3{{suffix}} dest, f32 a) {
|
||||
if (a == 0) { return dest; }
|
||||
dest[0] /= a;
|
||||
dest[1] /= a;
|
||||
@ -99,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 {{type}} *vec3{{suffix}}_normalize(Vec3{{suffix}} v) {
|
||||
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_normalize(Vec3{{suffix}} v) {
|
||||
f32 mag = vec3{{suffix}}_length(v);
|
||||
vec3{{suffix}}_div(v, mag);
|
||||
return v;
|
||||
@ -108,7 +128,7 @@ INLINE OPTIMIZE_O3 {{type}} *vec3{{suffix}}_normalize(Vec3{{suffix}} v) {
|
||||
/* |description|
|
||||
Sets the length (magnitude) of 3D {{desc}} vector `v`, while retaining its direction
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 {{type}} *vec3{{suffix}}_set_magnitude(Vec3{{suffix}} v, f32 mag) {
|
||||
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_set_magnitude(Vec3{{suffix}} v, f32 mag) {
|
||||
vec3{{suffix}}_normalize(v);
|
||||
vec3{{suffix}}_mul(v, mag);
|
||||
return v;
|
||||
@ -124,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 {{type}} *vec3{{suffix}}_cross(Vec3{{suffix}} dest, Vec3{{suffix}} a, Vec3{{suffix}} b) {
|
||||
INLINE OPTIMIZE_O3 Vec3{{suffix}}p vec3{{suffix}}_cross(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];
|
||||
@ -134,7 +154,7 @@ INLINE OPTIMIZE_O3 {{type}} *vec3{{suffix}}_cross(Vec3{{suffix}} dest, Vec3{{suf
|
||||
/* |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 {{type}} *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(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;
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* |description|
|
||||
Sets the components of the 3D floating-point vector `v` to 0
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 f32 *vec3f_zero(Vec3f v) {
|
||||
INLINE OPTIMIZE_O3 Vec3fp vec3f_zero(Vec3f v) {
|
||||
memset(v, 0, sizeof(Vec3f));
|
||||
return v;
|
||||
}
|
||||
@ -14,7 +14,7 @@ INLINE OPTIMIZE_O3 f32 *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 f32 *vec3f_copy(Vec3f dest, Vec3f src) {
|
||||
INLINE OPTIMIZE_O3 Vec3fp vec3f_copy(Vec3f dest, Vec3f src) {
|
||||
dest[0] = src[0];
|
||||
dest[1] = src[1];
|
||||
dest[2] = src[2];
|
||||
@ -24,7 +24,7 @@ INLINE OPTIMIZE_O3 f32 *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 f32 *vec3f_set(Vec3f dest, f32 x, f32 y, f32 z) {
|
||||
INLINE OPTIMIZE_O3 Vec3fp vec3f_set(Vec3f dest, f32 x, f32 y, f32 z) {
|
||||
dest[0] = x;
|
||||
dest[1] = y;
|
||||
dest[2] = z;
|
||||
@ -34,7 +34,7 @@ INLINE OPTIMIZE_O3 f32 *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 f32 *vec3f_add(Vec3f dest, Vec3f a) {
|
||||
INLINE OPTIMIZE_O3 Vec3fp vec3f_add(Vec3f dest, Vec3f a) {
|
||||
dest[0] += a[0];
|
||||
dest[1] += a[1];
|
||||
dest[2] += a[2];
|
||||
@ -44,7 +44,7 @@ INLINE OPTIMIZE_O3 f32 *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 f32 *vec3f_sum(Vec3f dest, Vec3f a, Vec3f b) {
|
||||
INLINE OPTIMIZE_O3 Vec3fp vec3f_sum(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 f32 *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 f32 *vec3f_sub(Vec3f dest, Vec3f a) {
|
||||
INLINE OPTIMIZE_O3 Vec3fp vec3f_sub(Vec3f dest, Vec3f a) {
|
||||
dest[0] -= a[0];
|
||||
dest[1] -= a[1];
|
||||
dest[2] -= a[2];
|
||||
@ -64,7 +64,7 @@ INLINE OPTIMIZE_O3 f32 *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 f32 *vec3f_dif(Vec3f dest, Vec3f a, Vec3f b) {
|
||||
INLINE OPTIMIZE_O3 Vec3fp vec3f_dif(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,17 +74,37 @@ INLINE OPTIMIZE_O3 f32 *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 f32 *vec3f_mul(Vec3f dest, f32 a) {
|
||||
INLINE OPTIMIZE_O3 Vec3fp vec3f_mul(Vec3f dest, f32 a) {
|
||||
dest[0] *= a;
|
||||
dest[1] *= a;
|
||||
dest[2] *= a;
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* |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) {
|
||||
dest[0] *= a[0];
|
||||
dest[1] *= a[1];
|
||||
dest[2] *= a[2];
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* |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) {
|
||||
dest[0] = a[0] * b[0];
|
||||
dest[1] = a[1] * b[1];
|
||||
dest[2] = a[2] * b[2];
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* |description|
|
||||
Divides each component of the 3D floating-point vector `dest` by the scalar value `a`
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 f32 *vec3f_div(Vec3f dest, f32 a) {
|
||||
INLINE OPTIMIZE_O3 Vec3fp vec3f_div(Vec3f dest, f32 a) {
|
||||
if (a == 0) { return dest; }
|
||||
dest[0] /= a;
|
||||
dest[1] /= a;
|
||||
@ -102,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 f32 *vec3f_normalize(Vec3f v) {
|
||||
INLINE OPTIMIZE_O3 Vec3fp vec3f_normalize(Vec3f v) {
|
||||
f32 mag = vec3f_length(v);
|
||||
vec3f_div(v, mag);
|
||||
return v;
|
||||
@ -111,7 +131,7 @@ INLINE OPTIMIZE_O3 f32 *vec3f_normalize(Vec3f v) {
|
||||
/* |description|
|
||||
Sets the length (magnitude) of 3D floating-point vector `v`, while retaining its direction
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 f32 *vec3f_set_magnitude(Vec3f v, f32 mag) {
|
||||
INLINE OPTIMIZE_O3 Vec3fp vec3f_set_magnitude(Vec3f v, f32 mag) {
|
||||
vec3f_normalize(v);
|
||||
vec3f_mul(v, mag);
|
||||
return v;
|
||||
@ -127,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 f32 *vec3f_cross(Vec3f dest, Vec3f a, Vec3f b) {
|
||||
INLINE OPTIMIZE_O3 Vec3fp vec3f_cross(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];
|
||||
@ -137,7 +157,7 @@ INLINE OPTIMIZE_O3 f32 *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 f32 *vec3f_combine(Vec3f dest, Vec3f vecA, Vec3f vecB, f32 sclA, f32 sclB) {
|
||||
INLINE OPTIMIZE_O3 Vec3fp vec3f_combine(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;
|
||||
@ -171,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 s32 *vec3f_to_vec3i(Vec3i dest, Vec3f a) {
|
||||
INLINE OPTIMIZE_O3 Vec3ip vec3f_to_vec3i(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);
|
||||
@ -181,7 +201,7 @@ INLINE OPTIMIZE_O3 s32 *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 s16 *vec3f_to_vec3s(Vec3s dest, Vec3f a) {
|
||||
INLINE OPTIMIZE_O3 Vec3sp vec3f_to_vec3s(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);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* |description|
|
||||
Sets the components of the 3D integer vector `v` to 0
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 s32 *vec3i_zero(Vec3i v) {
|
||||
INLINE OPTIMIZE_O3 Vec3ip vec3i_zero(Vec3i v) {
|
||||
memset(v, 0, sizeof(Vec3i));
|
||||
return v;
|
||||
}
|
||||
@ -14,7 +14,7 @@ INLINE OPTIMIZE_O3 s32 *vec3i_zero(Vec3i v) {
|
||||
/* |description|
|
||||
Copies the contents of a 3D integer vector (`src`) into another 3D integer vector (`dest`)
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 s32 *vec3i_copy(Vec3i dest, Vec3i src) {
|
||||
INLINE OPTIMIZE_O3 Vec3ip vec3i_copy(Vec3i dest, Vec3i src) {
|
||||
dest[0] = src[0];
|
||||
dest[1] = src[1];
|
||||
dest[2] = src[2];
|
||||
@ -24,7 +24,7 @@ INLINE OPTIMIZE_O3 s32 *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 s32 *vec3i_set(Vec3i dest, s32 x, s32 y, s32 z) {
|
||||
INLINE OPTIMIZE_O3 Vec3ip vec3i_set(Vec3i dest, s32 x, s32 y, s32 z) {
|
||||
dest[0] = x;
|
||||
dest[1] = y;
|
||||
dest[2] = z;
|
||||
@ -34,7 +34,7 @@ INLINE OPTIMIZE_O3 s32 *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 s32 *vec3i_add(Vec3i dest, Vec3i a) {
|
||||
INLINE OPTIMIZE_O3 Vec3ip vec3i_add(Vec3i dest, Vec3i a) {
|
||||
dest[0] += a[0];
|
||||
dest[1] += a[1];
|
||||
dest[2] += a[2];
|
||||
@ -44,7 +44,7 @@ INLINE OPTIMIZE_O3 s32 *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 s32 *vec3i_sum(Vec3i dest, Vec3i a, Vec3i b) {
|
||||
INLINE OPTIMIZE_O3 Vec3ip vec3i_sum(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 s32 *vec3i_sum(Vec3i dest, Vec3i a, Vec3i b) {
|
||||
/* |description|
|
||||
Subtracts the components of the 3D integer vector `a` from `dest`
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 s32 *vec3i_sub(Vec3i dest, Vec3i a) {
|
||||
INLINE OPTIMIZE_O3 Vec3ip vec3i_sub(Vec3i dest, Vec3i a) {
|
||||
dest[0] -= a[0];
|
||||
dest[1] -= a[1];
|
||||
dest[2] -= a[2];
|
||||
@ -64,7 +64,7 @@ INLINE OPTIMIZE_O3 s32 *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 s32 *vec3i_dif(Vec3i dest, Vec3i a, Vec3i b) {
|
||||
INLINE OPTIMIZE_O3 Vec3ip vec3i_dif(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,17 +74,37 @@ INLINE OPTIMIZE_O3 s32 *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 s32 *vec3i_mul(Vec3i dest, f32 a) {
|
||||
INLINE OPTIMIZE_O3 Vec3ip vec3i_mul(Vec3i dest, f32 a) {
|
||||
dest[0] *= a;
|
||||
dest[1] *= a;
|
||||
dest[2] *= a;
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* |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) {
|
||||
dest[0] *= a[0];
|
||||
dest[1] *= a[1];
|
||||
dest[2] *= a[2];
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* |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) {
|
||||
dest[0] = a[0] * b[0];
|
||||
dest[1] = a[1] * b[1];
|
||||
dest[2] = a[2] * b[2];
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* |description|
|
||||
Divides each component of the 3D integer vector `dest` by the scalar value `a`
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 s32 *vec3i_div(Vec3i dest, f32 a) {
|
||||
INLINE OPTIMIZE_O3 Vec3ip vec3i_div(Vec3i dest, f32 a) {
|
||||
if (a == 0) { return dest; }
|
||||
dest[0] /= a;
|
||||
dest[1] /= a;
|
||||
@ -102,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 s32 *vec3i_normalize(Vec3i v) {
|
||||
INLINE OPTIMIZE_O3 Vec3ip vec3i_normalize(Vec3i v) {
|
||||
f32 mag = vec3i_length(v);
|
||||
vec3i_div(v, mag);
|
||||
return v;
|
||||
@ -111,7 +131,7 @@ INLINE OPTIMIZE_O3 s32 *vec3i_normalize(Vec3i v) {
|
||||
/* |description|
|
||||
Sets the length (magnitude) of 3D integer vector `v`, while retaining its direction
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 s32 *vec3i_set_magnitude(Vec3i v, f32 mag) {
|
||||
INLINE OPTIMIZE_O3 Vec3ip vec3i_set_magnitude(Vec3i v, f32 mag) {
|
||||
vec3i_normalize(v);
|
||||
vec3i_mul(v, mag);
|
||||
return v;
|
||||
@ -127,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 s32 *vec3i_cross(Vec3i dest, Vec3i a, Vec3i b) {
|
||||
INLINE OPTIMIZE_O3 Vec3ip vec3i_cross(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];
|
||||
@ -137,7 +157,7 @@ INLINE OPTIMIZE_O3 s32 *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 s32 *vec3i_combine(Vec3i dest, Vec3i vecA, Vec3i vecB, f32 sclA, f32 sclB) {
|
||||
INLINE OPTIMIZE_O3 Vec3ip vec3i_combine(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;
|
||||
@ -171,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 f32 *vec3i_to_vec3f(Vec3f dest, Vec3i a) {
|
||||
INLINE OPTIMIZE_O3 Vec3fp vec3i_to_vec3f(Vec3f dest, Vec3i a) {
|
||||
dest[0] = a[0];
|
||||
dest[1] = a[1];
|
||||
dest[2] = a[2];
|
||||
@ -181,7 +201,7 @@ INLINE OPTIMIZE_O3 f32 *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 s16 *vec3i_to_vec3s(Vec3s dest, Vec3i a) {
|
||||
INLINE OPTIMIZE_O3 Vec3sp vec3i_to_vec3s(Vec3s dest, Vec3i a) {
|
||||
dest[0] = a[0];
|
||||
dest[1] = a[1];
|
||||
dest[2] = a[2];
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* |description|
|
||||
Sets the components of the 3D short integer vector `v` to 0
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 s16 *vec3s_zero(Vec3s v) {
|
||||
INLINE OPTIMIZE_O3 Vec3sp vec3s_zero(Vec3s v) {
|
||||
memset(v, 0, sizeof(Vec3s));
|
||||
return v;
|
||||
}
|
||||
@ -14,7 +14,7 @@ INLINE OPTIMIZE_O3 s16 *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 s16 *vec3s_copy(Vec3s dest, Vec3s src) {
|
||||
INLINE OPTIMIZE_O3 Vec3sp vec3s_copy(Vec3s dest, Vec3s src) {
|
||||
dest[0] = src[0];
|
||||
dest[1] = src[1];
|
||||
dest[2] = src[2];
|
||||
@ -24,7 +24,7 @@ INLINE OPTIMIZE_O3 s16 *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 s16 *vec3s_set(Vec3s dest, s16 x, s16 y, s16 z) {
|
||||
INLINE OPTIMIZE_O3 Vec3sp vec3s_set(Vec3s dest, s16 x, s16 y, s16 z) {
|
||||
dest[0] = x;
|
||||
dest[1] = y;
|
||||
dest[2] = z;
|
||||
@ -34,7 +34,7 @@ INLINE OPTIMIZE_O3 s16 *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 s16 *vec3s_add(Vec3s dest, Vec3s a) {
|
||||
INLINE OPTIMIZE_O3 Vec3sp vec3s_add(Vec3s dest, Vec3s a) {
|
||||
dest[0] += a[0];
|
||||
dest[1] += a[1];
|
||||
dest[2] += a[2];
|
||||
@ -44,7 +44,7 @@ INLINE OPTIMIZE_O3 s16 *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 s16 *vec3s_sum(Vec3s dest, Vec3s a, Vec3s b) {
|
||||
INLINE OPTIMIZE_O3 Vec3sp vec3s_sum(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 s16 *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 s16 *vec3s_sub(Vec3s dest, Vec3s a) {
|
||||
INLINE OPTIMIZE_O3 Vec3sp vec3s_sub(Vec3s dest, Vec3s a) {
|
||||
dest[0] -= a[0];
|
||||
dest[1] -= a[1];
|
||||
dest[2] -= a[2];
|
||||
@ -64,7 +64,7 @@ INLINE OPTIMIZE_O3 s16 *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 s16 *vec3s_dif(Vec3s dest, Vec3s a, Vec3s b) {
|
||||
INLINE OPTIMIZE_O3 Vec3sp vec3s_dif(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,17 +74,37 @@ INLINE OPTIMIZE_O3 s16 *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 s16 *vec3s_mul(Vec3s dest, f32 a) {
|
||||
INLINE OPTIMIZE_O3 Vec3sp vec3s_mul(Vec3s dest, f32 a) {
|
||||
dest[0] *= a;
|
||||
dest[1] *= a;
|
||||
dest[2] *= a;
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* |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) {
|
||||
dest[0] *= a[0];
|
||||
dest[1] *= a[1];
|
||||
dest[2] *= a[2];
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* |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) {
|
||||
dest[0] = a[0] * b[0];
|
||||
dest[1] = a[1] * b[1];
|
||||
dest[2] = a[2] * b[2];
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* |description|
|
||||
Divides each component of the 3D short integer vector `dest` by the scalar value `a`
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 s16 *vec3s_div(Vec3s dest, f32 a) {
|
||||
INLINE OPTIMIZE_O3 Vec3sp vec3s_div(Vec3s dest, f32 a) {
|
||||
if (a == 0) { return dest; }
|
||||
dest[0] /= a;
|
||||
dest[1] /= a;
|
||||
@ -102,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 s16 *vec3s_normalize(Vec3s v) {
|
||||
INLINE OPTIMIZE_O3 Vec3sp vec3s_normalize(Vec3s v) {
|
||||
f32 mag = vec3s_length(v);
|
||||
vec3s_div(v, mag);
|
||||
return v;
|
||||
@ -111,7 +131,7 @@ INLINE OPTIMIZE_O3 s16 *vec3s_normalize(Vec3s v) {
|
||||
/* |description|
|
||||
Sets the length (magnitude) of 3D short integer vector `v`, while retaining its direction
|
||||
|descriptionEnd| */
|
||||
INLINE OPTIMIZE_O3 s16 *vec3s_set_magnitude(Vec3s v, f32 mag) {
|
||||
INLINE OPTIMIZE_O3 Vec3sp vec3s_set_magnitude(Vec3s v, f32 mag) {
|
||||
vec3s_normalize(v);
|
||||
vec3s_mul(v, mag);
|
||||
return v;
|
||||
@ -127,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 s16 *vec3s_cross(Vec3s dest, Vec3s a, Vec3s b) {
|
||||
INLINE OPTIMIZE_O3 Vec3sp vec3s_cross(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];
|
||||
@ -137,7 +157,7 @@ INLINE OPTIMIZE_O3 s16 *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 s16 *vec3s_combine(Vec3s dest, Vec3s vecA, Vec3s vecB, f32 sclA, f32 sclB) {
|
||||
INLINE OPTIMIZE_O3 Vec3sp vec3s_combine(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;
|
||||
@ -171,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 f32 *vec3s_to_vec3f(Vec3f dest, Vec3s a) {
|
||||
INLINE OPTIMIZE_O3 Vec3fp vec3s_to_vec3f(Vec3f dest, Vec3s a) {
|
||||
dest[0] = a[0];
|
||||
dest[1] = a[1];
|
||||
dest[2] = a[2];
|
||||
@ -181,7 +201,7 @@ INLINE OPTIMIZE_O3 f32 *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 s32 *vec3s_to_vec3i(Vec3i dest, Vec3s a) {
|
||||
INLINE OPTIMIZE_O3 Vec3ip vec3s_to_vec3i(Vec3i dest, Vec3s a) {
|
||||
dest[0] = a[0];
|
||||
dest[1] = a[1];
|
||||
dest[2] = a[2];
|
||||
|
@ -20,10 +20,41 @@ char gSmluaConstants[] = ""
|
||||
"end\n"
|
||||
"}\n"
|
||||
"-----------\n"
|
||||
"-- table --\n"
|
||||
"-----------\n"
|
||||
"--- Creates a shallow copy of table `t`\n"
|
||||
"--- @param t table\n"
|
||||
"--- @return table\n"
|
||||
"function table.copy(t)\n"
|
||||
"return table_copy(t)\n"
|
||||
"end\n"
|
||||
"--- Creates a deep copy of table `t`\n"
|
||||
"--- @param t table\n"
|
||||
"--- @return table\n"
|
||||
"function table.deepcopy(t)\n"
|
||||
"return table_deepcopy(t)\n"
|
||||
"end\n"
|
||||
"--- Utility function to create a read-only table\n"
|
||||
"--- @param data table\n"
|
||||
"--- @return table\n"
|
||||
"function create_read_only_table(data)\n"
|
||||
"local t = {}\n"
|
||||
"local mt = {\n"
|
||||
"__index = data,\n"
|
||||
"__newindex = function(_, k, _)\n"
|
||||
"error('Attempting to modify key `' .. k .. '` of read-only table')\n"
|
||||
"end,\n"
|
||||
"__call = function() return table_copy(data) end,\n"
|
||||
"__metatable = false\n"
|
||||
"}\n"
|
||||
"setmetatable(t, mt)\n"
|
||||
"return t\n"
|
||||
"end\n"
|
||||
"-----------\n"
|
||||
"-- 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"
|
||||
@ -150,6 +181,44 @@ char gSmluaConstants[] = ""
|
||||
"function math.hypot(a, b)\n"
|
||||
"return __math_sqrt(a * a + b * b)\n"
|
||||
"end\n"
|
||||
"--- @param x number\n"
|
||||
"--- @return number\n"
|
||||
"--- Returns 1 if `x` is positive or zero, -1 otherwise\n"
|
||||
"function math.sign(x)\n"
|
||||
"return x >= 0 and 1 or -1\n"
|
||||
"end\n"
|
||||
"--- @param x number\n"
|
||||
"--- @return number\n"
|
||||
"--- Returns 1 if `x` is positive, 0 if it is zero, -1 otherwise\n"
|
||||
"function math.sign0(x)\n"
|
||||
"return x ~= 0 and (x > 0 and 1 or -1) or 0\n"
|
||||
"end\n"
|
||||
"--- @param t number\n"
|
||||
"--- @param a number\n"
|
||||
"--- @param b number\n"
|
||||
"--- @return number\n"
|
||||
"--- Linearly interpolates `t` between `a` and `b`\n"
|
||||
"function math.lerp(t, a, b)\n"
|
||||
"return a + (b - a) * t\n"
|
||||
"end\n"
|
||||
"--- @param x number\n"
|
||||
"--- @param a number\n"
|
||||
"--- @param b number\n"
|
||||
"--- @return number\n"
|
||||
"--- Determines where `x` linearly lies between `a` and `b`. It's the inverse of `math.lerp`\n"
|
||||
"function math.invlerp(x, a, b)\n"
|
||||
"return (x - a) / (b - a)\n"
|
||||
"end\n"
|
||||
"--- @param x number\n"
|
||||
"--- @param a number\n"
|
||||
"--- @param b number\n"
|
||||
"--- @param c number\n"
|
||||
"--- @param d number\n"
|
||||
"--- @return number\n"
|
||||
"--- Linearly remaps `x` from the source range `[a, b]` to the destination range `[c, d]`\n"
|
||||
"function math.remap(x, a, b, c, d)\n"
|
||||
"return c + (d - c) * ((x - a) / (b - a))\n"
|
||||
"end\n"
|
||||
"-----------------\n"
|
||||
"-- legacy font --\n"
|
||||
"-----------------\n"
|
||||
@ -171,6 +240,30 @@ char gSmluaConstants[] = ""
|
||||
"clamp = math.clamp\n"
|
||||
"clampf = math.clamp\n"
|
||||
"hypotf = math.hypot\n"
|
||||
"gVec2fZero = create_read_only_table({x=0,y=0})\n"
|
||||
"gVec2fOne = create_read_only_table({x=1,y=1})\n"
|
||||
"gVec3fZero = create_read_only_table({x=0,y=0,z=0})\n"
|
||||
"gVec3fOne = create_read_only_table({x=1,y=1,z=1})\n"
|
||||
"gVec3fX = create_read_only_table({x=1,y=0,z=0})\n"
|
||||
"gVec3fY = create_read_only_table({x=0,y=1,z=0})\n"
|
||||
"gVec3fZ = create_read_only_table({x=0,y=0,z=1})\n"
|
||||
"gVec4fZero = create_read_only_table({x=0,y=0,z=0,w=0})\n"
|
||||
"gVec4fOne = create_read_only_table({x=1,y=1,z=1,w=1})\n"
|
||||
"gVec2iZero = create_read_only_table({x=0,y=0})\n"
|
||||
"gVec2iOne = create_read_only_table({x=1,y=1})\n"
|
||||
"gVec3iZero = create_read_only_table({x=0,y=0,z=0})\n"
|
||||
"gVec3iOne = create_read_only_table({x=1,y=1,z=1})\n"
|
||||
"gVec4iZero = create_read_only_table({x=0,y=0,z=0,w=0})\n"
|
||||
"gVec4iOne = create_read_only_table({x=1,y=1,z=1,w=1})\n"
|
||||
"gVec2sZero = create_read_only_table({x=0,y=0})\n"
|
||||
"gVec2sOne = create_read_only_table({x=1,y=1})\n"
|
||||
"gVec3sZero = create_read_only_table({x=0,y=0,z=0})\n"
|
||||
"gVec3sOne = create_read_only_table({x=1,y=1,z=1})\n"
|
||||
"gVec4sZero = create_read_only_table({x=0,y=0,z=0,w=0})\n"
|
||||
"gVec4sOne = create_read_only_table({x=1,y=1,z=1,w=1})\n"
|
||||
"gMat4Zero = create_read_only_table({m00=0,m01=0,m02=0,m03=0,m10=0,m11=0,m12=0,m13=0,m20=0,m21=0,m22=0,m23=0,m30=0,m31=0,m32=0,m33=0})\n"
|
||||
"gMat4Identity = create_read_only_table({m00=1,m01=0,m02=0,m03=0,m10=0,m11=1,m12=0,m13=0,m20=0,m21=0,m22=1,m23=0,m30=0,m31=0,m32=0,m33=1})\n"
|
||||
"gMat4Fullscreen = create_read_only_table({m00=0.00625,m01=0,m02=0,m03=0,m10=0,m11=0.008333333333333333,m12=0,m13=0,m20=0,m21=0,m22=-1,m23=0,m30=-1,m31=-1,m32=-1,m33=1})\n"
|
||||
"INSTANT_WARP_INDEX_START=0x00\n"
|
||||
"INSTANT_WARP_INDEX_STOP=0x04\n"
|
||||
"MAX_AREAS=16\n"
|
||||
|
@ -40,6 +40,116 @@ bool smlua_functions_valid_param_range(lua_State* L, int min, int max) {
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////
|
||||
// table //
|
||||
///////////
|
||||
|
||||
int smlua_func_table_copy(lua_State *L) {
|
||||
LUA_STACK_CHECK_BEGIN_NUM(1);
|
||||
|
||||
if (!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
if (lua_type(L, 1) != LUA_TTABLE) {
|
||||
LOG_LUA_LINE("table_copy() called with an invalid type for param 1: %s", luaL_typename(L, 1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create a new table that will be the copy
|
||||
lua_newtable(L);
|
||||
|
||||
// Iterate through original table
|
||||
lua_pushnil(L); // first key
|
||||
while (lua_next(L, 1) != 0) {
|
||||
|
||||
// Stack at the start of iteration is orig_table, new_table, key, value
|
||||
// At the end of iteration, we need the key on top of the stack
|
||||
// But settable also needs the key, so we manipulate the stack to become:
|
||||
// orig_table, new_table, key, key, value (before settable)
|
||||
// orig_table, new_table, key (after settable)
|
||||
lua_pushvalue(L, -2);
|
||||
lua_insert(L, -2);
|
||||
lua_settable(L, 2);
|
||||
}
|
||||
|
||||
LUA_STACK_CHECK_END();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void table_deepcopy_table(lua_State *L, int idxTable, int idxCache);
|
||||
|
||||
static void table_deepcopy_value(lua_State *L, int idx, int idxCache) {
|
||||
idx = lua_absindex(L, idx);
|
||||
if (lua_type(L, idx) == LUA_TTABLE) {
|
||||
table_deepcopy_table(L, idx, idxCache);
|
||||
} else {
|
||||
lua_pushvalue(L, idx);
|
||||
}
|
||||
}
|
||||
|
||||
static void table_deepcopy_table(lua_State *L, int idxTable, int idxCache) {
|
||||
idxTable = lua_absindex(L, idxTable);
|
||||
idxCache = lua_absindex(L, idxCache);
|
||||
|
||||
// Check the cache to see if the table has already been copied
|
||||
lua_pushvalue(L, idxTable);
|
||||
lua_rawget(L, idxCache);
|
||||
if (!lua_isnil(L, -1)) {
|
||||
return;
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Create a new table that will be the copy and add it to the cache
|
||||
lua_newtable(L);
|
||||
int idxNewTable = lua_gettop(L);
|
||||
lua_pushvalue(L, idxTable);
|
||||
lua_pushvalue(L, idxNewTable);
|
||||
lua_rawset(L, idxCache);
|
||||
|
||||
// Iterate through original table
|
||||
lua_pushnil(L); // first key
|
||||
while (lua_next(L, idxTable) != 0) {
|
||||
int idxKey = lua_absindex(L, -2);
|
||||
int idxValue = lua_absindex(L, -1);
|
||||
|
||||
// Copy key and value to new table
|
||||
table_deepcopy_value(L, idxKey, idxCache);
|
||||
table_deepcopy_value(L, idxValue, idxCache);
|
||||
lua_settable(L, idxNewTable);
|
||||
|
||||
// Pop value to set key on top of the stack
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
// Copy metatable
|
||||
if (lua_getmetatable(L, idxTable)) {
|
||||
table_deepcopy_value(L, -1, idxCache);
|
||||
lua_setmetatable(L, idxNewTable);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
}
|
||||
|
||||
int smlua_func_table_deepcopy(lua_State *L) {
|
||||
LUA_STACK_CHECK_BEGIN_NUM(1);
|
||||
|
||||
if (!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
if (lua_type(L, 1) != LUA_TTABLE) {
|
||||
LOG_LUA_LINE("table_deepcopy() called with an invalid type for param 1: %s", luaL_typename(L, 1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Cache to prevent copying the same table twice
|
||||
lua_newtable(L);
|
||||
int idxCache = lua_gettop(L);
|
||||
|
||||
table_deepcopy_table(L, 1, idxCache);
|
||||
|
||||
lua_remove(L, idxCache);
|
||||
|
||||
LUA_STACK_CHECK_END();
|
||||
return 1;
|
||||
}
|
||||
|
||||
//////////
|
||||
// misc //
|
||||
//////////
|
||||
@ -1149,6 +1259,8 @@ void smlua_bind_functions(void) {
|
||||
lua_State* L = gLuaState;
|
||||
|
||||
// misc
|
||||
smlua_bind_function(L, "table_copy", smlua_func_table_copy);
|
||||
smlua_bind_function(L, "table_deepcopy", smlua_func_table_deepcopy);
|
||||
smlua_bind_function(L, "init_mario_after_warp", smlua_func_init_mario_after_warp);
|
||||
smlua_bind_function(L, "initiate_warp", smlua_func_initiate_warp);
|
||||
smlua_bind_function(L, "network_init_object", smlua_func_network_init_object);
|
||||
|
@ -19075,12 +19075,13 @@ int smlua_func_vec3f_rotate_zxy(lua_State* L) {
|
||||
smlua_get_vec3s(rotate, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3f_rotate_zxy"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_rotate_zxy(v, rotate), NULL);
|
||||
vec3f_rotate_zxy(v, rotate);
|
||||
|
||||
smlua_push_vec3f(v, 1);
|
||||
|
||||
smlua_push_vec3s(rotate, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -19108,7 +19109,7 @@ int smlua_func_vec3f_rotate_around_n(lua_State* L) {
|
||||
s16 r = smlua_to_integer(L, 4);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "vec3f_rotate_around_n"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_rotate_around_n(dest, v, n, r), NULL);
|
||||
vec3f_rotate_around_n(dest, v, n, r);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
@ -19116,6 +19117,7 @@ int smlua_func_vec3f_rotate_around_n(lua_State* L) {
|
||||
|
||||
smlua_push_vec3f(n, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -19141,7 +19143,7 @@ int smlua_func_vec3f_project(lua_State* L) {
|
||||
smlua_get_vec3f(onto, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "vec3f_project"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_project(dest, v, onto), NULL);
|
||||
vec3f_project(dest, v, onto);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
@ -19149,6 +19151,7 @@ int smlua_func_vec3f_project(lua_State* L) {
|
||||
|
||||
smlua_push_vec3f(onto, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -19182,7 +19185,7 @@ int smlua_func_vec3f_transform(lua_State* L) {
|
||||
smlua_get_vec3f(scale, 5);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "vec3f_transform"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_transform(dest, v, translation, rotation, scale), NULL);
|
||||
vec3f_transform(dest, v, translation, rotation, scale);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
@ -19194,6 +19197,7 @@ int smlua_func_vec3f_transform(lua_State* L) {
|
||||
|
||||
smlua_push_vec3f(scale, 5);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -19289,7 +19293,7 @@ int smlua_func_find_vector_perpendicular_to_plane(lua_State* L) {
|
||||
smlua_get_vec3f(c, 4);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "find_vector_perpendicular_to_plane"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)find_vector_perpendicular_to_plane(dest, a, b, c), NULL);
|
||||
find_vector_perpendicular_to_plane(dest, a, b, c);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
@ -19299,6 +19303,7 @@ int smlua_func_find_vector_perpendicular_to_plane(lua_State* L) {
|
||||
|
||||
smlua_push_vec3f(c, 4);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -19671,7 +19676,7 @@ int smlua_func_get_pos_from_transform_mtx(lua_State* L) {
|
||||
smlua_get_mat4(camMtx, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "get_pos_from_transform_mtx"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)get_pos_from_transform_mtx(dest, objMtx, camMtx), NULL);
|
||||
get_pos_from_transform_mtx(dest, objMtx, camMtx);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
@ -19679,6 +19684,7 @@ int smlua_func_get_pos_from_transform_mtx(lua_State* L) {
|
||||
|
||||
smlua_push_mat4(camMtx, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -19949,10 +19955,11 @@ int smlua_func_vec3f_zero(lua_State* L) {
|
||||
smlua_get_vec3f(v, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "vec3f_zero"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_zero(v), NULL);
|
||||
vec3f_zero(v);
|
||||
|
||||
smlua_push_vec3f(v, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -19974,12 +19981,13 @@ int smlua_func_vec3f_copy(lua_State* L) {
|
||||
smlua_get_vec3f(src, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3f_copy"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_copy(dest, src), NULL);
|
||||
vec3f_copy(dest, src);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
smlua_push_vec3f(src, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20003,10 +20011,11 @@ int smlua_func_vec3f_set(lua_State* L) {
|
||||
f32 z = smlua_to_number(L, 4);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "vec3f_set"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_set(dest, x, y, z), NULL);
|
||||
vec3f_set(dest, x, y, z);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20028,12 +20037,13 @@ int smlua_func_vec3f_add(lua_State* L) {
|
||||
smlua_get_vec3f(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3f_add"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_add(dest, a), NULL);
|
||||
vec3f_add(dest, a);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
smlua_push_vec3f(a, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20059,7 +20069,7 @@ int smlua_func_vec3f_sum(lua_State* L) {
|
||||
smlua_get_vec3f(b, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "vec3f_sum"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_sum(dest, a, b), NULL);
|
||||
vec3f_sum(dest, a, b);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
@ -20067,6 +20077,7 @@ int smlua_func_vec3f_sum(lua_State* L) {
|
||||
|
||||
smlua_push_vec3f(b, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20088,12 +20099,13 @@ int smlua_func_vec3f_sub(lua_State* L) {
|
||||
smlua_get_vec3f(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3f_sub"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_sub(dest, a), NULL);
|
||||
vec3f_sub(dest, a);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
smlua_push_vec3f(a, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20119,7 +20131,7 @@ int smlua_func_vec3f_dif(lua_State* L) {
|
||||
smlua_get_vec3f(b, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "vec3f_dif"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_dif(dest, a, b), NULL);
|
||||
vec3f_dif(dest, a, b);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
@ -20127,6 +20139,7 @@ int smlua_func_vec3f_dif(lua_State* L) {
|
||||
|
||||
smlua_push_vec3f(b, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20146,10 +20159,73 @@ int smlua_func_vec3f_mul(lua_State* L) {
|
||||
f32 a = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3f_mul"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_mul(dest, a), NULL);
|
||||
vec3f_mul(dest, a);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_vec3f_mult(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_mult", 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_mult"); return 0; }
|
||||
|
||||
Vec3f a;
|
||||
smlua_get_vec3f(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3f_mult"); return 0; }
|
||||
|
||||
vec3f_mult(dest, a);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
smlua_push_vec3f(a, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_vec3f_prod(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 3) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "vec3f_prod", 3, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Vec3f dest;
|
||||
smlua_get_vec3f(dest, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "vec3f_prod"); return 0; }
|
||||
|
||||
Vec3f a;
|
||||
smlua_get_vec3f(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3f_prod"); return 0; }
|
||||
|
||||
Vec3f b;
|
||||
smlua_get_vec3f(b, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "vec3f_prod"); return 0; }
|
||||
|
||||
vec3f_prod(dest, a, b);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
smlua_push_vec3f(a, 2);
|
||||
|
||||
smlua_push_vec3f(b, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20169,10 +20245,11 @@ int smlua_func_vec3f_div(lua_State* L) {
|
||||
f32 a = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3f_div"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_div(dest, a), NULL);
|
||||
vec3f_div(dest, a);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20211,10 +20288,11 @@ int smlua_func_vec3f_normalize(lua_State* L) {
|
||||
smlua_get_vec3f(v, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "vec3f_normalize"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_normalize(v), NULL);
|
||||
vec3f_normalize(v);
|
||||
|
||||
smlua_push_vec3f(v, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20234,10 +20312,11 @@ int smlua_func_vec3f_set_magnitude(lua_State* L) {
|
||||
f32 mag = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3f_set_magnitude"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_set_magnitude(v, mag), NULL);
|
||||
vec3f_set_magnitude(v, mag);
|
||||
|
||||
smlua_push_vec3f(v, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20290,7 +20369,7 @@ int smlua_func_vec3f_cross(lua_State* L) {
|
||||
smlua_get_vec3f(b, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "vec3f_cross"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_cross(dest, a, b), NULL);
|
||||
vec3f_cross(dest, a, b);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
@ -20298,6 +20377,7 @@ int smlua_func_vec3f_cross(lua_State* L) {
|
||||
|
||||
smlua_push_vec3f(b, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20327,7 +20407,7 @@ int smlua_func_vec3f_combine(lua_State* L) {
|
||||
f32 sclB = smlua_to_number(L, 5);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "vec3f_combine"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3f_combine(dest, vecA, vecB, sclA, sclB), NULL);
|
||||
vec3f_combine(dest, vecA, vecB, sclA, sclB);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
@ -20335,6 +20415,7 @@ int smlua_func_vec3f_combine(lua_State* L) {
|
||||
|
||||
smlua_push_vec3f(vecB, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20431,12 +20512,13 @@ int smlua_func_vec3f_to_vec3i(lua_State* L) {
|
||||
smlua_get_vec3f(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3f_to_vec3i"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)vec3f_to_vec3i(dest, a), NULL);
|
||||
vec3f_to_vec3i(dest, a);
|
||||
|
||||
smlua_push_vec3i(dest, 1);
|
||||
|
||||
smlua_push_vec3f(a, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20458,12 +20540,13 @@ int smlua_func_vec3f_to_vec3s(lua_State* L) {
|
||||
smlua_get_vec3f(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3f_to_vec3s"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S16_P, (void*)vec3f_to_vec3s(dest, a), NULL);
|
||||
vec3f_to_vec3s(dest, a);
|
||||
|
||||
smlua_push_vec3s(dest, 1);
|
||||
|
||||
smlua_push_vec3f(a, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20485,10 +20568,11 @@ int smlua_func_vec3i_zero(lua_State* L) {
|
||||
smlua_get_vec3i(v, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "vec3i_zero"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)vec3i_zero(v), NULL);
|
||||
vec3i_zero(v);
|
||||
|
||||
smlua_push_vec3i(v, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20510,12 +20594,13 @@ int smlua_func_vec3i_copy(lua_State* L) {
|
||||
smlua_get_vec3i(src, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3i_copy"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)vec3i_copy(dest, src), NULL);
|
||||
vec3i_copy(dest, src);
|
||||
|
||||
smlua_push_vec3i(dest, 1);
|
||||
|
||||
smlua_push_vec3i(src, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20539,10 +20624,11 @@ int smlua_func_vec3i_set(lua_State* L) {
|
||||
s32 z = smlua_to_integer(L, 4);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "vec3i_set"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)vec3i_set(dest, x, y, z), NULL);
|
||||
vec3i_set(dest, x, y, z);
|
||||
|
||||
smlua_push_vec3i(dest, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20564,12 +20650,13 @@ int smlua_func_vec3i_add(lua_State* L) {
|
||||
smlua_get_vec3i(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3i_add"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)vec3i_add(dest, a), NULL);
|
||||
vec3i_add(dest, a);
|
||||
|
||||
smlua_push_vec3i(dest, 1);
|
||||
|
||||
smlua_push_vec3i(a, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20595,7 +20682,7 @@ int smlua_func_vec3i_sum(lua_State* L) {
|
||||
smlua_get_vec3i(b, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "vec3i_sum"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)vec3i_sum(dest, a, b), NULL);
|
||||
vec3i_sum(dest, a, b);
|
||||
|
||||
smlua_push_vec3i(dest, 1);
|
||||
|
||||
@ -20603,6 +20690,7 @@ int smlua_func_vec3i_sum(lua_State* L) {
|
||||
|
||||
smlua_push_vec3i(b, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20624,12 +20712,13 @@ int smlua_func_vec3i_sub(lua_State* L) {
|
||||
smlua_get_vec3i(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3i_sub"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)vec3i_sub(dest, a), NULL);
|
||||
vec3i_sub(dest, a);
|
||||
|
||||
smlua_push_vec3i(dest, 1);
|
||||
|
||||
smlua_push_vec3i(a, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20655,7 +20744,7 @@ int smlua_func_vec3i_dif(lua_State* L) {
|
||||
smlua_get_vec3i(b, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "vec3i_dif"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)vec3i_dif(dest, a, b), NULL);
|
||||
vec3i_dif(dest, a, b);
|
||||
|
||||
smlua_push_vec3i(dest, 1);
|
||||
|
||||
@ -20663,6 +20752,7 @@ int smlua_func_vec3i_dif(lua_State* L) {
|
||||
|
||||
smlua_push_vec3i(b, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20682,10 +20772,73 @@ int smlua_func_vec3i_mul(lua_State* L) {
|
||||
f32 a = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3i_mul"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)vec3i_mul(dest, a), NULL);
|
||||
vec3i_mul(dest, a);
|
||||
|
||||
smlua_push_vec3i(dest, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_vec3i_mult(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", "vec3i_mult", 2, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Vec3i dest;
|
||||
smlua_get_vec3i(dest, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "vec3i_mult"); return 0; }
|
||||
|
||||
Vec3i a;
|
||||
smlua_get_vec3i(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3i_mult"); return 0; }
|
||||
|
||||
vec3i_mult(dest, a);
|
||||
|
||||
smlua_push_vec3i(dest, 1);
|
||||
|
||||
smlua_push_vec3i(a, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_vec3i_prod(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 3) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "vec3i_prod", 3, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Vec3i dest;
|
||||
smlua_get_vec3i(dest, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "vec3i_prod"); return 0; }
|
||||
|
||||
Vec3i a;
|
||||
smlua_get_vec3i(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3i_prod"); return 0; }
|
||||
|
||||
Vec3i b;
|
||||
smlua_get_vec3i(b, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "vec3i_prod"); return 0; }
|
||||
|
||||
vec3i_prod(dest, a, b);
|
||||
|
||||
smlua_push_vec3i(dest, 1);
|
||||
|
||||
smlua_push_vec3i(a, 2);
|
||||
|
||||
smlua_push_vec3i(b, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20705,10 +20858,11 @@ int smlua_func_vec3i_div(lua_State* L) {
|
||||
f32 a = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3i_div"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)vec3i_div(dest, a), NULL);
|
||||
vec3i_div(dest, a);
|
||||
|
||||
smlua_push_vec3i(dest, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20747,10 +20901,11 @@ int smlua_func_vec3i_normalize(lua_State* L) {
|
||||
smlua_get_vec3i(v, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "vec3i_normalize"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)vec3i_normalize(v), NULL);
|
||||
vec3i_normalize(v);
|
||||
|
||||
smlua_push_vec3i(v, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20770,10 +20925,11 @@ int smlua_func_vec3i_set_magnitude(lua_State* L) {
|
||||
f32 mag = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3i_set_magnitude"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)vec3i_set_magnitude(v, mag), NULL);
|
||||
vec3i_set_magnitude(v, mag);
|
||||
|
||||
smlua_push_vec3i(v, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20826,7 +20982,7 @@ int smlua_func_vec3i_cross(lua_State* L) {
|
||||
smlua_get_vec3i(b, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "vec3i_cross"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)vec3i_cross(dest, a, b), NULL);
|
||||
vec3i_cross(dest, a, b);
|
||||
|
||||
smlua_push_vec3i(dest, 1);
|
||||
|
||||
@ -20834,6 +20990,7 @@ int smlua_func_vec3i_cross(lua_State* L) {
|
||||
|
||||
smlua_push_vec3i(b, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20863,7 +21020,7 @@ int smlua_func_vec3i_combine(lua_State* L) {
|
||||
f32 sclB = smlua_to_number(L, 5);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "vec3i_combine"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)vec3i_combine(dest, vecA, vecB, sclA, sclB), NULL);
|
||||
vec3i_combine(dest, vecA, vecB, sclA, sclB);
|
||||
|
||||
smlua_push_vec3i(dest, 1);
|
||||
|
||||
@ -20871,6 +21028,7 @@ int smlua_func_vec3i_combine(lua_State* L) {
|
||||
|
||||
smlua_push_vec3i(vecB, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20967,12 +21125,13 @@ int smlua_func_vec3i_to_vec3f(lua_State* L) {
|
||||
smlua_get_vec3i(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3i_to_vec3f"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3i_to_vec3f(dest, a), NULL);
|
||||
vec3i_to_vec3f(dest, a);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
smlua_push_vec3i(a, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -20994,12 +21153,13 @@ int smlua_func_vec3i_to_vec3s(lua_State* L) {
|
||||
smlua_get_vec3i(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3i_to_vec3s"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S16_P, (void*)vec3i_to_vec3s(dest, a), NULL);
|
||||
vec3i_to_vec3s(dest, a);
|
||||
|
||||
smlua_push_vec3s(dest, 1);
|
||||
|
||||
smlua_push_vec3i(a, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21021,10 +21181,11 @@ int smlua_func_vec3s_zero(lua_State* L) {
|
||||
smlua_get_vec3s(v, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "vec3s_zero"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S16_P, (void*)vec3s_zero(v), NULL);
|
||||
vec3s_zero(v);
|
||||
|
||||
smlua_push_vec3s(v, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21046,12 +21207,13 @@ int smlua_func_vec3s_copy(lua_State* L) {
|
||||
smlua_get_vec3s(src, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3s_copy"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S16_P, (void*)vec3s_copy(dest, src), NULL);
|
||||
vec3s_copy(dest, src);
|
||||
|
||||
smlua_push_vec3s(dest, 1);
|
||||
|
||||
smlua_push_vec3s(src, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21075,10 +21237,11 @@ int smlua_func_vec3s_set(lua_State* L) {
|
||||
s16 z = smlua_to_integer(L, 4);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "vec3s_set"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S16_P, (void*)vec3s_set(dest, x, y, z), NULL);
|
||||
vec3s_set(dest, x, y, z);
|
||||
|
||||
smlua_push_vec3s(dest, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21100,12 +21263,13 @@ int smlua_func_vec3s_add(lua_State* L) {
|
||||
smlua_get_vec3s(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3s_add"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S16_P, (void*)vec3s_add(dest, a), NULL);
|
||||
vec3s_add(dest, a);
|
||||
|
||||
smlua_push_vec3s(dest, 1);
|
||||
|
||||
smlua_push_vec3s(a, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21131,7 +21295,7 @@ int smlua_func_vec3s_sum(lua_State* L) {
|
||||
smlua_get_vec3s(b, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "vec3s_sum"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S16_P, (void*)vec3s_sum(dest, a, b), NULL);
|
||||
vec3s_sum(dest, a, b);
|
||||
|
||||
smlua_push_vec3s(dest, 1);
|
||||
|
||||
@ -21139,6 +21303,7 @@ int smlua_func_vec3s_sum(lua_State* L) {
|
||||
|
||||
smlua_push_vec3s(b, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21160,12 +21325,13 @@ int smlua_func_vec3s_sub(lua_State* L) {
|
||||
smlua_get_vec3s(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3s_sub"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S16_P, (void*)vec3s_sub(dest, a), NULL);
|
||||
vec3s_sub(dest, a);
|
||||
|
||||
smlua_push_vec3s(dest, 1);
|
||||
|
||||
smlua_push_vec3s(a, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21191,7 +21357,7 @@ int smlua_func_vec3s_dif(lua_State* L) {
|
||||
smlua_get_vec3s(b, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "vec3s_dif"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S16_P, (void*)vec3s_dif(dest, a, b), NULL);
|
||||
vec3s_dif(dest, a, b);
|
||||
|
||||
smlua_push_vec3s(dest, 1);
|
||||
|
||||
@ -21199,6 +21365,7 @@ int smlua_func_vec3s_dif(lua_State* L) {
|
||||
|
||||
smlua_push_vec3s(b, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21218,10 +21385,73 @@ int smlua_func_vec3s_mul(lua_State* L) {
|
||||
f32 a = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3s_mul"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S16_P, (void*)vec3s_mul(dest, a), NULL);
|
||||
vec3s_mul(dest, a);
|
||||
|
||||
smlua_push_vec3s(dest, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_vec3s_mult(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_mult", 2, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Vec3s dest;
|
||||
smlua_get_vec3s(dest, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "vec3s_mult"); return 0; }
|
||||
|
||||
Vec3s a;
|
||||
smlua_get_vec3s(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3s_mult"); return 0; }
|
||||
|
||||
vec3s_mult(dest, a);
|
||||
|
||||
smlua_push_vec3s(dest, 1);
|
||||
|
||||
smlua_push_vec3s(a, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_vec3s_prod(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 3) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "vec3s_prod", 3, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Vec3s dest;
|
||||
smlua_get_vec3s(dest, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "vec3s_prod"); return 0; }
|
||||
|
||||
Vec3s a;
|
||||
smlua_get_vec3s(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3s_prod"); return 0; }
|
||||
|
||||
Vec3s b;
|
||||
smlua_get_vec3s(b, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "vec3s_prod"); return 0; }
|
||||
|
||||
vec3s_prod(dest, a, b);
|
||||
|
||||
smlua_push_vec3s(dest, 1);
|
||||
|
||||
smlua_push_vec3s(a, 2);
|
||||
|
||||
smlua_push_vec3s(b, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21241,10 +21471,11 @@ int smlua_func_vec3s_div(lua_State* L) {
|
||||
f32 a = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3s_div"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S16_P, (void*)vec3s_div(dest, a), NULL);
|
||||
vec3s_div(dest, a);
|
||||
|
||||
smlua_push_vec3s(dest, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21283,10 +21514,11 @@ int smlua_func_vec3s_normalize(lua_State* L) {
|
||||
smlua_get_vec3s(v, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "vec3s_normalize"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S16_P, (void*)vec3s_normalize(v), NULL);
|
||||
vec3s_normalize(v);
|
||||
|
||||
smlua_push_vec3s(v, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21306,10 +21538,11 @@ int smlua_func_vec3s_set_magnitude(lua_State* L) {
|
||||
f32 mag = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3s_set_magnitude"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S16_P, (void*)vec3s_set_magnitude(v, mag), NULL);
|
||||
vec3s_set_magnitude(v, mag);
|
||||
|
||||
smlua_push_vec3s(v, 1);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21362,7 +21595,7 @@ int smlua_func_vec3s_cross(lua_State* L) {
|
||||
smlua_get_vec3s(b, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "vec3s_cross"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S16_P, (void*)vec3s_cross(dest, a, b), NULL);
|
||||
vec3s_cross(dest, a, b);
|
||||
|
||||
smlua_push_vec3s(dest, 1);
|
||||
|
||||
@ -21370,6 +21603,7 @@ int smlua_func_vec3s_cross(lua_State* L) {
|
||||
|
||||
smlua_push_vec3s(b, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21399,7 +21633,7 @@ int smlua_func_vec3s_combine(lua_State* L) {
|
||||
f32 sclB = smlua_to_number(L, 5);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "vec3s_combine"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S16_P, (void*)vec3s_combine(dest, vecA, vecB, sclA, sclB), NULL);
|
||||
vec3s_combine(dest, vecA, vecB, sclA, sclB);
|
||||
|
||||
smlua_push_vec3s(dest, 1);
|
||||
|
||||
@ -21407,6 +21641,7 @@ int smlua_func_vec3s_combine(lua_State* L) {
|
||||
|
||||
smlua_push_vec3s(vecB, 3);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21503,12 +21738,13 @@ int smlua_func_vec3s_to_vec3f(lua_State* L) {
|
||||
smlua_get_vec3s(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3s_to_vec3f"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_F32_P, (void*)vec3s_to_vec3f(dest, a), NULL);
|
||||
vec3s_to_vec3f(dest, a);
|
||||
|
||||
smlua_push_vec3f(dest, 1);
|
||||
|
||||
smlua_push_vec3s(a, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -21530,12 +21766,13 @@ int smlua_func_vec3s_to_vec3i(lua_State* L) {
|
||||
smlua_get_vec3s(a, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "vec3s_to_vec3i"); return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)vec3s_to_vec3i(dest, a), NULL);
|
||||
vec3s_to_vec3i(dest, a);
|
||||
|
||||
smlua_push_vec3i(dest, 1);
|
||||
|
||||
smlua_push_vec3s(a, 2);
|
||||
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -36134,6 +36371,8 @@ void smlua_bind_functions_autogen(void) {
|
||||
smlua_bind_function(L, "vec3f_sub", smlua_func_vec3f_sub);
|
||||
smlua_bind_function(L, "vec3f_dif", smlua_func_vec3f_dif);
|
||||
smlua_bind_function(L, "vec3f_mul", smlua_func_vec3f_mul);
|
||||
smlua_bind_function(L, "vec3f_mult", smlua_func_vec3f_mult);
|
||||
smlua_bind_function(L, "vec3f_prod", smlua_func_vec3f_prod);
|
||||
smlua_bind_function(L, "vec3f_div", smlua_func_vec3f_div);
|
||||
smlua_bind_function(L, "vec3f_length", smlua_func_vec3f_length);
|
||||
smlua_bind_function(L, "vec3f_normalize", smlua_func_vec3f_normalize);
|
||||
@ -36156,6 +36395,8 @@ void smlua_bind_functions_autogen(void) {
|
||||
smlua_bind_function(L, "vec3i_sub", smlua_func_vec3i_sub);
|
||||
smlua_bind_function(L, "vec3i_dif", smlua_func_vec3i_dif);
|
||||
smlua_bind_function(L, "vec3i_mul", smlua_func_vec3i_mul);
|
||||
smlua_bind_function(L, "vec3i_mult", smlua_func_vec3i_mult);
|
||||
smlua_bind_function(L, "vec3i_prod", smlua_func_vec3i_prod);
|
||||
smlua_bind_function(L, "vec3i_div", smlua_func_vec3i_div);
|
||||
smlua_bind_function(L, "vec3i_length", smlua_func_vec3i_length);
|
||||
smlua_bind_function(L, "vec3i_normalize", smlua_func_vec3i_normalize);
|
||||
@ -36178,6 +36419,8 @@ void smlua_bind_functions_autogen(void) {
|
||||
smlua_bind_function(L, "vec3s_sub", smlua_func_vec3s_sub);
|
||||
smlua_bind_function(L, "vec3s_dif", smlua_func_vec3s_dif);
|
||||
smlua_bind_function(L, "vec3s_mul", smlua_func_vec3s_mul);
|
||||
smlua_bind_function(L, "vec3s_mult", smlua_func_vec3s_mult);
|
||||
smlua_bind_function(L, "vec3s_prod", smlua_func_vec3s_prod);
|
||||
smlua_bind_function(L, "vec3s_div", smlua_func_vec3s_div);
|
||||
smlua_bind_function(L, "vec3s_length", smlua_func_vec3s_length);
|
||||
smlua_bind_function(L, "vec3s_normalize", smlua_func_vec3s_normalize);
|
||||
|
@ -751,15 +751,21 @@ void smlua_logline(void) {
|
||||
// Get the folder and file
|
||||
// in the format: "folder/file.lua"
|
||||
const char* src = info.source;
|
||||
int slashCount = 0;
|
||||
const char* folderStart = NULL;
|
||||
for (const char* p = src + strlen(src); p > src; --p) {
|
||||
if (*p == '/' || *p == '\\') {
|
||||
if (++slashCount == 2) {
|
||||
folderStart = p + 1;
|
||||
break;
|
||||
if (strlen(src) < SYS_MAX_PATH) {
|
||||
int slashCount = 0;
|
||||
for (const char* p = src + strlen(src); p > src; --p) {
|
||||
if (*p == '/' || *p == '\\') {
|
||||
if (++slashCount == 2) {
|
||||
folderStart = p + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// That's not a filepath
|
||||
// It also explains why sometimes the whole gSmluaConstants string was printed to the console
|
||||
snprintf(info.short_src, sizeof(info.short_src), "gSmluaConstants");
|
||||
}
|
||||
|
||||
LOG_LUA(" [%d] '%s':%d -- %s [%s]",
|
||||
|
Loading…
x
Reference in New Issue
Block a user