fixes for address sanitizer issues

This commit is contained in:
Turánszki János
2022-09-14 16:06:57 +02:00
parent a585fa8eb3
commit 0932af95b8
23 changed files with 432 additions and 606 deletions
+11 -1
View File
@@ -25,8 +25,12 @@
#include <cstdlib>
#include <atomic>
//#define WICKED_ENGINE_HEAP_ALLOCATION_COUNTER
#ifdef WICKED_ENGINE_HEAP_ALLOCATION_COUNTER
static std::atomic<uint32_t> number_of_heap_allocations{ 0 };
static std::atomic<size_t> size_of_heap_allocations{ 0 };
#endif // WICKED_ENGINE_HEAP_ALLOCATION_COUNTER
using namespace wi::graphics;
@@ -113,7 +117,7 @@ namespace wi
graphicsDevice->SubmitCommandLists();
}
}
#endif
#endif // WICKEDENGINE_BUILD_DX12
static bool startup_script = false;
if (!startup_script)
@@ -391,12 +395,16 @@ namespace wi
if (infoDisplay.heap_allocation_counter)
{
infodisplay_str += "Heap allocations per frame: ";
#ifdef WICKED_ENGINE_HEAP_ALLOCATION_COUNTER
infodisplay_str += std::to_string(number_of_heap_allocations.load());
infodisplay_str += " (";
infodisplay_str += std::to_string(size_of_heap_allocations.load());
infodisplay_str += " bytes)\n";
number_of_heap_allocations.store(0);
size_of_heap_allocations.store(0);
#else
infodisplay_str += "[disabled]\n";
#endif // WICKED_ENGINE_HEAP_ALLOCATION_COUNTER
}
if (infoDisplay.pipeline_count)
{
@@ -592,6 +600,7 @@ namespace wi
}
#ifdef WICKED_ENGINE_HEAP_ALLOCATION_COUNTER
// Heap alloc replacements are used to count heap allocations:
// It is good practice to reduce the amount of heap allocations that happen during the frame,
// so keep an eye on the info display of the engine while Application::InfoDisplayer::heap_allocation_counter is enabled
@@ -624,3 +633,4 @@ void operator delete(void* ptr) throw() { free(ptr); }
void operator delete (void* ptr, const std::nothrow_t&) throw() { free(ptr); }
void operator delete[](void* ptr) throw() { free(ptr); }
void operator delete[](void* ptr, const std::nothrow_t&) throw() { free(ptr); }
#endif // WICKED_ENGINE_HEAP_ALLOCATION_COUNTER
+8 -8
View File
@@ -371,7 +371,7 @@ namespace wi::lua
Vector_BindLua* vec = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vec != nullptr)
{
XMStoreFloat3(&soundinstance3D.listenerPos, XMLoadFloat4(vec));
XMStoreFloat3(&soundinstance3D.listenerPos, XMLoadFloat4(&vec->data));
}
}
else
@@ -386,7 +386,7 @@ namespace wi::lua
Vector_BindLua* vec = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vec != nullptr)
{
XMStoreFloat3(&soundinstance3D.listenerUp, XMLoadFloat4(vec));
XMStoreFloat3(&soundinstance3D.listenerUp, XMLoadFloat4(&vec->data));
}
}
else
@@ -401,7 +401,7 @@ namespace wi::lua
Vector_BindLua* vec = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vec != nullptr)
{
XMStoreFloat3(&soundinstance3D.listenerFront, XMLoadFloat4(vec));
XMStoreFloat3(&soundinstance3D.listenerFront, XMLoadFloat4(&vec->data));
}
}
else
@@ -416,7 +416,7 @@ namespace wi::lua
Vector_BindLua* vec = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vec != nullptr)
{
XMStoreFloat3(&soundinstance3D.listenerVelocity, XMLoadFloat4(vec));
XMStoreFloat3(&soundinstance3D.listenerVelocity, XMLoadFloat4(&vec->data));
}
}
else
@@ -432,7 +432,7 @@ namespace wi::lua
Vector_BindLua* vec = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vec != nullptr)
{
XMStoreFloat3(&soundinstance3D.emitterPos, XMLoadFloat4(vec));
XMStoreFloat3(&soundinstance3D.emitterPos, XMLoadFloat4(&vec->data));
}
}
else
@@ -447,7 +447,7 @@ namespace wi::lua
Vector_BindLua* vec = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vec != nullptr)
{
XMStoreFloat3(&soundinstance3D.emitterUp, XMLoadFloat4(vec));
XMStoreFloat3(&soundinstance3D.emitterUp, XMLoadFloat4(&vec->data));
}
}
else
@@ -462,7 +462,7 @@ namespace wi::lua
Vector_BindLua* vec = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vec != nullptr)
{
XMStoreFloat3(&soundinstance3D.emitterFront, XMLoadFloat4(vec));
XMStoreFloat3(&soundinstance3D.emitterFront, XMLoadFloat4(&vec->data));
}
}
else
@@ -477,7 +477,7 @@ namespace wi::lua
Vector_BindLua* vec = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vec != nullptr)
{
XMStoreFloat3(&soundinstance3D.emitterVelocity, XMLoadFloat4(vec));
XMStoreFloat3(&soundinstance3D.emitterVelocity, XMLoadFloat4(&vec->data));
}
}
else
+2
View File
@@ -8,6 +8,8 @@ namespace wi
// The canvas specifies a DPI-aware drawing area
struct Canvas
{
virtual ~Canvas() = default;
uint32_t width = 0;
uint32_t height = 0;
float dpi = 96;
+2
View File
@@ -10,6 +10,8 @@ namespace wi::config
struct File;
struct Section
{
virtual ~Section() = default;
friend struct File;
// Check whether the key exists:
+1
View File
@@ -94,6 +94,7 @@ namespace wi::ecs
class ComponentManager_Interface
{
public:
virtual ~ComponentManager_Interface() = default;
virtual void Copy(const ComponentManager_Interface& other) = 0;
virtual void Merge(ComponentManager_Interface& other) = 0;
virtual void Clear() = 0;
+2
View File
@@ -683,6 +683,8 @@ namespace wi::graphics
{
std::shared_ptr<void> internal_state;
inline bool IsValid() const { return internal_state.get() != nullptr; }
virtual ~GraphicsDeviceChild() = default;
};
struct Sampler : public GraphicsDeviceChild
+8 -8
View File
@@ -156,7 +156,7 @@ namespace wi::lua
Vector_BindLua* vector = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vector != nullptr)
{
XMStoreFloat3(&params.pos, XMLoadFloat4(vector));
XMStoreFloat3(&params.pos, XMLoadFloat4(&vector->data));
}
}
else
@@ -173,7 +173,7 @@ namespace wi::lua
Vector_BindLua* vector = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vector != nullptr)
{
XMStoreFloat2(&params.siz, XMLoadFloat4(vector));
XMStoreFloat2(&params.siz, XMLoadFloat4(&vector->data));
}
}
else
@@ -190,7 +190,7 @@ namespace wi::lua
Vector_BindLua* vector = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vector != nullptr)
{
XMStoreFloat2(&params.pivot, XMLoadFloat4(vector));
XMStoreFloat2(&params.pivot, XMLoadFloat4(&vector->data));
}
}
else
@@ -207,7 +207,7 @@ namespace wi::lua
Vector_BindLua* param = Luna<Vector_BindLua>::lightcheck(L, 1);
if (param != nullptr)
{
XMStoreFloat4(&params.color, XMLoadFloat4(param));
XMStoreFloat4(&params.color, XMLoadFloat4(&param->data));
}
}
else
@@ -329,7 +329,7 @@ namespace wi::lua
Vector_BindLua* vector = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vector != nullptr)
{
XMStoreFloat2(&params.texOffset, XMLoadFloat4(vector));
XMStoreFloat2(&params.texOffset, XMLoadFloat4(&vector->data));
}
}
else
@@ -346,7 +346,7 @@ namespace wi::lua
Vector_BindLua* vector = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vector != nullptr)
{
XMStoreFloat2(&params.texOffset2, XMLoadFloat4(vector));
XMStoreFloat2(&params.texOffset2, XMLoadFloat4(&vector->data));
}
}
else
@@ -364,7 +364,7 @@ namespace wi::lua
if (vector != nullptr)
{
XMFLOAT4 drawrect;
XMStoreFloat4(&drawrect, XMLoadFloat4(vector));
XMStoreFloat4(&drawrect, XMLoadFloat4(&vector->data));
params.enableDrawRect(drawrect);
}
}
@@ -383,7 +383,7 @@ namespace wi::lua
if (vector != nullptr)
{
XMFLOAT4 drawrect2;
XMStoreFloat4(&drawrect2, XMLoadFloat4(vector));
XMStoreFloat4(&drawrect2, XMLoadFloat4(&vector->data));
params.enableDrawRect2(drawrect2);
}
}
+3 -3
View File
@@ -7,9 +7,9 @@
namespace wi::initializer
{
bool initializationStarted = false;
wi::jobsystem::context ctx;
wi::Timer timer;
static bool initializationStarted = false;
static wi::jobsystem::context ctx;
static wi::Timer timer;
static std::atomic_bool systems[INITIALIZED_SYSTEM_COUNT]{};
void InitializeComponentsImmediate()
+2 -2
View File
@@ -101,7 +101,7 @@ namespace wi::lua
Vector_BindLua* vec = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vec != nullptr)
{
wi::input::SetPointer(*vec);
wi::input::SetPointer(vec->data);
}
else
wi::lua::SError(L, "SetPointer(Vector props) argument is not a Vector!");
@@ -348,7 +348,7 @@ namespace wi::lua
Vector_BindLua* vec = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vec != nullptr)
{
feedback.led_color = wi::Color::fromFloat4(*vec);
feedback.led_color = wi::Color::fromFloat4(vec->data);
}
else
{
+2 -2
View File
@@ -145,6 +145,8 @@ namespace wi::lua
RegisterFunc("dofile", Internal_DoFile);
RunText(wiLua_Globals);
Vector_BindLua::Bind();
Matrix_BindLua::Bind();
Application_BindLua::Bind();
Canvas_BindLua::Bind();
RenderPath_BindLua::Bind();
@@ -158,8 +160,6 @@ namespace wi::lua
ImageParams_BindLua::Bind();
SpriteAnim_BindLua::Bind();
scene::Bind();
Vector_BindLua::Bind();
Matrix_BindLua::Bind();
Input_BindLua::Bind();
SpriteFont_BindLua::Bind();
backlog::Bind();
+7 -21
View File
@@ -124,17 +124,9 @@ namespace wi::lua
//push null to lua stack
void SSetNull(lua_State* L);
//get-setters template for custom types
class LuaProperty
{
public:
virtual int Get(lua_State*L) = 0;
virtual int Set(lua_State*L) = 0;
};
//get-setters for int type
class IntProperty final : public LuaProperty
struct IntProperty
{
public:
int *data = nullptr;
IntProperty(){}
IntProperty(int* data): data(data) {}
@@ -142,9 +134,8 @@ namespace wi::lua
int Set(lua_State* L);
};
//get-setters for long type
class LongProperty final : public LuaProperty
struct LongProperty
{
public:
long* data = nullptr;
LongProperty(){}
LongProperty(long* data): data(data) {}
@@ -152,9 +143,8 @@ namespace wi::lua
int Set(lua_State* L);
};
//get-setters for long long type
class LongLongProperty final : public LuaProperty
struct LongLongProperty
{
public:
long long* data = nullptr;
LongLongProperty(){}
LongLongProperty(long long* data): data(data) {}
@@ -162,9 +152,8 @@ namespace wi::lua
int Set(lua_State* L);
};
//get-setters for int type
class FloatProperty final : public LuaProperty
struct FloatProperty
{
public:
float* data = nullptr;
FloatProperty(){}
FloatProperty(float* data): data(data) {}
@@ -172,9 +161,8 @@ namespace wi::lua
int Set(lua_State* L);
};
//get-setters for double type
class DoubleProperty final : public LuaProperty
struct DoubleProperty
{
public:
double* data = nullptr;
DoubleProperty(){}
DoubleProperty(double* data): data(data) {}
@@ -182,9 +170,8 @@ namespace wi::lua
int Set(lua_State* L);
};
//get-setters for string type
class StringProperty final : public LuaProperty
struct StringProperty
{
public:
std::string* data = nullptr;
StringProperty(){}
StringProperty(std::string* data): data(data) {}
@@ -192,9 +179,8 @@ namespace wi::lua
int Set(lua_State* L);
};
//get-setters for bool type
class BoolProperty final : public LuaProperty
struct BoolProperty
{
public:
bool* data = nullptr;
BoolProperty(){}
BoolProperty(bool* data): data(data) {}
+72 -89
View File
@@ -43,50 +43,50 @@ namespace wi::lua
Vector_BindLua::Vector_BindLua()
{
x = 0;
y = 0;
z = 0;
w = 0;
data.x = 0;
data.y = 0;
data.z = 0;
data.w = 0;
}
Vector_BindLua::Vector_BindLua(const XMFLOAT3& vector)
{
x = vector.x;
y = vector.y;
z = vector.z;
w = 1;
data.x = vector.x;
data.y = vector.y;
data.z = vector.z;
data.w = 1;
}
Vector_BindLua::Vector_BindLua(const XMFLOAT4& vector)
{
x = vector.x;
y = vector.y;
z = vector.z;
w = vector.w;
data.x = vector.x;
data.y = vector.y;
data.z = vector.z;
data.w = vector.w;
}
Vector_BindLua::Vector_BindLua(const XMVECTOR& vector)
{
XMStoreFloat4(this, vector);
XMStoreFloat4(&data, vector);
}
Vector_BindLua::Vector_BindLua(lua_State* L)
{
x = 0;
y = 0;
z = 0;
w = 0;
data.x = 0;
data.y = 0;
data.z = 0;
data.w = 0;
int argc = wi::lua::SGetArgCount(L);
if (argc > 0)
{
x = wi::lua::SGetFloat(L, 1);
data.x = wi::lua::SGetFloat(L, 1);
if (argc > 1)
{
y = wi::lua::SGetFloat(L, 2);
data.y = wi::lua::SGetFloat(L, 2);
if (argc > 2)
{
z = wi::lua::SGetFloat(L, 3);
data.z = wi::lua::SGetFloat(L, 3);
if (argc > 3)
{
w = wi::lua::SGetFloat(L, 4);
data.w = wi::lua::SGetFloat(L, 4);
}
}
}
@@ -97,22 +97,22 @@ namespace wi::lua
int Vector_BindLua::GetX(lua_State* L)
{
wi::lua::SSetFloat(L, x);
wi::lua::SSetFloat(L, data.x);
return 1;
}
int Vector_BindLua::GetY(lua_State* L)
{
wi::lua::SSetFloat(L, y);
wi::lua::SSetFloat(L, data.y);
return 1;
}
int Vector_BindLua::GetZ(lua_State* L)
{
wi::lua::SSetFloat(L, z);
wi::lua::SSetFloat(L, data.z);
return 1;
}
int Vector_BindLua::GetW(lua_State* L)
{
wi::lua::SSetFloat(L, w);
wi::lua::SSetFloat(L, data.w);
return 1;
}
@@ -121,7 +121,7 @@ namespace wi::lua
int argc = wi::lua::SGetArgCount(L);
if (argc > 0)
{
x = wi::lua::SGetFloat(L, 1);
data.x = wi::lua::SGetFloat(L, 1);
}
else
wi::lua::SError(L, "SetX(float value) not enough arguments!");
@@ -132,7 +132,7 @@ namespace wi::lua
int argc = wi::lua::SGetArgCount(L);
if (argc > 0)
{
y = wi::lua::SGetFloat(L, 1);
data.y = wi::lua::SGetFloat(L, 1);
}
else
wi::lua::SError(L, "SetY(float value) not enough arguments!");
@@ -143,7 +143,7 @@ namespace wi::lua
int argc = wi::lua::SGetArgCount(L);
if (argc > 0)
{
z = wi::lua::SGetFloat(L, 1);
data.z = wi::lua::SGetFloat(L, 1);
}
else
wi::lua::SError(L, "SetZ(float value) not enough arguments!");
@@ -154,7 +154,7 @@ namespace wi::lua
int argc = wi::lua::SGetArgCount(L);
if (argc > 0)
{
w = wi::lua::SGetFloat(L, 1);
data.w = wi::lua::SGetFloat(L, 1);
}
else
wi::lua::SError(L, "SetW(float value) not enough arguments!");
@@ -170,7 +170,7 @@ namespace wi::lua
Matrix_BindLua* mat = Luna<Matrix_BindLua>::lightcheck(L, 2);
if (vec && mat)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVector4Transform(XMLoadFloat4(vec), XMLoadFloat4x4(mat))));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVector4Transform(XMLoadFloat4(&vec->data), XMLoadFloat4x4(&mat->data))));
return 1;
}
else
@@ -189,7 +189,7 @@ namespace wi::lua
Matrix_BindLua* mat = Luna<Matrix_BindLua>::lightcheck(L, 2);
if (vec && mat)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVector3TransformNormal(XMLoadFloat4(vec), XMLoadFloat4x4(mat))));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVector3TransformNormal(XMLoadFloat4(&vec->data), XMLoadFloat4x4(&mat->data))));
return 1;
}
else
@@ -208,7 +208,7 @@ namespace wi::lua
Matrix_BindLua* mat = Luna<Matrix_BindLua>::lightcheck(L, 2);
if (vec && mat)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVector3TransformCoord(XMLoadFloat4(vec), XMLoadFloat4x4(mat))));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVector3TransformCoord(XMLoadFloat4(&vec->data), XMLoadFloat4x4(&mat->data))));
return 1;
}
else
@@ -220,17 +220,17 @@ namespace wi::lua
}
int Vector_BindLua::Length(lua_State* L)
{
wi::lua::SSetFloat(L, XMVectorGetX(XMVector3Length(XMLoadFloat4(this))));
wi::lua::SSetFloat(L, XMVectorGetX(XMVector3Length(XMLoadFloat4(&data))));
return 1;
}
int Vector_BindLua::Normalize(lua_State* L)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVector3Normalize(XMLoadFloat4(this))));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVector3Normalize(XMLoadFloat4(&data))));
return 1;
}
int Vector_BindLua::QuaternionNormalize(lua_State* L)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMQuaternionNormalize(XMLoadFloat4(this))));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMQuaternionNormalize(XMLoadFloat4(&data))));
return 1;
}
int Vector_BindLua::Clamp(lua_State* L)
@@ -240,7 +240,7 @@ namespace wi::lua
{
float a = wi::lua::SGetFloat(L, 1);
float b = wi::lua::SGetFloat(L, 2);
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVectorClamp(XMLoadFloat4(this), XMVectorSet(a, a, a, a), XMVectorSet(b, b, b, b))));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVectorClamp(XMLoadFloat4(&data), XMVectorReplicate(a), XMVectorReplicate(b))));
return 1;
}
else
@@ -249,7 +249,7 @@ namespace wi::lua
}
int Vector_BindLua::Saturate(lua_State* L)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVectorSaturate(XMLoadFloat4(this))));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVectorSaturate(XMLoadFloat4(&data))));
return 1;
}
@@ -264,7 +264,7 @@ namespace wi::lua
Vector_BindLua* v2 = Luna<Vector_BindLua>::lightcheck(L, 2);
if (v1 && v2)
{
wi::lua::SSetFloat(L, XMVectorGetX(XMVector3Dot(XMLoadFloat4(v1), XMLoadFloat4(v2))));
wi::lua::SSetFloat(L, XMVectorGetX(XMVector3Dot(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data))));
return 1;
}
}
@@ -280,7 +280,7 @@ namespace wi::lua
Vector_BindLua* v2 = Luna<Vector_BindLua>::lightcheck(L, 2);
if (v1 && v2)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVector3Cross(XMLoadFloat4(v1), XMLoadFloat4(v2))));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVector3Cross(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data))));
return 1;
}
}
@@ -296,17 +296,17 @@ namespace wi::lua
Vector_BindLua* v2 = Luna<Vector_BindLua>::lightcheck(L, 2);
if (v1 && v2)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVectorMultiply(XMLoadFloat4(v1), XMLoadFloat4(v2))));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVectorMultiply(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data))));
return 1;
}
else if (v1)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat4(v1) * wi::lua::SGetFloat(L, 2)));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat4(&v1->data) * wi::lua::SGetFloat(L, 2)));
return 1;
}
else if (v2)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(wi::lua::SGetFloat(L, 1) * XMLoadFloat4(v2)));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(wi::lua::SGetFloat(L, 1) * XMLoadFloat4(&v2->data)));
return 1;
}
}
@@ -322,7 +322,7 @@ namespace wi::lua
Vector_BindLua* v2 = Luna<Vector_BindLua>::lightcheck(L, 2);
if (v1 && v2)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVectorAdd(XMLoadFloat4(v1), XMLoadFloat4(v2))));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVectorAdd(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data))));
return 1;
}
}
@@ -338,7 +338,7 @@ namespace wi::lua
Vector_BindLua* v2 = Luna<Vector_BindLua>::lightcheck(L, 2);
if (v1 && v2)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVectorSubtract(XMLoadFloat4(v1), XMLoadFloat4(v2))));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVectorSubtract(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data))));
return 1;
}
}
@@ -355,7 +355,7 @@ namespace wi::lua
float t = wi::lua::SGetFloat(L, 3);
if (v1 && v2)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVectorLerp(XMLoadFloat4(v1), XMLoadFloat4(v2), t)));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVectorLerp(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data), t)));
return 1;
}
}
@@ -373,7 +373,7 @@ namespace wi::lua
Vector_BindLua* v2 = Luna<Vector_BindLua>::lightcheck(L, 2);
if (v1 && v2)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMQuaternionMultiply(XMLoadFloat4(v1), XMLoadFloat4(v2))));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMQuaternionMultiply(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data))));
return 1;
}
}
@@ -388,7 +388,7 @@ namespace wi::lua
Vector_BindLua* v1 = Luna<Vector_BindLua>::lightcheck(L, 1);
if (v1)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMQuaternionRotationRollPitchYawFromVector(XMLoadFloat4(v1))));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMQuaternionRotationRollPitchYawFromVector(XMLoadFloat4(&v1->data))));
return 1;
}
}
@@ -403,7 +403,7 @@ namespace wi::lua
Vector_BindLua* v1 = Luna<Vector_BindLua>::lightcheck(L, 1);
if (v1)
{
XMFLOAT3 xyz = wi::math::QuaternionToRollPitchYaw(*v1);
XMFLOAT3 xyz = wi::math::QuaternionToRollPitchYaw(v1->data);
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMFLOAT4(xyz.x, xyz.y, xyz.z, 0)));
return 1;
}
@@ -421,7 +421,7 @@ namespace wi::lua
float t = wi::lua::SGetFloat(L, 3);
if (v1 && v2)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMQuaternionSlerp(XMLoadFloat4(v1), XMLoadFloat4(v2), t)));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMQuaternionSlerp(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data), t)));
return 1;
}
}
@@ -458,10 +458,6 @@ namespace wi::lua
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat4(data_f4)));
}
if(data_v)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(*data_v));
}
return 1;
}
int VectorProperty::Set(lua_State* L)
@@ -471,19 +467,15 @@ namespace wi::lua
{
if(data_f2)
{
XMStoreFloat2(data_f2, XMLoadFloat4(get));
XMStoreFloat2(data_f2, XMLoadFloat4(&get->data));
}
if(data_f3)
{
XMStoreFloat3(data_f3, XMLoadFloat4(get));
XMStoreFloat3(data_f3, XMLoadFloat4(&get->data));
}
if(data_f4)
{
*data_f4 = *get;
}
if(data_v)
{
*data_v = XMLoadFloat4(get);
*data_f4 = get->data;
}
}
return 0;
@@ -519,15 +511,14 @@ namespace wi::lua
Matrix_BindLua::Matrix_BindLua()
{
std::memcpy(this, &wi::math::IDENTITY_MATRIX, sizeof(wi::math::IDENTITY_MATRIX));
}
Matrix_BindLua::Matrix_BindLua(const XMFLOAT4X4& matrix)
{
std::memcpy(this, &matrix, sizeof(matrix));
data = matrix;
}
Matrix_BindLua::Matrix_BindLua(const XMMATRIX& matrix)
{
XMStoreFloat4x4(this, matrix);
XMStoreFloat4x4(&data, matrix);
}
Matrix_BindLua::Matrix_BindLua(lua_State* L)
{
@@ -555,10 +546,10 @@ namespace wi::lua
}
}
}
this->m[i][0] = x;
this->m[i][1] = x;
this->m[i][2] = x;
this->m[i][3] = x;
data.m[i][0] = x;
data.m[i][1] = x;
data.m[i][2] = x;
data.m[i][3] = x;
}
}
@@ -573,7 +564,7 @@ namespace wi::lua
if (row < 0 || row > 3)
row = 0;
}
XMFLOAT4 r = XMFLOAT4(m[row][0], m[row][1], m[row][2], m[row][3]);
XMFLOAT4 r = XMFLOAT4(data.m[row][0], data.m[row][1], data.m[row][2], data.m[row][3]);
Luna<Vector_BindLua>::push(L, new Vector_BindLua(r));
return 1;
}
@@ -589,7 +580,7 @@ namespace wi::lua
Vector_BindLua* vector = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vector != nullptr)
{
mat = XMMatrixTranslationFromVector(XMLoadFloat4(vector));
mat = XMMatrixTranslationFromVector(XMLoadFloat4(&vector->data));
}
}
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(mat));
@@ -605,7 +596,7 @@ namespace wi::lua
Vector_BindLua* vector = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vector != nullptr)
{
mat = XMMatrixRotationRollPitchYawFromVector(XMLoadFloat4(vector));
mat = XMMatrixRotationRollPitchYawFromVector(XMLoadFloat4(&vector->data));
}
}
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(mat));
@@ -657,7 +648,7 @@ namespace wi::lua
Vector_BindLua* vector = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vector != nullptr)
{
mat = XMMatrixRotationQuaternion(XMLoadFloat4(vector));
mat = XMMatrixRotationQuaternion(XMLoadFloat4(&vector->data));
}
}
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(mat));
@@ -673,7 +664,7 @@ namespace wi::lua
Vector_BindLua* vector = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vector != nullptr)
{
mat = XMMatrixScalingFromVector(XMLoadFloat4(vector));
mat = XMMatrixScalingFromVector(XMLoadFloat4(&vector->data));
}
}
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(mat));
@@ -693,11 +684,11 @@ namespace wi::lua
if (argc > 3)
{
Vector_BindLua* up = Luna<Vector_BindLua>::lightcheck(L, 3);
Up = XMLoadFloat4(up);
Up = XMLoadFloat4(&up->data);
}
else
Up = XMVectorSet(0, 1, 0, 0);
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(XMMatrixLookToLH(XMLoadFloat4(pos), XMLoadFloat4(dir), Up)));
Luna<Matrix_BindLua>::push(L, new 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!");
@@ -720,11 +711,11 @@ namespace wi::lua
if (argc > 3)
{
Vector_BindLua* up = Luna<Vector_BindLua>::lightcheck(L, 3);
Up = XMLoadFloat4(up);
Up = XMLoadFloat4(&up->data);
}
else
Up = XMVectorSet(0, 1, 0, 0);
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(XMMatrixLookAtLH(XMLoadFloat4(pos), XMLoadFloat4(dir), Up)));
Luna<Matrix_BindLua>::push(L, new 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!");
@@ -743,7 +734,7 @@ namespace wi::lua
Matrix_BindLua* m2 = Luna<Matrix_BindLua>::lightcheck(L, 2);
if (m1 && m2)
{
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(XMMatrixMultiply(XMLoadFloat4x4(m1), XMLoadFloat4x4(m2))));
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(XMMatrixMultiply(XMLoadFloat4x4(&m1->data), XMLoadFloat4x4(&m2->data))));
return 1;
}
}
@@ -759,7 +750,7 @@ namespace wi::lua
Matrix_BindLua* m2 = Luna<Matrix_BindLua>::lightcheck(L, 2);
if (m1 && m2)
{
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(XMLoadFloat4x4(m1) + XMLoadFloat4x4(m2)));
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(XMLoadFloat4x4(&m1->data) + XMLoadFloat4x4(&m2->data)));
return 1;
}
}
@@ -774,7 +765,7 @@ namespace wi::lua
Matrix_BindLua* m1 = Luna<Matrix_BindLua>::lightcheck(L, 1);
if (m1)
{
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(XMMatrixTranspose(XMLoadFloat4x4(m1))));
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(XMMatrixTranspose(XMLoadFloat4x4(&m1->data))));
return 1;
}
}
@@ -790,7 +781,7 @@ namespace wi::lua
if (m1)
{
XMVECTOR det;
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(XMMatrixInverse(&det, XMLoadFloat4x4(m1))));
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(XMMatrixInverse(&det, XMLoadFloat4x4(&m1->data))));
wi::lua::SSetFloat(L, XMVectorGetX(det));
return 2;
}
@@ -819,10 +810,6 @@ namespace wi::lua
{
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(*data_f4x4));
}
if(data_m)
{
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(*data_m));
}
return 1;
}
int MatrixProperty::Set(lua_State *L)
@@ -832,11 +819,7 @@ namespace wi::lua
{
if(data_f4x4)
{
*data_f4x4 = *get;
}
if(data_m)
{
*data_m = XMLoadFloat4x4(get);
*data_f4x4 = get->data;
}
}
return 0;
+7 -9
View File
@@ -7,9 +7,10 @@
namespace wi::lua
{
class Vector_BindLua : public XMFLOAT4
class Vector_BindLua
{
public:
XMFLOAT4 data = {};
static const char className[];
static Luna<Vector_BindLua>::FunctionType methods[];
static Luna<Vector_BindLua>::PropertyType properties[];
@@ -54,14 +55,13 @@ namespace wi::lua
static void Bind();
};
class VectorProperty final : public LuaProperty
struct VectorProperty
{
public:
VectorProperty(){}
VectorProperty(XMFLOAT2* data): data_f2(data) {}
VectorProperty(XMFLOAT3* data): data_f3(data) {}
VectorProperty(XMFLOAT4* data): data_f4(data) {}
VectorProperty(XMVECTOR* data): data_v(data) {}
int Get(lua_State*L);
int Set(lua_State*L);
@@ -69,12 +69,12 @@ namespace wi::lua
XMFLOAT2* data_f2 = nullptr;
XMFLOAT3* data_f3 = nullptr;
XMFLOAT4* data_f4 = nullptr;
XMVECTOR* data_v = nullptr;
};
class Matrix_BindLua : public XMFLOAT4X4
class Matrix_BindLua
{
public:
XMFLOAT4X4 data = wi::math::IDENTITY_MATRIX;
static const char className[];
static Luna<Matrix_BindLua>::FunctionType methods[];
static Luna<Matrix_BindLua>::PropertyType properties[];
@@ -103,17 +103,15 @@ namespace wi::lua
static void Bind();
};
class MatrixProperty final : public LuaProperty
struct MatrixProperty
{
public:
MatrixProperty(){}
MatrixProperty(XMFLOAT4X4* data): data_f4x4(data) {}
MatrixProperty(XMMATRIX* data): data_m(data) {}
int Get(lua_State*L);
int Set(lua_State*L);
private:
XMFLOAT4X4* data_f4x4;
XMMATRIX* data_m;
XMFLOAT4X4* data_f4x4 = nullptr;
};
}
+15 -15
View File
@@ -49,7 +49,7 @@ namespace wi::lua::primitive
Vector_BindLua* d = Luna<Vector_BindLua>::lightcheck(L, 2);
if (o && d)
{
ray = Ray(XMLoadFloat4(o), XMLoadFloat4(d));
ray = Ray(XMLoadFloat4(&o->data), XMLoadFloat4(&d->data));
if (argc > 2)
{
ray.TMin = wi::lua::SGetFloat(L, 3);
@@ -116,7 +116,7 @@ namespace wi::lua::primitive
Vector_BindLua* v = Luna<Vector_BindLua>::lightcheck(L, 1);
if (v != nullptr)
{
XMStoreFloat3(&ray.origin, XMLoadFloat4(v));
XMStoreFloat3(&ray.origin, XMLoadFloat4(&v->data));
}
else
{
@@ -142,7 +142,7 @@ namespace wi::lua::primitive
Vector_BindLua* v = Luna<Vector_BindLua>::lightcheck(L, 1);
if (v != nullptr)
{
XMStoreFloat3(&ray.direction, XMLoadFloat4(v));
XMStoreFloat3(&ray.direction, XMLoadFloat4(&v->data));
}
else
{
@@ -189,15 +189,15 @@ namespace wi::lua::primitive
if (_minV && _maxV)
{
XMFLOAT3 _min, _max;
XMStoreFloat3(&_min, XMLoadFloat4(_minV));
XMStoreFloat3(&_max, XMLoadFloat4(_maxV));
XMStoreFloat3(&_min, XMLoadFloat4(&_minV->data));
XMStoreFloat3(&_max, XMLoadFloat4(&_maxV->data));
aabb = AABB(_min, _max);
}
else if (_minV)
{
XMFLOAT3 _min;
XMStoreFloat3(&_min, XMLoadFloat4(_minV));
XMStoreFloat3(&_min, XMLoadFloat4(&_minV->data));
aabb = AABB(_min);
}
@@ -278,7 +278,7 @@ namespace wi::lua::primitive
Vector_BindLua* v = Luna<Vector_BindLua>::lightcheck(L, 1);
if (v != nullptr)
{
XMStoreFloat3(&aabb._min, XMLoadFloat4(v));
XMStoreFloat3(&aabb._min, XMLoadFloat4(&v->data));
}
else
{
@@ -305,7 +305,7 @@ namespace wi::lua::primitive
Vector_BindLua* v = Luna<Vector_BindLua>::lightcheck(L, 1);
if (v != nullptr)
{
XMStoreFloat3(&aabb._max, XMLoadFloat4(v));
XMStoreFloat3(&aabb._max, XMLoadFloat4(&v->data));
}
else
{
@@ -338,7 +338,7 @@ namespace wi::lua::primitive
Matrix_BindLua* _matrix = Luna<Matrix_BindLua>::lightcheck(L, 1);
if (_matrix)
{
Luna<AABB_BindLua>::push(L, new AABB_BindLua(aabb.transform(*_matrix)));
Luna<AABB_BindLua>::push(L, new AABB_BindLua(aabb.transform(_matrix->data)));
return 1;
}
else
@@ -382,7 +382,7 @@ namespace wi::lua::primitive
if (cV)
{
XMFLOAT3 c;
XMStoreFloat3(&c, XMLoadFloat4(cV));
XMStoreFloat3(&c, XMLoadFloat4(&cV->data));
float r = wi::lua::SGetFloat(L, 2);
@@ -450,7 +450,7 @@ namespace wi::lua::primitive
Vector_BindLua* cV = Luna<Vector_BindLua>::lightcheck(L, 1);
if (cV)
{
XMStoreFloat3(&sphere.center, XMLoadFloat4(cV));
XMStoreFloat3(&sphere.center, XMLoadFloat4(&cV->data));
}
else
{
@@ -509,9 +509,9 @@ namespace wi::lua::primitive
if (bV && tV)
{
XMFLOAT3 b;
XMStoreFloat3(&b, XMLoadFloat4(bV));
XMStoreFloat3(&b, XMLoadFloat4(&bV->data));
XMFLOAT3 t;
XMStoreFloat3(&t, XMLoadFloat4(tV));
XMStoreFloat3(&t, XMLoadFloat4(&tV->data));
float r = wi::lua::SGetFloat(L, 3);
@@ -585,7 +585,7 @@ namespace wi::lua::primitive
Vector_BindLua* cV = Luna<Vector_BindLua>::lightcheck(L, 1);
if (cV)
{
XMStoreFloat3(&capsule.base, XMLoadFloat4(cV));
XMStoreFloat3(&capsule.base, XMLoadFloat4(&cV->data));
}
else
{
@@ -606,7 +606,7 @@ namespace wi::lua::primitive
Vector_BindLua* cV = Luna<Vector_BindLua>::lightcheck(L, 1);
if (cV)
{
XMStoreFloat3(&capsule.tip, XMLoadFloat4(cV));
XMStoreFloat3(&capsule.tip, XMLoadFloat4(&cV->data));
}
else
{
+1
View File
@@ -26,6 +26,7 @@ namespace wi::lua
{
this->component = &renderpath;
}
virtual ~RenderPath2D_BindLua() = default;
int AddSprite(lua_State* L);
int AddFont(lua_State* L);
+18 -15
View File
@@ -164,15 +164,15 @@ namespace wi::lua::renderer
if (a && b)
{
wi::renderer::RenderableLine line;
XMStoreFloat3(&line.start, XMLoadFloat4(a));
XMStoreFloat3(&line.end, XMLoadFloat4(b));
XMStoreFloat3(&line.start, XMLoadFloat4(&a->data));
XMStoreFloat3(&line.end, XMLoadFloat4(&b->data));
if (argc > 2)
{
Vector_BindLua* c = Luna<Vector_BindLua>::lightcheck(L, 3);
if (c)
{
XMStoreFloat4(&line.color_start, XMLoadFloat4(c));
XMStoreFloat4(&line.color_end, XMLoadFloat4(c));
XMStoreFloat4(&line.color_start, XMLoadFloat4(&c->data));
XMStoreFloat4(&line.color_end, XMLoadFloat4(&c->data));
}
else
wi::lua::SError(L, "DrawLine(Vector origin,end, opt Vector color) one or more arguments are not vectors!");
@@ -196,7 +196,7 @@ namespace wi::lua::renderer
if (a)
{
wi::renderer::RenderablePoint point;
XMStoreFloat3(&point.position, XMLoadFloat4(a));
XMStoreFloat3(&point.position, XMLoadFloat4(&a->data));
if (argc > 1)
{
point.size = wi::lua::SGetFloat(L, 2);
@@ -204,7 +204,10 @@ namespace wi::lua::renderer
if (argc > 2)
{
Vector_BindLua* color = Luna<Vector_BindLua>::lightcheck(L, 3);
point.color = *color;
if (color)
{
point.color = color->data;
}
}
}
wi::renderer::DrawPoint(point);
@@ -230,12 +233,12 @@ namespace wi::lua::renderer
Vector_BindLua* color = Luna<Vector_BindLua>::lightcheck(L, 2);
if (color)
{
wi::renderer::DrawBox(*m, *color);
wi::renderer::DrawBox(m->data, color->data);
return 0;
}
}
wi::renderer::DrawBox(*m);
wi::renderer::DrawBox(m->data);
}
else
wi::lua::SError(L, "DrawBox(Matrix boxMatrix, opt Vector color) first argument must be a Matrix type!");
@@ -258,7 +261,7 @@ namespace wi::lua::renderer
Vector_BindLua* color = Luna<Vector_BindLua>::lightcheck(L, 2);
if (color)
{
wi::renderer::DrawSphere(sphere->sphere, *color);
wi::renderer::DrawSphere(sphere->sphere, color->data);
return 0;
}
}
@@ -286,7 +289,7 @@ namespace wi::lua::renderer
Vector_BindLua* color = Luna<Vector_BindLua>::lightcheck(L, 2);
if (color)
{
wi::renderer::DrawCapsule(capsule->capsule, *color);
wi::renderer::DrawCapsule(capsule->capsule, color->data);
return 0;
}
}
@@ -313,16 +316,16 @@ namespace wi::lua::renderer
Vector_BindLua* position = Luna<Vector_BindLua>::lightcheck(L, 2);
if (position != nullptr)
{
params.position.x = position->x;
params.position.y = position->y;
params.position.z = position->z;
params.position.x = position->data.x;
params.position.y = position->data.y;
params.position.z = position->data.z;
if (argc > 2)
{
Vector_BindLua* color = Luna<Vector_BindLua>::lightcheck(L, 3);
if (color != nullptr)
{
params.color = *color;
params.color = color->data;
if (argc > 3)
{
@@ -359,7 +362,7 @@ namespace wi::lua::renderer
if (v)
{
XMFLOAT3 pos;
XMStoreFloat3(&pos, XMLoadFloat4(v));
XMStoreFloat3(&pos, XMLoadFloat4(&v->data));
GetGlobalScene()->PutWaterRipple(name, pos);
}
else
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -119,7 +119,7 @@ namespace wi::lua
Vector_BindLua* vec = Luna<Vector_BindLua>::lightcheck(L, 1);
if (vec != nullptr)
{
XMStoreFloat3(&anim.vel, XMLoadFloat4(vec));
XMStoreFloat3(&anim.vel, XMLoadFloat4(&vec->data));
}
else
{
+8 -8
View File
@@ -109,8 +109,8 @@ namespace wi::lua
Vector_BindLua* param = Luna<Vector_BindLua>::lightcheck(L, 1);
if (param != nullptr)
{
font.params.posX = param->x;
font.params.posY = param->y;
font.params.posX = param->data.x;
font.params.posY = param->data.y;
}
else
wi::lua::SError(L, "SetPos(Vector pos) argument is not a vector!");
@@ -127,8 +127,8 @@ namespace wi::lua
Vector_BindLua* param = Luna<Vector_BindLua>::lightcheck(L, 1);
if (param != nullptr)
{
font.params.spacingX = param->x;
font.params.spacingY = param->y;
font.params.spacingX = param->data.x;
font.params.spacingY = param->data.y;
}
else
wi::lua::SError(L, "SetSpacing(Vector spacing) argument is not a vector!");
@@ -160,7 +160,7 @@ namespace wi::lua
Vector_BindLua* param = Luna<Vector_BindLua>::lightcheck(L, 1);
if (param != nullptr)
{
font.params.color = wi::Color::fromFloat4(*param);
font.params.color = wi::Color::fromFloat4(param->data);
}
else
{
@@ -180,7 +180,7 @@ namespace wi::lua
Vector_BindLua* param = Luna<Vector_BindLua>::lightcheck(L, 1);
if (param != nullptr)
{
font.params.shadowColor = wi::Color::fromFloat4(*param);
font.params.shadowColor = wi::Color::fromFloat4(param->data);
}
else
{
@@ -248,8 +248,8 @@ namespace wi::lua
Vector_BindLua* param = Luna<Vector_BindLua>::lightcheck(L, 1);
if (param != nullptr)
{
font.params.shadow_offset_x = param->x;
font.params.shadow_offset_y = param->y;
font.params.shadow_offset_x = param->data.x;
font.params.shadow_offset_y = param->data.y;
}
else
wi::lua::SError(L, "SetShadowOffset(Vector pos) argument is not a vector!");
+1 -1
View File
@@ -1202,7 +1202,7 @@ namespace wi::terrain
archive << chunks.size();
for (auto& it : chunks)
{
Chunk& chunk = it.first;
const Chunk& chunk = it.first;
archive << chunk.x;
archive << chunk.z;
ChunkData& chunk_data = it.second;
+2
View File
@@ -171,6 +171,8 @@ namespace wi::terrain
struct Modifier
{
virtual ~Modifier() = default;
enum class Type
{
Perlin,
+1 -1
View File
@@ -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 = 43;
const int revision = 44;
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);