// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) VRMADA, All rights reserved.
//
// --------------------------------------------------------------------------------------------------------------------
using System;
using UnityEngine;
namespace UltimateXR.Animation.IK
{
///
/// Stores parameters that drive Inverse Kinematics for full-body avatars.
///
///
/// For now only half-body Inverse Kinematics is supported. Full-body will be implemented at some point.
///
[Serializable]
public class UxrBodyIKSettings
{
#region Inspector Properties/Serialized Fields
[SerializeField] private bool _lockBodyPivot;
[SerializeField] private float _bodyPivotRotationSpeed = 0.2f;
[SerializeField] private float _headFreeRangeBend = 20.0f;
[SerializeField] private float _headFreeRangeTorsion = 30.0f;
[SerializeField] private float _neckHeadBalance = 0.5f;
[SerializeField] private float _spineBend = 0.05f;
[SerializeField] private float _spineTorsion = 0.4f;
[SerializeField] private float _chestBend = 0.3f;
[SerializeField] private float _chestTorsion = 0.8f;
[SerializeField] private float _upperChestBend = 0.4f;
[SerializeField] private float _upperChestTorsion = 0.2f;
[SerializeField] private float _neckBaseHeight = 1.6f;
[SerializeField] private float _neckForwardOffset;
[SerializeField] private float _eyesBaseHeight = 1.75f;
[SerializeField] private float _eyesForwardOffset = 0.1f;
#endregion
#region Public Types & Data
///
/// Gets whether the avatar pivot will be kept in place so that it will only rotate around.
///
public bool LockBodyPivot => _lockBodyPivot;
///
/// Gets the speed the body will turn around with. This is used to smooth out rotation.
///
public float BodyPivotRotationSpeed => _bodyPivotRotationSpeed;
///
/// Gets the amount of degrees the head can bend before requiring rotation of other bones down the spine.
///
public float HeadFreeRangeBend => _headFreeRangeBend;
///
/// Gets the amount of degrees the head can turn before requiring rotation of other bones down the spine.
///
public float HeadFreeRangeTorsion => _headFreeRangeTorsion;
///
/// Gets a value in [0.0, 1.0] range that tells how rotation will be distributed between the head and the neck. 0.0
/// will fully use the neck and 1.0 will fully use the head. Values in between will distribute it among the two.
///
public float NeckHeadBalance => _neckHeadBalance;
///
/// Gets the amount the spine will bend when the head bends.
///
public float SpineBend => _spineBend;
///
/// Gets the amount the spine will turn when the head turns.
///
public float SpineTorsion => _spineTorsion;
///
/// Gets the amount the chest will bend when the head bends.
///
public float ChestBend => _chestBend;
///
/// Gets the amount the chest will turn when the head turns.
///
public float ChestTorsion => _chestTorsion;
///
/// Gets the amount the upper chest will bend when the head bends.
///
public float UpperChestBend => _upperChestBend;
///
/// Gets the amount the upper chest will turn when the head turns.
///
public float UpperChestTorsion => _upperChestTorsion;
///
/// Gets the height of the base of the neck starting from the avatar root Y. This is used to create a dummy neck when
/// the avatar is lacking a neck bone.
///
public float NeckBaseHeight => _neckBaseHeight;
///
/// Gets the forward offset of the neck starting from the avatar root Z. This is used to create a dummy neck when the
/// avatar is lacking a neck bone.
///
public float NeckForwardOffset => _neckForwardOffset;
///
/// Gets the height of the eyes starting from the avatar root Y. This is used to know where to place the avatar head
/// knowing the camera will be positioned on the eyes.
///
public float EyesBaseHeight => _eyesBaseHeight;
///
/// Gets the forward offset of the eyes starting from the avatar root Z. This is used to know where to place the avatar
/// head knowing the camera will be positioned on the eyes.
///
public float EyesForwardOffset => _eyesForwardOffset;
#endregion
}
}