mirror of
https://github.com/brl/mutter.git
synced 2024-11-12 17:27:03 -05:00
quaternions: Allow multiplication into 'a' arg
When multiplying two quaternions, we now implicitly copy the components of the 'a' argument so that the result can be reliably written back to the 'a' argument quaternion without conflicting with the multiplication itself. This is consistent with the cogl_matrix_multiply() api which allows the 'result' and 'a' arguments to point to the same matrix. In debug builds Cogl will assert that the 'b' and 'result' arguments don't point to the same quaternion. Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit 207527313a8957789390069e84189254cf41e88f)
This commit is contained in:
parent
8f4dd4587e
commit
961832164b
@ -434,11 +434,18 @@ cogl_quaternion_multiply (CoglQuaternion *result,
|
||||
const CoglQuaternion *a,
|
||||
const CoglQuaternion *b)
|
||||
{
|
||||
result->w = a->w * b->w - a->x * b->x - a->y * b->y - a->z * b->z;
|
||||
float w = a->w;
|
||||
float x = a->x;
|
||||
float y = a->y;
|
||||
float z = a->z;
|
||||
|
||||
result->x = a->w * b->x + a->x * b->w + a->y * b->z - a->z * b->y;
|
||||
result->y = a->w * b->y + a->y * b->w + a->z * b->x - a->x * b->z;
|
||||
result->z = a->w * b->z + a->z * b->w + a->x * b->y - a->y * b->x;
|
||||
_COGL_RETURN_IF_FAIL (b != result);
|
||||
|
||||
result->w = w * b->w - x * b->x - y * b->y - z * b->z;
|
||||
|
||||
result->x = w * b->x + x * b->w + y * b->z - z * b->y;
|
||||
result->y = w * b->y + y * b->w + z * b->x - x * b->z;
|
||||
result->z = w * b->z + z * b->w + x * b->y - y * b->x;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -394,6 +394,9 @@ cogl_quaternion_invert (CoglQuaternion *quaternion);
|
||||
* so the rotations are applied @right to @left. This is similar to the
|
||||
* combining of matrices.
|
||||
*
|
||||
* <note>It is possible to multiply the @a quaternion in-place, so
|
||||
* @result can be equal to @a but can't be equal to @b.</note>
|
||||
*
|
||||
* Since: 2.0
|
||||
*/
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user