diff options
Diffstat (limited to 'src/rmath.c')
| -rw-r--r-- | src/rmath.c | 777 |
1 files changed, 75 insertions, 702 deletions
diff --git a/src/rmath.c b/src/rmath.c index 6effbd5..f1f4642 100644 --- a/src/rmath.c +++ b/src/rmath.c @@ -20,18 +20,12 @@ inline int imax( int a, int b ) { Clamp float value -- Failure return false - Success return float */ int lmathClamp( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Clamp( float value, float min, float max )" ); - lua_pushboolean( L, false ); - return 1; - } - float value = lua_tonumber( L, 1 ); - float min = lua_tonumber( L, 2 ); - float max = lua_tonumber( L, 3 ); + float value = luaL_checknumber( L, 1 ); + float min = luaL_checknumber( L, 2 ); + float max = luaL_checknumber( L, 3 ); lua_pushnumber( L, Clamp( value, min, max ) ); @@ -43,18 +37,12 @@ int lmathClamp( lua_State *L ) { Calculate linear interpolation between two floats -- Failure return false - Success return float */ int lmathLerp( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Lerp( float a, float b, float amount )" ); - lua_pushboolean( L, false ); - return 1; - } - float start = lua_tonumber( L, 1 ); - float end = lua_tonumber( L, 2 ); - float amount = lua_tonumber( L, 3 ); + float start = luaL_checknumber( L, 1 ); + float end = luaL_checknumber( L, 2 ); + float amount = luaL_checknumber( L, 3 ); lua_pushnumber( L, Lerp( start, end, amount ) ); @@ -66,18 +54,12 @@ int lmathLerp( lua_State *L ) { Normalize input value within input range -- Failure return false - Success return float */ int lmathNormalize( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Normalize( float value, float a, float b )" ); - lua_pushboolean( L, false ); - return 1; - } - float value = lua_tonumber( L, 1 ); - float start = lua_tonumber( L, 2 ); - float end = lua_tonumber( L, 3 ); + float value = luaL_checknumber( L, 1 ); + float start = luaL_checknumber( L, 2 ); + float end = luaL_checknumber( L, 3 ); lua_pushnumber( L, Normalize( value, start, end ) ); @@ -89,21 +71,14 @@ int lmathNormalize( lua_State *L ) { Remap input value within input range to output range -- Failure return false - Success return float */ int lmathRemap( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Remap( float value, float inputStart, float inputEnd, float outputStart, float outputEnd )" ); - lua_pushboolean( L, false ); - return 1; - } - float value = lua_tonumber( L, 1 ); - float inputStart = lua_tonumber( L, 2 ); - float inputEnd = lua_tonumber( L, 3 ); - float outputStart = lua_tonumber( L, 4 ); - float outputEnd = lua_tonumber( L, 5 ); + float value = luaL_checknumber( L, 1 ); + float inputStart = luaL_checknumber( L, 2 ); + float inputEnd = luaL_checknumber( L, 3 ); + float outputStart = luaL_checknumber( L, 4 ); + float outputEnd = luaL_checknumber( L, 5 ); lua_pushnumber( L, Remap( value, inputStart, inputEnd, outputStart, outputEnd ) ); @@ -115,18 +90,12 @@ int lmathRemap( lua_State *L ) { Wrap input value from min to max -- Failure return false - Success return float */ int lmathWrap( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Wrap( float value, float min, float max )" ); - lua_pushboolean( L, false ); - return 1; - } - float value = lua_tonumber( L, 1 ); - float min = lua_tonumber( L, 2 ); - float max = lua_tonumber( L, 3 ); + float value = luaL_checknumber( L, 1 ); + float min = luaL_checknumber( L, 2 ); + float max = luaL_checknumber( L, 3 ); lua_pushnumber( L, Wrap( value, min, max ) ); @@ -138,17 +107,11 @@ int lmathWrap( lua_State *L ) { Check whether two given floats are almost equal -- Failure return false - Success return int */ int lmathFloatEquals( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.FloatEquals( float x, float y )" ); - lua_pushboolean( L, false ); - return 1; - } - float x = lua_tonumber( L, 1 ); - float y = lua_tonumber( L, 2 ); + float x = luaL_checknumber( L, 1 ); + float y = luaL_checknumber( L, 2 ); lua_pushinteger( L, FloatEquals( x, y ) ); @@ -190,15 +153,9 @@ int lmathVector2One( lua_State *L ) { Add two vectors (v1 + v2) -- Failure return false - Success return Vector2 */ int lmathVector2Add( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Add( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -212,17 +169,11 @@ int lmathVector2Add( lua_State *L ) { Add vector and float value -- Failure return false - Success return Vector2 */ int lmathVector2AddValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2AddValue( Vector2 v, float add )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); - float add = lua_tonumber( L, 2 ); + float add = luaL_checknumber( L, 2 ); uluaPushVector2( L, Vector2AddValue( v, add ) ); @@ -234,15 +185,9 @@ int lmathVector2AddValue( lua_State *L ) { Subtract two vectors (v1 - v2) -- Failure return false - Success return Vector2 */ int lmathVector2Subtract( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Subtract( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -256,17 +201,11 @@ int lmathVector2Subtract( lua_State *L ) { Subtract vector by float value -- Failure return false - Success return Vector2 */ int lmathVector2SubtractValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2SubtractValue( Vector2 v, float sub )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); - float sub = lua_tonumber( L, 2 ); + float sub = luaL_checknumber( L, 2 ); uluaPushVector2( L, Vector2SubtractValue( v, sub ) ); @@ -278,15 +217,9 @@ int lmathVector2SubtractValue( lua_State *L ) { Calculate vector length -- Failure return false - Success return float */ int lmathVector2Length( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Length( vector2 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); lua_pushnumber( L, Vector2Length( v ) ); @@ -299,15 +232,9 @@ int lmathVector2Length( lua_State *L ) { Calculate vector square length -- Failure return false - Success return float */ int lmathVector2LengthSqr( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2LengthSqr( vector2 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); lua_pushnumber( L, Vector2LengthSqr( v ) ); @@ -320,15 +247,9 @@ int lmathVector2LengthSqr( lua_State *L ) { Calculate two vectors dot product -- Failure return false - Success return float */ int lmathVector2DotProduct( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2DotProduct( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -342,15 +263,9 @@ int lmathVector2DotProduct( lua_State *L ) { Calculate distance between two vectors -- Failure return false - Success return float */ int lmathVector2Distance( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Distance( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -364,15 +279,9 @@ int lmathVector2Distance( lua_State *L ) { Calculate square distance between two vectors -- Failure return false - Success return float */ int lmathVector2DistanceSqr( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2DistanceSqr( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -386,15 +295,9 @@ int lmathVector2DistanceSqr( lua_State *L ) { Calculate angle from two vectors -- Failure return false - Success return float */ int lmathVector2Angle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Angle( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -410,15 +313,9 @@ Calculate angle defined by a two vectors line. NOTE: Parameters need to be normalized. Current implementation should be aligned with glm::angle. -- Failure return false - Success return float */ int lmathVector2LineAngle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2LineAngle( Vector2 a, Vector2 b )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 start = uluaGetVector2Index( L, 1 ); Vector2 end = uluaGetVector2Index( L, 2 ); @@ -430,19 +327,13 @@ int lmathVector2LineAngle( lua_State *L ) { /* > result = RL.Vector2Scale( Vector2 v, float scale ) -Scale vector ( multiply by value ) +Scale vector (multiply by value) -- Failure return false - Success return Vector2 */ int lmathVector2Scale( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Scale( Vector2 v, float scale )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); - float scale = lua_tonumber( L, 2 ); + float scale = luaL_checknumber( L, 2 ); uluaPushVector2( L, Vector2Scale( v, scale ) ); @@ -454,15 +345,9 @@ int lmathVector2Scale( lua_State *L ) { Multiply vector by vector -- Failure return false - Success return Vector2 */ int lmathVector2Multiply( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Multiply( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -476,15 +361,9 @@ int lmathVector2Multiply( lua_State *L ) { Negate vector -- Failure return false - Success return Vector2 */ int lmathVector2Negate( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Negate( Vector2 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); uluaPushVector2( L, Vector2Negate( v ) ); @@ -497,15 +376,9 @@ int lmathVector2Negate( lua_State *L ) { Divide vector by vector -- Failure return false - Success return Vector2 */ int lmathVector2Divide( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Divide( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -519,15 +392,9 @@ int lmathVector2Divide( lua_State *L ) { Normalize provided vector -- Failure return false - Success return Vector2 */ int lmathVector2Normalize( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Normalize( Vector2 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); uluaPushVector2( L, Vector2Normalize( v ) ); @@ -540,15 +407,9 @@ int lmathVector2Normalize( lua_State *L ) { Transforms a Vector2 by a given Matrix -- Failure return false - Success return Vector2 */ int lmathVector2Transform( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Transform( Vector2 v, Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); Matrix mat = uluaGetMatrixIndex( L, 2 ); @@ -562,18 +423,12 @@ int lmathVector2Transform( lua_State *L ) { Calculate linear interpolation between two vectors -- Failure return false - Success return Vector2 */ int lmathVector2Lerp( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Lerp( Vector2 v1, Vector2 v2, float amount )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); - float amount = lua_tonumber( L, 3 ); + float amount = luaL_checknumber( L, 3 ); uluaPushVector2( L, Vector2Lerp( v1, v2, amount ) ); @@ -585,15 +440,9 @@ int lmathVector2Lerp( lua_State *L ) { Calculate reflected vector to normal -- Failure return false - Success return Vector2 */ int lmathVector2Reflect( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Reflect( Vector2 v, Vector2 normal )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -607,17 +456,11 @@ int lmathVector2Reflect( lua_State *L ) { Rotate vector by angle -- Failure return false - Success return Vector2 */ int lmathVector2Rotate( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Rotate( Vector2 v, float angle )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); - float degs = lua_tonumber( L, 2 ); + float degs = luaL_checknumber( L, 2 ); uluaPushVector2( L, Vector2Rotate( v, degs ) ); @@ -629,18 +472,12 @@ int lmathVector2Rotate( lua_State *L ) { Move Vector towards target -- Failure return false - Success return Vector2 */ int lmathVector2MoveTowards( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2MoveTowards( Vector2 v, Vector2 target, float maxDistance )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); - float maxDistance = lua_tonumber( L, 3 ); + float maxDistance = luaL_checknumber( L, 3 ); uluaPushVector2( L, Vector2MoveTowards( v1, v2, maxDistance ) ); @@ -652,15 +489,9 @@ int lmathVector2MoveTowards( lua_State *L ) { Invert the given vector -- Failure return false - Success return Vector2 */ int lmathVector2Invert( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Invert( Vector2 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); uluaPushVector2( L, Vector2Invert( v ) ); @@ -674,15 +505,9 @@ int lmathVector2Invert( lua_State *L ) { Clamp the components of the vector between min and max values specified by the given vectors -- Failure return false - Success return Vector2 */ int lmathVector2Clamp( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Clamp( Vector2 v, Vector2 min, Vector2 max )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); Vector2 min = uluaGetVector2Index( L, 2 ); Vector2 max = uluaGetVector2Index( L, 3 ); @@ -697,18 +522,12 @@ int lmathVector2Clamp( lua_State *L ) { Clamp the magnitude of the vector between two min and max values -- Failure return false - Success return Vector2 */ int lmathVector2ClampValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2ClampValue( Vector2 v, float min, float max )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); - float min = lua_tonumber( L, 2 ); - float max = lua_tonumber( L, 3 ); + float min = luaL_checknumber( L, 2 ); + float max = luaL_checknumber( L, 3 ); uluaPushVector2( L, Vector2ClampValue( v, min, max ) ); @@ -720,15 +539,9 @@ int lmathVector2ClampValue( lua_State *L ) { Check whether two given vectors are almost equal -- Failure return false - Success return int */ int lmathVector2Equals( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Equals( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -772,15 +585,9 @@ int lmathVector3One( lua_State *L ) { Add two vectors -- Failure return false - Success return Vector3 */ int lmathVector3Add( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Add( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -794,17 +601,11 @@ int lmathVector3Add( lua_State *L ) { Add vector and float value -- Failure return false - Success return Vector3 */ int lmathVector3AddValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3AddValue( Vector3 v, float add )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); - float add = lua_tonumber( L, 2 ); + float add = luaL_checknumber( L, 2 ); uluaPushVector3( L, Vector3AddValue( v, add ) ); @@ -816,15 +617,9 @@ int lmathVector3AddValue( lua_State *L ) { Subtract two vectors -- Failure return false - Success return Vector3 */ int lmathVector3Subtract( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Subtract( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -838,17 +633,11 @@ int lmathVector3Subtract( lua_State *L ) { Subtract vector by float value -- Failure return false - Success return Vector3 */ int lmathVector3SubtractValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3SubtractValue( Vector3 v, float sub )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); - float sub = lua_tonumber( L, 2 ); + float sub = luaL_checknumber( L, 2 ); uluaPushVector3( L, Vector3SubtractValue( v, sub ) ); @@ -860,17 +649,11 @@ int lmathVector3SubtractValue( lua_State *L ) { Multiply vector by scalar -- Failure return false - Success return Vector3 */ int lmathVector3Scale( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Scale( Vector3 v, float scalar )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); - float scalar = lua_tonumber( L, 2 ); + float scalar = luaL_checknumber( L, 2 ); uluaPushVector3( L, Vector3Scale( v, scalar ) ); @@ -882,15 +665,9 @@ int lmathVector3Scale( lua_State *L ) { Multiply vector by vector -- Failure return false - Success return Vector3 */ int lmathVector3Multiply( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Multiply( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -904,15 +681,9 @@ int lmathVector3Multiply( lua_State *L ) { Calculate two vectors cross product -- Failure return false - Success return Vector3 */ int lmathVector3CrossProduct( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3CrossProduct( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -926,15 +697,9 @@ int lmathVector3CrossProduct( lua_State *L ) { Calculate one vector perpendicular vector -- Failure return false - Success return Vector3 */ int lmathVector3Perpendicular( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Perpendicular( Vector3 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushVector3( L, Vector3Perpendicular( v ) ); @@ -947,15 +712,9 @@ int lmathVector3Perpendicular( lua_State *L ) { Calculate vector length -- Failure return false - Success return float */ int lmathVector3Length( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Length( Vector3 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); lua_pushnumber( L, Vector3Length( v ) ); @@ -968,15 +727,9 @@ int lmathVector3Length( lua_State *L ) { Calculate vector square length -- Failure return false - Success return float */ int lmathVector3LengthSqr( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3LengthSqr( Vector3 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); lua_pushnumber( L, Vector3LengthSqr( v ) ); @@ -989,15 +742,9 @@ int lmathVector3LengthSqr( lua_State *L ) { Calculate two vectors dot product -- Failure return false - Success return float */ int lmathVector3DotProduct( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3DotProduct( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1011,15 +758,9 @@ int lmathVector3DotProduct( lua_State *L ) { Calculate distance between two vectors -- Failure return false - Success return float */ int lmathVector3Distance( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Distance( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1033,15 +774,9 @@ int lmathVector3Distance( lua_State *L ) { Calculate square distance between two vectors -- Failure return false - Success return float */ int lmathVector3DistanceSqr( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3DistanceSqr( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1055,15 +790,9 @@ int lmathVector3DistanceSqr( lua_State *L ) { Calculate angle between two vectors -- Failure return false - Success return float */ int lmathVector3Angle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Angle( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1075,17 +804,11 @@ int lmathVector3Angle( lua_State *L ) { /* > result = RL.Vector3Negate( Vector3 v ) -Negate provided vector ( invert direction ) +Negate provided vector (invert direction) -- Failure return false - Success return Vector3 */ int lmathVector3Negate( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Negate( Vector3 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushVector3( L, Vector3Negate( v ) ); @@ -1098,15 +821,9 @@ int lmathVector3Negate( lua_State *L ) { Divide vector by vector -- Failure return false - Success return Vector3 */ int lmathVector3Divide( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Divide( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1120,15 +837,9 @@ int lmathVector3Divide( lua_State *L ) { Normalize provided vector -- Failure return false - Success return Vector3 */ int lmathVector3Normalize( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Normalize( Vector3 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushVector3( L, Vector3Normalize( v ) ); @@ -1142,15 +853,9 @@ int lmathVector3Normalize( lua_State *L ) { Orthonormalize provided vectors. Makes vectors normalized and orthogonal to each other. Gram-Schmidt function implementation -- Failure return false - Success return Vector3, Vector3 */ int lmathVector3OrthoNormalize( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3OrthoNormalize( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1167,15 +872,9 @@ int lmathVector3OrthoNormalize( lua_State *L ) { Transforms a Vector3 by a given Matrix -- Failure return false - Success return Vector3 */ int lmathVector3Transform( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Transform( Vector3 v, Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); Matrix mat = uluaGetMatrixIndex( L, 2 ); @@ -1189,15 +888,9 @@ int lmathVector3Transform( lua_State *L ) { Transform a vector by quaternion rotation -- Failure return false - Success return Vector3 */ int lmathVector3RotateByQuaternion( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3RotateByQuaternion( Vector3 v, Quaternion q )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); Quaternion q = uluaGetQuaternionIndex( L, 2 ); @@ -1211,18 +904,12 @@ int lmathVector3RotateByQuaternion( lua_State *L ) { Rotates a vector around an axis -- Failure return false - Success return Vector3 */ int lmathVector3RotateByAxisAngle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3RotateByAxisAngle( Vector3 v, Vector3 axis, float angle )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); Vector3 axis = uluaGetVector3Index( L, 2 ); - float angle = lua_tonumber( L, 3 ); + float angle = luaL_checknumber( L, 3 ); uluaPushVector3( L, Vector3RotateByAxisAngle( v, axis, angle ) ); @@ -1234,18 +921,12 @@ int lmathVector3RotateByAxisAngle( lua_State *L ) { Calculate linear interpolation between two vectors -- Failure return false - Success return Vector3 */ int lmathVector3Lerp( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Lerp( Vector3 v1, Vector3 v2, float amount )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); - float amount = lua_tonumber( L, 3 ); + float amount = luaL_checknumber( L, 3 ); uluaPushVector3( L, Vector3Lerp( v1, v2, amount ) ); @@ -1257,15 +938,9 @@ int lmathVector3Lerp( lua_State *L ) { Calculate reflected vector to normal -- Failure return false - Success return Vector3 */ int lmathVector3Reflect( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Reflect( Vector3 v, Vector3 normal )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); Vector3 normal = uluaGetVector3Index( L, 2 ); @@ -1279,15 +954,9 @@ int lmathVector3Reflect( lua_State *L ) { Get min value for each pair of components -- Failure return false - Success return Vector3 */ int lmathVector3Min( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Min( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1301,15 +970,9 @@ int lmathVector3Min( lua_State *L ) { Get max value for each pair of components -- Failure return false - Success return Vector3 */ int lmathVector3Max( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Max( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1321,18 +984,12 @@ int lmathVector3Max( lua_State *L ) { /* > result = RL.Vector3Barycenter( Vector3 p, Vector3 a, Vector3 b, Vector3 c ) -Compute barycenter coordinates ( u, v, w ) for point p with respect to triangle ( a, b, c ) +Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c) NOTE: Assumes P is on the plane of the triangle -- Failure return false - Success return Vector3 */ int lmathVector3Barycenter( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Barycenter( Vector3 p, Vector3 a, Vector3 b, Vector3 c )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 p = uluaGetVector3Index( L, 1 ); Vector3 a = uluaGetVector3Index( L, 2 ); Vector3 b = uluaGetVector3Index( L, 3 ); @@ -1349,15 +1006,9 @@ int lmathVector3Barycenter( lua_State *L ) { Projects a Vector3 from screen space into object space NOTE: We are avoiding calling other raymath functions despite available -- Failure return false - Success return Vector3 */ int lmathVector3Unproject( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Unproject( Vector3 source, Matrix projection, Matrix view )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 source = uluaGetVector3Index( L, 1 ); Matrix projection = uluaGetMatrixIndex( L, 2 ); Matrix view = uluaGetMatrixIndex( L, 3 ); @@ -1372,15 +1023,9 @@ int lmathVector3Unproject( lua_State *L ) { Invert the given vector -- Failure return false - Success return Vector3 */ int lmathVector3Invert( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Invert( Vector3 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushVector3( L, Vector3Invert( v ) ); @@ -1394,15 +1039,9 @@ int lmathVector3Invert( lua_State *L ) { Clamp the components of the vector between min and max values specified by the given vectors -- Failure return false - Success return Vector3 */ int lmathVector3Clamp( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Clamp( Vector3 v, Vector3 min, Vector3 max )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); Vector3 min = uluaGetVector3Index( L, 2 ); Vector3 max = uluaGetVector3Index( L, 3 ); @@ -1417,18 +1056,12 @@ int lmathVector3Clamp( lua_State *L ) { Clamp the magnitude of the vector between two values -- Failure return false - Success return Vector3 */ int lmathVector3ClampValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3ClampValue( Vector3 v, float min, float max )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); - float min = lua_tonumber( L, 2 ); - float max = lua_tonumber( L, 3 ); + float min = luaL_checknumber( L, 2 ); + float max = luaL_checknumber( L, 3 ); uluaPushVector3( L, Vector3ClampValue( v, min, max ) ); @@ -1440,15 +1073,9 @@ int lmathVector3ClampValue( lua_State *L ) { Check whether two given vectors are almost equal -- Failure return false - Success return int */ int lmathVector3Equals( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Equals( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1467,18 +1094,12 @@ and r specifies the ratio of the refractive index of the medium from where the ray comes to the refractive index of the medium on the other side of the surface -- Failure return false - Success return Vector3 */ int lmathVector3Refract( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Refract( Vector3 v, Vector3 n, float r )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); Vector3 n = uluaGetVector3Index( L, 2 ); - float r = lua_tonumber( L, 3 ); + float r = luaL_checknumber( L, 3 ); uluaPushVector3( L, Vector3Refract( v, n, r ) ); @@ -1494,15 +1115,9 @@ int lmathVector3Refract( lua_State *L ) { Compute matrix determinant -- Failure return false - Success return float */ int lmathMatrixDeterminant( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixDeterminant( Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat = uluaGetMatrixIndex( L, 1 ); lua_pushnumber( L, MatrixDeterminant( mat ) ); @@ -1513,17 +1128,11 @@ int lmathMatrixDeterminant( lua_State *L ) { /* > result = RL.MatrixTrace( Matrix mat ) -Get the trace of the matrix ( sum of the values along the diagonal ) +Get the trace of the matrix (sum of the values along the diagonal) -- Failure return false - Success return float */ int lmathMatrixTrace( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixTrace( Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat = uluaGetMatrixIndex( L, 1 ); lua_pushnumber( L, MatrixTrace( mat ) ); @@ -1536,15 +1145,9 @@ int lmathMatrixTrace( lua_State *L ) { Transposes provided matrix -- Failure return false - Success return Matrix */ int lmathMatrixTranspose( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixTranspose( Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat = uluaGetMatrixIndex( L, 1 ); uluaPushMatrix( L, MatrixTranspose( mat ) ); @@ -1557,15 +1160,9 @@ int lmathMatrixTranspose( lua_State *L ) { Invert provided matrix -- Failure return false - Success return Matrix */ int lmathMatrixInvert( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixInvert( Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat = uluaGetMatrixIndex( L, 1 ); uluaPushMatrix( L, MatrixInvert( mat ) ); @@ -1591,15 +1188,9 @@ int lmathMatrixIdentity( lua_State *L ) { Add two matrices -- Failure return false - Success return Matrix */ int lmathMatrixAdd( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixAdd( Matrix left, Matrix right )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat1 = uluaGetMatrixIndex( L, 1 ); Matrix mat2 = uluaGetMatrixIndex( L, 2 ); @@ -1613,15 +1204,9 @@ int lmathMatrixAdd( lua_State *L ) { Subtract two matrices (left - right) -- Failure return false - Success return Matrix */ int lmathMatrixSubtract( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixSubtract( Matrix left, Matrix right )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat1 = uluaGetMatrixIndex( L, 1 ); Matrix mat2 = uluaGetMatrixIndex( L, 2 ); @@ -1635,15 +1220,9 @@ int lmathMatrixSubtract( lua_State *L ) { Get two matrix multiplication -- Failure return false - Success return Matrix */ int lmathMatrixMultiply( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixMultiply( Matrix left, Matrix right )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat1 = uluaGetMatrixIndex( L, 1 ); Matrix mat2 = uluaGetMatrixIndex( L, 2 ); @@ -1657,15 +1236,9 @@ int lmathMatrixMultiply( lua_State *L ) { Get translation matrix -- Failure return false - Success return Matrix */ int lmathMatrixTranslate( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixTranslate( Vector3 translate )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushMatrix( L, MatrixTranslate( v.x, v.y, v.z ) ); @@ -1678,17 +1251,11 @@ int lmathMatrixTranslate( lua_State *L ) { Create rotation matrix from axis and angle. NOTE: Angle should be provided in radians -- Failure return false - Success return Matrix */ int lmathMatrixRotate( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixRotate( Vector3 axis, float angle )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 axis = uluaGetVector3Index( L, 1 ); - float angle = lua_tonumber( L, 2 ); + float angle = luaL_checknumber( L, 2 ); uluaPushMatrix( L, MatrixRotate( axis, angle ) ); @@ -1698,18 +1265,12 @@ int lmathMatrixRotate( lua_State *L ) { /* > result = RL.MatrixRotateX( float angle ) -Get x-rotation matrix ( angle in radians ) +Get x-rotation matrix (angle in radians) -- Failure return false - Success return Matrix */ int lmathMatrixRotateX( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixRotateX( float angle )" ); - lua_pushboolean( L, false ); - return 1; - } - float angle = lua_tonumber( L, 1 ); + float angle = luaL_checknumber( L, 1 ); uluaPushMatrix( L, MatrixRotateX( angle ) ); @@ -1719,18 +1280,12 @@ int lmathMatrixRotateX( lua_State *L ) { /* > result = RL.MatrixRotateY( float angle ) -Get y-rotation matrix ( angle in radians ) +Get y-rotation matrix (angle in radians) -- Failure return false - Success return Matrix */ int lmathMatrixRotateY( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixRotateY( float angle )" ); - lua_pushboolean( L, false ); - return 1; - } - float angle = lua_tonumber( L, 1 ); + float angle = luaL_checknumber( L, 1 ); uluaPushMatrix( L, MatrixRotateY( angle ) ); @@ -1740,18 +1295,12 @@ int lmathMatrixRotateY( lua_State *L ) { /* > result = RL.MatrixRotateZ( float angle ) -Get z-rotation matrix ( angle in radians ) +Get z-rotation matrix (angle in radians) -- Failure return false - Success return Matrix */ int lmathMatrixRotateZ( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixRotateZ( float angle )" ); - lua_pushboolean( L, false ); - return 1; - } - float angle = lua_tonumber( L, 1 ); + float angle = luaL_checknumber( L, 1 ); uluaPushMatrix( L, MatrixRotateZ( angle ) ); @@ -1761,17 +1310,11 @@ int lmathMatrixRotateZ( lua_State *L ) { /* > result = RL.MatrixRotateXYZ( Vector3 angle ) -Get xyz-rotation matrix ( angles in radians ) +Get xyz-rotation matrix (angles in radians) -- Failure return false - Success return Matrix */ int lmathMatrixRotateXYZ( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixRotateXYZ( Vector3 angle )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 angle = uluaGetVector3Index( L, 1 ); uluaPushMatrix( L, MatrixRotateXYZ( angle ) ); @@ -1782,17 +1325,11 @@ int lmathMatrixRotateXYZ( lua_State *L ) { /* > result = RL.MatrixRotateZYX( Vector3 angle ) -Get zyx-rotation matrix ( angles in radians ) +Get zyx-rotation matrix (angles in radians) -- Failure return false - Success return Matrix */ int lmathMatrixRotateZYX( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixRotateZYX( Vector3 angle )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 angle = uluaGetVector3Index( L, 1 ); uluaPushMatrix( L, MatrixRotateZYX( angle ) ); @@ -1805,15 +1342,9 @@ int lmathMatrixRotateZYX( lua_State *L ) { Get scaling matrix -- Failure return false - Success return Matrix */ int lmathMatrixScale( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixScale( Vector3 scale )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushMatrix( L, MatrixScale( v.x, v.y, v.z ) ); @@ -1826,22 +1357,15 @@ int lmathMatrixScale( lua_State *L ) { Get perspective projection matrix -- Failure return false - Success return Matrix */ int lmathMatrixFrustum( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixFrustum( double left, double right, double bottom, double top, double near, double far )" ); - lua_pushboolean( L, false ); - return 1; - } - float left = lua_tonumber( L, 1 ); - float right = lua_tonumber( L, 2); - float bottom = lua_tonumber( L, 3 ); - float top = lua_tonumber( L, 4 ); - float near = lua_tonumber( L, 5 ); - float far = lua_tonumber( L, 6 ); + float left = luaL_checknumber( L, 1 ); + float right = luaL_checknumber( L, 2); + float bottom = luaL_checknumber( L, 3 ); + float top = luaL_checknumber( L, 4 ); + float near = luaL_checknumber( L, 5 ); + float far = luaL_checknumber( L, 6 ); uluaPushMatrix( L, MatrixFrustum( left, right, bottom, top, near, far ) ); @@ -1853,19 +1377,13 @@ int lmathMatrixFrustum( lua_State *L ) { Get perspective projection matrix -- Failure return false - Success return Matrix */ int lmathMatrixPerspective( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixPerspective( double fovy, double aspect, double near, double far )" ); - lua_pushboolean( L, false ); - return 1; - } - float fovy = lua_tonumber( L, 1 ); - float aspect = lua_tonumber( L, 2 ); - float near = lua_tonumber( L, 3 ); - float far = lua_tonumber( L, 4 ); + float fovy = luaL_checknumber( L, 1 ); + float aspect = luaL_checknumber( L, 2 ); + float near = luaL_checknumber( L, 3 ); + float far = luaL_checknumber( L, 4 ); uluaPushMatrix( L, MatrixPerspective( fovy, aspect, near, far ) ); @@ -1877,22 +1395,15 @@ int lmathMatrixPerspective( lua_State *L ) { Get orthographic projection matrix -- Failure return false - Success return Matrix */ int lmathMatrixOrtho( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixOrtho( double left, double right, double bottom, double top, double near, double far )" ); - lua_pushboolean( L, false ); - return 1; - } - float left = lua_tonumber( L, 1 ); - float right = lua_tonumber( L, 2 ); - float bottom = lua_tonumber( L, 3 ); - float top = lua_tonumber( L, 4 ); - float near = lua_tonumber( L, 5 ); - float far = lua_tonumber( L, 6 ); + float left = luaL_checknumber( L, 1 ); + float right = luaL_checknumber( L, 2 ); + float bottom = luaL_checknumber( L, 3 ); + float top = luaL_checknumber( L, 4 ); + float near = luaL_checknumber( L, 5 ); + float far = luaL_checknumber( L, 6 ); uluaPushMatrix( L, MatrixOrtho( left, right, bottom, top, near, far ) ); @@ -1902,17 +1413,11 @@ int lmathMatrixOrtho( lua_State *L ) { /* > result = RL.MatrixLookAt( Vector3 eye, Vector3 target, Vector3 up ) -Get camera look-at matrix ( View matrix ) +Get camera look-at matrix (View matrix) -- Failure return false - Success return Matrix */ int lmathMatrixLookAt( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixLookAt( Vector3 eye, Vector3 target, Vector3 up )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 eye = uluaGetVector3Index( L, 1 ); Vector3 target = uluaGetVector3Index( L, 2 ); Vector3 up = uluaGetVector3Index( L, 3 ); @@ -1931,15 +1436,9 @@ int lmathMatrixLookAt( lua_State *L ) { Add two quaternions -- Failure return false - Success return Quaternion */ int lmathQuaternionAdd( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionAdd( Quaternion q1, Quaternion q2 )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); @@ -1953,17 +1452,11 @@ int lmathQuaternionAdd( lua_State *L ) { Add quaternion and float value -- Failure return false - Success return Quaternion */ int lmathQuaternionAddValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionAddValue( Quaternion q, float add )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); - float add = lua_tonumber( L, 2 ); + float add = luaL_checknumber( L, 2 ); uluaPushQuaternion( L, QuaternionAddValue( q, add ) ); @@ -1975,15 +1468,9 @@ int lmathQuaternionAddValue( lua_State *L ) { Subtract two quaternions -- Failure return false - Success return Quaternion */ int lmathQuaternionSubtract( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionSubtract( Quaternion q1, Quaternion q2 )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); @@ -1997,17 +1484,11 @@ int lmathQuaternionSubtract( lua_State *L ) { Subtract quaternion and float value -- Failure return false - Success return Quaternion */ int lmathQuaternionSubtractValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionSubtractValue( Quaternion q, float sub )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); - float sub = lua_tonumber( L, 2 ); + float sub = luaL_checknumber( L, 2 ); uluaPushQuaternion( L, QuaternionSubtractValue( q, sub ) ); @@ -2032,15 +1513,9 @@ int lmathQuaternionIdentity( lua_State *L ) { Computes the length of a quaternion -- Failure return false - Success return float */ int lmathQuaternionLength( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionLength( Quaternion q )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); lua_pushnumber( L, QuaternionLength( q ) ); @@ -2053,15 +1528,9 @@ int lmathQuaternionLength( lua_State *L ) { Normalize provided quaternion -- Failure return false - Success return Quaternion */ int lmathQuaternionNormalize( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionNormalize( Quaternion q )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); uluaPushQuaternion( L, QuaternionNormalize( q ) ); @@ -2074,15 +1543,9 @@ int lmathQuaternionNormalize( lua_State *L ) { Invert provided quaternion -- Failure return false - Success return Quaternion */ int lmathQuaternionInvert( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionInvert( Quaternion q )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); uluaPushQuaternion( L, QuaternionInvert( q ) ); @@ -2095,15 +1558,9 @@ int lmathQuaternionInvert( lua_State *L ) { Calculate two quaternion multiplication -- Failure return false - Success return Quaternion */ int lmathQuaternionMultiply( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionMultiply( Quaternion q1, Quaternion q2 )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); @@ -2117,17 +1574,11 @@ int lmathQuaternionMultiply( lua_State *L ) { Scale quaternion by float value -- Failure return false - Success return Quaternion */ int lmathQuaternionScale( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionScale( Quaternion q, float mul )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); - float mul = lua_tonumber( L, 2 ); + float mul = luaL_checknumber( L, 2 ); uluaPushQuaternion( L, QuaternionScale( q, mul ) ); @@ -2139,15 +1590,9 @@ int lmathQuaternionScale( lua_State *L ) { Divide two quaternions -- Failure return false - Success return Quaternion */ int lmathQuaternionDivide( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionDivide( Quaternion q1, Quaternion q2 )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); @@ -2161,18 +1606,12 @@ int lmathQuaternionDivide( lua_State *L ) { Calculate linear interpolation between two quaternions -- Failure return false - Success return Quaternion */ int lmathQuaternionLerp( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionLerp( Quaternion q1, Quaternion q2, float amount )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); - float amount = lua_tonumber( L, 3 ); + float amount = luaL_checknumber( L, 3 ); uluaPushQuaternion( L, QuaternionLerp( q1, q2, amount ) ); @@ -2184,18 +1623,12 @@ int lmathQuaternionLerp( lua_State *L ) { Calculate slerp-optimized interpolation between two quaternions -- Failure return false - Success return Quaternion */ int lmathQuaternionNlerp( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionNlerp( Quaternion q1, Quaternion q2, float amount )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); - float amount = lua_tonumber( L, 3 ); + float amount = luaL_checknumber( L, 3 ); uluaPushQuaternion( L, QuaternionNlerp( q1, q2, amount ) ); @@ -2207,18 +1640,12 @@ int lmathQuaternionNlerp( lua_State *L ) { Calculates spherical linear interpolation between two quaternions -- Failure return false - Success return Quaternion */ int lmathQuaternionSlerp( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionSlerp( Quaternion q1, Quaternion q2, float amount )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); - float amount = lua_tonumber( L, 3 ); + float amount = luaL_checknumber( L, 3 ); uluaPushQuaternion( L, QuaternionSlerp( q1, q2, amount ) ); @@ -2230,15 +1657,9 @@ int lmathQuaternionSlerp( lua_State *L ) { Calculate quaternion based on the rotation from one vector to another -- Failure return false - Success return Quaternion */ int lmathQuaternionFromVector3ToVector3( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionFromVector3ToVector3( Vector3 from, Vector3 to )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 from = uluaGetVector3Index( L, 1 ); Vector3 to = uluaGetVector3Index( L, 2 ); @@ -2252,15 +1673,9 @@ int lmathQuaternionFromVector3ToVector3( lua_State *L ) { Get a quaternion for a given rotation matrix -- Failure return false - Success return Quaternion */ int lmathQuaternionFromMatrix( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionFromMatrix( Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat = uluaGetMatrixIndex( L, 1 ); uluaPushQuaternion( L, QuaternionFromMatrix( mat ) ); @@ -2273,15 +1688,9 @@ int lmathQuaternionFromMatrix( lua_State *L ) { Get a quaternion for a given rotation matrix -- Failure return false - Success return Matrix */ int lmathQuaternionToMatrix( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionToMatrix( Quaternion q )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); uluaPushMatrix( L, QuaternionToMatrix( q ) ); @@ -2295,17 +1704,11 @@ int lmathQuaternionToMatrix( lua_State *L ) { Get rotation quaternion for an angle and axis NOTE: angle must be provided in radians -- Failure return false - Success return Quaternion */ int lmathQuaternionFromAxisAngle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionFromAxisAngle( Vector3 axis, float angle )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 axis = uluaGetVector3Index( L, 1 ); - float angle = lua_tonumber( L, 2 ); + float angle = luaL_checknumber( L, 2 ); uluaPushQuaternion( L, QuaternionFromAxisAngle( axis, angle ) ); @@ -2317,15 +1720,9 @@ int lmathQuaternionFromAxisAngle( lua_State *L ) { Get the rotation angle and axis for a given quaternion -- Failure return false - Success return Vector3, float */ int lmathQuaternionToAxisAngle( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionToAxisAngle( Quaternion q )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); float angle = 0.0; Vector3 axis = { 0.0 }; @@ -2344,18 +1741,12 @@ int lmathQuaternionToAxisAngle( lua_State *L ) { Get the quaternion equivalent to Euler angles NOTE: Rotation order is ZYX -- Failure return false - Success return Quaternion */ int lmathQuaternionFromEuler( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionFromEuler( float pitch, float yaw, float roll )" ); - lua_pushboolean( L, false ); - return 1; - } - float pitch = lua_tonumber( L, 1 ); - float yaw = lua_tonumber( L, 2 ); - float roll = lua_tonumber( L, 3 ); + float pitch = luaL_checknumber( L, 1 ); + float yaw = luaL_checknumber( L, 2 ); + float roll = luaL_checknumber( L, 3 ); uluaPushQuaternion( L, QuaternionFromEuler( pitch, yaw, roll ) ); @@ -2368,15 +1759,9 @@ int lmathQuaternionFromEuler( lua_State *L ) { Get the Euler angles equivalent to quaternion (roll, pitch, yaw) NOTE: Angles are returned in a Vector3 struct in radians -- Failure return false - Success return Vector3 */ int lmathQuaternionToEuler( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionToEuler( Quaternion q )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); uluaPushVector3( L, QuaternionToEuler( q ) ); @@ -2389,15 +1774,9 @@ int lmathQuaternionToEuler( lua_State *L ) { Transform a quaternion given a transformation matrix -- Failure return false - Success return Quaternion */ int lmathQuaternionTransform( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionTransform( Quaternion q, Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); Matrix mat = uluaGetMatrixIndex( L, 2 ); @@ -2411,15 +1790,9 @@ int lmathQuaternionTransform( lua_State *L ) { Check whether two given quaternions are almost equal -- Failure return false - Success return int */ int lmathQuaternionEquals( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionEquals( Quaternion q1, Quaternion q2 )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); |
