Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Quatf::setRPY(f32, f32, f32) helper function #193

Open
malleoz opened this issue Dec 11, 2024 · 2 comments · May be fixed by #224
Open

Add Quatf::setRPY(f32, f32, f32) helper function #193

malleoz opened this issue Dec 11, 2024 · 2 comments · May be fixed by #224
Labels
engine Code involving engine (C++) improvement Improvement to existing code P3 Priority: Low

Comments

@malleoz
Copy link
Contributor

malleoz commented Dec 11, 2024

Add a setRPY function which takes in floats instead of a vector. This is useful when we end up constructing temporary Vector3f objects solely so that we can call into setRPY. Audit all existing uses of setRPY to eliminate temporary construction of vectors.

@malleoz
Copy link
Contributor Author

malleoz commented Dec 11, 2024

/// @brief Helper function to avoid unnecessary Vector3f construction.
void Quatf::setRPY(f32 r, f32 p, f32 y) {
    const f32 cy = Mathf::cos(y * 0.5f);
    const f32 cp = Mathf::cos(p * 0.5f);
    const f32 cr = Mathf::cos(r * 0.5f);
    const f32 sy = Mathf::sin(y * 0.5f);
    const f32 sp = Mathf::sin(p * 0.5f);
    const f32 sr = Mathf::sin(r * 0.5f);

    w = cy * cp * cr + sy * sp * sr;
    v.x = cy * cp * sr - sy * sp * cr;
    v.y = cy * sp * cr + sy * cp * sr;
    v.z = sy * cp * cr - cy * sp * sr;
}

@vabold
Copy link
Owner

vabold commented Dec 11, 2024

One defaults to the other in EGG. I'm not sure which is which.

Vectors should decay into floats in this case.

@vabold vabold added engine Code involving engine (C++) improvement Improvement to existing code P3 Priority: Low labels Dec 11, 2024
@malleoz malleoz linked a pull request Jan 1, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engine Code involving engine (C++) improvement Improvement to existing code P3 Priority: Low
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants