diff --git a/Source/Engine/Core/Collections/Dictionary.h b/Source/Engine/Core/Collections/Dictionary.h index c354aec01..c1e36e5dc 100644 --- a/Source/Engine/Core/Collections/Dictionary.h +++ b/Source/Engine/Core/Collections/Dictionary.h @@ -530,7 +530,7 @@ public: for (int32 i = 0; i < oldSize; i++) { if (oldData[i].IsOccupied()) - Add(oldData[i].Key, oldData[i].Value); + Add(oldData[i].Key, MoveTemp(oldData[i].Value)); } } if (oldElementsCount != 0) diff --git a/Source/Engine/Core/Delegate.h b/Source/Engine/Core/Delegate.h index bba43eb16..9269fec9d 100644 --- a/Source/Engine/Core/Delegate.h +++ b/Source/Engine/Core/Delegate.h @@ -89,6 +89,20 @@ public: _lambda = nullptr; } + /// + /// Initializes a new instance of the class. + /// + template + Function(const T& lambda) + { + _lambda = (Lambda*)Allocator::Allocate(sizeof(Lambda) + sizeof(T)); + _lambda->Refs = 1; + _lambda->Dtor = [](void* callee) -> void { static_cast(callee)->~T(); }; + _function = [](void* callee, Params ... params) -> ReturnType { return (*static_cast(callee))(Forward(params)...); }; + _callee = (byte*)_lambda + sizeof(Lambda); + new(_callee) T(lambda); + } + Function(const Function& other) : _callee(other._callee) , _function(other._function) diff --git a/Source/Engine/Core/Math/Math.cpp b/Source/Engine/Core/Math/Math.cpp index d0642d7ca..0e60a3248 100644 --- a/Source/Engine/Core/Math/Math.cpp +++ b/Source/Engine/Core/Math/Math.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #include "Math.h" +#include "Mathd.h" #include "Vector3.h" void Math::SinCos(float angle, float& sine, float& cosine) @@ -9,6 +10,12 @@ void Math::SinCos(float angle, float& sine, float& cosine) cosine = Math::Cos(angle); } +void Math::SinCos(double angle, double& sine, double& cosine) +{ + sine = Math::Sin(angle); + cosine = Math::Cos(angle); +} + uint32 Math::FloorLog2(uint32 value) { // References: diff --git a/Source/Engine/Threading/Task.h b/Source/Engine/Threading/Task.h index 7004c130e..86a34a992 100644 --- a/Source/Engine/Threading/Task.h +++ b/Source/Engine/Threading/Task.h @@ -248,6 +248,19 @@ public: /// Task static Task* StartNew(Function::Signature action, Object* target = nullptr); + /// + /// Starts the new task. + /// + /// The callee object. + /// Task + template + static Task* StartNew(T* callee) + { + Function action; + action.Bind(callee); + return StartNew(action, dynamic_cast(callee)); + } + /// /// Starts the new task. ///