From f05f9d5ade64bfb5030a55411a52379e3a6fef0e Mon Sep 17 00:00:00 2001 From: intolerantape Date: Sat, 20 Nov 2021 12:34:25 -0800 Subject: [PATCH 1/4] Made Dictionary support movable value types with deleted copy constructors. --- Source/Engine/Core/Collections/Dictionary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 6ed655f8c31f2f9aa970535dbc553a637366deef Mon Sep 17 00:00:00 2001 From: intolerantape Date: Thu, 2 Dec 2021 04:57:07 -0800 Subject: [PATCH 2/4] Implementated Math::SinCos() overload taking doubles as parameters. --- Source/Engine/Core/Math/Math.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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: From 8d758ced1552c45c09f7e54234dcb4c9413759da Mon Sep 17 00:00:00 2001 From: intolerantape Date: Thu, 2 Dec 2021 07:13:11 -0800 Subject: [PATCH 3/4] Added a constructor for C++ Function class to support initialization directly from reference-captured lambda. Previously, Function had to initialize reference-captured lambdas with the Bind() method. --- Source/Engine/Core/Delegate.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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) From 25deea220c01fb4548407598f1ed319b55172580 Mon Sep 17 00:00:00 2001 From: intolerantape Date: Fri, 3 Dec 2021 07:53:03 -0800 Subject: [PATCH 4/4] Added overload of Task::StartNew() to support void-returning member functions. --- Source/Engine/Threading/Task.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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. ///