Skip to content

Commit

Permalink
physenv: Add GetTable to all metatables.
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelIT7 committed Nov 20, 2024
1 parent e3555c0 commit 3961559
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2172,24 +2172,52 @@ This table structure is used by a few functions.
Returns `CPhysCollide [NULL]` if invalid.
Else it returns `CPhysCollide`.

#### bool CPhysCollide:IsValid()
Returns `true` if the CPhysCollide is still valid.

#### table CPhysCollide:GetTable()
Returns the lua table of this object.
You can store variables into it.

### CPhysPolySoup

#### CPhysPolySoup:\_\_tostring()
Returns `CPhysPolySoup [NULL]` if invalid.
Else it returns `CPhysPolySoup`.

#### bool CPhysPolySoup:IsValid()
Returns `true` if the CPhysPolySoup is still valid.

#### table CPhysPolySoup:GetTable()
Returns the lua table of this object.
You can store variables into it.

### CPhysConvex

#### CPhysConvex:\_\_tostring()
Returns `CPhysConvex [NULL]` if invalid.
Else it returns `CPhysConvex`.

#### bool CPhysConvex:IsValid()
Returns `true` if the CPhysConvex is still valid.

#### table CPhysConvex:GetTable()
Returns the lua table of this object.
You can store variables into it.

### ICollisionQuery

#### ICollisionQuery:\_\_tostring()
Returns `ICollisionQuery [NULL]` if invalid.
Else it returns `ICollisionQuery`.

#### bool ICollisionQuery:IsValid()
Returns `true` if the collision query is still valid.

#### table ICollisionQuery:GetTable()
Returns the lua table of this object.
You can store variables into it.

#### number ICollisionQuery:ConvexCount()
Returns the number of Convexes.

Expand All @@ -2214,6 +2242,13 @@ Sets the three Vectors that build the triangle at the given index.
Returns `IPhysicsCollisionSet [NULL]` if invalid.
Else it returns `IPhysicsCollisionSet`.

#### bool IPhysicsCollisionSet:IsValid()
Returns `true` if the collisionset is still valid.

#### table IPhysicsCollisionSet:GetTable()
Returns the lua table of this object.
You can store variables into it.

#### IPhysicsCollisionSet:EnableCollisions(number index1, number index2)
Marks collisions to be enabled for the two indexes.

Expand All @@ -2229,6 +2264,13 @@ Returns `true` if the collision between the two objects are enabled.
Returns `IPhysicsEnvironment [NULL]` if invalid.
Else it returns `IPhysicsEnvironment`.

#### bool IPhysicsEnvironment:IsValid()
Returns `true` if the environment is still valid.

#### table IPhysicsEnvironment:GetTable()
Returns the lua table of this object.
You can store variables into it.

#### bool IPhysicsEnvironment:TransferObject(IPhysicsObject obj, IPhysicsEnvironment newEnvironment)
Transfers the physics object from this environment to the new environment. #

Expand Down
60 changes: 60 additions & 0 deletions source/modules/physenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,15 @@ LUA_FUNCTION_STATIC(IPhysicsCollisionSet_IsValid)
return 1;
}

LUA_FUNCTION_STATIC(IPhysicsCollisionSet_GetTable)
{
IPhysicsCollisionSet* pCollideSet = Get_IPhysicsCollisionSet(1, true);
LuaUserData* pUserData = g_pPushedIPhysicsCollisionSet[pCollideSet];
LUA->ReferencePush(pUserData->iTableReference);

return 1;
}

LUA_FUNCTION_STATIC(IPhysicsCollisionSet_EnableCollisions)
{
IPhysicsCollisionSet* pCollideSet = Get_IPhysicsCollisionSet(1, true);
Expand Down Expand Up @@ -546,6 +555,15 @@ LUA_FUNCTION_STATIC(IPhysicsEnvironment_IsValid)
return 1;
}

LUA_FUNCTION_STATIC(IPhysicsEnvironment_GetTable)
{
ILuaPhysicsEnvironment* pLuaEnv = Get_ILuaPhysicsEnvironment(1, true);
LuaUserData* pUserData = g_pPushedILuaPhysicsEnvironment[pLuaEnv];
LUA->ReferencePush(pUserData->iTableReference);

return 1;
}

LUA_FUNCTION_STATIC(IPhysicsEnvironment_TransferObject)
{
IPhysicsEnvironment* pEnvironment = GetPhysicsEnvironment(1, true);
Expand Down Expand Up @@ -1218,6 +1236,15 @@ LUA_FUNCTION_STATIC(CPhysCollide_IsValid)
return 1;
}

LUA_FUNCTION_STATIC(CPhysCollide_GetTable)
{
CPhysCollide* pCollide = Get_CPhysCollide(1, true);
LuaUserData* pUserData = g_pPushedCPhysCollide[pCollide];
LUA->ReferencePush(pUserData->iTableReference);

return 1;
}

LUA_FUNCTION_STATIC(CPhysPolysoup__tostring)
{
CPhysPolysoup* pPolySoup = Get_CPhysPolysoup(1, false);
Expand All @@ -1237,6 +1264,15 @@ LUA_FUNCTION_STATIC(CPhysPolysoup_IsValid)
return 1;
}

LUA_FUNCTION_STATIC(CPhysPolysoup_GetTable)
{
CPhysPolysoup* pPolySoup = Get_CPhysPolysoup(1, true);
LuaUserData* pUserData = g_pPushedCPhysPolysoup[pPolySoup];
LUA->ReferencePush(pUserData->iTableReference);

return 1;
}

LUA_FUNCTION_STATIC(CPhysConvex__tostring)
{
CPhysConvex* pConvex = Get_CPhysConvex(1, false);
Expand All @@ -1256,6 +1292,15 @@ LUA_FUNCTION_STATIC(CPhysConvex_IsValid)
return 1;
}

LUA_FUNCTION_STATIC(CPhysConvex_GetTable)
{
CPhysConvex* pConvex = Get_CPhysConvex(1, true);
LuaUserData* pUserData = g_pPushedCPhysConvex[pConvex];
LUA->ReferencePush(pUserData->iTableReference);

return 1;
}

LUA_FUNCTION_STATIC(ICollisionQuery__tostring)
{
ICollisionQuery* pQuery = Get_ICollisionQuery(1, false);
Expand All @@ -1275,6 +1320,15 @@ LUA_FUNCTION_STATIC(ICollisionQuery_IsValid)
return 1;
}

LUA_FUNCTION_STATIC(ICollisionQuery_GetTable)
{
ICollisionQuery* pQuery = Get_ICollisionQuery(1, true);
LuaUserData* pUserData = g_pPushedICollisionQuery[pQuery];
LUA->ReferencePush(pUserData->iTableReference);

return 1;
}

LUA_FUNCTION_STATIC(ICollisionQuery_ConvexCount)
{
ICollisionQuery* pQuery = Get_ICollisionQuery(1, true);
Expand Down Expand Up @@ -1825,24 +1879,28 @@ void CPhysEnvModule::LuaInit(bool bServerInit)
Util::AddFunc(CPhysCollide__tostring, "__tostring");
Util::AddFunc(Default__Index, "__index");
Util::AddFunc(CPhysCollide_IsValid, "IsValid");
Util::AddFunc(CPhysCollide_GetTable, "GetTable");
g_Lua->Pop(1);

CPhysPolysoup_TypeID = g_Lua->CreateMetaTable("CPhysPolysoup");
Util::AddFunc(CPhysPolysoup__tostring, "__tostring");
Util::AddFunc(Default__Index, "__index");
Util::AddFunc(CPhysPolysoup_IsValid, "IsValid");
Util::AddFunc(CPhysPolysoup_GetTable, "GetTable");
g_Lua->Pop(1);

CPhysConvex_TypeID = g_Lua->CreateMetaTable("CPhysCollide");
Util::AddFunc(CPhysConvex__tostring, "__tostring");
Util::AddFunc(Default__Index, "__index");
Util::AddFunc(CPhysConvex_IsValid, "IsValid");
Util::AddFunc(CPhysConvex_GetTable, "GetTable");
g_Lua->Pop(1);

ICollisionQuery_TypeID = g_Lua->CreateMetaTable("ICollisionQuery");
Util::AddFunc(ICollisionQuery__tostring, "__tostring");
Util::AddFunc(Default__Index, "__index");
Util::AddFunc(ICollisionQuery_IsValid, "IsValid");
Util::AddFunc(ICollisionQuery_GetTable, "GetTable");
Util::AddFunc(ICollisionQuery_ConvexCount, "ConvexCount");
Util::AddFunc(ICollisionQuery_TriangleCount, "TriangleCount");
Util::AddFunc(ICollisionQuery_GetTriangleMaterialIndex, "GetTriangleMaterialIndex");
Expand All @@ -1855,6 +1913,7 @@ void CPhysEnvModule::LuaInit(bool bServerInit)
Util::AddFunc(IPhysicsCollisionSet__tostring, "__tostring");
Util::AddFunc(Default__Index, "__index");
Util::AddFunc(IPhysicsCollisionSet_IsValid, "IsValid");
Util::AddFunc(IPhysicsCollisionSet_GetTable, "GetTable");
Util::AddFunc(IPhysicsCollisionSet_EnableCollisions, "EnableCollisions");
Util::AddFunc(IPhysicsCollisionSet_DisableCollisions, "DisableCollisions");
Util::AddFunc(IPhysicsCollisionSet_ShouldCollide, "ShouldCollide");
Expand All @@ -1864,6 +1923,7 @@ void CPhysEnvModule::LuaInit(bool bServerInit)
Util::AddFunc(IPhysicsEnvironment__tostring, "__tostring");
Util::AddFunc(Default__Index, "__index");
Util::AddFunc(IPhysicsEnvironment_IsValid, "IsValid");
Util::AddFunc(IPhysicsEnvironment_GetTable, "GetTable");
Util::AddFunc(IPhysicsEnvironment_TransferObject, "TransferObject");
Util::AddFunc(IPhysicsEnvironment_SetGravity, "SetGravity");
Util::AddFunc(IPhysicsEnvironment_GetGravity, "GetGravity");
Expand Down

0 comments on commit 3961559

Please sign in to comment.