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

Function Matrix4_newindex

engine/script/src/script_vmath.cpp:767–794  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

765 }
766
767 static int Matrix4_newindex(lua_State *L)
768 {
769 Matrix4* m = (Matrix4*)lua_touserdata(L, 1);
770
771 size_t key_len = 0;
772 const char* key = luaL_checklstring(L, 2, &key_len);
773 if (key_len == 3)
774 {
775 int row = key[1] - (char)'0';
776 int col = key[2] - (char)'0';
777 if (0 <= row && row < 4 && 0 <= col && col < 4)
778 {
779 m->setElem(col, row, (float) luaL_checknumber(L, -1));
780 return 0;
781 }
782 }
783 else if (key_len == 2)
784 {
785 int col = key[1] - (char)'0';
786 if (0 <= col && col < 4)
787 {
788 Vector4* vec = CheckVector4(L, -1);
789 m->setCol(col, *vec);
790 return 0;
791 }
792 }
793 return luaL_error(L, "%s.%s only has fields c0, ..., c3 and m00, m01, ..., m10, ..., m33.", SCRIPT_LIB_NAME, SCRIPT_TYPE_NAME_MATRIX4);
794 }
795
796 static int Matrix4_mul(lua_State *L)
797 {

Callers

nothing calls this directly

Calls 5

lua_touserdataFunction · 0.85
luaL_checklstringFunction · 0.85
luaL_checknumberFunction · 0.85
CheckVector4Function · 0.85
luaL_errorFunction · 0.85

Tested by

no test coverage detected