New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[arkit] Fix 'Vertices', 'TextureCoordinates' and 'TriangleIndices' in 'ARFaceGeometry' #3090
[arkit] Fix 'Vertices', 'TextureCoordinates' and 'TriangleIndices' in 'ARFaceGeometry' #3090
Conversation
- Fixes bug #61056: [ARKit] short TriangleIndices should be short[] (https://bugzilla.xamarin.com/show_bug.cgi?id=61056) - Obsolete `short TriangleIndices`. - Introduced new `short [] TriangleIndexes` property to avoid name collision.
Need to address ARFaceGeometry's They're |
src/arkit.cs
Outdated
@@ -850,8 +850,17 @@ interface ARFaceGeometry : NSCopying { | |||
[Export ("triangleCount")] | |||
nuint TriangleCount { get; } | |||
|
|||
#if !XAMCORE_4_0 | |||
[Obsolete ("Use the 'GetTriangleIndices' method that return a 'short' array instead.")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> TriangleIndexes
src/ARKit/ARFaceGeometry.cs
Outdated
var rv = new short [count]; | ||
var ptr = (short *) GetTriangleIndexes (); | ||
for (int i = 0; i < count; i++) | ||
rv [i] = *ptr++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how many items there is usually but it might be better to use Marshal.Copy
and drop the unsafe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have an exact answer to this question, would need a test case. However this from the documentation: "Each 16-bit integer value in this buffer represents an index into the vertices and textureCoordinates buffers. Each set of three indices identifies the vertices comprising a single triangle in the mesh." makes me think it can be quite a lot (all the meshes representing a face).
Also I'd like to point out that we use the same code for ARPointCloud: https://github.com/xamarin/xamarin-macios/blob/master/src/ARKit/ARPointCloud.cs#L19-L39 (initially suggested by Rolf).
- Obsolete `Vector3 Vertices`. - Obsolete `Vector2 TextureCoordinates`. - Introduced new `Vector3 [] GetVertices ()`. - Introduced new `Vector2 [] GetTextureCoordinates ()`.
4da24a2
to
0334f1e
Compare
src/arkit.cs
Outdated
[Export ("vertices")] | ||
[Sealed] // Just to avoid the duplicate selector error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a breaking change as it will remove virtual
since it's largely unusable just remove the [Export]
, which means moving it to ARCompat.cs
, so the right thing can still be done on the new API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah makes sense for [Sealed]
an other option would have been to add [Sealed]
to the new duplicated [Export]
(looks like it's what we usually do). However I like the ARCompat.cs
option better. Going for that.
src/ARKit/ARFaceGeometry.cs
Outdated
public partial class ARFaceGeometry { | ||
|
||
// Going for GetXXX methods so we can keep the same name as the matching obsoleted property 'Vertices'. | ||
public unsafe Vector3 [] GetVertices () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: style {
on next line
src/ARKit/ARFaceGeometry.cs
Outdated
} | ||
|
||
// Going for GetXXX methods so we can keep the same name as the matching obsoleted property 'TextureCoordinates'. | ||
public unsafe Vector2 [] GetTextureCoordinates () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
src/ARKit/ARFaceGeometry.cs
Outdated
} | ||
|
||
// Going for GetXXX methods so we can keep the same name as the matching obsoleted property 'TriangleIndices'. | ||
public unsafe short [] GetTriangleIndices () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
src/arkit.cs
Outdated
[Export ("textureCoordinates")] | ||
[Sealed] // Just to avoid the duplicate selector error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
src/arkit.cs
Outdated
[Export ("triangleIndices")] | ||
[Sealed] // Just to avoid the duplicate selector error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
PR title also needs to be updated to match the set of changes :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when merging update Introduced new short [] TriangleIndexes property to avoid name collision. since it's not a property anymore :)
Build success |
Link to successful build -> https://jenkins.mono-project.com/job/xamarin-macios-pr-builder/5756/ Status is broken :( |
… 'ARFaceGeometry' (xamarin#3090) - Fixes bug #61056: [ARKit] TriangleIndices, Vertices and TextureCoordinates should be respectively short [], Vector3 [] and Vector2 [] (https://bugzilla.xamarin.com/show_bug.cgi?id=61056) - Obsolete `short TriangleIndices`. - Obsolete `Vector3 Vertices`. - Obsolete `Vector2 TextureCoordinates`. - Introduced new `short [] GetTriangleIndices ()`. - Introduced new `Vector3 [] GetVertices ()`. - Introduced new `Vector2 [] GetTextureCoordinates ()`.
…ndices' in 'ARFaceGeometry' (#3090) (#3342) - Fixes bug #61056: [ARKit] TriangleIndices, Vertices and TextureCoordinates should be respectively short [], Vector3 [] and Vector2 [] (https://bugzilla.xamarin.com/show_bug.cgi?id=61056) - Obsolete `short TriangleIndices`. - Obsolete `Vector3 Vertices`. - Obsolete `Vector2 TextureCoordinates`. - Introduced new `short [] GetTriangleIndices ()`. - Introduced new `Vector3 [] GetVertices ()`. - Introduced new `Vector2 [] GetTextureCoordinates ()`.
(https://bugzilla.xamarin.com/show_bug.cgi?id=61056)
short TriangleIndices
.Vector3 Vertices
.Vector2 TextureCoordinates
.short [] GetTriangleIndices ()
.Vector3 [] GetVertices ()
.Vector2 [] GetTextureCoordinates ()
.