diff --git a/Source/Engine/Graphics/Models/SkinnedModelLOD.cpp b/Source/Engine/Graphics/Models/SkinnedModelLOD.cpp index 0e2b60aea..ada7d89f2 100644 --- a/Source/Engine/Graphics/Models/SkinnedModelLOD.cpp +++ b/Source/Engine/Graphics/Models/SkinnedModelLOD.cpp @@ -3,6 +3,7 @@ #include "SkinnedModelLOD.h" #include "MeshDeformation.h" #include "Engine/Core/Log.h" +#include "Engine/Core/Math/Transform.h" #include "Engine/Graphics/GPUDevice.h" #include "Engine/Content/Assets/Model.h" #include "Engine/Serialization/MemoryReadStream.h" diff --git a/Source/Engine/Platform/Mac/MacPlatform.cpp b/Source/Engine/Platform/Mac/MacPlatform.cpp index 04f928bba..46b978e1d 100644 --- a/Source/Engine/Platform/Mac/MacPlatform.cpp +++ b/Source/Engine/Platform/Mac/MacPlatform.cpp @@ -56,36 +56,94 @@ DialogResult MessageBox::Show(Window* parent, const StringView& text, const Stri { if (CommandLine::Options.Headless) return DialogResult::None; - CFStringRef textRef = AppleUtils::ToString(text); - CFStringRef captionRef = AppleUtils::ToString(caption); - CFOptionFlags flags = 0; + NSAlert* alert = [[NSAlert alloc] init]; + ASSERT(alert); switch (buttons) { case MessageBoxButtons::AbortRetryIgnore: + [alert addButtonWithTitle:@"Abort"]; + [alert addButtonWithTitle:@"Retry"]; + [alert addButtonWithTitle:@"Ignore"]; + break; + case MessageBoxButtons::OK: + [alert addButtonWithTitle:@"OK"]; + break; case MessageBoxButtons::OKCancel: + [alert addButtonWithTitle:@"OK"]; + [alert addButtonWithTitle:@"Cancel"]; + break; case MessageBoxButtons::RetryCancel: + [alert addButtonWithTitle:@"Retry"]; + [alert addButtonWithTitle:@"Cancel"]; + break; case MessageBoxButtons::YesNo: + [alert addButtonWithTitle:@"Yes"]; + [alert addButtonWithTitle:@"No"]; + break; case MessageBoxButtons::YesNoCancel: - flags |= kCFUserNotificationCancelResponse; + [alert addButtonWithTitle:@"Yes"]; + [alert addButtonWithTitle:@"No"]; + [alert addButtonWithTitle:@"Cancel"]; break; } switch (icon) { case MessageBoxIcon::Information: - flags |= kCFUserNotificationNoteAlertLevel; + [alert setAlertStyle:NSAlertStyleCritical]; break; case MessageBoxIcon::Error: case MessageBoxIcon::Stop: - flags |= kCFUserNotificationStopAlertLevel; + [alert setAlertStyle:NSAlertStyleInformational]; break; case MessageBoxIcon::Warning: - flags |= kCFUserNotificationCautionAlertLevel; + [alert setAlertStyle:NSAlertStyleWarning]; break; } - SInt32 result = CFUserNotificationDisplayNotice(0, flags, nullptr, nullptr, nullptr, captionRef, textRef, nullptr); - CFRelease(captionRef); - CFRelease(textRef); - return DialogResult::OK; + [alert setMessageText:(NSString*)AppleUtils::ToString(caption)]; + [alert setInformativeText:(NSString*)AppleUtils::ToString(text)]; + NSInteger button = [alert runModal]; + DialogResult result = DialogResult::OK; + switch (buttons) + { + case MessageBoxButtons::AbortRetryIgnore: + if (button == NSAlertFirstButtonReturn) + result = DialogResult::Abort; + else if (button == NSAlertSecondButtonReturn) + result = DialogResult::Retry; + else + result = DialogResult::Ignore; + break; + case MessageBoxButtons::OK: + result = DialogResult::OK; + break; + case MessageBoxButtons::OKCancel: + if (button == NSAlertFirstButtonReturn) + result = DialogResult::OK; + else + result = DialogResult::Cancel; + break; + case MessageBoxButtons::RetryCancel: + if (button == NSAlertFirstButtonReturn) + result = DialogResult::Retry; + else + result = DialogResult::Cancel; + break; + case MessageBoxButtons::YesNo: + if (button == NSAlertFirstButtonReturn) + result = DialogResult::Yes; + else + result = DialogResult::No; + break; + case MessageBoxButtons::YesNoCancel: + if (button == NSAlertFirstButtonReturn) + result = DialogResult::Yes; + else if (button == NSAlertSecondButtonReturn) + result = DialogResult::No; + else + result = DialogResult::Cancel; + break; + } + return result; } Float2 AppleUtils::PosToCoca(const Float2& pos) @@ -301,15 +359,16 @@ Float2 MacPlatform::GetMousePosition() CGEventRef event = CGEventCreate(nullptr); CGPoint cursor = CGEventGetLocation(event); CFRelease(event); - return Float2((float)cursor.x, (float)cursor.y); + return Float2((float)cursor.x, (float)cursor.y) * MacPlatform::ScreenScale; } void MacPlatform::SetMousePosition(const Float2& pos) { CGPoint cursor; - cursor.x = (CGFloat)pos.X; - cursor.y = (CGFloat)pos.Y; + cursor.x = (CGFloat)(pos.X / MacPlatform::ScreenScale); + cursor.y = (CGFloat)(pos.Y / MacPlatform::ScreenScale); CGWarpMouseCursorPosition(cursor); + CGAssociateMouseAndMouseCursorPosition(true); } Float2 MacPlatform::GetDesktopSize() diff --git a/Source/Engine/Platform/Mac/MacWindow.cpp b/Source/Engine/Platform/Mac/MacWindow.cpp index 90bb07279..aeee93e37 100644 --- a/Source/Engine/Platform/Mac/MacWindow.cpp +++ b/Source/Engine/Platform/Mac/MacWindow.cpp @@ -72,11 +72,11 @@ KeyboardKeys GetKey(NSEvent* event) case 0x30: return KeyboardKeys::Tab; case 0x31: return KeyboardKeys::Spacebar; case 0x32: return KeyboardKeys::BackQuote; - case 0x33: return KeyboardKeys::Delete; + case 0x33: return KeyboardKeys::Backspace; //case 0x34: case 0x35: return KeyboardKeys::Escape; - //case 0x36: - //case 0x37: Command + case 0x36: return KeyboardKeys::Control; // Command (right) + case 0x37: return KeyboardKeys::Control; // Command (left) case 0x38: return KeyboardKeys::Shift; case 0x39: return KeyboardKeys::Capital; case 0x3A: return KeyboardKeys::Alt; @@ -378,7 +378,7 @@ static void ConvertNSRect(NSScreen *screen, NSRect *r) { KeyboardKeys key = GetKey(event); if (key != KeyboardKeys::None) - Input::Keyboard->OnKeyDown(key); + Input::Keyboard->OnKeyDown(key, Window); // Send a text input event switch (key) @@ -400,7 +400,7 @@ static void ConvertNSRect(NSScreen *screen, NSRect *r) if (length >= 16) length = 15; [text getCharacters:buffer range:NSMakeRange(0, length)]; - Input::Keyboard->OnCharInput((Char)buffer[0]); + Input::Keyboard->OnCharInput((Char)buffer[0], Window); } } @@ -408,7 +408,32 @@ static void ConvertNSRect(NSScreen *screen, NSRect *r) { KeyboardKeys key = GetKey(event); if (key != KeyboardKeys::None) - Input::Keyboard->OnKeyUp(key); + Input::Keyboard->OnKeyUp(key, Window); +} + +- (void)flagsChanged:(NSEvent*)event +{ + int32 modMask; + int32 keyCode = [event keyCode]; + if (keyCode == 0x36 || keyCode == 0x37) + modMask = NSEventModifierFlagCommand; + else if (keyCode == 0x38 || keyCode == 0x3c) + modMask = NSEventModifierFlagShift; + else if (keyCode == 0x3a || keyCode == 0x3d) + modMask = NSEventModifierFlagOption; + else if (keyCode == 0x3b || keyCode == 0x3e) + modMask = NSEventModifierFlagControl; + else + return; + KeyboardKeys key = GetKey(event); + if (key != KeyboardKeys::None) + { + int32 modifierFlags = [event modifierFlags]; + if ((modifierFlags & modMask) == modMask) + Input::Keyboard->OnKeyDown(key, Window); + else + Input::Keyboard->OnKeyUp(key, Window); + } } - (void)scrollWheel:(NSEvent*)event @@ -643,7 +668,6 @@ MacWindow::MacWindow(const CreateWindowSettings& settings) // TODO: impl StartPosition for MacWindow // TODO: impl Fullscreen for MacWindow // TODO: impl ShowInTaskbar for MacWindow - // TODO: impl AllowInput for MacWindow // TODO: impl IsTopmost for MacWindow } diff --git a/Source/Platforms/Mac/Binaries/ThirdParty/ARM64/libNvCloth.a b/Source/Platforms/Mac/Binaries/ThirdParty/ARM64/libNvCloth.a new file mode 100644 index 000000000..569db20de --- /dev/null +++ b/Source/Platforms/Mac/Binaries/ThirdParty/ARM64/libNvCloth.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ac9b222da70871221c00cb4a143ae9a6400244e92f321f2cc1313aa999f9bc9 +size 301400 diff --git a/Source/Platforms/Mac/Binaries/ThirdParty/x64/libNvCloth.a b/Source/Platforms/Mac/Binaries/ThirdParty/x64/libNvCloth.a new file mode 100644 index 000000000..69e23cabf --- /dev/null +++ b/Source/Platforms/Mac/Binaries/ThirdParty/x64/libNvCloth.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8ca814f6aae7ee644da11440dfa5dacc0c70cb8ca25f6de70f6e6983f36bb907 +size 367504 diff --git a/Source/Platforms/iOS/Binaries/ThirdParty/ARM64/libNvCloth.a b/Source/Platforms/iOS/Binaries/ThirdParty/ARM64/libNvCloth.a new file mode 100644 index 000000000..63187c05f --- /dev/null +++ b/Source/Platforms/iOS/Binaries/ThirdParty/ARM64/libNvCloth.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a5257892706e3ec0360fc4a323f09c0b30fa3991f4b9d4bce56a77f2b5fe0eb6 +size 300696 diff --git a/Source/ThirdParty/NvCloth/NvCloth.Build.cs b/Source/ThirdParty/NvCloth/NvCloth.Build.cs index ea2bc02c8..3be1e903e 100644 --- a/Source/ThirdParty/NvCloth/NvCloth.Build.cs +++ b/Source/ThirdParty/NvCloth/NvCloth.Build.cs @@ -35,6 +35,8 @@ public class NvCloth : DepsModule case TargetPlatform.PS4: case TargetPlatform.PS5: case TargetPlatform.Android: + case TargetPlatform.Mac: + case TargetPlatform.iOS: libName = "NvCloth"; break; case TargetPlatform.Switch: diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs b/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs index 7288add63..b096eef24 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs @@ -82,6 +82,13 @@ namespace Flax.Deps.Dependencies case TargetPlatform.Android: Build(options, platform, TargetArchitecture.ARM64); break; + case TargetPlatform.Mac: + Build(options, platform, TargetArchitecture.x64); + Build(options, platform, TargetArchitecture.ARM64); + break; + case TargetPlatform.iOS: + Build(options, platform, TargetArchitecture.ARM64); + break; } } @@ -140,6 +147,16 @@ namespace Flax.Deps.Dependencies envVars.Add("PM_ANDROIDNDK_PATH", AndroidNdk.Instance.RootPath); } break; + case TargetPlatform.Mac: + cmakeArgs += " -DTARGET_BUILD_PLATFORM=mac"; + cmakeName = "mac"; + binariesPrefix = "lib"; + break; + case TargetPlatform.iOS: + cmakeArgs += " -DTARGET_BUILD_PLATFORM=ios"; + cmakeName = "ios"; + binariesPrefix = "lib"; + break; default: throw new InvalidPlatformException(platform); } var cmakeFolder = Path.Combine(nvCloth, "compiler", "cmake", cmakeName);