| 617 | // *********************************************************************** |
| 618 | |
| 619 | i32 VecDistance(lua_State* L) { |
| 620 | UserData* pUserData = (UserData*)luaL_checkudata(L, 1, "UserData"); |
| 621 | UserData* pOther = (UserData*)luaL_checkudata(L, 2, "UserData"); |
| 622 | |
| 623 | i32 bufSize = pUserData->width * pUserData->height; |
| 624 | i32 otherSize = pUserData->width * pUserData->height; |
| 625 | if (bufSize != otherSize) { |
| 626 | luaL_error(L, "Both userdatas must be the same size for distance"); |
| 627 | } |
| 628 | |
| 629 | switch(pUserData->type) { |
| 630 | case Type::Float32: lua_pushnumber(L, CalcDistance<f32>(pUserData, pOther)); break; |
| 631 | case Type::Int32: lua_pushinteger(L, CalcDistance<i32>(pUserData, pOther)); break; |
| 632 | case Type::Int16: lua_pushinteger(L, CalcDistance<i16>(pUserData, pOther)); break; |
| 633 | case Type::Uint8: lua_pushunsigned(L, CalcDistance<u8>(pUserData, pOther)); break; |
| 634 | default: return 0; |
| 635 | } |
| 636 | return 1; |
| 637 | } |
| 638 | |
| 639 | // *********************************************************************** |
| 640 |
nothing calls this directly
no outgoing calls
no test coverage detected