Repository navigation
libobs/graphics: Fix component order in quat_set - #86
Merged
Merged
Conversation
quat_set(&q, 1, 2, 3, 4) must give x=1, y=2, z=3, w=4, and quat_set(&q, 0, 0, 0, 1) must equal quat_identity. Today it stores x=4, y=3, z=2, w=1 (checked with MSVC against graphics/quat.h), so both cases fail. Co-Authored-By: Claude Opus 5.5 <[email protected]>
quat_set passed x, y, z, w to _mm_set_ps, which takes its arguments high lane first, so the quaternion was stored reversed: x got w, y got z, z got y and w got x. vec3_set and vec4_set already pass the lanes high first. Nothing in the tree calls quat_set, but it is public API and the Lua and Python scripting bindings expose quat.h. Also fixes the quat_set entry in the docs, which listed only x and y in the signature and named the z parameter y. Co-Authored-By: Claude Opus 5.5 <[email protected]>
b7216309-jpg
added a commit
to b7216309-jpg/obs-studio
that referenced
this pull request
Oct 10, 2026
obs-rust#86 fixed quat_set's component order, so the field-by-field helper added to work around it is no longer needed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
quat_setinlibobs/graphics/quat.hstores the quaternion reversed:So
quat_set(&q, 1, 2, 3, 4)givesx=4, y=3, z=2, w=1, andquat_set(&q, 0, 0, 0, 1)is not the identity. This PR passes the lanes high first,_mm_set_ps(w, z, y, x), the wayvec3_setandvec4_setalready do.It also fixes the
quat_setentry indocs/sphinx/reference-libobs-graphics-quat.rst. The signature listed onlyx, y, and the z parameter was namedy.Motivation and Context
Found while porting
axisang.c(#83):test_axisang.cbuilt its inputs withquat_setand failed in Tier 2 with the original C (OFF). Nothing in the tree callsquat_set, but it is public API.obslua.iandobspython.i%include "graphics/quat.h", so Lua and Python scripts can call it. Any script that does gets a reversed quaternion today and the intended one after this change.How Has This Been Tested?
test/cmocka/test_quat.c: component order,ptr[]aliasing, andquat_set(0, 0, 0, 1) == quat_identity), then the fix.quat_set(&q, 1, 2, 3, 4)fromgraphics/quat.hprintsx=4 y=3 z=2 w=1on master andx=1 y=2 z=3 w=4with the fix. The cmocka test first runs in Tier 2 CI. On Linux and macOS,_mm_set_pscomes from SIMDe with the same argument order.python ci/local_gate.py --lane lintpasses.Types of changes
Checklist:
🤖 Generated with Claude Code