// SPDX-FileCopyrightText: 2025 Unity Technologies and the glTFast authors
// SPDX-License-Identifier: Apache-2.0
using System;
using System.Runtime.CompilerServices;
using Unity.Mathematics;
using static Unity.Mathematics.math;
namespace GLTFast
{
/// A 4 component vector of signed bytes.
struct sbyte4
{
/// x component of the vector.
public sbyte x;
/// y component of the vector.
public sbyte y;
/// z component of the vector.
public sbyte z;
/// w component of the vector.
public sbyte w;
/// Constructs an sbyte4 vector from four sbyte values.
/// The constructed vector's x component will be set to this value.
/// The constructed vector's y component will be set to this value.
/// The constructed vector's z component will be set to this value.
/// The constructed vector's z component will be set to this value.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public sbyte4(sbyte x, sbyte y, sbyte z, sbyte w)
{
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
///
/// Converts glTF rotation signed byte quaternion values in to a
/// quaternion rotation in Unity space.
///
/// Rotation in Unity space.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public quaternion GltfToUnityRotation()
{
return new quaternion(
max(x / 127f, -1f),
-max(y / 127f, -1f),
-max(z / 127f, -1f),
max(w / 127f, -1f)
);
}
}
}