3 #include "Platform/Main/BaseApp.h"
5 #include "TecLibs/Tec3D.h"
8 #include <winrt/Windows.UI.Core.h>
9 #include <winrt/Windows.Foundation.h>
10 #include <winrt/Windows.Foundation.Numerics.h>
12 inline mat4 Mat4FromFloat4x4(
const winrt::Windows::Foundation::Numerics::float4x4& transform)
14 auto mat_row_major = mat4(
15 v4f(transform.m11, transform.m12, transform.m13, transform.m14),
16 v4f(transform.m21, transform.m22, transform.m23, transform.m24),
17 v4f(transform.m31, transform.m32, transform.m33, transform.m34),
18 v4f(transform.m41, transform.m42, transform.m43, transform.m44));
23 inline mat3x4 Mat3x4FromFloat4x4(
const winrt::Windows::Foundation::Numerics::float4x4& transform)
26 transform.m11, transform.m21, transform.m31, transform.m41,
27 transform.m12, transform.m22, transform.m32, transform.m42,
28 transform.m13, transform.m23, transform.m33, transform.m43,
29 transform.m14, transform.m24, transform.m34, transform.m44);
32 mat3x4 m{ mat.XAxis.xyz, mat.YAxis.xyz, mat.ZAxis.xyz, mat.Pos.xyz };
36 template<
typename TLambda>
37 auto invoke_async_lambda(TLambda lambda) -> decltype(lambda())
39 return co_await lambda();
43 winrt::fire_and_forget no_await_lambda(T lambda)
49 winrt::fire_and_forget no_await(T awaitable)
54 inline concurrency::task<SmartPointer<FileHandle>> MakeHandleFromStorageFile(winrt::Windows::Storage::StorageFile file)
56 SmartPointer<FileHandle> result;
57 auto name = file.Name();
59 auto file_copy = co_await file.CopyAsync(winrt::Windows::Storage::ApplicationData::Current().TemporaryFolder(), name, winrt::Windows::Storage::NameCollisionOption::ReplaceExisting);
62 result = FilePathManager::CreateFileHandle(to_utf8(file_copy.Path().data()));
67 inline SmartPointer<FileHandle> MakeHandleFromStorageFileNoCopy(winrt::Windows::Storage::StorageFile file)
69 SmartPointer<FileHandle> result;
70 result = FilePathManager::CreateFileHandle(to_utf8(file.Path().data()));
74 inline auto resume_on_kigs_thread()
76 return winrt::resume_foreground(App::GetApp()->GetWindow().Dispatcher());
79 template<
typename Pred>
80 winrt::Windows::Foundation::IAsyncAction wait_until(Pred predicate, winrt::Windows::Foundation::TimeSpan check_frequency,
bool check_on_same_thread =
false)
82 winrt::apartment_context ctx;
85 co_await winrt::resume_after(check_frequency);
86 if (check_on_same_thread)