mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
more ocd
This commit is contained in:
parent
7d2ced73e9
commit
59799c0ccd
1 changed files with 60 additions and 60 deletions
|
@ -112,18 +112,6 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
0.8138595f,
|
0.8138595f,
|
||||||
0.8110138f
|
0.8110138f
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AvatarPose
|
|
||||||
{
|
|
||||||
Default = 0,
|
|
||||||
Initial = 1,
|
|
||||||
IKPose = 2,
|
|
||||||
TPose = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChilloutVR Player Components
|
|
||||||
private PlayerSetup playerSetup;
|
|
||||||
private MovementSystem movementSystem;
|
|
||||||
|
|
||||||
// DesktopVRIK Settings
|
// DesktopVRIK Settings
|
||||||
public bool Setting_Enabled = true;
|
public bool Setting_Enabled = true;
|
||||||
|
@ -148,31 +136,43 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
public VRIK avatarVRIK = null;
|
public VRIK avatarVRIK = null;
|
||||||
public IKSolverVR avatarIKSolver = null;
|
public IKSolverVR avatarIKSolver = null;
|
||||||
|
|
||||||
|
// ChilloutVR Player Components
|
||||||
|
PlayerSetup playerSetup;
|
||||||
|
MovementSystem movementSystem;
|
||||||
|
|
||||||
// Calibration Objects
|
// Calibration Objects
|
||||||
public HumanPose HumanPose;
|
HumanPose _humanPose;
|
||||||
public HumanPose InitialHumanPose;
|
HumanPose _initialHumanPose;
|
||||||
public HumanPoseHandler HumanPoseHandler;
|
HumanPoseHandler _humanPoseHandler;
|
||||||
|
|
||||||
// Animator Info
|
// Animator Info
|
||||||
public int locomotionLayer = -1;
|
int _locomotionLayer = -1;
|
||||||
public int customIKPoseLayer = -1;
|
int _customIKPoseLayer = -1;
|
||||||
public bool requireFixTransforms = false;
|
bool _requireFixTransforms = false;
|
||||||
|
|
||||||
// VRIK Calibration Info
|
// VRIK Calibration Info
|
||||||
public Vector3 leftKneeNormal;
|
Vector3 _leftKneeNormal;
|
||||||
public Vector3 rightKneeNormal;
|
Vector3 _rightKneeNormal;
|
||||||
public float initialFootDistance;
|
float _initialFootDistance;
|
||||||
public float initialStepThreshold;
|
float _initialStepThreshold;
|
||||||
public float initialStepHeight;
|
float _initialStepHeight;
|
||||||
|
|
||||||
// Player Info
|
// Player Info
|
||||||
private Transform _cameraTransform;
|
Transform _cameraTransform;
|
||||||
private bool _isEmotePlaying;
|
bool _isEmotePlaying;
|
||||||
private float _simulatedRootAngle;
|
float _simulatedRootAngle;
|
||||||
|
|
||||||
// Last Movement Parent Info
|
// Last Movement Parent Info
|
||||||
private Vector3 _previousPosition;
|
Vector3 _previousPosition;
|
||||||
private Quaternion _previousRotation;
|
Quaternion _previousRotation;
|
||||||
|
|
||||||
|
enum AvatarPose
|
||||||
|
{
|
||||||
|
Default = 0,
|
||||||
|
Initial = 1,
|
||||||
|
IKPose = 2,
|
||||||
|
TPose = 3
|
||||||
|
}
|
||||||
|
|
||||||
DesktopVRIKSystem()
|
DesktopVRIKSystem()
|
||||||
{
|
{
|
||||||
|
@ -309,9 +309,9 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
VRIKUtils.ApplyScaleToVRIK
|
VRIKUtils.ApplyScaleToVRIK
|
||||||
(
|
(
|
||||||
avatarVRIK,
|
avatarVRIK,
|
||||||
initialFootDistance,
|
_initialFootDistance,
|
||||||
initialStepThreshold,
|
_initialStepThreshold,
|
||||||
initialStepHeight,
|
_initialStepHeight,
|
||||||
scaleDifference
|
scaleDifference
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -444,19 +444,19 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
avatarLookAtIK = playerSetup.lookIK;
|
avatarLookAtIK = playerSetup.lookIK;
|
||||||
|
|
||||||
// Get animator layer inticies
|
// Get animator layer inticies
|
||||||
locomotionLayer = avatarAnimator.GetLayerIndex("IKPose");
|
_locomotionLayer = avatarAnimator.GetLayerIndex("IKPose");
|
||||||
customIKPoseLayer = avatarAnimator.GetLayerIndex("Locomotion/Emotes");
|
_customIKPoseLayer = avatarAnimator.GetLayerIndex("Locomotion/Emotes");
|
||||||
|
|
||||||
// Dispose and create new HumanPoseHandler
|
// Dispose and create new _humanPoseHandler
|
||||||
HumanPoseHandler?.Dispose();
|
_humanPoseHandler?.Dispose();
|
||||||
HumanPoseHandler = new HumanPoseHandler(avatarAnimator.avatar, avatarTransform);
|
_humanPoseHandler = new HumanPoseHandler(avatarAnimator.avatar, avatarTransform);
|
||||||
|
|
||||||
// Get initial human poses
|
// Get initial human poses
|
||||||
HumanPoseHandler.GetHumanPose(ref HumanPose);
|
_humanPoseHandler.GetHumanPose(ref _humanPose);
|
||||||
HumanPoseHandler.GetHumanPose(ref InitialHumanPose);
|
_humanPoseHandler.GetHumanPose(ref _initialHumanPose);
|
||||||
|
|
||||||
// Dumb fix for rare upload issue
|
// Dumb fix for rare upload issue
|
||||||
requireFixTransforms = !avatarAnimator.enabled;
|
_requireFixTransforms = !avatarAnimator.enabled;
|
||||||
|
|
||||||
// Find available HumanoidBodyBones
|
// Find available HumanoidBodyBones
|
||||||
BoneExists.Clear();
|
BoneExists.Clear();
|
||||||
|
@ -479,7 +479,7 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
VRIKUtils.ConfigureVRIKReferences(avatarVRIK, Setting_UseVRIKToes, Setting_FindUnmappedToes, out bool foundUnmappedToes);
|
VRIKUtils.ConfigureVRIKReferences(avatarVRIK, Setting_UseVRIKToes, Setting_FindUnmappedToes, out bool foundUnmappedToes);
|
||||||
|
|
||||||
// Fix animator issue or non-human mapped toes
|
// Fix animator issue or non-human mapped toes
|
||||||
avatarVRIK.fixTransforms = requireFixTransforms || foundUnmappedToes;
|
avatarVRIK.fixTransforms = _requireFixTransforms || foundUnmappedToes;
|
||||||
|
|
||||||
// Default solver settings
|
// Default solver settings
|
||||||
avatarIKSolver.locomotion.weight = 0f;
|
avatarIKSolver.locomotion.weight = 0f;
|
||||||
|
@ -533,12 +533,12 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
SetAvatarPose(AvatarPose.Default);
|
SetAvatarPose(AvatarPose.Default);
|
||||||
|
|
||||||
// Calculate bend normals with motorcycle pose
|
// Calculate bend normals with motorcycle pose
|
||||||
VRIKUtils.CalculateKneeBendNormals(avatarVRIK, out leftKneeNormal, out rightKneeNormal);
|
VRIKUtils.CalculateKneeBendNormals(avatarVRIK, out _leftKneeNormal, out _rightKneeNormal);
|
||||||
|
|
||||||
SetAvatarPose(AvatarPose.IKPose);
|
SetAvatarPose(AvatarPose.IKPose);
|
||||||
|
|
||||||
// Calculate initial IK scaling values with IKPose
|
// Calculate initial IK scaling values with IKPose
|
||||||
VRIKUtils.CalculateInitialIKScaling(avatarVRIK, out initialFootDistance, out initialStepThreshold, out initialStepHeight);
|
VRIKUtils.CalculateInitialIKScaling(avatarVRIK, out _initialFootDistance, out _initialStepThreshold, out _initialStepHeight);
|
||||||
|
|
||||||
// Setup HeadIKTarget
|
// Setup HeadIKTarget
|
||||||
VRIKUtils.SetupHeadIKTarget(avatarVRIK);
|
VRIKUtils.SetupHeadIKTarget(avatarVRIK);
|
||||||
|
@ -554,12 +554,12 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
VRIKUtils.ApplyScaleToVRIK
|
VRIKUtils.ApplyScaleToVRIK
|
||||||
(
|
(
|
||||||
avatarVRIK,
|
avatarVRIK,
|
||||||
initialFootDistance,
|
_initialFootDistance,
|
||||||
initialStepThreshold,
|
_initialStepThreshold,
|
||||||
initialStepHeight,
|
_initialStepHeight,
|
||||||
1f
|
1f
|
||||||
);
|
);
|
||||||
VRIKUtils.ApplyKneeBendNormals(avatarVRIK, leftKneeNormal, rightKneeNormal);
|
VRIKUtils.ApplyKneeBendNormals(avatarVRIK, _leftKneeNormal, _rightKneeNormal);
|
||||||
avatarVRIK.onPreSolverUpdate.AddListener(new UnityAction(DesktopVRIKSystem.Instance.OnPreSolverUpdate));
|
avatarVRIK.onPreSolverUpdate.AddListener(new UnityAction(DesktopVRIKSystem.Instance.OnPreSolverUpdate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,7 +576,7 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
SetMusclesToValue(0f);
|
SetMusclesToValue(0f);
|
||||||
break;
|
break;
|
||||||
case AvatarPose.Initial:
|
case AvatarPose.Initial:
|
||||||
HumanPoseHandler.SetHumanPose(ref InitialHumanPose);
|
_humanPoseHandler.SetHumanPose(ref _initialHumanPose);
|
||||||
break;
|
break;
|
||||||
case AvatarPose.IKPose:
|
case AvatarPose.IKPose:
|
||||||
if (HasCustomIKPose())
|
if (HasCustomIKPose())
|
||||||
|
@ -596,40 +596,40 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
|
|
||||||
bool HasCustomIKPose()
|
bool HasCustomIKPose()
|
||||||
{
|
{
|
||||||
return locomotionLayer != -1 && customIKPoseLayer != -1;
|
return _locomotionLayer != -1 && _customIKPoseLayer != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetCustomLayersWeights(float customIKPoseLayerWeight, float locomotionLayerWeight)
|
void SetCustomLayersWeights(float customIKPoseLayerWeight, float locomotionLayerWeight)
|
||||||
{
|
{
|
||||||
avatarAnimator.SetLayerWeight(customIKPoseLayer, customIKPoseLayerWeight);
|
avatarAnimator.SetLayerWeight(_customIKPoseLayer, customIKPoseLayerWeight);
|
||||||
avatarAnimator.SetLayerWeight(locomotionLayer, locomotionLayerWeight);
|
avatarAnimator.SetLayerWeight(_locomotionLayer, locomotionLayerWeight);
|
||||||
avatarAnimator.Update(0f);
|
avatarAnimator.Update(0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetMusclesToValue(float value)
|
void SetMusclesToValue(float value)
|
||||||
{
|
{
|
||||||
HumanPoseHandler.GetHumanPose(ref HumanPose);
|
_humanPoseHandler.GetHumanPose(ref _humanPose);
|
||||||
|
|
||||||
for (int i = 0; i < HumanPose.muscles.Length; i++)
|
for (int i = 0; i < _humanPose.muscles.Length; i++)
|
||||||
{
|
{
|
||||||
ApplyMuscleValue((MuscleIndex)i, value, ref HumanPose.muscles);
|
ApplyMuscleValue((MuscleIndex)i, value, ref _humanPose.muscles);
|
||||||
}
|
}
|
||||||
|
|
||||||
HumanPose.bodyRotation = Quaternion.identity;
|
_humanPose.bodyRotation = Quaternion.identity;
|
||||||
HumanPoseHandler.SetHumanPose(ref HumanPose);
|
_humanPoseHandler.SetHumanPose(ref _humanPose);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetMusclesToPose(float[] muscles)
|
void SetMusclesToPose(float[] muscles)
|
||||||
{
|
{
|
||||||
HumanPoseHandler.GetHumanPose(ref HumanPose);
|
_humanPoseHandler.GetHumanPose(ref _humanPose);
|
||||||
|
|
||||||
for (int i = 0; i < HumanPose.muscles.Length; i++)
|
for (int i = 0; i < _humanPose.muscles.Length; i++)
|
||||||
{
|
{
|
||||||
ApplyMuscleValue((MuscleIndex)i, muscles[i], ref HumanPose.muscles);
|
ApplyMuscleValue((MuscleIndex)i, muscles[i], ref _humanPose.muscles);
|
||||||
}
|
}
|
||||||
|
|
||||||
HumanPose.bodyRotation = Quaternion.identity;
|
_humanPose.bodyRotation = Quaternion.identity;
|
||||||
HumanPoseHandler.SetHumanPose(ref HumanPose);
|
_humanPoseHandler.SetHumanPose(ref _humanPose);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyMuscleValue(MuscleIndex index, float value, ref float[] muscles)
|
void ApplyMuscleValue(MuscleIndex index, float value, ref float[] muscles)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue