MCPcopy Create free account
hub / github.com/DavidColson/Polybox / VecDot

Function VecDot

source/userdata.cpp:656–674  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

654// ***********************************************************************
655
656i32 VecDot(lua_State* L) {
657 UserData* pUserData = (UserData*)luaL_checkudata(L, 1, "UserData");
658 UserData* pOther = (UserData*)luaL_checkudata(L, 2, "UserData");
659
660 i32 bufSize = pUserData->width * pUserData->height;
661 i32 otherSize = pUserData->width * pUserData->height;
662 if (bufSize != otherSize) {
663 luaL_error(L, "Both userdatas must be the same size for dot");
664 }
665
666 switch(pUserData->type) {
667 case Type::Float32: lua_pushnumber(L, CalcDot<f32>(pUserData, pOther)); break;
668 case Type::Int32: lua_pushinteger(L, CalcDot<i32>(pUserData, pOther)); break;
669 case Type::Int16: lua_pushinteger(L, CalcDot<i16>(pUserData, pOther)); break;
670 case Type::Uint8: lua_pushunsigned(L, CalcDot<u8>(pUserData, pOther)); break;
671 default: return 0;
672 }
673 return 1;
674}
675
676// ***********************************************************************
677

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected