bitshifter / glam-rs

A simple and fast linear algebra library for games and graphics
Apache License 2.0
1.5k stars 152 forks source link

Unreal ABI Compatibility #507

Closed herohiralal closed 5 months ago

herohiralal commented 5 months ago

Updates:

Minor changes only.

bitshifter commented 5 months ago

For this kind of thing it's best to start a discussion (see https://github.com/bitshifter/glam-rs?tab=readme-ov-file#contribution).

I don't think that a lot of this makes sense for glam. It may be preferable to maintain a separate crate for interop with Unreal.

As far as I can tell in UE5 FVector3f and FVector4f are not 16 byte aligned, they, see https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/Core/Public/Math/MathFwd.h declarations of FVector, FVector3d and FVector3f which are specializations of TVector, there is no alignment specified as far as I can tell. There are types like VectorRegister4Float but they are just typedefs to register types for SSE, Neon, etc, not general purpose Vector3 types, so I don't think it makes sense to add alignment to glam types like this.

I also don't want to maintain a copy of Unreal's Rotator type, I don't think it makes sense in the context of glam.

I'm going to close this PR but feel free to start a discussion if you want to explain what you are wanting further.

herohiralal commented 5 months ago

FQuat4f/FQuat4d and FVector4f/FVector4d both are. Hyperlinks are to the lines setting the alignment.

Using it in a personal project regardless of the addition to the main crate, but thought it might be helpful to others too. And might help ease up some amount of pains involved in using Rust for gamedev (having to start in feature-scarce engines or start from scratch), by instead being more accessibly integrateable into a more popular engine.

Not going to pursue integration further, and so just posting this minor info in this context for visibility.

bitshifter commented 3 months ago

Thanks for the additional context, and the links. Visual Assist never seems to find the right thing for Unreal math types.

Optional alignment is a hassle to maintain which is a big reason I wouldn't want to take this until it's mature and there's a some demand.