Unity-Technologies / Unity-Technologies/Unity.Mathematics

Multiplication operator behaves differently between Unity.Mathematics.float4x4 and UnityEngine.Matrix4x4

Open
#83 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
1.4k
Forks
159
PR merge metrics
No merged PRs in 30d

Description

The multiplication operator is defined for both float4x4 and Matrix4x4, but has different semantics. The traditional Unity Matrix4x4 does the intuitive thing, which is a matrix multiplication, whereas float4x4 does a componentwise multiplication (like HLSL) and requires using mul to get the matrix multiplication.

This can lead to bugs that are very hard to spot while porting over math code from C# to HPC#, so it could be worth considering changing this, or at least very clearly highlighting this in the documentation and possible best practice / upgrade guides.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the float4x4 and Matrix4x4 multiplication operator definitions and comparing their semantics with the mul function described in the issue. Review the existing documentation and upgrade guidance for these types. Done requires an agreed choice between changing the operator behavior and clearly documenting the difference, with corresponding documentation or implementation work.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, unity
Domain
game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.