[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 |
| nuint TriangleCount { get; } | ||
|
|
||
| #if !XAMCORE_4_0 | ||
| [Obsolete ("Use the 'GetTriangleIndices' method that return a 'short' array instead.")] |
| 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.
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.
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
| #if !XAMCORE_4_0 | ||
| [Obsolete ("Use the 'GetVertices' method instead.")] | ||
| [Export ("vertices")] | ||
| [Sealed] // Just to avoid the duplicate selector error |
There was a problem hiding this comment.
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.
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.
| 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.
minor: style { on next line
| } | ||
|
|
||
| // Going for GetXXX methods so we can keep the same name as the matching obsoleted property 'TextureCoordinates'. | ||
| public unsafe Vector2 [] GetTextureCoordinates () { |
| } | ||
|
|
||
| // Going for GetXXX methods so we can keep the same name as the matching obsoleted property 'TriangleIndices'. | ||
| public unsafe short [] GetTriangleIndices () { |
| #if !XAMCORE_4_0 | ||
| [Obsolete ("Use the 'GetTextureCoordinates' method instead.")] | ||
| [Export ("textureCoordinates")] | ||
| [Sealed] // Just to avoid the duplicate selector error |
| #if !XAMCORE_4_0 | ||
| [Obsolete ("Use the 'GetTriangleIndices' method instead.")] | ||
| [Export ("triangleIndices")] | ||
| [Sealed] // Just to avoid the duplicate selector error |
|
PR title also needs to be updated to match the set of changes :) |
spouliot
left a comment
There was a problem hiding this comment.
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' (dotnet#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 ().