Skip to content

Commit

Permalink
[SceneKit] Make SCNMatrix4 column-major in .NET. Fixes dotnet#4652.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne committed Dec 21, 2021
1 parent a7eacd2 commit 019789c
Show file tree
Hide file tree
Showing 5 changed files with 1,995 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dotnet/BreakingChanges.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,14 @@ These APIs are used to determine whether we're executing in the simulator or
on a device. Neither apply to a Mac Catalyst app, so they've been removed.

Any code that these APIs will have to be ported to not use these APIs.

## The SceneKit.SCNMatrix4 matrix is transposed in memory.

The managed SCNMatrix4 struct used to be a row-major matrix, while the native
SCNMatrix4 struct is a column-major matrix. This difference in the memory
representation meant that matrices would often have to be transposed when
interacting with the platform.

In .NET, we've changed the managed SCNMatrix4 to be a column-major matrix, to
match the native version. This means that any transposing that's currently
done when accessing Apple APIs has to be undone.
5 changes: 5 additions & 0 deletions src/SceneKit/SCNMatrix4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

#if !NET

using System;
using System.Runtime.InteropServices;
using Foundation;
Expand Down Expand Up @@ -1176,3 +1178,6 @@ public static implicit operator CoreAnimation.CATransform3D (SCNMatrix4 source)
#endif
}
}

#endif // !NET

Loading

0 comments on commit 019789c

Please sign in to comment.