|
12 | 12 |
|
13 | 13 | #include "StdInc.h"
|
14 | 14 | using std::list;
|
| 15 | +#define MIN_CLIENT_REQ_GETBOUNDINGBOX_OOP "1.5.5-9.13999" |
15 | 16 |
|
16 | 17 | void CLuaElementDefs::LoadFunctions(void)
|
17 | 18 | {
|
@@ -129,7 +130,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM)
|
129 | 130 | lua_classfunction(luaVM, "getChildrenCount", "getElementChildrenCount");
|
130 | 131 | lua_classfunction(luaVM, "getID", "getElementID");
|
131 | 132 | lua_classfunction(luaVM, "getParent", "getElementParent");
|
132 |
| - lua_classfunction(luaVM, "getBoundingBox", "getElementBoundingBox"); |
| 133 | + lua_classfunction(luaVM, "getBoundingBox", OOP_GetElementBoundingBox); |
133 | 134 | lua_classfunction(luaVM, "getPosition", OOP_GetElementPosition);
|
134 | 135 | lua_classfunction(luaVM, "getRotation", OOP_GetElementRotation);
|
135 | 136 | lua_classfunction(luaVM, "getMatrix", OOP_GetElementMatrix);
|
@@ -199,6 +200,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM)
|
199 | 200 | lua_classvariable(luaVM, "distanceFromCentreOfMassToBaseOfModel", NULL, "getElementDistanceFromCentreOfMassToBaseOfModel");
|
200 | 201 | lua_classvariable(luaVM, "radius", NULL, "getElementRadius");
|
201 | 202 | lua_classvariable(luaVM, "childrenCount", NULL, "getElementChildrenCount");
|
| 203 | + lua_classvariable(luaVM, "boundingBox", NULL, OOP_GetElementBoundingBox); |
202 | 204 | lua_classvariable(luaVM, "position", SetElementPosition, OOP_GetElementPosition);
|
203 | 205 | lua_classvariable(luaVM, "rotation", OOP_SetElementRotation, OOP_GetElementRotation);
|
204 | 206 | lua_classvariable(luaVM, "matrix", SetElementMatrix, OOP_GetElementMatrix);
|
@@ -1000,6 +1002,43 @@ int CLuaElementDefs::GetElementDimension(lua_State* luaVM)
|
1000 | 1002 | return 1;
|
1001 | 1003 | }
|
1002 | 1004 |
|
| 1005 | +int CLuaElementDefs::OOP_GetElementBoundingBox(lua_State* luaVM) |
| 1006 | +{ |
| 1007 | + CClientEntity* pEntity; |
| 1008 | + CScriptArgReader argStream(luaVM); |
| 1009 | + argStream.ReadUserData(pEntity); |
| 1010 | + |
| 1011 | + if (!argStream.HasErrors()) |
| 1012 | + { |
| 1013 | + // Grab the bounding box and return it |
| 1014 | + CVector vecMin, vecMax; |
| 1015 | + if (CStaticFunctionDefinitions::GetElementBoundingBox(*pEntity, vecMin, vecMax)) |
| 1016 | + { |
| 1017 | + if (!MinClientReqCheck(argStream, MIN_CLIENT_REQ_GETBOUNDINGBOX_OOP)) |
| 1018 | + { |
| 1019 | + lua_pushvector(luaVM, vecMin); |
| 1020 | + lua_pushvector(luaVM, vecMax); |
| 1021 | + return 2; |
| 1022 | + } |
| 1023 | + else |
| 1024 | + { |
| 1025 | + lua_pushnumber(luaVM, vecMin.fX); |
| 1026 | + lua_pushnumber(luaVM, vecMin.fY); |
| 1027 | + lua_pushnumber(luaVM, vecMin.fZ); |
| 1028 | + lua_pushnumber(luaVM, vecMax.fX); |
| 1029 | + lua_pushnumber(luaVM, vecMax.fY); |
| 1030 | + lua_pushnumber(luaVM, vecMax.fZ); |
| 1031 | + return 6; |
| 1032 | + } |
| 1033 | + } |
| 1034 | + } |
| 1035 | + else |
| 1036 | + m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage()); |
| 1037 | + |
| 1038 | + // Failed |
| 1039 | + lua_pushboolean(luaVM, false); |
| 1040 | +} |
| 1041 | + |
1003 | 1042 | int CLuaElementDefs::GetElementBoundingBox(lua_State* luaVM)
|
1004 | 1043 | {
|
1005 | 1044 | // Verify the argument
|
|
0 commit comments