From 7295a4adf17954a3c9b45d9be26d03c4b765f5c2 Mon Sep 17 00:00:00 2001 From: Vincent Dondain Date: Fri, 14 Jul 2017 17:16:24 -0400 Subject: [PATCH 1/6] [spritekit] Update for Xcode 9 beta 1, 2 & 3 - Added Quaternion support to XI runtime (simd_quatf). --- Make.config | 2 +- runtime/bindings-generator.cs | 39 ++++ runtime/bindings.h | 6 + src/SpriteKit/Enums.cs | 11 ++ src/spritekit.cs | 176 ++++++++++++++---- tests/introspection/iOS/iOSApiSelectorTest.cs | 3 +- tests/monotouch-test/Asserts.cs | 8 + .../SpriteKit/SKTransformNodeTest.cs | 72 +++++++ tests/monotouch-test/monotouch-test.csproj | 1 + 9 files changed, 284 insertions(+), 34 deletions(-) create mode 100644 tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs diff --git a/Make.config b/Make.config index ae58e0c841b6..f1ee080cf401 100644 --- a/Make.config +++ b/Make.config @@ -60,7 +60,7 @@ MIN_MONO_URL=https://bosstoragemirror.blob.core.windows.net/wrench/mono-2017-04/ # Minimum Visual Studio version MIN_VISUAL_STUDIO_URL=https://bosstoragemirror.blob.core.windows.net/wrench/monodevelop-lion-dogfood-vNext/8f/8f1c13cb983138ee63bd53e09908ea5e737988cd/VisualStudioForMac-Preview-7.0.0.2728.dmg MIN_VISUAL_STUDIO_VERSION=7.0.0.2728 -MAX_VISUAL_STUDIO_VERSION=7.2.99 +MAX_VISUAL_STUDIO_VERSION=7.3.99 # Minimum CMake version MIN_CMAKE_URL=https://cmake.org/files/v3.6/cmake-3.6.2-Darwin-x86_64.dmg diff --git a/runtime/bindings-generator.cs b/runtime/bindings-generator.cs index 8e46f9955588..3c409bf488b1 100644 --- a/runtime/bindings-generator.cs +++ b/runtime/bindings-generator.cs @@ -1444,6 +1444,26 @@ static IEnumerable GetFunctionData () } ); + data.Add ( + new FunctionData { + Comment = " // Quaternion func ()", + Prefix = "simd__", + Variants = Variants.All, + ReturnType = Types.QuatF, + } + ); + + data.Add ( + new FunctionData { + Comment = " // void func (Quaternion)", + Prefix = "simd__", + Variants = Variants.NonStret, + Parameters = new ParameterData[] { + new ParameterData { TypeData = Types.QuatF }, + }, + } + ); + // Required for ModelIO data.Add ( new FunctionData { @@ -1994,6 +2014,12 @@ static void MarshalToManaged (StringWriter writer, TypeData type, string nativeV writer.WriteLine ("\t\t{0}.points [i].c = {1}.points [i] [2];", managedVariable, nativeVariable); writer.WriteLine ("\t}"); break; + case "Quaternion": + writer.WriteLine ("\t{0}.vector.a = {1}.vector [0];", managedVariable, nativeVariable); + writer.WriteLine ("\t{0}.vector.b = {1}.vector [1];", managedVariable, nativeVariable); + writer.WriteLine ("\t{0}.vector.c = {1}.vector [2];", managedVariable, nativeVariable); + writer.WriteLine ("\t{0}.vector.d = {1}.vector [3];", managedVariable, nativeVariable); + break; default: throw new NotImplementedException (string.Format ("MarshalToManaged for: NativeType: {0} ManagedType: {1}", type.NativeType, type.ManagedType)); } @@ -2081,6 +2107,12 @@ static void MarshalToNative (StringWriter writer, TypeData type, string nativeVa writer.WriteLine ("\t\t{0}.points [i][2] = {1}.points [i].c;", nativeVariable, managedVariable); writer.WriteLine ("\t}"); break; + case "Quaternion": + writer.WriteLine ("\t{0}.vector [0] = {1}.vector.a;", nativeVariable, managedVariable); + writer.WriteLine ("\t{0}.vector [1] = {1}.vector.b;", nativeVariable, managedVariable); + writer.WriteLine ("\t{0}.vector [2] = {1}.vector.c;", nativeVariable, managedVariable); + writer.WriteLine ("\t{0}.vector [3] = {1}.vector.d;", nativeVariable, managedVariable); + break; default: throw new NotImplementedException (string.Format ("MarshalToNative for: NativeType: {0} ManagedType: {1}", type.NativeType, type.ManagedType)); } @@ -2658,6 +2690,13 @@ public static class Types { NativeWrapperType = "CGSize", RequireMarshal = false, }; + + public static TypeData QuatF = new TypeData { + ManagedType = "Quaternion", + NativeType = "simd_quatf", + NativeWrapperType = "struct QuatF", + RequireMarshal = true, + }; } } diff --git a/runtime/bindings.h b/runtime/bindings.h index fd91e261a072..d8e07b3fb5d1 100644 --- a/runtime/bindings.h +++ b/runtime/bindings.h @@ -83,6 +83,8 @@ typedef struct { vector_float2 columns[2]; } matrix_float2x2; typedef struct { vector_float3 columns[3]; } matrix_float3x3; typedef struct { vector_float4 columns[4]; } matrix_float4x4; +typedef struct { vector_float4 vector; } simd_quatf; + typedef struct { vector_float3 maxBounds; vector_float3 minBounds; @@ -149,6 +151,10 @@ struct Matrix4f { Vector4f columns [4]; }; +struct QuatF { + Vector4f vector; +}; + struct MDLAxisAlignedBoundingBoxWrapper { Vector3f maxBounds; Vector3f minBounds; diff --git a/src/SpriteKit/Enums.cs b/src/SpriteKit/Enums.cs index 3ca62af8ec74..417b29cb9b2a 100644 --- a/src/SpriteKit/Enums.cs +++ b/src/SpriteKit/Enums.cs @@ -183,4 +183,15 @@ public enum SKTileAdjacencyMask : nuint LowerLeftCorner = Up | Right | LowerRight | Down | LowerLeft | Left | UpperLeft, UpperLeftCorner = Up | UpperRight | Right | Down | LowerLeft | Left | UpperLeft, } + + [NoWatch] + [NoMac] + [TV (11,0), iOS (11,0)] + [Native] + public enum SKNodeFocusBehavior : nint + { + None = 0, + Occluding, + Focusable, + } } diff --git a/src/spritekit.cs b/src/spritekit.cs index b91288a64d06..6f8b064173b4 100644 --- a/src/spritekit.cs +++ b/src/spritekit.cs @@ -21,6 +21,9 @@ using XamCore.CoreGraphics; using XamCore.CoreVideo; using XamCore.SceneKit; +#if !WATCH +using XamCore.Metal; +#endif using Vector2 = global::OpenTK.Vector2; using Vector3 = global::OpenTK.Vector3; @@ -28,6 +31,7 @@ using Matrix3 = global::OpenTK.Matrix3; using Matrix4 = global::OpenTK.Matrix4; using Vector4 = global::OpenTK.Vector4; +using Quaternion = global::OpenTK.Quaternion; #if MONOMAC using XamCore.AppKit; @@ -37,6 +41,7 @@ using pfloat = System.nfloat; #else using XamCore.UIKit; +using NSLineBreakMode = global::XamCore.UIKit.UILineBreakMode; using pfloat = System.Single; #if !WATCH using UIView = global::XamCore.UIKit.UIView; @@ -51,6 +56,11 @@ interface AVPlayer {} interface CIFilter {} interface GKPolygonObstacle {} interface UIView {} + interface IMTLCommandBuffer {} + interface IMTLCommandQueue {} + interface IMTLDevice {} + interface IMTLRenderCommandEncoder {} + interface MTLRenderPassDescriptor {} #endif delegate void SKNodeChildEnumeratorHandler (SKNode node, out bool stop); @@ -166,6 +176,12 @@ partial interface SKNode : NSCoding, NSCopying { [Export ("userInteractionEnabled")] bool UserInteractionEnabled { [Bind ("isUserInteractionEnabled")] get; set; } + [NoWatch] + [NoMac] + [TV (11,0), iOS (11,0)] + [Export ("focusBehavior", ArgumentSemantic.Assign)] + SKNodeFocusBehavior FocusBehavior { get; set; } + [Export ("parent")] SKNode Parent { get; } @@ -1182,12 +1198,29 @@ partial interface SKLabelNode { [Static, Export ("labelNodeWithText:")] SKLabelNode FromText ([NullAllowed] string text); + [TV (11,0), Watch (4,0), Mac (13,0), iOS (11,0)] + [Static] + [Export ("labelNodeWithAttributedText:")] + SKLabelNode FromText ([NullAllowed] NSAttributedString attributedText); + [Export ("verticalAlignmentMode")] SKLabelVerticalAlignmentMode VerticalAlignmentMode { get; set; } [Export ("horizontalAlignmentMode")] SKLabelHorizontalAlignmentMode HorizontalAlignmentMode { get; set; } + [TV (11,0), Watch (4,0), Mac (13,0), iOS (11,0)] + [Export ("numberOfLines")] + nint NumberOfLines { get; set; } + + [TV (11,0), Watch (4,0), Mac (13,0), iOS (11,0)] + [Export ("lineBreakMode", ArgumentSemantic.Assign)] + NSLineBreakMode LineBreakMode { get; set; } + + [TV (11,0), Watch (4,0), Mac (13,0), iOS (11,0)] + [Export ("preferredMaxLayoutWidth")] + nfloat PreferredMaxLayoutWidth { get; set; } + [Export ("fontName", ArgumentSemantic.Copy)] string FontName { get; set; } @@ -1195,6 +1228,10 @@ partial interface SKLabelNode { [NullAllowed] // nullable in Xcode7 headers and caught by introspection tests string Text { get; set; } + [TV (11,0), Watch (4,0), Mac (13,0), iOS (11,0)] + [NullAllowed, Export ("attributedText", ArgumentSemantic.Copy)] + NSAttributedString AttributedText { get; set; } + [Export ("fontSize")] nfloat FontSize { get; set; } @@ -1954,28 +1991,28 @@ partial interface SKAction : NSCoding, NSCopying { // These are in a category [Static, Export ("moveByX:y:duration:")] - SKAction MoveBy (nfloat deltaX, nfloat deltaY, double sec); + SKAction MoveBy (nfloat deltaX, nfloat deltaY, double duration); [Static, Export ("moveBy:duration:")] SKAction MoveBy (CGVector delta, double duration); [Static, Export ("moveTo:duration:")] - SKAction MoveTo (CGPoint location, double sec); + SKAction MoveTo (CGPoint location, double duration); [Static, Export ("moveToX:duration:")] - SKAction MoveToX (nfloat x, double sec); + SKAction MoveToX (nfloat x, double duration); [Static, Export ("moveToY:duration:")] - SKAction MoveToY (nfloat y, double sec); + SKAction MoveToY (nfloat y, double duration); [Static, Export ("rotateByAngle:duration:")] - SKAction RotateByAngle (nfloat radians, double sec); + SKAction RotateByAngle (nfloat radians, double duration); [Static, Export ("rotateToAngle:duration:")] - SKAction RotateToAngle (nfloat radians, double sec); + SKAction RotateToAngle (nfloat radians, double duration); [Static, Export ("rotateToAngle:duration:shortestUnitArc:")] - SKAction RotateToAngle (nfloat radians, double sec, bool shortedUnitArc); + SKAction RotateToAngle (nfloat radians, double duration, bool shortedUnitArc); [Static, Export ("resizeByWidth:height:duration:")] SKAction ResizeByWidth (nfloat width, nfloat height, double duration); @@ -1990,28 +2027,28 @@ partial interface SKAction : NSCoding, NSCopying { SKAction ResizeToHeight (nfloat height, double duration); [Static, Export ("scaleBy:duration:")] - SKAction ScaleBy (nfloat scale, double sec); + SKAction ScaleBy (nfloat scale, double duration); [Static, Export ("scaleXBy:y:duration:")] - SKAction ScaleBy (nfloat xScale, nfloat yScale, double sec); + SKAction ScaleBy (nfloat xScale, nfloat yScale, double duration); [Static, Export ("scaleTo:duration:")] - SKAction ScaleTo (nfloat scale, double sec); + SKAction ScaleTo (nfloat scale, double duration); [Static, Export ("scaleXTo:y:duration:")] - SKAction ScaleTo (nfloat xScale, nfloat yScale, double sec); + SKAction ScaleTo (nfloat xScale, nfloat yScale, double duration); [Static, Export ("scaleXTo:duration:")] - SKAction ScaleXTo (nfloat scale, double sec); + SKAction ScaleXTo (nfloat scale, double duration); [Static, Export ("scaleYTo:duration:")] - SKAction ScaleYTo (nfloat scale, double sec); + SKAction ScaleYTo (nfloat scale, double duration); [iOS (10,0)][Mac (10,12)] [TV (10,0)] [Static] [Export ("scaleToSize:duration:")] - SKAction ScaleTo (CGSize size, double sec); + SKAction ScaleTo (CGSize size, double duration); [Static, Export ("sequence:")] SKAction Sequence ([Params] SKAction [] actions); @@ -2026,16 +2063,16 @@ partial interface SKAction : NSCoding, NSCopying { SKAction RepeatActionForever (SKAction action); [Static, Export ("fadeInWithDuration:")] - SKAction FadeInWithDuration (double sec); + SKAction FadeInWithDuration (double duration); [Static, Export ("fadeOutWithDuration:")] - SKAction FadeOutWithDuration (double sec); + SKAction FadeOutWithDuration (double duration); [Static, Export ("fadeAlphaBy:duration:")] - SKAction FadeAlphaBy (nfloat factor, double sec); + SKAction FadeAlphaBy (nfloat factor, double duration); [Static, Export ("fadeAlphaTo:duration:")] - SKAction FadeAlphaTo (nfloat alpha, double sec); + SKAction FadeAlphaTo (nfloat alpha, double duration); [iOS (7,1), Mac (10,10)] [Static, Export ("setTexture:")] @@ -2055,16 +2092,16 @@ partial interface SKAction : NSCoding, NSCopying { SKAction PlaySoundFileNamed (string soundFile, bool wait); [Static, Export ("colorizeWithColor:colorBlendFactor:duration:")] - SKAction ColorizeWithColor (UIColor color, nfloat colorBlendFactor, double sec); + SKAction ColorizeWithColor (UIColor color, nfloat colorBlendFactor, double duration); [Static, Export ("colorizeWithColorBlendFactor:duration:")] - SKAction ColorizeWithColorBlendFactor (nfloat colorBlendFactor, double sec); + SKAction ColorizeWithColorBlendFactor (nfloat colorBlendFactor, double duration); [Static, Export ("followPath:duration:")] - SKAction FollowPath (CGPath path, double sec); + SKAction FollowPath (CGPath path, double duration); [Static, Export ("followPath:asOffset:orientToPath:duration:")] - SKAction FollowPath (CGPath path, bool offset, bool orient, double sec); + SKAction FollowPath (CGPath path, bool offset, bool orient, double duration); [iOS (8,0), Mac (10,10)] // this method is missing the NS_AVAILABLE macro, but it shows up in the 10.10 sdk, but not the 10.9 sdk. [Static, Export ("followPath:speed:")] @@ -2075,16 +2112,16 @@ partial interface SKAction : NSCoding, NSCopying { SKAction FollowPath (CGPath path, bool offset, bool orient, nfloat speed); [Static, Export ("speedBy:duration:")] - SKAction SpeedBy (nfloat speed, double sec); + SKAction SpeedBy (nfloat speed, double duration); [Static, Export ("speedTo:duration:")] - SKAction SpeedTo (nfloat speed, double sec); + SKAction SpeedTo (nfloat speed, double duration); [Static, Export ("waitForDuration:")] - SKAction WaitForDuration (double sec); + SKAction WaitForDuration (double duration); [Static, Export ("waitForDuration:withRange:")] - SKAction WaitForDuration (double sec, double durationRange); + SKAction WaitForDuration (double duration, double durationRange); [Static, Export ("removeFromParent")] SKAction RemoveFromParent (); @@ -2102,7 +2139,7 @@ partial interface SKAction : NSCoding, NSCopying { SKAction RunAction (SKAction action, string name); [Static, Export ("customActionWithDuration:actionBlock:")] - SKAction CustomActionWithDuration (double seconds, SKActionDurationHandler actionHandler); + SKAction CustomActionWithDuration (double duration, SKActionDurationHandler actionHandler); // // iOS 8 cluster (a few more are above, as part of their family @@ -2117,7 +2154,7 @@ partial interface SKAction : NSCoding, NSCopying { [iOS (8,0), Mac(10,10)] [Static, Export ("reachTo:rootNode:duration:")] - SKAction ReachTo (CGPoint position, SKNode rootNode, double secs); + SKAction ReachTo (CGPoint position, SKNode rootNode, double duration); [iOS (8,0), Mac(10,10)] [Static, Export ("reachTo:rootNode:velocity:")] @@ -2125,7 +2162,7 @@ partial interface SKAction : NSCoding, NSCopying { [iOS (8,0), Mac(10,10)] [Static, Export ("reachToNode:rootNode:duration:")] - SKAction ReachToNode (SKNode node, SKNode rootNode, double sec); + SKAction ReachToNode (SKNode node, SKNode rootNode, double duration); [iOS (8,0), Mac(10,10)] [Static, Export ("reachToNode:rootNode:velocity:")] @@ -2133,11 +2170,11 @@ partial interface SKAction : NSCoding, NSCopying { [iOS (8,0), Mac (10,10)] // this method is missing the NS_AVAILABLE macro, but it shows up in the 10.10 sdk, but not the 10.9 sdk. [Static, Export ("strengthTo:duration:")] - SKAction StrengthTo (float /* float, not CGFloat */ strength, double sec); + SKAction StrengthTo (float /* float, not CGFloat */ strength, double duration); [iOS (8,0), Mac (10,10)] // this method is missing the NS_AVAILABLE macro, but it shows up in the 10.10 sdk, but not the 10.9 sdk. [Static, Export ("strengthBy:duration:")] - SKAction StrengthBy (float /* float, not CGFloat */ strength, double sec); + SKAction StrengthBy (float /* float, not CGFloat */ strength, double duration); [iOS (8,0), Mac (10,10)] [NullAllowed, Export ("timingFunction", ArgumentSemantic.Assign)] @@ -2150,7 +2187,7 @@ partial interface SKAction : NSCoding, NSCopying { [iOS (8,0), Mac(10,10)] [Static] [Export ("falloffTo:duration:")] - SKAction FalloffTo (float falloff, double sec); + SKAction FalloffTo (float falloff, double duration); // iOS 9 cluster [iOS (9,0)][Mac (10,11, onlyOn64 : true)] @@ -3223,5 +3260,80 @@ interface SKWarpGeometryGrid : NSCoding [Export ("gridByReplacingDestPositions:")] SKWarpGeometryGrid _GridByReplacingDestPositions (IntPtr destPositions); } + + // SKRenderer is not available for WatchKit apps and the iOS simulator + [NoWatch] + [TV (11,0), Mac (10,13), iOS (11,0)] + [BaseType (typeof(NSObject))] + [DisableDefaultCtor] + interface SKRenderer + { + [Static] + [Export ("rendererWithDevice:")] + [return: NullAllowed] + SKRenderer FromDevice ([NullAllowed] IMTLDevice device); + + [Export ("renderWithViewport:commandBuffer:renderPassDescriptor:")] + void Render (CGRect viewport, IMTLCommandBuffer commandBuffer, MTLRenderPassDescriptor renderPassDescriptor); + + [Export ("renderWithViewport:renderCommandEncoder:renderPassDescriptor:commandQueue:")] + void Render (CGRect viewport, IMTLRenderCommandEncoder renderCommandEncoder, MTLRenderPassDescriptor renderPassDescriptor, IMTLCommandQueue commandQueue); + + [Export ("updateAtTime:")] + void UpdateAtTime (double currentTime); + + [NullAllowed, Export ("scene", ArgumentSemantic.Assign)] + SKScene Scene { get; set; } + + [Export ("ignoresSiblingOrder")] + bool IgnoresSiblingOrder { get; set; } + + [Export ("shouldCullNonVisibleNodes")] + bool ShouldCullNonVisibleNodes { get; set; } + + [Export ("showsDrawCount")] + bool ShowsDrawCount { get; set; } + + [Export ("showsNodeCount")] + bool ShowsNodeCount { get; set; } + + [Export ("showsQuadCount")] + bool ShowsQuadCount { get; set; } + + [Export ("showsPhysics")] + bool ShowsPhysics { get; set; } + + [Export ("showsFields")] + bool ShowsFields { get; set; } + } + + [TV (11,0), Watch (4,0), Mac (13,0), iOS (11,0)] + [BaseType (typeof(SKNode))] + interface SKTransformNode + { + [Export ("xRotation")] + nfloat XRotation { get; set; } + + [Export ("yRotation")] + nfloat YRotation { get; set; } + + [Export ("eulerAngles")] + Vector3 EulerAngles { + [MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] get; + [MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] set; + } + + [Export ("rotationMatrix")] + Matrix3 RotationMatrix { + [MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] get; + [MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] set; + } + + [Export ("quaternion")] + Quaternion Quaternion { + [MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] get; + [MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] set; + } + } } #endif diff --git a/tests/introspection/iOS/iOSApiSelectorTest.cs b/tests/introspection/iOS/iOSApiSelectorTest.cs index ba705baac34a..69b393522929 100644 --- a/tests/introspection/iOS/iOSApiSelectorTest.cs +++ b/tests/introspection/iOS/iOSApiSelectorTest.cs @@ -92,8 +92,9 @@ protected override bool Skip (Type type) case "UILocalNotification": return true; - // Metal is not available on the (iOS8) simulator + // Metal is not available on the simulator case "CAMetalLayer": + case "SKRenderer": return (Runtime.Arch == Arch.SIMULATOR); // iOS 10 - this type can only be instantiated on devices, but the selectors are forwarded diff --git a/tests/monotouch-test/Asserts.cs b/tests/monotouch-test/Asserts.cs index 8d468eb504c5..fe3d7c325158 100644 --- a/tests/monotouch-test/Asserts.cs +++ b/tests/monotouch-test/Asserts.cs @@ -83,6 +83,14 @@ public static void AreEqual (MDLAxisAlignedBoundingBox expected, MDLAxisAlignedB AreEqual (expected.MaxBounds, actual.MaxBounds, message + " (MaxBounds)"); AreEqual (expected.MinBounds, actual.MinBounds, message + " (MinBounds)"); } + + public static void AreEqual (Quaternion expected, Quaternion actual, string message) + { + Assert.AreEqual (expected.X, actual.X, message + " (X)"); + Assert.AreEqual (expected.Y, actual.Y, message + " (Y)"); + Assert.AreEqual (expected.Z, actual.Z, message + " (Z)"); + Assert.AreEqual (expected.W, actual.W, message + " (W)"); + } #endif // !__WATCHOS__ } diff --git a/tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs b/tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs new file mode 100644 index 000000000000..271e05b44c76 --- /dev/null +++ b/tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs @@ -0,0 +1,72 @@ + +using System; +#if XAMCORE_2_0 +using Foundation; +#if !MONOMAC +using UIKit; +#endif +using SpriteKit; +using ObjCRuntime; +#else +using MonoTouch.Foundation; +using MonoTouch.SpriteKit; +using MonoTouch.UIKit; +using MonoTouch.ObjCRuntime; +#endif +using OpenTK; +using NUnit.Framework; + +namespace MonoTouchFixtures.SpriteKit { + + [TestFixture] + [Preserve (AllMembers = true)] + public class SKTransformNodeTest { + [SetUp] + public void VersionCheck () + { + if (!TestRuntime.CheckXcodeVersion (9,0)) + Assert.Inconclusive ("Requires Xcode9+"); + } + + [Test] + public void EulerAngles () + { + Vector3 V3; + + using (var obj = new SKTransformNode ()) + { + Asserts.AreEqual (Vector3.Zero, obj.EulerAngles, "1 EulerAngles"); + V3 = new Vector3 (1, 2, 3); + obj.EulerAngles = V3; + Assert.AreEqual (-2.14159298f, obj.EulerAngles.X, "#x1"); + Assert.AreEqual (1.14159274f, obj.EulerAngles.Y, "#y1"); + Assert.AreEqual (-0.141592711f, obj.EulerAngles.Z, "#z1"); + } + } + + [Test] + public void RotationMatrix () + { + using (var obj = new SKTransformNode ()) + { + obj.RotationMatrix = Matrix3.Zero; + Asserts.AreEqual (Matrix3.Identity, obj.RotationMatrix, "RotationMatrix"); + } + } + + [Test] + public void QuaternionTest () + { + Quaternion Q; + + using (var obj = new SKTransformNode ()) + { + Asserts.AreEqual (Quaternion.Identity, obj.Quaternion, "1 Quaternion"); + Q = new Quaternion (new Vector3 (1, 2, 3), 4); + obj.Quaternion = Q; + Asserts.AreEqual (Q, obj.Quaternion, "2 Quaternion"); + } + } + } +} + diff --git a/tests/monotouch-test/monotouch-test.csproj b/tests/monotouch-test/monotouch-test.csproj index 53c53030c816..6bb0e3e9b6f9 100644 --- a/tests/monotouch-test/monotouch-test.csproj +++ b/tests/monotouch-test/monotouch-test.csproj @@ -657,6 +657,7 @@ + From 1af8b71f2a1d16f689c4321b09cb7448fbfea5c9 Mon Sep 17 00:00:00 2001 From: Vincent Dondain Date: Tue, 18 Jul 2017 11:59:38 -0400 Subject: [PATCH 2/6] [spritekit] Fixes based on comments --- Make.config | 2 +- runtime/bindings-generator.cs | 2 +- src/spritekit.cs | 64 +++++++++---------- .../SpriteKit/SKTransformNodeTest.cs | 12 ++-- 4 files changed, 38 insertions(+), 42 deletions(-) diff --git a/Make.config b/Make.config index f1ee080cf401..ae58e0c841b6 100644 --- a/Make.config +++ b/Make.config @@ -60,7 +60,7 @@ MIN_MONO_URL=https://bosstoragemirror.blob.core.windows.net/wrench/mono-2017-04/ # Minimum Visual Studio version MIN_VISUAL_STUDIO_URL=https://bosstoragemirror.blob.core.windows.net/wrench/monodevelop-lion-dogfood-vNext/8f/8f1c13cb983138ee63bd53e09908ea5e737988cd/VisualStudioForMac-Preview-7.0.0.2728.dmg MIN_VISUAL_STUDIO_VERSION=7.0.0.2728 -MAX_VISUAL_STUDIO_VERSION=7.3.99 +MAX_VISUAL_STUDIO_VERSION=7.2.99 # Minimum CMake version MIN_CMAKE_URL=https://cmake.org/files/v3.6/cmake-3.6.2-Darwin-x86_64.dmg diff --git a/runtime/bindings-generator.cs b/runtime/bindings-generator.cs index 3c409bf488b1..05549d4b1dc8 100644 --- a/runtime/bindings-generator.cs +++ b/runtime/bindings-generator.cs @@ -1458,7 +1458,7 @@ static IEnumerable GetFunctionData () Comment = " // void func (Quaternion)", Prefix = "simd__", Variants = Variants.NonStret, - Parameters = new ParameterData[] { + Parameters = new ParameterData [] { new ParameterData { TypeData = Types.QuatF }, }, } diff --git a/src/spritekit.cs b/src/spritekit.cs index 6f8b064173b4..88bb5dc0e782 100644 --- a/src/spritekit.cs +++ b/src/spritekit.cs @@ -1991,64 +1991,64 @@ partial interface SKAction : NSCoding, NSCopying { // These are in a category [Static, Export ("moveByX:y:duration:")] - SKAction MoveBy (nfloat deltaX, nfloat deltaY, double duration); + SKAction MoveBy (nfloat deltaX, nfloat deltaY, double sec); [Static, Export ("moveBy:duration:")] - SKAction MoveBy (CGVector delta, double duration); + SKAction MoveBy (CGVector delta, double sec); [Static, Export ("moveTo:duration:")] - SKAction MoveTo (CGPoint location, double duration); + SKAction MoveTo (CGPoint location, double sec); [Static, Export ("moveToX:duration:")] - SKAction MoveToX (nfloat x, double duration); + SKAction MoveToX (nfloat x, double sec); [Static, Export ("moveToY:duration:")] - SKAction MoveToY (nfloat y, double duration); + SKAction MoveToY (nfloat y, double sec); [Static, Export ("rotateByAngle:duration:")] - SKAction RotateByAngle (nfloat radians, double duration); + SKAction RotateByAngle (nfloat radians, double sec); [Static, Export ("rotateToAngle:duration:")] - SKAction RotateToAngle (nfloat radians, double duration); + SKAction RotateToAngle (nfloat radians, double sec); [Static, Export ("rotateToAngle:duration:shortestUnitArc:")] - SKAction RotateToAngle (nfloat radians, double duration, bool shortedUnitArc); + SKAction RotateToAngle (nfloat radians, double sec, bool shortedUnitArc); [Static, Export ("resizeByWidth:height:duration:")] - SKAction ResizeByWidth (nfloat width, nfloat height, double duration); + SKAction ResizeByWidth (nfloat width, nfloat height, double sec); [Static, Export ("resizeToWidth:height:duration:")] - SKAction ResizeTo (nfloat width, nfloat height, double duration); + SKAction ResizeTo (nfloat width, nfloat height, double sec); [Static, Export ("resizeToWidth:duration:")] - SKAction ResizeToWidth (nfloat width, double duration); + SKAction ResizeToWidth (nfloat width, double sec); [Static, Export ("resizeToHeight:duration:")] - SKAction ResizeToHeight (nfloat height, double duration); + SKAction ResizeToHeight (nfloat height, double sec); [Static, Export ("scaleBy:duration:")] - SKAction ScaleBy (nfloat scale, double duration); + SKAction ScaleBy (nfloat scale, double sec); [Static, Export ("scaleXBy:y:duration:")] - SKAction ScaleBy (nfloat xScale, nfloat yScale, double duration); + SKAction ScaleBy (nfloat xScale, nfloat yScale, double sec); [Static, Export ("scaleTo:duration:")] - SKAction ScaleTo (nfloat scale, double duration); + SKAction ScaleTo (nfloat scale, double sec); [Static, Export ("scaleXTo:y:duration:")] - SKAction ScaleTo (nfloat xScale, nfloat yScale, double duration); + SKAction ScaleTo (nfloat xScale, nfloat yScale, double sec); [Static, Export ("scaleXTo:duration:")] - SKAction ScaleXTo (nfloat scale, double duration); + SKAction ScaleXTo (nfloat scale, double sec); [Static, Export ("scaleYTo:duration:")] - SKAction ScaleYTo (nfloat scale, double duration); + SKAction ScaleYTo (nfloat scale, double sec); [iOS (10,0)][Mac (10,12)] [TV (10,0)] [Static] [Export ("scaleToSize:duration:")] - SKAction ScaleTo (CGSize size, double duration); + SKAction ScaleTo (CGSize size, double sec); [Static, Export ("sequence:")] SKAction Sequence ([Params] SKAction [] actions); @@ -2063,16 +2063,16 @@ partial interface SKAction : NSCoding, NSCopying { SKAction RepeatActionForever (SKAction action); [Static, Export ("fadeInWithDuration:")] - SKAction FadeInWithDuration (double duration); + SKAction FadeInWithDuration (double sec); [Static, Export ("fadeOutWithDuration:")] - SKAction FadeOutWithDuration (double duration); + SKAction FadeOutWithDuration (double sec); [Static, Export ("fadeAlphaBy:duration:")] - SKAction FadeAlphaBy (nfloat factor, double duration); + SKAction FadeAlphaBy (nfloat factor, double sec); [Static, Export ("fadeAlphaTo:duration:")] - SKAction FadeAlphaTo (nfloat alpha, double duration); + SKAction FadeAlphaTo (nfloat alpha, double sec); [iOS (7,1), Mac (10,10)] [Static, Export ("setTexture:")] @@ -2092,16 +2092,16 @@ partial interface SKAction : NSCoding, NSCopying { SKAction PlaySoundFileNamed (string soundFile, bool wait); [Static, Export ("colorizeWithColor:colorBlendFactor:duration:")] - SKAction ColorizeWithColor (UIColor color, nfloat colorBlendFactor, double duration); + SKAction ColorizeWithColor (UIColor color, nfloat colorBlendFactor, double sec); [Static, Export ("colorizeWithColorBlendFactor:duration:")] - SKAction ColorizeWithColorBlendFactor (nfloat colorBlendFactor, double duration); + SKAction ColorizeWithColorBlendFactor (nfloat colorBlendFactor, double sec); [Static, Export ("followPath:duration:")] - SKAction FollowPath (CGPath path, double duration); + SKAction FollowPath (CGPath path, double sec); [Static, Export ("followPath:asOffset:orientToPath:duration:")] - SKAction FollowPath (CGPath path, bool offset, bool orient, double duration); + SKAction FollowPath (CGPath path, bool offset, bool orient, double sec); [iOS (8,0), Mac (10,10)] // this method is missing the NS_AVAILABLE macro, but it shows up in the 10.10 sdk, but not the 10.9 sdk. [Static, Export ("followPath:speed:")] @@ -2112,16 +2112,16 @@ partial interface SKAction : NSCoding, NSCopying { SKAction FollowPath (CGPath path, bool offset, bool orient, nfloat speed); [Static, Export ("speedBy:duration:")] - SKAction SpeedBy (nfloat speed, double duration); + SKAction SpeedBy (nfloat speed, double sec); [Static, Export ("speedTo:duration:")] - SKAction SpeedTo (nfloat speed, double duration); + SKAction SpeedTo (nfloat speed, double sec); [Static, Export ("waitForDuration:")] - SKAction WaitForDuration (double duration); + SKAction WaitForDuration (double sec); [Static, Export ("waitForDuration:withRange:")] - SKAction WaitForDuration (double duration, double durationRange); + SKAction WaitForDuration (double sec, double durationRange); [Static, Export ("removeFromParent")] SKAction RemoveFromParent (); @@ -2139,7 +2139,7 @@ partial interface SKAction : NSCoding, NSCopying { SKAction RunAction (SKAction action, string name); [Static, Export ("customActionWithDuration:actionBlock:")] - SKAction CustomActionWithDuration (double duration, SKActionDurationHandler actionHandler); + SKAction CustomActionWithDuration (double sec, SKActionDurationHandler actionHandler); // // iOS 8 cluster (a few more are above, as part of their family diff --git a/tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs b/tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs index 271e05b44c76..fcab6a14a91e 100644 --- a/tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs +++ b/tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs @@ -24,8 +24,7 @@ public class SKTransformNodeTest { [SetUp] public void VersionCheck () { - if (!TestRuntime.CheckXcodeVersion (9,0)) - Assert.Inconclusive ("Requires Xcode9+"); + TestRuntime.AssertXcodeVersion (9, 0); } [Test] @@ -33,8 +32,7 @@ public void EulerAngles () { Vector3 V3; - using (var obj = new SKTransformNode ()) - { + using (var obj = new SKTransformNode ()) { Asserts.AreEqual (Vector3.Zero, obj.EulerAngles, "1 EulerAngles"); V3 = new Vector3 (1, 2, 3); obj.EulerAngles = V3; @@ -47,8 +45,7 @@ public void EulerAngles () [Test] public void RotationMatrix () { - using (var obj = new SKTransformNode ()) - { + using (var obj = new SKTransformNode ()) { obj.RotationMatrix = Matrix3.Zero; Asserts.AreEqual (Matrix3.Identity, obj.RotationMatrix, "RotationMatrix"); } @@ -59,8 +56,7 @@ public void QuaternionTest () { Quaternion Q; - using (var obj = new SKTransformNode ()) - { + using (var obj = new SKTransformNode ()) { Asserts.AreEqual (Quaternion.Identity, obj.Quaternion, "1 Quaternion"); Q = new Quaternion (new Vector3 (1, 2, 3), 4); obj.Quaternion = Q; From 07df2b23a7b8f4456685b3bd8924fab16b89ea1c Mon Sep 17 00:00:00 2001 From: Vincent Dondain Date: Tue, 18 Jul 2017 12:05:24 -0400 Subject: [PATCH 3/6] [spritekit] Fixes based on comments (2) --- src/spritekit.cs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/spritekit.cs b/src/spritekit.cs index 88bb5dc0e782..370f717a9e14 100644 --- a/src/spritekit.cs +++ b/src/spritekit.cs @@ -1994,7 +1994,7 @@ partial interface SKAction : NSCoding, NSCopying { SKAction MoveBy (nfloat deltaX, nfloat deltaY, double sec); [Static, Export ("moveBy:duration:")] - SKAction MoveBy (CGVector delta, double sec); + SKAction MoveBy (CGVector delta, double duration); [Static, Export ("moveTo:duration:")] SKAction MoveTo (CGPoint location, double sec); @@ -2015,16 +2015,16 @@ partial interface SKAction : NSCoding, NSCopying { SKAction RotateToAngle (nfloat radians, double sec, bool shortedUnitArc); [Static, Export ("resizeByWidth:height:duration:")] - SKAction ResizeByWidth (nfloat width, nfloat height, double sec); + SKAction ResizeByWidth (nfloat width, nfloat height, double duration); [Static, Export ("resizeToWidth:height:duration:")] - SKAction ResizeTo (nfloat width, nfloat height, double sec); + SKAction ResizeTo (nfloat width, nfloat height, double duration); [Static, Export ("resizeToWidth:duration:")] - SKAction ResizeToWidth (nfloat width, double sec); + SKAction ResizeToWidth (nfloat width, double duration); [Static, Export ("resizeToHeight:duration:")] - SKAction ResizeToHeight (nfloat height, double sec); + SKAction ResizeToHeight (nfloat height, double duration); [Static, Export ("scaleBy:duration:")] SKAction ScaleBy (nfloat scale, double sec); @@ -2139,7 +2139,7 @@ partial interface SKAction : NSCoding, NSCopying { SKAction RunAction (SKAction action, string name); [Static, Export ("customActionWithDuration:actionBlock:")] - SKAction CustomActionWithDuration (double sec, SKActionDurationHandler actionHandler); + SKAction CustomActionWithDuration (double seconds, SKActionDurationHandler actionHandler); // // iOS 8 cluster (a few more are above, as part of their family @@ -2154,7 +2154,7 @@ partial interface SKAction : NSCoding, NSCopying { [iOS (8,0), Mac(10,10)] [Static, Export ("reachTo:rootNode:duration:")] - SKAction ReachTo (CGPoint position, SKNode rootNode, double duration); + SKAction ReachTo (CGPoint position, SKNode rootNode, double sec); [iOS (8,0), Mac(10,10)] [Static, Export ("reachTo:rootNode:velocity:")] @@ -2162,7 +2162,7 @@ partial interface SKAction : NSCoding, NSCopying { [iOS (8,0), Mac(10,10)] [Static, Export ("reachToNode:rootNode:duration:")] - SKAction ReachToNode (SKNode node, SKNode rootNode, double duration); + SKAction ReachToNode (SKNode node, SKNode rootNode, double sec); [iOS (8,0), Mac(10,10)] [Static, Export ("reachToNode:rootNode:velocity:")] @@ -2170,11 +2170,11 @@ partial interface SKAction : NSCoding, NSCopying { [iOS (8,0), Mac (10,10)] // this method is missing the NS_AVAILABLE macro, but it shows up in the 10.10 sdk, but not the 10.9 sdk. [Static, Export ("strengthTo:duration:")] - SKAction StrengthTo (float /* float, not CGFloat */ strength, double duration); + SKAction StrengthTo (float /* float, not CGFloat */ strength, double sec); [iOS (8,0), Mac (10,10)] // this method is missing the NS_AVAILABLE macro, but it shows up in the 10.10 sdk, but not the 10.9 sdk. [Static, Export ("strengthBy:duration:")] - SKAction StrengthBy (float /* float, not CGFloat */ strength, double duration); + SKAction StrengthBy (float /* float, not CGFloat */ strength, double sec); [iOS (8,0), Mac (10,10)] [NullAllowed, Export ("timingFunction", ArgumentSemantic.Assign)] @@ -2182,12 +2182,12 @@ partial interface SKAction : NSCoding, NSCopying { [iOS (8,0), Mac(10,10)] [Static, Export ("falloffBy:duration:")] - SKAction FalloffBy (float /* float, not CGFloat */ to, double duration); + SKAction FalloffBy (float /* float, not CGFloat */ to, double sec); [iOS (8,0), Mac(10,10)] [Static] [Export ("falloffTo:duration:")] - SKAction FalloffTo (float falloff, double duration); + SKAction FalloffTo (float falloff, double sec); // iOS 9 cluster [iOS (9,0)][Mac (10,11, onlyOn64 : true)] @@ -3280,7 +3280,7 @@ interface SKRenderer void Render (CGRect viewport, IMTLRenderCommandEncoder renderCommandEncoder, MTLRenderPassDescriptor renderPassDescriptor, IMTLCommandQueue commandQueue); [Export ("updateAtTime:")] - void UpdateAtTime (double currentTime); + void Update (double currentTime); [NullAllowed, Export ("scene", ArgumentSemantic.Assign)] SKScene Scene { get; set; } From 3e4679b583cc1c711104a4d1727ef130e4386b61 Mon Sep 17 00:00:00 2001 From: Vincent Dondain Date: Tue, 18 Jul 2017 12:10:24 -0400 Subject: [PATCH 4/6] [spritekit] Fixes based on comments (3) --- src/spritekit.cs | 4 ++-- tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/spritekit.cs b/src/spritekit.cs index 370f717a9e14..e388a56246fe 100644 --- a/src/spritekit.cs +++ b/src/spritekit.cs @@ -2154,7 +2154,7 @@ partial interface SKAction : NSCoding, NSCopying { [iOS (8,0), Mac(10,10)] [Static, Export ("reachTo:rootNode:duration:")] - SKAction ReachTo (CGPoint position, SKNode rootNode, double sec); + SKAction ReachTo (CGPoint position, SKNode rootNode, double secs); [iOS (8,0), Mac(10,10)] [Static, Export ("reachTo:rootNode:velocity:")] @@ -2182,7 +2182,7 @@ partial interface SKAction : NSCoding, NSCopying { [iOS (8,0), Mac(10,10)] [Static, Export ("falloffBy:duration:")] - SKAction FalloffBy (float /* float, not CGFloat */ to, double sec); + SKAction FalloffBy (float /* float, not CGFloat */ to, double duration); [iOS (8,0), Mac(10,10)] [Static] diff --git a/tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs b/tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs index fcab6a14a91e..93b2ab2b9db4 100644 --- a/tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs +++ b/tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs @@ -36,6 +36,7 @@ public void EulerAngles () Asserts.AreEqual (Vector3.Zero, obj.EulerAngles, "1 EulerAngles"); V3 = new Vector3 (1, 2, 3); obj.EulerAngles = V3; + // The values bellow match what the same code in Swift returns. Assert.AreEqual (-2.14159298f, obj.EulerAngles.X, "#x1"); Assert.AreEqual (1.14159274f, obj.EulerAngles.Y, "#y1"); Assert.AreEqual (-0.141592711f, obj.EulerAngles.Z, "#z1"); @@ -47,6 +48,7 @@ public void RotationMatrix () { using (var obj = new SKTransformNode ()) { obj.RotationMatrix = Matrix3.Zero; + // In Swift, a rotated zero matrice also becomes the identity matrice. Asserts.AreEqual (Matrix3.Identity, obj.RotationMatrix, "RotationMatrix"); } } From 19ae06f002278939fcdcf0c8ef7e76f9d2abc425 Mon Sep 17 00:00:00 2001 From: Vincent Dondain Date: Tue, 18 Jul 2017 14:05:29 -0400 Subject: [PATCH 5/6] [spritekit] Don't execute on watchOS --- tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs b/tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs index 93b2ab2b9db4..2f2fcfa13574 100644 --- a/tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs +++ b/tests/monotouch-test/SpriteKit/SKTransformNodeTest.cs @@ -1,4 +1,5 @@ - +#if !__WATCHOS__ + using System; #if XAMCORE_2_0 using Foundation; @@ -68,3 +69,4 @@ public void QuaternionTest () } } +#endif // !__WATCHOS__ From e0085f2f919ab6446c688806692c64be8731d7be Mon Sep 17 00:00:00 2001 From: Vincent Dondain Date: Tue, 18 Jul 2017 14:16:03 -0400 Subject: [PATCH 6/6] [spritekit] Fix braces new line --- src/SpriteKit/Enums.cs | 3 +-- src/spritekit.cs | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/SpriteKit/Enums.cs b/src/SpriteKit/Enums.cs index 417b29cb9b2a..4bdef22eba97 100644 --- a/src/SpriteKit/Enums.cs +++ b/src/SpriteKit/Enums.cs @@ -188,8 +188,7 @@ public enum SKTileAdjacencyMask : nuint [NoMac] [TV (11,0), iOS (11,0)] [Native] - public enum SKNodeFocusBehavior : nint - { + public enum SKNodeFocusBehavior : nint { None = 0, Occluding, Focusable, diff --git a/src/spritekit.cs b/src/spritekit.cs index e388a56246fe..1cce92bb055d 100644 --- a/src/spritekit.cs +++ b/src/spritekit.cs @@ -3266,8 +3266,7 @@ interface SKWarpGeometryGrid : NSCoding [TV (11,0), Mac (10,13), iOS (11,0)] [BaseType (typeof(NSObject))] [DisableDefaultCtor] - interface SKRenderer - { + interface SKRenderer { [Static] [Export ("rendererWithDevice:")] [return: NullAllowed] @@ -3309,8 +3308,7 @@ interface SKRenderer [TV (11,0), Watch (4,0), Mac (13,0), iOS (11,0)] [BaseType (typeof(SKNode))] - interface SKTransformNode - { + interface SKTransformNode { [Export ("xRotation")] nfloat XRotation { get; set; }