MCPcopy Create free account
hub / github.com/defold/defold / Matrix4_index

Function Matrix4_index

engine/script/src/script_vmath.cpp:739–765  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

737 }
738
739 static int Matrix4_index(lua_State *L)
740 {
741 Matrix4* m = (Matrix4*)lua_touserdata(L, 1);
742
743 size_t key_len = 0;
744 const char* key = luaL_checklstring(L, 2, &key_len);
745 if (key_len == 3)
746 {
747 int row = key[1] - (char)'0';
748 int col = key[2] - (char)'0';
749 if (0 <= row && row < 4 && 0 <= col && col < 4)
750 {
751 lua_pushnumber(L, m->getElem(col, row));
752 return 1;
753 }
754 }
755 else if (key_len == 2)
756 {
757 int col = key[1] - (char)'0';
758 if (0 <= col && col < 4)
759 {
760 PushVector4(L, m->getCol(col));
761 return 1;
762 }
763 }
764 return luaL_error(L, "%s.%s only has fields c0, ..., c3 and m00, m01, ..., m10, ..., m33.", SCRIPT_LIB_NAME, SCRIPT_TYPE_NAME_MATRIX4);
765 }
766
767 static int Matrix4_newindex(lua_State *L)
768 {

Callers

nothing calls this directly

Calls 7

lua_touserdataFunction · 0.85
luaL_checklstringFunction · 0.85
lua_pushnumberFunction · 0.85
PushVector4Function · 0.85
luaL_errorFunction · 0.85
getElemMethod · 0.45
getColMethod · 0.45

Tested by

no test coverage detected