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

Function InitializeVmath

engine/script/src/script_vmath.cpp:2752–2779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2750 };
2751
2752 void InitializeVmath(lua_State* L)
2753 {
2754 int top = lua_gettop(L);
2755
2756 const uint32_t type_count = 5;
2757 struct
2758 {
2759 const char* m_Name;
2760 const luaL_reg* m_Methods;
2761 const luaL_reg* m_Metatable;
2762 uint32_t* m_TypeHash;
2763 } types[type_count] =
2764 {
2765 {SCRIPT_TYPE_NAME_VECTOR, Vector_methods, Vector_meta, &TYPE_HASHES[SCRIPT_TYPE_VECTOR]},
2766 {SCRIPT_TYPE_NAME_VECTOR3, Vector3_methods, Vector3_meta, &TYPE_HASHES[SCRIPT_TYPE_VECTOR3]},
2767 {SCRIPT_TYPE_NAME_VECTOR4, Vector4_methods, Vector4_meta, &TYPE_HASHES[SCRIPT_TYPE_VECTOR4]},
2768 {SCRIPT_TYPE_NAME_QUAT, Quat_methods, Quat_meta, &TYPE_HASHES[SCRIPT_TYPE_QUAT]},
2769 {SCRIPT_TYPE_NAME_MATRIX4, Matrix4_methods, Matrix4_meta, &TYPE_HASHES[SCRIPT_TYPE_MATRIX4]}
2770 };
2771 for (uint32_t i = 0; i < type_count; ++i)
2772 {
2773 *types[i].m_TypeHash = dmScript::RegisterUserType(L, types[i].m_Name, types[i].m_Methods, types[i].m_Metatable);
2774 }
2775 luaL_register(L, SCRIPT_LIB_NAME, methods);
2776 lua_pop(L, 1);
2777
2778 assert(top == lua_gettop(L));
2779 }
2780
2781 void PushVector(lua_State* L, FloatVector* v)
2782 {

Callers 1

InitializeFunction · 0.85

Calls 3

lua_gettopFunction · 0.85
RegisterUserTypeFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected