From c4a0509a7b26cdac359cd2148aedbcf31d04fab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Sat, 11 Feb 2023 06:58:35 -0500 Subject: [PATCH] Block allocator for lua objects (#640) - changes lua object allocations that use Luna wrapper from heap allocation to using block allocator --- WickedEngine/wiAllocator.h | 36 +++++ WickedEngine/wiApplication.cpp | 4 +- WickedEngine/wiApplication_BindLua.cpp | 10 +- WickedEngine/wiImageParams_BindLua.cpp | 16 +- WickedEngine/wiInput_BindLua.cpp | 10 +- WickedEngine/wiLuna.h | 24 ++- WickedEngine/wiMath_BindLua.cpp | 82 +++++----- WickedEngine/wiPrimitive_BindLua.cpp | 28 ++-- WickedEngine/wiScene_BindLua.cpp | 212 ++++++++++++------------- WickedEngine/wiSpriteAnim_BindLua.cpp | 6 +- WickedEngine/wiSpriteFont_BindLua.cpp | 10 +- WickedEngine/wiSprite_BindLua.cpp | 4 +- WickedEngine/wiVersion.cpp | 2 +- 13 files changed, 242 insertions(+), 202 deletions(-) diff --git a/WickedEngine/wiAllocator.h b/WickedEngine/wiAllocator.h index 72fe5b558..80addb116 100644 --- a/WickedEngine/wiAllocator.h +++ b/WickedEngine/wiAllocator.h @@ -1,5 +1,6 @@ #pragma once #include "CommonInclude.h" +#include "wiVector.h" #include #include @@ -36,4 +37,39 @@ namespace wi::allocator offset = 0; } }; + + template + struct BlockAllocator + { + struct Block + { + wi::vector mem; + }; + wi::vector blocks; + wi::vector free_list; + + template + inline T* allocate(ARG&&... args) + { + if (free_list.empty()) + { + free_list.reserve(block_size); + Block& block = blocks.emplace_back(); + block.mem.resize(sizeof(T) * block_size); + T* ptr = (T*)block.mem.data(); + for (size_t i = 0; i < block_size; ++i) + { + free_list.push_back(ptr + i); + } + } + T* ptr = free_list.back(); + free_list.pop_back(); + return new (ptr) T(std::forward(args)...); + } + inline void free(T* ptr) + { + ptr->~T(); + free_list.push_back(ptr); + } + }; } diff --git a/WickedEngine/wiApplication.cpp b/WickedEngine/wiApplication.cpp index ccc6c18c5..02cfdc598 100644 --- a/WickedEngine/wiApplication.cpp +++ b/WickedEngine/wiApplication.cpp @@ -123,8 +123,8 @@ namespace wi if (!startup_script) { startup_script = true; - wi::lua::RegisterObject(wi::lua::Application_BindLua::className, "main", new wi::lua::Application_BindLua(this)); - wi::lua::RegisterObject(wi::lua::Application_BindLua::className, "application", new wi::lua::Application_BindLua(this)); + Luna::push_global(wi::lua::GetLuaState(), "main", this); + Luna::push_global(wi::lua::GetLuaState(), "application", this); wi::lua::RunFile("startup.lua"); } diff --git a/WickedEngine/wiApplication_BindLua.cpp b/WickedEngine/wiApplication_BindLua.cpp index f797b098a..ce4be1bb9 100644 --- a/WickedEngine/wiApplication_BindLua.cpp +++ b/WickedEngine/wiApplication_BindLua.cpp @@ -54,7 +54,7 @@ namespace wi::lua RenderPath3D* comp3D = dynamic_cast(component->GetActivePath()); if (comp3D != nullptr) { - Luna::push(L, new RenderPath3D_BindLua(comp3D)); + Luna::push(L, comp3D); return 1; } @@ -62,7 +62,7 @@ namespace wi::lua LoadingScreen* compLoad = dynamic_cast(component->GetActivePath()); if (compLoad != nullptr) { - Luna::push(L, new LoadingScreen_BindLua(compLoad)); + Luna::push(L, compLoad); return 1; } @@ -70,7 +70,7 @@ namespace wi::lua RenderPath2D* comp2D = dynamic_cast(component->GetActivePath()); if (comp2D != nullptr) { - Luna::push(L, new RenderPath2D_BindLua(comp2D)); + Luna::push(L, comp2D); return 1; } @@ -78,7 +78,7 @@ namespace wi::lua RenderPath* comp = dynamic_cast(component->GetActivePath()); if (comp != nullptr) { - Luna::push(L, new RenderPath_BindLua(comp)); + Luna::push(L, comp); return 1; } @@ -353,7 +353,7 @@ namespace wi::lua wi::lua::SError(L, "GetCanvas() component is empty!"); return 0; } - Luna::push(L, new Canvas_BindLua(component->canvas)); + Luna::push(L, Canvas_BindLua(component->canvas)); return 1; } int Application_BindLua::SetCanvas(lua_State* L) diff --git a/WickedEngine/wiImageParams_BindLua.cpp b/WickedEngine/wiImageParams_BindLua.cpp index b291e25da..c2306561c 100644 --- a/WickedEngine/wiImageParams_BindLua.cpp +++ b/WickedEngine/wiImageParams_BindLua.cpp @@ -69,22 +69,22 @@ namespace wi::lua int ImageParams_BindLua::GetPos(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat3(¶ms.pos))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(¶ms.pos))); return 1; } int ImageParams_BindLua::GetSize(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat2(¶ms.siz))); + Luna::push(L, Vector_BindLua(XMLoadFloat2(¶ms.siz))); return 1; } int ImageParams_BindLua::GetPivot(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat2(¶ms.pivot))); + Luna::push(L, Vector_BindLua(XMLoadFloat2(¶ms.pivot))); return 1; } int ImageParams_BindLua::GetColor(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat4(¶ms.color))); + Luna::push(L, Vector_BindLua(XMLoadFloat4(¶ms.color))); return 1; } int ImageParams_BindLua::GetOpacity(lua_State* L) @@ -104,22 +104,22 @@ namespace wi::lua } int ImageParams_BindLua::GetTexOffset(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat2(¶ms.texOffset))); + Luna::push(L, Vector_BindLua(XMLoadFloat2(¶ms.texOffset))); return 1; } int ImageParams_BindLua::GetTexOffset2(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat2(¶ms.texOffset2))); + Luna::push(L, Vector_BindLua(XMLoadFloat2(¶ms.texOffset2))); return 1; } int ImageParams_BindLua::GetDrawRect(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat4(¶ms.drawRect))); + Luna::push(L, Vector_BindLua(XMLoadFloat4(¶ms.drawRect))); return 1; } int ImageParams_BindLua::GetDrawRect2(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat4(¶ms.drawRect2))); + Luna::push(L, Vector_BindLua(XMLoadFloat4(¶ms.drawRect2))); return 1; } int ImageParams_BindLua::IsDrawRectEnabled(lua_State* L) diff --git a/WickedEngine/wiInput_BindLua.cpp b/WickedEngine/wiInput_BindLua.cpp index 1ab89a89c..132a16efa 100644 --- a/WickedEngine/wiInput_BindLua.cpp +++ b/WickedEngine/wiInput_BindLua.cpp @@ -90,7 +90,7 @@ namespace wi::lua int Input_BindLua::GetPointer(lua_State* L) { XMFLOAT4 P = wi::input::GetPointer(); - Luna::push(L, new Vector_BindLua(XMLoadFloat4(&P))); + Luna::push(L, Vector_BindLua(XMLoadFloat4(&P))); return 1; } int Input_BindLua::SetPointer(lua_State* L) @@ -112,7 +112,7 @@ namespace wi::lua } int Input_BindLua::GetPointerDelta(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat2(&wi::input::GetMouseState().delta_position))); + Luna::push(L, Vector_BindLua(XMLoadFloat2(&wi::input::GetMouseState().delta_position))); return 1; } int Input_BindLua::HidePointer(lua_State* L) @@ -144,7 +144,7 @@ namespace wi::lua else wi::lua::SError(L, "GetAnalog(int type, opt int playerindex = 0) not enough arguments!"); - Luna::push(L, new Vector_BindLua(XMLoadFloat4(&result))); + Luna::push(L, Vector_BindLua(XMLoadFloat4(&result))); return 1; } int Input_BindLua::GetTouches(lua_State* L) @@ -152,7 +152,7 @@ namespace wi::lua auto& touches = wi::input::GetTouches(); for (auto& touch : touches) { - Luna::push(L, new Touch_BindLua(touch)); + Luna::push(L, Touch_BindLua(touch)); } return (int)touches.size(); } @@ -282,7 +282,7 @@ namespace wi::lua } int Touch_BindLua::GetPos(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat2(&touch.pos))); + Luna::push(L, Vector_BindLua(XMLoadFloat2(&touch.pos))); return 1; } diff --git a/WickedEngine/wiLuna.h b/WickedEngine/wiLuna.h index c532127ed..1c8aacc74 100644 --- a/WickedEngine/wiLuna.h +++ b/WickedEngine/wiLuna.h @@ -1,7 +1,9 @@ #pragma once //Luna : Official C++ to Lua binder project, 5th version -//modified to fit with Wicked Engine, removed warnings +// modified for Wicked Engine to use custom memory allocator and removed warnings + +#include "wiAllocator.h" #define lunamethod(class, name) {#name, &class::name} #define lunaproperty(class, name) {#name, &class::Get##name, &class::Set##name} @@ -13,6 +15,8 @@ int Set##property (lua_State* L) { return property.Set(L); } template < class T > class Luna { public: + inline static wi::allocator::BlockAllocator allocator; + struct PropertyType { const char *name; int (T::*getter) (lua_State *); @@ -133,7 +137,7 @@ public: */ static int constructor(lua_State * L) { - T* ap = new T(L); + T* ap = allocator.allocate(L); T** a = static_cast(lua_newuserdata(L, sizeof(T *))); // Push value = userdata *a = ap; @@ -151,16 +155,26 @@ public: Description: Loads an instance of the class into the Lua stack, and provides you a pointer so you can modify it. */ - static void push(lua_State * L, T* instance) + template + static void push(lua_State * L, ARG&&... args) { T **a = (T **)lua_newuserdata(L, sizeof(T *)); // Create userdata - *a = instance; + *a = allocator.allocate(std::forward(args)...); luaL_getmetatable(L, T::className); lua_setmetatable(L, -2); } + // Pushes an instance and registers it into a global object + // example: name = T(args) + template + static void push_global(lua_State* L, const char* name, ARG&&... args) + { + push(L, std::forward(args)...); + lua_setglobal(L, name); + } + /* @ property_getter (internal) Arguments: @@ -264,7 +278,7 @@ public: T** obj = static_cast < T ** >(lua_touserdata(L, -1)); if (obj) - delete(*obj); + allocator.free(*obj); return 0; } diff --git a/WickedEngine/wiMath_BindLua.cpp b/WickedEngine/wiMath_BindLua.cpp index 38496e585..ff12af270 100644 --- a/WickedEngine/wiMath_BindLua.cpp +++ b/WickedEngine/wiMath_BindLua.cpp @@ -42,13 +42,6 @@ namespace wi::lua { NULL, NULL } }; - Vector_BindLua::Vector_BindLua() - { - data.x = 0; - data.y = 0; - data.z = 0; - data.w = 0; - } Vector_BindLua::Vector_BindLua(const XMFLOAT3& vector) { data.x = vector.x; @@ -171,7 +164,7 @@ namespace wi::lua Matrix_BindLua* mat = Luna::lightcheck(L, 2); if (vec && mat) { - Luna::push(L, new Vector_BindLua(XMVector4Transform(XMLoadFloat4(&vec->data), XMLoadFloat4x4(&mat->data)))); + Luna::push(L, Vector_BindLua(XMVector4Transform(XMLoadFloat4(&vec->data), XMLoadFloat4x4(&mat->data)))); return 1; } else @@ -190,7 +183,7 @@ namespace wi::lua Matrix_BindLua* mat = Luna::lightcheck(L, 2); if (vec && mat) { - Luna::push(L, new Vector_BindLua(XMVector3TransformNormal(XMLoadFloat4(&vec->data), XMLoadFloat4x4(&mat->data)))); + Luna::push(L, Vector_BindLua(XMVector3TransformNormal(XMLoadFloat4(&vec->data), XMLoadFloat4x4(&mat->data)))); return 1; } else @@ -209,7 +202,7 @@ namespace wi::lua Matrix_BindLua* mat = Luna::lightcheck(L, 2); if (vec && mat) { - Luna::push(L, new Vector_BindLua(XMVector3TransformCoord(XMLoadFloat4(&vec->data), XMLoadFloat4x4(&mat->data)))); + Luna::push(L, Vector_BindLua(XMVector3TransformCoord(XMLoadFloat4(&vec->data), XMLoadFloat4x4(&mat->data)))); return 1; } else @@ -226,12 +219,12 @@ namespace wi::lua } int Vector_BindLua::Normalize(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMVector3Normalize(XMLoadFloat4(&data)))); + Luna::push(L, Vector_BindLua(XMVector3Normalize(XMLoadFloat4(&data)))); return 1; } int Vector_BindLua::QuaternionNormalize(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMQuaternionNormalize(XMLoadFloat4(&data)))); + Luna::push(L, Vector_BindLua(XMQuaternionNormalize(XMLoadFloat4(&data)))); return 1; } int Vector_BindLua::Clamp(lua_State* L) @@ -241,7 +234,7 @@ namespace wi::lua { float a = wi::lua::SGetFloat(L, 1); float b = wi::lua::SGetFloat(L, 2); - Luna::push(L, new Vector_BindLua(XMVectorClamp(XMLoadFloat4(&data), XMVectorReplicate(a), XMVectorReplicate(b)))); + Luna::push(L, Vector_BindLua(XMVectorClamp(XMLoadFloat4(&data), XMVectorReplicate(a), XMVectorReplicate(b)))); return 1; } else @@ -250,7 +243,7 @@ namespace wi::lua } int Vector_BindLua::Saturate(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMVectorSaturate(XMLoadFloat4(&data)))); + Luna::push(L, Vector_BindLua(XMVectorSaturate(XMLoadFloat4(&data)))); return 1; } @@ -281,7 +274,7 @@ namespace wi::lua Vector_BindLua* v2 = Luna::lightcheck(L, 2); if (v1 && v2) { - Luna::push(L, new Vector_BindLua(XMVector3Cross(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data)))); + Luna::push(L, Vector_BindLua(XMVector3Cross(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data)))); return 1; } } @@ -297,17 +290,17 @@ namespace wi::lua Vector_BindLua* v2 = Luna::lightcheck(L, 2); if (v1 && v2) { - Luna::push(L, new Vector_BindLua(XMVectorMultiply(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data)))); + Luna::push(L, Vector_BindLua(XMVectorMultiply(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data)))); return 1; } else if (v1) { - Luna::push(L, new Vector_BindLua(XMLoadFloat4(&v1->data) * wi::lua::SGetFloat(L, 2))); + Luna::push(L, Vector_BindLua(XMLoadFloat4(&v1->data) * wi::lua::SGetFloat(L, 2))); return 1; } else if (v2) { - Luna::push(L, new Vector_BindLua(wi::lua::SGetFloat(L, 1) * XMLoadFloat4(&v2->data))); + Luna::push(L, Vector_BindLua(wi::lua::SGetFloat(L, 1) * XMLoadFloat4(&v2->data))); return 1; } } @@ -323,7 +316,7 @@ namespace wi::lua Vector_BindLua* v2 = Luna::lightcheck(L, 2); if (v1 && v2) { - Luna::push(L, new Vector_BindLua(XMVectorAdd(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data)))); + Luna::push(L, Vector_BindLua(XMVectorAdd(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data)))); return 1; } } @@ -339,7 +332,7 @@ namespace wi::lua Vector_BindLua* v2 = Luna::lightcheck(L, 2); if (v1 && v2) { - Luna::push(L, new Vector_BindLua(XMVectorSubtract(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data)))); + Luna::push(L, Vector_BindLua(XMVectorSubtract(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data)))); return 1; } } @@ -356,7 +349,7 @@ namespace wi::lua float t = wi::lua::SGetFloat(L, 3); if (v1 && v2) { - Luna::push(L, new Vector_BindLua(XMVectorLerp(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data), t))); + Luna::push(L, Vector_BindLua(XMVectorLerp(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data), t))); return 1; } } @@ -374,7 +367,7 @@ namespace wi::lua Vector_BindLua* v2 = Luna::lightcheck(L, 2); if (v1 && v2) { - Luna::push(L, new Vector_BindLua(XMQuaternionMultiply(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data)))); + Luna::push(L, Vector_BindLua(XMQuaternionMultiply(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data)))); return 1; } } @@ -389,7 +382,7 @@ namespace wi::lua Vector_BindLua* v1 = Luna::lightcheck(L, 1); if (v1) { - Luna::push(L, new Vector_BindLua(XMQuaternionRotationRollPitchYawFromVector(XMLoadFloat4(&v1->data)))); + Luna::push(L, Vector_BindLua(XMQuaternionRotationRollPitchYawFromVector(XMLoadFloat4(&v1->data)))); return 1; } } @@ -405,7 +398,7 @@ namespace wi::lua if (v1) { XMFLOAT3 xyz = wi::math::QuaternionToRollPitchYaw(v1->data); - Luna::push(L, new Vector_BindLua(XMFLOAT4(xyz.x, xyz.y, xyz.z, 0))); + Luna::push(L, Vector_BindLua(XMFLOAT4(xyz.x, xyz.y, xyz.z, 0))); return 1; } } @@ -422,7 +415,7 @@ namespace wi::lua float t = wi::lua::SGetFloat(L, 3); if (v1 && v2) { - Luna::push(L, new Vector_BindLua(XMQuaternionSlerp(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data), t))); + Luna::push(L, Vector_BindLua(XMQuaternionSlerp(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data), t))); return 1; } } @@ -476,15 +469,15 @@ namespace wi::lua { if(data_f2) { - Luna::push(L, new Vector_BindLua(XMLoadFloat2(data_f2))); + Luna::push(L, Vector_BindLua(XMLoadFloat2(data_f2))); } if(data_f3) { - Luna::push(L, new Vector_BindLua(XMLoadFloat3(data_f3))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(data_f3))); } if(data_f4) { - Luna::push(L, new Vector_BindLua(XMLoadFloat4(data_f4))); + Luna::push(L, Vector_BindLua(XMLoadFloat4(data_f4))); } return 1; } @@ -537,9 +530,6 @@ namespace wi::lua { NULL, NULL } }; - Matrix_BindLua::Matrix_BindLua() - { - } Matrix_BindLua::Matrix_BindLua(const XMFLOAT4X4& matrix) { data = matrix; @@ -593,7 +583,7 @@ namespace wi::lua row = 0; } XMFLOAT4 r = XMFLOAT4(data.m[row][0], data.m[row][1], data.m[row][2], data.m[row][3]); - Luna::push(L, new Vector_BindLua(r)); + Luna::push(L, Vector_BindLua(r)); return 1; } @@ -611,7 +601,7 @@ namespace wi::lua mat = XMMatrixTranslationFromVector(XMLoadFloat4(&vector->data)); } } - Luna::push(L, new Matrix_BindLua(mat)); + Luna::push(L, Matrix_BindLua(mat)); return 1; } @@ -627,7 +617,7 @@ namespace wi::lua mat = XMMatrixRotationRollPitchYawFromVector(XMLoadFloat4(&vector->data)); } } - Luna::push(L, new Matrix_BindLua(mat)); + Luna::push(L, Matrix_BindLua(mat)); return 1; } @@ -639,7 +629,7 @@ namespace wi::lua { mat = XMMatrixRotationX(wi::lua::SGetFloat(L, 1)); } - Luna::push(L, new Matrix_BindLua(mat)); + Luna::push(L, Matrix_BindLua(mat)); return 1; } @@ -651,7 +641,7 @@ namespace wi::lua { mat = XMMatrixRotationY(wi::lua::SGetFloat(L, 1)); } - Luna::push(L, new Matrix_BindLua(mat)); + Luna::push(L, Matrix_BindLua(mat)); return 1; } @@ -663,7 +653,7 @@ namespace wi::lua { mat = XMMatrixRotationZ(wi::lua::SGetFloat(L, 1)); } - Luna::push(L, new Matrix_BindLua(mat)); + Luna::push(L, Matrix_BindLua(mat)); return 1; } @@ -679,7 +669,7 @@ namespace wi::lua mat = XMMatrixRotationQuaternion(XMLoadFloat4(&vector->data)); } } - Luna::push(L, new Matrix_BindLua(mat)); + Luna::push(L, Matrix_BindLua(mat)); return 1; } @@ -695,7 +685,7 @@ namespace wi::lua mat = XMMatrixScalingFromVector(XMLoadFloat4(&vector->data)); } } - Luna::push(L, new Matrix_BindLua(mat)); + Luna::push(L, Matrix_BindLua(mat)); return 1; } @@ -716,7 +706,7 @@ namespace wi::lua } else Up = XMVectorSet(0, 1, 0, 0); - Luna::push(L, new Matrix_BindLua(XMMatrixLookToLH(XMLoadFloat4(&pos->data), XMLoadFloat4(&dir->data), Up))); + Luna::push(L, Matrix_BindLua(XMMatrixLookToLH(XMLoadFloat4(&pos->data), XMLoadFloat4(&dir->data), Up))); } else wi::lua::SError(L, "LookTo(Vector eye, Vector direction, opt Vector up) argument is not a Vector!"); @@ -743,7 +733,7 @@ namespace wi::lua } else Up = XMVectorSet(0, 1, 0, 0); - Luna::push(L, new Matrix_BindLua(XMMatrixLookAtLH(XMLoadFloat4(&pos->data), XMLoadFloat4(&dir->data), Up))); + Luna::push(L, Matrix_BindLua(XMMatrixLookAtLH(XMLoadFloat4(&pos->data), XMLoadFloat4(&dir->data), Up))); } else wi::lua::SError(L, "LookAt(Vector eye, Vector focusPos, opt Vector up) argument is not a Vector!"); @@ -762,7 +752,7 @@ namespace wi::lua Matrix_BindLua* m2 = Luna::lightcheck(L, 2); if (m1 && m2) { - Luna::push(L, new Matrix_BindLua(XMMatrixMultiply(XMLoadFloat4x4(&m1->data), XMLoadFloat4x4(&m2->data)))); + Luna::push(L, Matrix_BindLua(XMMatrixMultiply(XMLoadFloat4x4(&m1->data), XMLoadFloat4x4(&m2->data)))); return 1; } } @@ -778,7 +768,7 @@ namespace wi::lua Matrix_BindLua* m2 = Luna::lightcheck(L, 2); if (m1 && m2) { - Luna::push(L, new Matrix_BindLua(XMLoadFloat4x4(&m1->data) + XMLoadFloat4x4(&m2->data))); + Luna::push(L, Matrix_BindLua(XMLoadFloat4x4(&m1->data) + XMLoadFloat4x4(&m2->data))); return 1; } } @@ -793,7 +783,7 @@ namespace wi::lua Matrix_BindLua* m1 = Luna::lightcheck(L, 1); if (m1) { - Luna::push(L, new Matrix_BindLua(XMMatrixTranspose(XMLoadFloat4x4(&m1->data)))); + Luna::push(L, Matrix_BindLua(XMMatrixTranspose(XMLoadFloat4x4(&m1->data)))); return 1; } } @@ -809,7 +799,7 @@ namespace wi::lua if (m1) { XMVECTOR det; - Luna::push(L, new Matrix_BindLua(XMMatrixInverse(&det, XMLoadFloat4x4(&m1->data)))); + Luna::push(L, Matrix_BindLua(XMMatrixInverse(&det, XMLoadFloat4x4(&m1->data)))); wi::lua::SSetFloat(L, XMVectorGetX(det)); return 2; } @@ -836,7 +826,7 @@ namespace wi::lua { if(data_f4x4) { - Luna::push(L, new Matrix_BindLua(*data_f4x4)); + Luna::push(L, Matrix_BindLua(*data_f4x4)); } return 1; } diff --git a/WickedEngine/wiPrimitive_BindLua.cpp b/WickedEngine/wiPrimitive_BindLua.cpp index bb9edbd48..20308ea6c 100644 --- a/WickedEngine/wiPrimitive_BindLua.cpp +++ b/WickedEngine/wiPrimitive_BindLua.cpp @@ -105,7 +105,7 @@ namespace wi::lua::primitive } int Ray_BindLua::GetOrigin(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&ray.origin))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&ray.origin))); return 1; } int Ray_BindLua::SetOrigin(lua_State *L) @@ -131,7 +131,7 @@ namespace wi::lua::primitive } int Ray_BindLua::GetDirection(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&ray.direction))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&ray.direction))); return 1; } int Ray_BindLua::SetDirection(lua_State *L) @@ -267,7 +267,7 @@ namespace wi::lua::primitive int AABB_BindLua::GetMin(lua_State* L) { XMFLOAT3 M = aabb.getMin(); - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&M))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&M))); return 1; } int AABB_BindLua::SetMin(lua_State *L) @@ -294,7 +294,7 @@ namespace wi::lua::primitive int AABB_BindLua::GetMax(lua_State* L) { XMFLOAT3 M = aabb.getMax(); - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&M))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&M))); return 1; } int AABB_BindLua::SetMax(lua_State *L) @@ -321,13 +321,13 @@ namespace wi::lua::primitive int AABB_BindLua::GetCenter(lua_State* L) { XMFLOAT3 C = aabb.getCenter(); - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&C))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&C))); return 1; } int AABB_BindLua::GetHalfExtents(lua_State* L) { XMFLOAT3 H = aabb.getHalfWidth(); - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&H))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&H))); return 1; } int AABB_BindLua::Transform(lua_State* L) @@ -338,7 +338,7 @@ namespace wi::lua::primitive Matrix_BindLua* _matrix = Luna::lightcheck(L, 1); if (_matrix) { - Luna::push(L, new AABB_BindLua(aabb.transform(_matrix->data))); + Luna::push(L, AABB_BindLua(aabb.transform(_matrix->data))); return 1; } else @@ -351,7 +351,7 @@ namespace wi::lua::primitive } int AABB_BindLua::GetAsBoxMatrix(lua_State* L) { - Luna::push(L, new Matrix_BindLua(aabb.getAsBoxMatrix())); + Luna::push(L, Matrix_BindLua(aabb.getAsBoxMatrix())); return 1; } @@ -434,7 +434,7 @@ namespace wi::lua::primitive } int Sphere_BindLua::GetCenter(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&sphere.center))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&sphere.center))); return 1; } int Sphere_BindLua::GetRadius(lua_State* L) @@ -541,8 +541,8 @@ namespace wi::lua::primitive float depth = 0; bool intersects = capsule.intersects(_capsule->capsule, position, normal, depth); wi::lua::SSetBool(L, intersects); - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&position))); - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&normal))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&position))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&normal))); wi::lua::SSetFloat(L, depth); return 4; } @@ -559,17 +559,17 @@ namespace wi::lua::primitive } int Capsule_BindLua::GetAABB(lua_State* L) { - Luna::push(L, new AABB_BindLua(capsule.getAABB())); + Luna::push(L, AABB_BindLua(capsule.getAABB())); return 1; } int Capsule_BindLua::GetBase(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&capsule.base))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&capsule.base))); return 1; } int Capsule_BindLua::GetTip(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&capsule.tip))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&capsule.tip))); return 1; } int Capsule_BindLua::GetRadius(lua_State* L) diff --git a/WickedEngine/wiScene_BindLua.cpp b/WickedEngine/wiScene_BindLua.cpp index 36611ce91..210beba7e 100644 --- a/WickedEngine/wiScene_BindLua.cpp +++ b/WickedEngine/wiScene_BindLua.cpp @@ -46,12 +46,12 @@ int CreateEntity_BindLua(lua_State* L) int GetCamera(lua_State* L) { - Luna::push(L, new CameraComponent_BindLua(GetGlobalCamera())); + Luna::push(L, CameraComponent_BindLua(GetGlobalCamera())); return 1; } int GetScene(lua_State* L) { - Luna::push(L, new Scene_BindLua(GetGlobalScene())); + Luna::push(L, Scene_BindLua(GetGlobalScene())); return 1; } int LoadModel(lua_State* L) @@ -160,8 +160,8 @@ int Pick(lua_State* L) } auto pick = wi::scene::Pick(ray->ray, filterMask, layerMask, *scene, lod); wi::lua::SSetLongLong(L, pick.entity); - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&pick.position))); - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&pick.normal))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&pick.position))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&pick.normal))); wi::lua::SSetFloat(L, pick.distance); return 4; } @@ -216,8 +216,8 @@ int SceneIntersectSphere(lua_State* L) } auto pick = wi::scene::SceneIntersectSphere(sphere->sphere, filterMask, layerMask, *scene, lod); wi::lua::SSetLongLong(L, pick.entity); - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&pick.position))); - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&pick.normal))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&pick.position))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&pick.normal))); wi::lua::SSetFloat(L, pick.depth); return 4; } @@ -272,8 +272,8 @@ int SceneIntersectCapsule(lua_State* L) } auto pick = wi::scene::SceneIntersectCapsule(capsule->capsule, filterMask, layerMask, *scene, lod); wi::lua::SSetLongLong(L, pick.entity); - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&pick.position))); - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&pick.normal))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&pick.position))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&pick.normal))); wi::lua::SSetFloat(L, pick.depth); return 4; } @@ -759,10 +759,10 @@ int Scene_BindLua::Intersects(lua_State* L) { auto result = scene->Intersects(ray->ray, filterMask, layerMask, lod); wi::lua::SSetInt(L, (int)result.entity); - Luna::push(L, new Vector_BindLua(result.position)); - Luna::push(L, new Vector_BindLua(result.normal)); + Luna::push(L, Vector_BindLua(result.position)); + Luna::push(L, Vector_BindLua(result.normal)); wi::lua::SSetFloat(L, result.distance); - Luna::push(L, new Vector_BindLua(result.velocity)); + Luna::push(L, Vector_BindLua(result.velocity)); return 5; } @@ -771,10 +771,10 @@ int Scene_BindLua::Intersects(lua_State* L) { auto result = scene->Intersects(sphere->sphere, filterMask, layerMask, lod); wi::lua::SSetInt(L, (int)result.entity); - Luna::push(L, new Vector_BindLua(result.position)); - Luna::push(L, new Vector_BindLua(result.normal)); + Luna::push(L, Vector_BindLua(result.position)); + Luna::push(L, Vector_BindLua(result.normal)); wi::lua::SSetFloat(L, result.depth); - Luna::push(L, new Vector_BindLua(result.velocity)); + Luna::push(L, Vector_BindLua(result.velocity)); return 5; } @@ -783,10 +783,10 @@ int Scene_BindLua::Intersects(lua_State* L) { auto result = scene->Intersects(capsule->capsule, filterMask, layerMask, lod); wi::lua::SSetInt(L, (int)result.entity); - Luna::push(L, new Vector_BindLua(result.position)); - Luna::push(L, new Vector_BindLua(result.normal)); + Luna::push(L, Vector_BindLua(result.position)); + Luna::push(L, Vector_BindLua(result.normal)); wi::lua::SSetFloat(L, result.depth); - Luna::push(L, new Vector_BindLua(result.velocity)); + Luna::push(L, Vector_BindLua(result.velocity)); return 5; } @@ -807,7 +807,7 @@ int Scene_BindLua::Component_CreateName(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); NameComponent& component = scene->names.Create(entity); - Luna::push(L, new NameComponent_BindLua(&component)); + Luna::push(L, NameComponent_BindLua(&component)); return 1; } else @@ -824,7 +824,7 @@ int Scene_BindLua::Component_CreateLayer(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); LayerComponent& component = scene->layers.Create(entity); - Luna::push(L, new LayerComponent_BindLua(&component)); + Luna::push(L, LayerComponent_BindLua(&component)); return 1; } else @@ -841,7 +841,7 @@ int Scene_BindLua::Component_CreateTransform(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); TransformComponent& component = scene->transforms.Create(entity); - Luna::push(L, new TransformComponent_BindLua(&component)); + Luna::push(L, TransformComponent_BindLua(&component)); return 1; } else @@ -858,7 +858,7 @@ int Scene_BindLua::Component_CreateLight(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); LightComponent& component = scene->lights.Create(entity); - Luna::push(L, new LightComponent_BindLua(&component)); + Luna::push(L, LightComponent_BindLua(&component)); return 1; } else @@ -875,7 +875,7 @@ int Scene_BindLua::Component_CreateEmitter(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); EmittedParticleSystem& component = scene->emitters.Create(entity); - Luna::push(L, new EmitterComponent_BindLua(&component)); + Luna::push(L, EmitterComponent_BindLua(&component)); return 1; } else @@ -892,7 +892,7 @@ int Scene_BindLua::Component_CreateHairParticleSystem(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); HairParticleSystem& component = scene->hairs.Create(entity); - Luna::push(L, new HairParticleSystem_BindLua(&component)); + Luna::push(L, HairParticleSystem_BindLua(&component)); return 1; } else @@ -909,7 +909,7 @@ int Scene_BindLua::Component_CreateObject(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); ObjectComponent& component = scene->objects.Create(entity); - Luna::push(L, new ObjectComponent_BindLua(&component)); + Luna::push(L, ObjectComponent_BindLua(&component)); return 1; } else @@ -926,7 +926,7 @@ int Scene_BindLua::Component_CreateMaterial(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); MaterialComponent& component = scene->materials.Create(entity); - Luna::push(L, new MaterialComponent_BindLua(&component)); + Luna::push(L, MaterialComponent_BindLua(&component)); return 1; } else @@ -943,7 +943,7 @@ int Scene_BindLua::Component_CreateInverseKinematics(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); InverseKinematicsComponent& component = scene->inverse_kinematics.Create(entity); - Luna::push(L, new InverseKinematicsComponent_BindLua(&component)); + Luna::push(L, InverseKinematicsComponent_BindLua(&component)); return 1; } else @@ -960,7 +960,7 @@ int Scene_BindLua::Component_CreateSpring(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); SpringComponent& component = scene->springs.Create(entity); - Luna::push(L, new SpringComponent_BindLua(&component)); + Luna::push(L, SpringComponent_BindLua(&component)); return 1; } else @@ -977,7 +977,7 @@ int Scene_BindLua::Component_CreateScript(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); ScriptComponent& component = scene->scripts.Create(entity); - Luna::push(L, new ScriptComponent_BindLua(&component)); + Luna::push(L, ScriptComponent_BindLua(&component)); return 1; } else @@ -994,7 +994,7 @@ int Scene_BindLua::Component_CreateRigidBodyPhysics(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); RigidBodyPhysicsComponent& component = scene->rigidbodies.Create(entity); - Luna::push(L, new RigidBodyPhysicsComponent_BindLua(&component)); + Luna::push(L, RigidBodyPhysicsComponent_BindLua(&component)); return 1; } else @@ -1011,7 +1011,7 @@ int Scene_BindLua::Component_CreateSoftBodyPhysics(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); SoftBodyPhysicsComponent& component = scene->softbodies.Create(entity); - Luna::push(L, new SoftBodyPhysicsComponent_BindLua(&component)); + Luna::push(L, SoftBodyPhysicsComponent_BindLua(&component)); return 1; } else @@ -1028,7 +1028,7 @@ int Scene_BindLua::Component_CreateForceField(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); ForceFieldComponent& component = scene->forces.Create(entity); - Luna::push(L, new ForceFieldComponent_BindLua(&component)); + Luna::push(L, ForceFieldComponent_BindLua(&component)); return 1; } else @@ -1045,7 +1045,7 @@ int Scene_BindLua::Component_CreateWeather(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); WeatherComponent& component = scene->weathers.Create(entity); - Luna::push(L, new WeatherComponent_BindLua(&component)); + Luna::push(L, WeatherComponent_BindLua(&component)); return 1; } else @@ -1062,7 +1062,7 @@ int Scene_BindLua::Component_CreateSound(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); SoundComponent& component = scene->sounds.Create(entity); - Luna::push(L, new SoundComponent_BindLua(&component)); + Luna::push(L, SoundComponent_BindLua(&component)); return 1; } else @@ -1079,7 +1079,7 @@ int Scene_BindLua::Component_CreateCollider(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); ColliderComponent& component = scene->colliders.Create(entity); - Luna::push(L, new ColliderComponent_BindLua(&component)); + Luna::push(L, ColliderComponent_BindLua(&component)); return 1; } else @@ -1096,7 +1096,7 @@ int Scene_BindLua::Component_CreateExpression(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); ExpressionComponent& component = scene->expressions.Create(entity); - Luna::push(L, new ExpressionComponent_BindLua(&component)); + Luna::push(L, ExpressionComponent_BindLua(&component)); return 1; } else @@ -1113,7 +1113,7 @@ int Scene_BindLua::Component_CreateHumanoid(lua_State* L) Entity entity = (Entity)wi::lua::SGetLongLong(L, 1); HumanoidComponent& component = scene->humanoids.Create(entity); - Luna::push(L, new HumanoidComponent_BindLua(&component)); + Luna::push(L, HumanoidComponent_BindLua(&component)); return 1; } else @@ -1136,7 +1136,7 @@ int Scene_BindLua::Component_GetName(lua_State* L) return 0; } - Luna::push(L, new NameComponent_BindLua(component)); + Luna::push(L, NameComponent_BindLua(component)); return 1; } else @@ -1158,7 +1158,7 @@ int Scene_BindLua::Component_GetLayer(lua_State* L) return 0; } - Luna::push(L, new LayerComponent_BindLua(component)); + Luna::push(L, LayerComponent_BindLua(component)); return 1; } else @@ -1180,7 +1180,7 @@ int Scene_BindLua::Component_GetTransform(lua_State* L) return 0; } - Luna::push(L, new TransformComponent_BindLua(component)); + Luna::push(L, TransformComponent_BindLua(component)); return 1; } else @@ -1202,7 +1202,7 @@ int Scene_BindLua::Component_GetCamera(lua_State* L) return 0; } - Luna::push(L, new CameraComponent_BindLua(component)); + Luna::push(L, CameraComponent_BindLua(component)); return 1; } else @@ -1224,7 +1224,7 @@ int Scene_BindLua::Component_GetAnimation(lua_State* L) return 0; } - Luna::push(L, new AnimationComponent_BindLua(component)); + Luna::push(L, AnimationComponent_BindLua(component)); return 1; } else @@ -1246,7 +1246,7 @@ int Scene_BindLua::Component_GetMaterial(lua_State* L) return 0; } - Luna::push(L, new MaterialComponent_BindLua(component)); + Luna::push(L, MaterialComponent_BindLua(component)); return 1; } else @@ -1268,7 +1268,7 @@ int Scene_BindLua::Component_GetMesh(lua_State* L) return 0; } - Luna::push(L, new MeshComponent_BindLua(component)); + Luna::push(L, MeshComponent_BindLua(component)); return 1; } else @@ -1290,7 +1290,7 @@ int Scene_BindLua::Component_GetEmitter(lua_State* L) return 0; } - Luna::push(L, new EmitterComponent_BindLua(component)); + Luna::push(L, EmitterComponent_BindLua(component)); return 1; } else @@ -1312,7 +1312,7 @@ int Scene_BindLua::Component_GetHairParticleSystem(lua_State* L) return 0; } - Luna::push(L, new HairParticleSystem_BindLua(component)); + Luna::push(L, HairParticleSystem_BindLua(component)); return 1; } else @@ -1334,7 +1334,7 @@ int Scene_BindLua::Component_GetLight(lua_State* L) return 0; } - Luna::push(L, new LightComponent_BindLua(component)); + Luna::push(L, LightComponent_BindLua(component)); return 1; } else @@ -1356,7 +1356,7 @@ int Scene_BindLua::Component_GetObject(lua_State* L) return 0; } - Luna::push(L, new ObjectComponent_BindLua(component)); + Luna::push(L, ObjectComponent_BindLua(component)); return 1; } else @@ -1378,7 +1378,7 @@ int Scene_BindLua::Component_GetInverseKinematics(lua_State* L) return 0; } - Luna::push(L, new InverseKinematicsComponent_BindLua(component)); + Luna::push(L, InverseKinematicsComponent_BindLua(component)); return 1; } else @@ -1400,7 +1400,7 @@ int Scene_BindLua::Component_GetSpring(lua_State* L) return 0; } - Luna::push(L, new SpringComponent_BindLua(component)); + Luna::push(L, SpringComponent_BindLua(component)); return 1; } else @@ -1422,7 +1422,7 @@ int Scene_BindLua::Component_GetScript(lua_State* L) return 0; } - Luna::push(L, new ScriptComponent_BindLua(component)); + Luna::push(L, ScriptComponent_BindLua(component)); return 1; } else @@ -1444,7 +1444,7 @@ int Scene_BindLua::Component_GetRigidBodyPhysics(lua_State* L) return 0; } - Luna::push(L, new RigidBodyPhysicsComponent_BindLua(component)); + Luna::push(L, RigidBodyPhysicsComponent_BindLua(component)); return 1; } else @@ -1466,7 +1466,7 @@ int Scene_BindLua::Component_GetSoftBodyPhysics(lua_State* L) return 0; } - Luna::push(L, new SoftBodyPhysicsComponent_BindLua(component)); + Luna::push(L, SoftBodyPhysicsComponent_BindLua(component)); return 1; } else @@ -1488,7 +1488,7 @@ int Scene_BindLua::Component_GetForceField(lua_State* L) return 0; } - Luna::push(L, new ForceFieldComponent_BindLua(component)); + Luna::push(L, ForceFieldComponent_BindLua(component)); return 1; } else @@ -1510,7 +1510,7 @@ int Scene_BindLua::Component_GetWeather(lua_State* L) return 0; } - Luna::push(L, new WeatherComponent_BindLua(component)); + Luna::push(L, WeatherComponent_BindLua(component)); return 1; } else @@ -1532,7 +1532,7 @@ int Scene_BindLua::Component_GetSound(lua_State* L) return 0; } - Luna::push(L, new SoundComponent_BindLua(component)); + Luna::push(L, SoundComponent_BindLua(component)); return 1; } else @@ -1554,7 +1554,7 @@ int Scene_BindLua::Component_GetCollider(lua_State* L) return 0; } - Luna::push(L, new ColliderComponent_BindLua(component)); + Luna::push(L, ColliderComponent_BindLua(component)); return 1; } else @@ -1576,7 +1576,7 @@ int Scene_BindLua::Component_GetExpression(lua_State* L) return 0; } - Luna::push(L, new ExpressionComponent_BindLua(component)); + Luna::push(L, ExpressionComponent_BindLua(component)); return 1; } else @@ -1598,7 +1598,7 @@ int Scene_BindLua::Component_GetHumanoid(lua_State* L) return 0; } - Luna::push(L, new HumanoidComponent_BindLua(component)); + Luna::push(L, HumanoidComponent_BindLua(component)); return 1; } else @@ -1614,7 +1614,7 @@ int Scene_BindLua::Component_GetNameArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->names.GetCount(); ++i) { - Luna::push(L, new NameComponent_BindLua(&scene->names[i])); + Luna::push(L, NameComponent_BindLua(&scene->names[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1625,7 +1625,7 @@ int Scene_BindLua::Component_GetLayerArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->layers.GetCount(); ++i) { - Luna::push(L, new LayerComponent_BindLua(&scene->layers[i])); + Luna::push(L, LayerComponent_BindLua(&scene->layers[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1636,7 +1636,7 @@ int Scene_BindLua::Component_GetTransformArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->transforms.GetCount(); ++i) { - Luna::push(L, new TransformComponent_BindLua(&scene->transforms[i])); + Luna::push(L, TransformComponent_BindLua(&scene->transforms[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1647,7 +1647,7 @@ int Scene_BindLua::Component_GetCameraArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->cameras.GetCount(); ++i) { - Luna::push(L, new CameraComponent_BindLua(&scene->cameras[i])); + Luna::push(L, CameraComponent_BindLua(&scene->cameras[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1658,7 +1658,7 @@ int Scene_BindLua::Component_GetAnimationArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->animations.GetCount(); ++i) { - Luna::push(L, new AnimationComponent_BindLua(&scene->animations[i])); + Luna::push(L, AnimationComponent_BindLua(&scene->animations[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1669,7 +1669,7 @@ int Scene_BindLua::Component_GetMaterialArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->materials.GetCount(); ++i) { - Luna::push(L, new MaterialComponent_BindLua(&scene->materials[i])); + Luna::push(L, MaterialComponent_BindLua(&scene->materials[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1680,7 +1680,7 @@ int Scene_BindLua::Component_GetMeshArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->meshes.GetCount(); ++i) { - Luna::push(L, new MeshComponent_BindLua(&scene->meshes[i])); + Luna::push(L, MeshComponent_BindLua(&scene->meshes[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1691,7 +1691,7 @@ int Scene_BindLua::Component_GetEmitterArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->emitters.GetCount(); ++i) { - Luna::push(L, new EmitterComponent_BindLua(&scene->emitters[i])); + Luna::push(L, EmitterComponent_BindLua(&scene->emitters[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1702,7 +1702,7 @@ int Scene_BindLua::Component_GetHairParticleSystemArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->hairs.GetCount(); ++i) { - Luna::push(L, new HairParticleSystem_BindLua(&scene->hairs[i])); + Luna::push(L, HairParticleSystem_BindLua(&scene->hairs[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1713,7 +1713,7 @@ int Scene_BindLua::Component_GetLightArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->lights.GetCount(); ++i) { - Luna::push(L, new LightComponent_BindLua(&scene->lights[i])); + Luna::push(L, LightComponent_BindLua(&scene->lights[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1724,7 +1724,7 @@ int Scene_BindLua::Component_GetObjectArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->objects.GetCount(); ++i) { - Luna::push(L, new ObjectComponent_BindLua(&scene->objects[i])); + Luna::push(L, ObjectComponent_BindLua(&scene->objects[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1735,7 +1735,7 @@ int Scene_BindLua::Component_GetInverseKinematicsArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->inverse_kinematics.GetCount(); ++i) { - Luna::push(L, new InverseKinematicsComponent_BindLua(&scene->inverse_kinematics[i])); + Luna::push(L, InverseKinematicsComponent_BindLua(&scene->inverse_kinematics[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1746,7 +1746,7 @@ int Scene_BindLua::Component_GetSpringArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->springs.GetCount(); ++i) { - Luna::push(L, new SpringComponent_BindLua(&scene->springs[i])); + Luna::push(L, SpringComponent_BindLua(&scene->springs[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1757,7 +1757,7 @@ int Scene_BindLua::Component_GetScriptArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->scripts.GetCount(); ++i) { - Luna::push(L, new ScriptComponent_BindLua(&scene->scripts[i])); + Luna::push(L, ScriptComponent_BindLua(&scene->scripts[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1768,7 +1768,7 @@ int Scene_BindLua::Component_GetRigidBodyPhysicsArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->rigidbodies.GetCount(); ++i) { - Luna::push(L, new RigidBodyPhysicsComponent_BindLua(&scene->rigidbodies[i])); + Luna::push(L, RigidBodyPhysicsComponent_BindLua(&scene->rigidbodies[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1779,7 +1779,7 @@ int Scene_BindLua::Component_GetSoftBodyPhysicsArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->softbodies.GetCount(); ++i) { - Luna::push(L, new SoftBodyPhysicsComponent_BindLua(&scene->softbodies[i])); + Luna::push(L, SoftBodyPhysicsComponent_BindLua(&scene->softbodies[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1790,7 +1790,7 @@ int Scene_BindLua::Component_GetForceFieldArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->forces.GetCount(); ++i) { - Luna::push(L, new ForceFieldComponent_BindLua(&scene->forces[i])); + Luna::push(L, ForceFieldComponent_BindLua(&scene->forces[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1801,7 +1801,7 @@ int Scene_BindLua::Component_GetWeatherArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->weathers.GetCount(); ++i) { - Luna::push(L, new WeatherComponent_BindLua(&scene->weathers[i])); + Luna::push(L, WeatherComponent_BindLua(&scene->weathers[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1812,7 +1812,7 @@ int Scene_BindLua::Component_GetSoundArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->sounds.GetCount(); ++i) { - Luna::push(L, new SoundComponent_BindLua(&scene->sounds[i])); + Luna::push(L, SoundComponent_BindLua(&scene->sounds[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1823,7 +1823,7 @@ int Scene_BindLua::Component_GetColliderArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->colliders.GetCount(); ++i) { - Luna::push(L, new ColliderComponent_BindLua(&scene->colliders[i])); + Luna::push(L, ColliderComponent_BindLua(&scene->colliders[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1834,7 +1834,7 @@ int Scene_BindLua::Component_GetExpressionArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->expressions.GetCount(); ++i) { - Luna::push(L, new ExpressionComponent_BindLua(&scene->expressions[i])); + Luna::push(L, ExpressionComponent_BindLua(&scene->expressions[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -1845,7 +1845,7 @@ int Scene_BindLua::Component_GetHumanoidArray(lua_State* L) int newTable = lua_gettop(L); for (size_t i = 0; i < scene->humanoids.GetCount(); ++i) { - Luna::push(L, new HumanoidComponent_BindLua(&scene->humanoids[i])); + Luna::push(L, HumanoidComponent_BindLua(&scene->humanoids[i])); lua_rawseti(L, newTable, lua_Integer(i + 1)); } return 1; @@ -2551,13 +2551,13 @@ int Scene_BindLua::Component_DetachChildren(lua_State* L) int Scene_BindLua::GetBounds(lua_State* L) { - Luna::push(L, new AABB_BindLua(scene->bounds)); + Luna::push(L, AABB_BindLua(scene->bounds)); return 1; } int Scene_BindLua::GetWeather(lua_State* L) { - Luna::push(L, new WeatherComponent_BindLua(&scene->weather)); + Luna::push(L, WeatherComponent_BindLua(&scene->weather)); return 1; } int Scene_BindLua::SetWeather(lua_State* L) @@ -2905,7 +2905,7 @@ int TransformComponent_BindLua::MatrixTransform(lua_State* L) int TransformComponent_BindLua::GetMatrix(lua_State* L) { XMMATRIX M = XMLoadFloat4x4(&component->world); - Luna::push(L, new Matrix_BindLua(M)); + Luna::push(L, Matrix_BindLua(M)); return 1; } int TransformComponent_BindLua::ClearTransform(lua_State* L) @@ -2921,19 +2921,19 @@ int TransformComponent_BindLua::UpdateTransform(lua_State* L) int TransformComponent_BindLua::GetPosition(lua_State* L) { XMVECTOR V = component->GetPositionV(); - Luna::push(L, new Vector_BindLua(V)); + Luna::push(L, Vector_BindLua(V)); return 1; } int TransformComponent_BindLua::GetRotation(lua_State* L) { XMVECTOR V = component->GetRotationV(); - Luna::push(L, new Vector_BindLua(V)); + Luna::push(L, Vector_BindLua(V)); return 1; } int TransformComponent_BindLua::GetScale(lua_State* L) { XMVECTOR V = component->GetScaleV(); - Luna::push(L, new Vector_BindLua(V)); + Luna::push(L, Vector_BindLua(V)); return 1; } int TransformComponent_BindLua::IsDirty(lua_State *L) @@ -3123,7 +3123,7 @@ int CameraComponent_BindLua::SetApertureSize(lua_State* L) } int CameraComponent_BindLua::GetApertureShape(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat2(&component->aperture_shape))); + Luna::push(L, Vector_BindLua(XMLoadFloat2(&component->aperture_shape))); return 1; } int CameraComponent_BindLua::SetApertureShape(lua_State* L) @@ -3145,47 +3145,47 @@ int CameraComponent_BindLua::SetApertureShape(lua_State* L) } int CameraComponent_BindLua::GetView(lua_State* L) { - Luna::push(L, new Matrix_BindLua(component->GetView())); + Luna::push(L, Matrix_BindLua(component->GetView())); return 1; } int CameraComponent_BindLua::GetProjection(lua_State* L) { - Luna::push(L, new Matrix_BindLua(component->GetProjection())); + Luna::push(L, Matrix_BindLua(component->GetProjection())); return 1; } int CameraComponent_BindLua::GetViewProjection(lua_State* L) { - Luna::push(L, new Matrix_BindLua(component->GetViewProjection())); + Luna::push(L, Matrix_BindLua(component->GetViewProjection())); return 1; } int CameraComponent_BindLua::GetInvView(lua_State* L) { - Luna::push(L, new Matrix_BindLua(component->GetInvView())); + Luna::push(L, Matrix_BindLua(component->GetInvView())); return 1; } int CameraComponent_BindLua::GetInvProjection(lua_State* L) { - Luna::push(L, new Matrix_BindLua(component->GetInvProjection())); + Luna::push(L, Matrix_BindLua(component->GetInvProjection())); return 1; } int CameraComponent_BindLua::GetInvViewProjection(lua_State* L) { - Luna::push(L, new Matrix_BindLua(component->GetInvViewProjection())); + Luna::push(L, Matrix_BindLua(component->GetInvViewProjection())); return 1; } int CameraComponent_BindLua::GetPosition(lua_State* L) { - Luna::push(L, new Vector_BindLua(component->GetEye())); + Luna::push(L, Vector_BindLua(component->GetEye())); return 1; } int CameraComponent_BindLua::GetLookDirection(lua_State* L) { - Luna::push(L, new Vector_BindLua(component->GetAt())); + Luna::push(L, Vector_BindLua(component->GetAt())); return 1; } int CameraComponent_BindLua::GetUpDirection(lua_State* L) { - Luna::push(L, new Vector_BindLua(component->GetUp())); + Luna::push(L, Vector_BindLua(component->GetUp())); return 1; } int CameraComponent_BindLua::SetPosition(lua_State* L) @@ -3462,7 +3462,7 @@ Luna::PropertyType MaterialComponent_BindLua::propert int MaterialComponent_BindLua::GetBaseColor(lua_State* L) { - Luna::push(L, new Vector_BindLua(component->baseColor)); + Luna::push(L, Vector_BindLua(component->baseColor)); return 1; } int MaterialComponent_BindLua::SetBaseColor(lua_State* L) @@ -3491,7 +3491,7 @@ int MaterialComponent_BindLua::SetBaseColor(lua_State* L) } int MaterialComponent_BindLua::GetEmissiveColor(lua_State* L) { - Luna::push(L, new Vector_BindLua(component->emissiveColor)); + Luna::push(L, Vector_BindLua(component->emissiveColor)); return 1; } int MaterialComponent_BindLua::SetEmissiveColor(lua_State* L) @@ -4150,7 +4150,7 @@ int LightComponent_BindLua::SetIntensity(lua_State* L) } int LightComponent_BindLua::GetColor(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&component->color))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&component->color))); return 1; } int LightComponent_BindLua::SetColor(lua_State* L) @@ -4325,12 +4325,12 @@ int ObjectComponent_BindLua::GetRendertypeMask(lua_State *L){ } int ObjectComponent_BindLua::GetColor(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat4(&component->color))); + Luna::push(L, Vector_BindLua(XMLoadFloat4(&component->color))); return 1; } int ObjectComponent_BindLua::GetEmissiveColor(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat4(&component->emissiveColor))); + Luna::push(L, Vector_BindLua(XMLoadFloat4(&component->emissiveColor))); return 1; } int ObjectComponent_BindLua::GetUserStencilRef(lua_State* L) @@ -4880,7 +4880,7 @@ Luna::PropertyType Weather_OceanParams_BindLua::pro int Weather_OceanParams_Property::Get(lua_State *L) { - Luna::push(L, new Weather_OceanParams_BindLua(data)); + Luna::push(L, Weather_OceanParams_BindLua(data)); return 1; } int Weather_OceanParams_Property::Set(lua_State *L) @@ -4929,7 +4929,7 @@ Luna::PropertyType Weather_AtmosphereParams_Bi int Weather_AtmosphereParams_Property::Get(lua_State *L) { - Luna::push(L, new Weather_AtmosphereParams_BindLua(data)); + Luna::push(L, Weather_AtmosphereParams_BindLua(data)); return 1; } int Weather_AtmosphereParams_Property::Set(lua_State *L) @@ -5021,7 +5021,7 @@ Luna::PropertyType Weather_VolumetricClou int Weather_VolumetricCloudParams_Property::Get(lua_State *L) { - Luna::push(L, new Weather_VolumetricCloudParams_BindLua(data)); + Luna::push(L, Weather_VolumetricCloudParams_BindLua(data)); return 1; } int Weather_VolumetricCloudParams_Property::Set(lua_State *L) @@ -5363,7 +5363,7 @@ int ColliderComponent_BindLua::GetCapsule(lua_State* L) wi::lua::SError(L, "GetCapsule() component is null!"); return 0; } - Luna::push(L, new Capsule_BindLua(component->capsule)); + Luna::push(L, Capsule_BindLua(component->capsule)); return 1; } int ColliderComponent_BindLua::GetSphere(lua_State* L) @@ -5373,7 +5373,7 @@ int ColliderComponent_BindLua::GetSphere(lua_State* L) wi::lua::SError(L, "GetCapsule() component is null!"); return 0; } - Luna::push(L, new Sphere_BindLua(component->sphere)); + Luna::push(L, Sphere_BindLua(component->sphere)); return 1; } diff --git a/WickedEngine/wiSpriteAnim_BindLua.cpp b/WickedEngine/wiSpriteAnim_BindLua.cpp index aaa232ea3..15e22b98c 100644 --- a/WickedEngine/wiSpriteAnim_BindLua.cpp +++ b/WickedEngine/wiSpriteAnim_BindLua.cpp @@ -227,7 +227,7 @@ namespace wi::lua } int SpriteAnim_BindLua::GetVelocity(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMLoadFloat3(&anim.vel))); + Luna::push(L, Vector_BindLua(XMLoadFloat3(&anim.vel))); return 1; } int SpriteAnim_BindLua::GetScaleX(lua_State* L) @@ -242,12 +242,12 @@ namespace wi::lua } int SpriteAnim_BindLua::GetMovingTexAnim(lua_State* L) { - Luna::push(L, new MovingTexAnim_BindLua(anim.movingTexAnim)); + Luna::push(L, MovingTexAnim_BindLua(anim.movingTexAnim)); return 1; } int SpriteAnim_BindLua::GetDrawRecAnim(lua_State* L) { - Luna::push(L, new DrawRectAnim_BindLua(anim.drawRectAnim)); + Luna::push(L, DrawRectAnim_BindLua(anim.drawRectAnim)); return 1; } diff --git a/WickedEngine/wiSpriteFont_BindLua.cpp b/WickedEngine/wiSpriteFont_BindLua.cpp index 82e4953a8..57fd00343 100644 --- a/WickedEngine/wiSpriteFont_BindLua.cpp +++ b/WickedEngine/wiSpriteFont_BindLua.cpp @@ -271,12 +271,12 @@ namespace wi::lua } int SpriteFont_BindLua::GetPos(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMVectorSet((float)font.params.posX, (float)font.params.posY, 0, 0))); + Luna::push(L, Vector_BindLua(XMVectorSet((float)font.params.posX, (float)font.params.posY, 0, 0))); return 1; } int SpriteFont_BindLua::GetSpacing(lua_State* L) { - Luna::push(L, new Vector_BindLua(XMVectorSet((float)font.params.spacingX, (float)font.params.spacingY, 0, 0))); + Luna::push(L, Vector_BindLua(XMVectorSet((float)font.params.spacingX, (float)font.params.spacingY, 0, 0))); return 1; } int SpriteFont_BindLua::GetAlign(lua_State* L) @@ -288,13 +288,13 @@ namespace wi::lua int SpriteFont_BindLua::GetColor(lua_State* L) { XMFLOAT4 C = font.params.color.toFloat4(); - Luna::push(L, new Vector_BindLua(XMLoadFloat4(&C))); + Luna::push(L, Vector_BindLua(XMLoadFloat4(&C))); return 1; } int SpriteFont_BindLua::GetShadowColor(lua_State* L) { XMFLOAT4 C = font.params.color.toFloat4(); - Luna::push(L, new Vector_BindLua(XMLoadFloat4(&C))); + Luna::push(L, Vector_BindLua(XMLoadFloat4(&C))); return 1; } int SpriteFont_BindLua::GetBolden(lua_State* L) @@ -320,7 +320,7 @@ namespace wi::lua int SpriteFont_BindLua::GetShadowOffset(lua_State* L) { XMFLOAT4 C = XMFLOAT4(font.params.shadow_offset_x, font.params.shadow_offset_y, 0, 0); - Luna::push(L, new Vector_BindLua(XMLoadFloat4(&C))); + Luna::push(L, Vector_BindLua(XMLoadFloat4(&C))); return 1; } diff --git a/WickedEngine/wiSprite_BindLua.cpp b/WickedEngine/wiSprite_BindLua.cpp index f41c52fb2..a72f7538a 100644 --- a/WickedEngine/wiSprite_BindLua.cpp +++ b/WickedEngine/wiSprite_BindLua.cpp @@ -59,7 +59,7 @@ namespace wi::lua } int Sprite_BindLua::GetParams(lua_State* L) { - Luna::push(L, new wi::lua::ImageParams_BindLua(sprite.params)); + Luna::push(L, wi::lua::ImageParams_BindLua(sprite.params)); return 1; } int Sprite_BindLua::SetAnim(lua_State* L) @@ -81,7 +81,7 @@ namespace wi::lua } int Sprite_BindLua::GetAnim(lua_State* L) { - Luna::push(L, new SpriteAnim_BindLua(sprite.anim)); + Luna::push(L, SpriteAnim_BindLua(sprite.anim)); return 1; } diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 943e601ce..811ffba82 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 147; + const int revision = 148; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);