[arkit] Update for Xcode 9.3 beta 1 - #3343
Conversation
dalexsoto
left a comment
There was a problem hiding this comment.
Very small naming detail, otherwise it looks good to me 👍
| namespace XamCore.ARKit { | ||
| public partial class ARPlaneGeometry { | ||
|
|
||
| // Using GetXXX methods so it's similar to the ARFaceGeometry methods. |
There was a problem hiding this comment.
I think I prefer methods over props when the operation is "expensive" like interfacing with unmanaged code. Just a personal preference :)
| [Static] | ||
| [Export ("planeGeometryWithDevice:")] | ||
| [return: NullAllowed] | ||
| ARSCNPlaneGeometry CreatePlaneGeometry (IMTLDevice device); |
There was a problem hiding this comment.
Why not just Create? you already know it is a PlaneGeometry because of the type name.
There was a problem hiding this comment.
Mmh that was good feedback for #2681 when ARSCNFaceGeometry.CreateFaceGeometry was introduced (:
I agree though, PlaneGeometry should be implied by the type's name.
I'll make CreateFaceGeometry [Obsolete] and move it to Create too for API consistency.
|
|
||
| [EditorBrowsable (EditorBrowsableState.Advanced)] | ||
| [Export ("vertices")] | ||
| IntPtr GetRawVertices (); |
There was a problem hiding this comment.
were not the previous one made internal or protected ? instead of public ?
There was a problem hiding this comment.
looks like it was not (from the back port PR)
|
Build success |
|
Build success |
| ExistingPlane = 1 << 3, | ||
| ExistingPlaneUsingExtent = 1 << 4, | ||
| [iOS (11,3)] | ||
| ExistingPlaneUsingGeometry = (1 << 5), |
There was a problem hiding this comment.
Why the (1 << 5) and not simply 1 << 5?
There was a problem hiding this comment.
Because sharpie :P
I agree it's not needed, if I have to editor this PR again I'll fix it. It's minor though.
|
|
||
| [EditorBrowsable (EditorBrowsableState.Advanced)] | ||
| [Export ("boundaryVertices")] | ||
| IntPtr GetRawBoundaryVertices (); |
There was a problem hiding this comment.
Why are GetRawTextureCoordinates, GetRawTextureCoordinates and GetRawTextureCoordinates methods and not properties?
At least in the diff we have:
@property (nonatomic, readonly) const vector_float2 *textureCoordinates NS_REFINED_FOR_SWIFT;
There was a problem hiding this comment.
See the description of this PR (consistency with ARFaceGeometry), see #3090 (properties were incorrect and obsoleted) and see Alex's comment #3343 (comment) (Sebastien made the same comment).
| public override IntPtr GetRawTriangleIndices () | ||
| { | ||
| // Two triangles (set of 3 indices) | ||
| indices = new short [] { 1, 2, 3, 4, 5, 6 }; |
There was a problem hiding this comment.
I'm a little confused, is this line creating an array of 6 shorts? can't you do new short [6]?? I might be missing something.
There was a problem hiding this comment.
Because I'm setting values that I can then test. See https://github.com/xamarin/xamarin-macios/pull/3343/files#diff-58636f8c30f5f14ba7b2793d5900e7cfR129
I'm simulating the fact that there are actual indices.
| var face = new ARPlaneGeometryPoker (); | ||
| var vertices = face.GetVertices (); | ||
| Assert.AreEqual (new VectorFloat3 (1, 2, 3), vertices [0]); | ||
| Assert.AreEqual (new VectorFloat3 (4, 5, 6), vertices [1]); |
There was a problem hiding this comment.
AFAIK we have as good practice to add a string if we have more than one assert in a test.
There was a problem hiding this comment.
Oops, I missed that good practice (will remember for the next time). Minor comment though no (not sure it's blocking this PR)?
There was a problem hiding this comment.
This wasn't mentioned when the first (similar) tests were added: #3090
| var face = new ARPlaneGeometryPoker (); | ||
| var textureCoordinates = face.GetTextureCoordinates (); | ||
| Assert.AreEqual (new VectorFloat2 (1, 2), textureCoordinates [0]); | ||
| Assert.AreEqual (new VectorFloat2 (3, 4), textureCoordinates [1]); |
There was a problem hiding this comment.
Same as the previous one.
| var face = new ARPlaneGeometryPoker (); | ||
| var boundaryVertices = face.GetBoundaryVertices (); | ||
| Assert.AreEqual (new VectorFloat3 (1, 2, 3), boundaryVertices [0]); | ||
| Assert.AreEqual (new VectorFloat3 (4, 5, 6), boundaryVertices [1]); |
There was a problem hiding this comment.
Same as previous comments about several asserts.
|
|
||
| [iOS (11,3)] | ||
| [BaseType (typeof(SCNGeometry))] | ||
| interface ARSCNPlaneGeometry { |
There was a problem hiding this comment.
the base SCNGeometry class does not have a default .ctor
and since there seems to be a requirement for a metal device it seems likely this type cannot be created with init
There was a problem hiding this comment.
Not specified in the headers but I agree with you it makes sense (it's safer to ship it with [DisableDefaultCtor]. Also it's then similar to ARSCNFaceGeometry.
|
|
||
| [NoWatch, NoTV, NoMac, iOS (11,3)] | ||
| [BaseType (typeof(NSObject))] | ||
| interface ARReferenceImage : NSCopying, NSSecureCoding { |
There was a problem hiding this comment.
this is also not clear it can be created with init, the 2 .ctors don't accept nil images
easier to add it later than removing it (breaking changes)
| [BaseType (typeof(SCNGeometry))] | ||
| [DisableDefaultCtor] | ||
| interface ARSCNFaceGeometry { | ||
| [Obsolete ("Use the 'Create' static constructor instead.")] |
There was a problem hiding this comment.
put Obsolete under a !XAMCORE_4_0
also invert them, so the right one (this one) does not call the obsolete one
i.e. the bad one should suffer the extra call (and makes the !XAMCORE_4_0 compile
| [Wrap ("CreateFaceGeometry (device)")] | ||
| ARSCNFaceGeometry Create (IMTLDevice device); | ||
|
|
||
| [Obsolete ("Use the 'Create' static constructor instead.")] |
|
|
||
| [NoWatch, NoTV, NoMac, iOS (11,3)] | ||
| [BaseType (typeof(ARAnchor))] | ||
| interface ARImageAnchor { |
There was a problem hiding this comment.
the base type ARAnchor has a [DisableDefaultCtor] and I don't see any reason for this subclass not to have it ?
There was a problem hiding this comment.
Mmh so ARAnchor.h has:
/**
Initializes a new anchor object.
@param transform The transformation matrix that defines the anchor’s rotation, translation and scale in world coordinates.
*/
- (instancetype)initWithTransform:(matrix_float4x4)transform;
/** Unavailable */
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
ARImageAnchor and ARFaceAnchor (the only 2 subclasses) only have:
/** Unavailable */
- (instancetype)initWithTransform:(matrix_float4x4)transform NS_UNAVAILABLE;
Nothing is specified for init and new but given that initWithTransform is unavailable the must still have 1 constructor left (:
There was a problem hiding this comment.
yes, init* are methods in objc so they are inherited
and that's why we need to inline some init* in subclasses
still it means no init - it's the `initWithTransform1 that must be duplicated
There was a problem hiding this comment.
Oh yea ok so indeed init and new are also unavailable in the subclasses because they are inherited so [DisableDefaultCtor] makes sense (btw that could be caught by a test no? Unless the subclass in ObjC sometimes re-expose init and new even it's marked as unavailable in the parent?).
Now I don't follow your conclusion because initWithTransform is explicitly marked as unavailable. Looks like this type is not meant to be created by the user.
|
@spouliot @mandel-macaque @dalexsoto please re-review (: |
|
Build success |
Sorry Manuel but I have to dismiss your review to merge this PR. I addressed your changes (they were non-blocking)
Note: I chose to use
GetVerticesand friends instead of properties to match what was done in ARFaceGeometry (where the properties where wrong and unfortunately obsoleted).Diff file: https://github.com/xamarin/xamarin-macios/wiki/ARKit-iOS-xcode9.3-beta1