Skip to content

Use glam_matrix_extensions and symmetric matrices#5

Merged
Jondolf merged 4 commits intomainfrom
symmetric-matrices
Jul 16, 2025
Merged

Use glam_matrix_extensions and symmetric matrices#5
Jondolf merged 4 commits intomainfrom
symmetric-matrices

Conversation

@Jondolf
Copy link
Member

@Jondolf Jondolf commented Jul 16, 2025

Objective

3D angular inertia tensors are symmetric 3x3 matrices. Currently, we just use a Mat3, but for better performance and lower memory usage, it'd be better to use a dedicated symmetric matrix type instead. The same is done by physics engines like Rapier and Bepu.

Instead of having a custom type in bevy_heavy, I have recently developed glam_matrix_extensions for various matrix types and utilities needed for physics. I also added 2x2 and 3x3 Eigen solvers there. We should use them!

Solution

Use SymmetricMat3 for the AngularInertiaTensor and update its constructor APIs. Replace SymmetricEigen3 with the version provided by glam_matrix_extensions.

Also added the nostd-libm feature.


Migration Guide

The AngularInertiaTensor now stores a SymmetricMat3. The from_mat3 constructor has been replaced by from_symmetric_mat3, try_from_mat3, and from_mat3_unchecked. The as_mat3 and as_mat3_mut getters have been replaced by as_symmetric_mat3 and as_symmetric_mat3_mut.

The SymmetricEigen3 type is now provided by glam_matrix_extensions instead of bevy_heavy.

@Jondolf Jondolf merged commit f2a6e3b into main Jul 16, 2025
8 checks passed
@Jondolf Jondolf deleted the symmetric-matrices branch July 16, 2025 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant