Performance convert Matrix4x4 into float4x4
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 52/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- csharp, unity
- Domain
- performance
Research direction
Start by searching the Unity.Mathematics source for the implicit operator float4x4(Matrix4x4 m) entry point and inspect the reverse float4x4-to-Matrix4x4 cast mentioned in the issue. Compare the conversion paths and verify that all matrix elements are preserved without the current column-based construction; done means the optimized conversion remains equivalent.
Written by the indexing model from the issue text.
Description
I spot a little improve to convert Matrix4x4 into float4x4
In the current version:
public static implicit operator float4x4(Matrix4x4 m) { return new float4x4(m.GetColumn(0), m.GetColumn(1), m.GetColumn(2), m.GetColumn(3)); }
My suggestion:
public static implicit operator float4x4(Matrix4x4 m) { return new float4x4(m.m00, m.m01, m.m02, m.m03, m.m10, m.m11, m.m12, m.m13, m.m20, m.m21, m.m22, m.m23, m.m30, m.m31, m.m32, m.m33); }
In the current version, you call the column to give you an Vector4 that you convert by an implicit cast into a float4. For the construction, that's not very efficient, i think it's because you want to use a "mirror" function with the cast float4x4 into Matrix4x4
Guillaume
- Dominant language
- C#
- Stars
- 1.4k
- Forks
- 159
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Unity-Technologies/Unity.Mathematics
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Unity-Technologies/Unity.Mathematics#245 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
Unity-Technologies/Unity.Mathematics#243 · 6 reactions ·
All issues in Unity-Technologies/Unity.Mathematics
Similar issues
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Type: enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
apache/arrow-adbc#4809 ·
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
microsoft/vscode-azurefunctions#5197 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
microsoft/microsoft-ui-reactor#1274 ·