mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
i have no fucking clue
This commit is contained in:
parent
730ff58adc
commit
f783fe612d
21 changed files with 496 additions and 49 deletions
|
@ -127,28 +127,31 @@ internal static class BodySystemPatches
|
|||
SetPelvisWeight(solver.spine, 0f);
|
||||
}
|
||||
|
||||
float maxRootAngle = BodySystem.isCalibratedAsFullBody || IKFixes.EntryUseFakeRootAngle.Value ? (PlayerSetup.Instance._emotePlaying ? 180f : 0f) : (PlayerSetup.Instance._emotePlaying ? 180f : 25f);
|
||||
solver.spine.maxRootAngle = maxRootAngle;
|
||||
float maxRootAngle = 25f;
|
||||
float rootHeadingOffset = 0f;
|
||||
|
||||
if (IKFixes.EntryUseFakeRootAngle.Value)
|
||||
if (BodySystem.isCalibratedAsFullBody || IKFixes.EntryUseFakeRootAngle.Value)
|
||||
maxRootAngle = 0f;
|
||||
|
||||
if (PlayerSetup.Instance._emotePlaying)
|
||||
maxRootAngle = 180f;
|
||||
|
||||
if (IKFixes.EntryUseFakeRootAngle.Value && !BodySystem.isCalibratedAsFullBody)
|
||||
{
|
||||
// Emulate maxRootAngle because CVR doesn't have the player controller set up ideally for VRIK.
|
||||
// I believe they'd need to change which object vrik.references.root is, as using avatar object is bad!
|
||||
// This is a small small fix, but makes it so the feet dont point in the direction of the head
|
||||
// when turning. It also means turning with joystick & turning IRL make feet behave the same and follow behind.
|
||||
float weightedAngleLimit = IKFixes.EntryFakeRootAngleLimit.Value * solver.locomotion.weight;
|
||||
float pivotAngle = MovementSystem.Instance.rotationPivot.eulerAngles.y;
|
||||
float deltaAngleRoot = Mathf.DeltaAngle(pivotAngle, _ikSimulatedRootAngle);
|
||||
float absDeltaAngleRoot = Mathf.Abs(deltaAngleRoot);
|
||||
|
||||
if (absDeltaAngleRoot > weightedAngleLimit)
|
||||
{
|
||||
deltaAngleRoot = Mathf.Sign(deltaAngleRoot) * weightedAngleLimit;
|
||||
_ikSimulatedRootAngle = Mathf.MoveTowardsAngle(_ikSimulatedRootAngle, pivotAngle, absDeltaAngleRoot - weightedAngleLimit);
|
||||
}
|
||||
solver.spine.rootHeadingOffset = deltaAngleRoot;
|
||||
deltaAngleRoot = Mathf.Clamp(deltaAngleRoot, -weightedAngleLimit, weightedAngleLimit);
|
||||
_ikSimulatedRootAngle = Mathf.MoveTowardsAngle(_ikSimulatedRootAngle, pivotAngle, absDeltaAngleRoot - weightedAngleLimit);
|
||||
|
||||
rootHeadingOffset = deltaAngleRoot;
|
||||
}
|
||||
|
||||
solver.spine.maxRootAngle = maxRootAngle;
|
||||
solver.spine.rootHeadingOffset = rootHeadingOffset;
|
||||
|
||||
// custom IK settings
|
||||
solver.spine.neckStiffness = IKFixes.EntryNeckStiffness.Value;
|
||||
solver.spine.bodyRotStiffness = IKFixes.EntryBodyRotStiffness.Value;
|
||||
|
@ -194,25 +197,24 @@ internal static class BodySystemPatches
|
|||
if (BodySystem.isCalibrating)
|
||||
{
|
||||
IKSystem.Instance.humanPose.bodyRotation = Quaternion.identity;
|
||||
IKSystem.vrik.solver.spine.maxRootAngle = 0f; // idk, testing
|
||||
//IKSystem.vrik.solver.spine.maxRootAngle = 0f; // idk, testing
|
||||
}
|
||||
|
||||
// makes running animation look better
|
||||
if (BodySystem.isCalibratedAsFullBody && BodySystem.PlayRunningAnimationInFullBody && BodySystem.TrackingPositionWeight > 0f)
|
||||
if (BodySystem.isCalibratedAsFullBody && BodySystem.TrackingPositionWeight > 0f)
|
||||
{
|
||||
bool isRunning = MovementSystem.Instance.movementVector.magnitude > 0f;
|
||||
bool isGrounded = MovementSystem.Instance._isGrounded;
|
||||
bool isFlying = MovementSystem.Instance.flying;
|
||||
if (isRunning || !isGrounded && !isFlying)
|
||||
bool playRunningAnimation = BodySystem.PlayRunningAnimationInFullBody;
|
||||
|
||||
if ((playRunningAnimation && (isRunning || !isGrounded && !isFlying)))
|
||||
{
|
||||
SetPelvisWeight(IKSystem.vrik.solver.spine, 0f);
|
||||
// This looks much better when running
|
||||
IKSystem.Instance.applyOriginalHipPosition = true;
|
||||
IKSystem.Instance.applyOriginalHipRotation = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Resetting bodyRotation made running animations look funky
|
||||
IKSystem.Instance.applyOriginalHipPosition = true;
|
||||
IKSystem.Instance.applyOriginalHipRotation = false;
|
||||
IKSystem.Instance.humanPose.bodyRotation = Quaternion.identity;
|
||||
|
|
|
@ -25,6 +25,6 @@ using System.Reflection;
|
|||
namespace NAK.IKFixes.Properties;
|
||||
internal static class AssemblyInfoParams
|
||||
{
|
||||
public const string Version = "1.0.4";
|
||||
public const string Version = "1.0.5";
|
||||
public const string Author = "NotAKidoS";
|
||||
}
|
59
InteractionTest/ColliderTest/AvatarColliderStruct.cs
Normal file
59
InteractionTest/ColliderTest/AvatarColliderStruct.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public struct AvatarTransforms
|
||||
{
|
||||
public Transform root;
|
||||
public Transform hips;
|
||||
public Transform spine;
|
||||
public Transform chest;
|
||||
public Transform neck;
|
||||
public Transform head;
|
||||
public Transform leftShoulder;
|
||||
public Transform leftUpperArm;
|
||||
public Transform leftLowerArm;
|
||||
public Transform leftHand;
|
||||
public Transform rightShoulder;
|
||||
public Transform rightUpperArm;
|
||||
public Transform rightLowerArm;
|
||||
public Transform rightHand;
|
||||
public Transform leftUpperLeg;
|
||||
public Transform leftLowerLeg;
|
||||
public Transform leftFoot;
|
||||
public Transform rightUpperLeg;
|
||||
public Transform rightLowerLeg;
|
||||
public Transform rightFoot;
|
||||
|
||||
public AvatarTransforms GetAvatarTransforms(Animator animator)
|
||||
{
|
||||
AvatarTransforms result = new AvatarTransforms()
|
||||
{
|
||||
root = animator.transform,
|
||||
hips = animator.GetBoneTransform(HumanBodyBones.Hips),
|
||||
spine = animator.GetBoneTransform(HumanBodyBones.Spine),
|
||||
chest = animator.GetBoneTransform(HumanBodyBones.Chest),
|
||||
neck = animator.GetBoneTransform(HumanBodyBones.Neck),
|
||||
head = animator.GetBoneTransform(HumanBodyBones.Head),
|
||||
leftShoulder = animator.GetBoneTransform(HumanBodyBones.LeftShoulder),
|
||||
leftUpperArm = animator.GetBoneTransform(HumanBodyBones.LeftUpperArm),
|
||||
leftLowerArm = animator.GetBoneTransform(HumanBodyBones.LeftLowerArm),
|
||||
leftHand = animator.GetBoneTransform(HumanBodyBones.LeftHand),
|
||||
rightShoulder = animator.GetBoneTransform(HumanBodyBones.RightShoulder),
|
||||
rightUpperArm = animator.GetBoneTransform(HumanBodyBones.RightUpperArm),
|
||||
rightLowerArm = animator.GetBoneTransform(HumanBodyBones.RightLowerArm),
|
||||
rightHand = animator.GetBoneTransform(HumanBodyBones.RightHand),
|
||||
leftUpperLeg = animator.GetBoneTransform(HumanBodyBones.LeftUpperLeg),
|
||||
leftLowerLeg = animator.GetBoneTransform(HumanBodyBones.LeftLowerLeg),
|
||||
leftFoot = animator.GetBoneTransform(HumanBodyBones.LeftFoot),
|
||||
rightUpperLeg = animator.GetBoneTransform(HumanBodyBones.RightUpperLeg),
|
||||
rightLowerLeg = animator.GetBoneTransform(HumanBodyBones.RightLowerLeg),
|
||||
rightFoot = animator.GetBoneTransform(HumanBodyBones.RightFoot),
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
175
InteractionTest/ColliderTest/AvatarColliders.cs
Normal file
175
InteractionTest/ColliderTest/AvatarColliders.cs
Normal file
|
@ -0,0 +1,175 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AvatarColliders : MonoBehaviour
|
||||
{
|
||||
public Animator animator;
|
||||
public AvatarTransforms m_avatarTransforms;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (animator == null)
|
||||
animator = GetComponent<Animator>();
|
||||
|
||||
m_avatarTransforms = m_avatarTransforms.GetAvatarTransforms(animator);
|
||||
|
||||
CreateColliderTorso();
|
||||
CreateColliderLeftArm();
|
||||
CreateColliderRightArm();
|
||||
}
|
||||
|
||||
void CreateColliderLeftArm()
|
||||
{
|
||||
// Calculate the magnitudes for the upper arm, lower arm, and hand.
|
||||
// This would need to be adjusted based on the specific avatar model being used.
|
||||
float upperArmMagnitude = CalculateMagnitude(m_avatarTransforms.leftUpperArm.position, m_avatarTransforms.leftLowerArm.position);
|
||||
//float lowerArmMagnitude = CalculateMagnitude(m_avatarTransforms.leftLowerArm.position, m_avatarTransforms.leftHand.position);
|
||||
|
||||
float handMagnitude = upperArmMagnitude * 0.25f; // Assuming hand is about half the size of the upper arm.
|
||||
|
||||
// Create a collider for the upper arm area
|
||||
Vector3 upperArmPosition = m_avatarTransforms.leftUpperArm.position;
|
||||
Vector3 lowerArmPosition = m_avatarTransforms.leftLowerArm.position;
|
||||
CreateCollider(m_avatarTransforms.leftUpperArm, upperArmPosition, lowerArmPosition, handMagnitude, 0.15f);
|
||||
|
||||
// Create a collider for the lower arm area
|
||||
Vector3 handPosition = m_avatarTransforms.leftHand.position;
|
||||
CreateCollider(m_avatarTransforms.leftLowerArm, lowerArmPosition, handPosition, handMagnitude, 0.15f);
|
||||
|
||||
// Create a collider for the hand area
|
||||
// For simplicity, let's assume the end position is slightly offset from the hand position.
|
||||
Vector3 handEndPosition = handPosition + (handPosition - lowerArmPosition) * 0.5f;
|
||||
CreateCollider(m_avatarTransforms.leftHand, handPosition, handEndPosition, handMagnitude, 0.15f);
|
||||
}
|
||||
|
||||
void CreateColliderRightArm()
|
||||
{
|
||||
// Calculate the magnitudes for the upper arm, lower arm, and hand.
|
||||
// This would need to be adjusted based on the specific avatar model being used.
|
||||
float upperArmMagnitude = CalculateMagnitude(m_avatarTransforms.rightUpperArm.position, m_avatarTransforms.rightLowerArm.position);
|
||||
//float lowerArmMagnitude = CalculateMagnitude(m_avatarTransforms.rightLowerArm.position, m_avatarTransforms.rightHand.position);
|
||||
|
||||
float handMagnitude = upperArmMagnitude * 0.25f; // Assuming hand is about half the size of the upper arm.
|
||||
|
||||
// Create a collider for the upper arm area
|
||||
Vector3 upperArmPosition = m_avatarTransforms.rightUpperArm.position;
|
||||
Vector3 lowerArmPosition = m_avatarTransforms.rightLowerArm.position;
|
||||
CreateCollider(m_avatarTransforms.rightUpperArm, upperArmPosition, lowerArmPosition, handMagnitude, 0.15f);
|
||||
|
||||
// Create a collider for the lower arm area
|
||||
Vector3 handPosition = m_avatarTransforms.rightHand.position;
|
||||
CreateCollider(m_avatarTransforms.rightLowerArm, lowerArmPosition, handPosition, handMagnitude, 0.15f);
|
||||
|
||||
// Create a collider for the hand area
|
||||
// For simplicity, let's assume the end position is slightly offset from the hand position.
|
||||
Vector3 handEndPosition = handPosition + (handPosition - lowerArmPosition) * 0.5f;
|
||||
CreateCollider(m_avatarTransforms.rightHand, handPosition, handEndPosition, handMagnitude, 0.15f);
|
||||
}
|
||||
|
||||
void CreateColliderTorso()
|
||||
{
|
||||
float legMagnitude = CalculateMagnitude(m_avatarTransforms.rightUpperLeg.position, m_avatarTransforms.leftUpperLeg.position);
|
||||
|
||||
//gets between upperarm and shoulder distances
|
||||
float armMagnitude = CalculateMagnitude(m_avatarTransforms.rightUpperArm.position, m_avatarTransforms.leftShoulder.position);
|
||||
|
||||
Vector3 hipsPosition = GetHipsPosition();
|
||||
|
||||
// Create a collider for the hips area
|
||||
Vector3 spinePosition = m_avatarTransforms.spine.position;
|
||||
CreateCollider(m_avatarTransforms.hips, hipsPosition, spinePosition, legMagnitude, 0.15f);
|
||||
|
||||
// Create a collider for the chest area
|
||||
Vector3 chestPosition = m_avatarTransforms.chest.position;
|
||||
CreateCollider(m_avatarTransforms.spine, spinePosition, chestPosition, (legMagnitude + armMagnitude) / 2, 0.15f);
|
||||
|
||||
// Create a collider for the neck area
|
||||
Vector3 neckPosition = m_avatarTransforms.neck.position;
|
||||
CreateCollider(m_avatarTransforms.chest, chestPosition, neckPosition, armMagnitude, 0.15f);
|
||||
}
|
||||
|
||||
static float CalculateMagnitude(Vector3 position1, Vector3 position2)
|
||||
{
|
||||
return (position1 - position2).magnitude;
|
||||
}
|
||||
|
||||
Vector3 GetHipsPosition()
|
||||
{
|
||||
Vector3 hipsPosition = m_avatarTransforms.hips.position;
|
||||
|
||||
if (Vector3.Distance(hipsPosition, m_avatarTransforms.root.position) < Vector3.Distance(m_avatarTransforms.head.position, m_avatarTransforms.root.position) * 0.25f)
|
||||
{
|
||||
hipsPosition = Vector3.Lerp(m_avatarTransforms.leftUpperLeg.position, m_avatarTransforms.rightUpperLeg.position, 0.5f);
|
||||
}
|
||||
|
||||
return hipsPosition;
|
||||
}
|
||||
|
||||
static void CreateCollider(Transform root, Vector3 start, Vector3 end, float width, float overlap)
|
||||
{
|
||||
Vector3 direction = end - start;
|
||||
float length = direction.magnitude * (1f + overlap);
|
||||
Vector3 axisVectorToDirection = GetAxisVectorToDirection(root.rotation, direction);
|
||||
|
||||
Vector3 lossyScale = root.lossyScale;
|
||||
float scaleF = (lossyScale.x + lossyScale.y + lossyScale.z) / 3f;
|
||||
|
||||
CapsuleCollider capsuleCollider = root.gameObject.AddComponent<CapsuleCollider>();
|
||||
capsuleCollider.height = Mathf.Abs(length / scaleF);
|
||||
capsuleCollider.radius = Mathf.Abs(width / scaleF);
|
||||
capsuleCollider.direction = DirectionVector3ToInt(axisVectorToDirection);
|
||||
capsuleCollider.center = root.InverseTransformPoint(Vector3.Lerp(start, end, 0.5f));
|
||||
capsuleCollider.isTrigger = true;
|
||||
}
|
||||
|
||||
public static Vector3 GetAxisVectorToDirection(Quaternion rotation, Vector3 direction)
|
||||
{
|
||||
direction = direction.normalized;
|
||||
Vector3 result = Vector3.right;
|
||||
|
||||
Vector3 right = rotation * Vector3.right;
|
||||
Vector3 up = rotation * Vector3.up;
|
||||
Vector3 forward = rotation * Vector3.forward;
|
||||
|
||||
float dotRight = Mathf.Abs(Vector3.Dot(Vector3.Normalize(right), direction));
|
||||
float dotUp = Mathf.Abs(Vector3.Dot(Vector3.Normalize(up), direction));
|
||||
float dotForward = Mathf.Abs(Vector3.Dot(Vector3.Normalize(forward), direction));
|
||||
|
||||
if (dotUp > dotRight)
|
||||
{
|
||||
result = Vector3.up;
|
||||
}
|
||||
|
||||
if (dotForward > dotRight && dotForward > dotUp)
|
||||
{
|
||||
result = Vector3.forward;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int DirectionVector3ToInt(Vector3 dir)
|
||||
{
|
||||
float dotRight = Vector3.Dot(dir, Vector3.right);
|
||||
float dotUp = Vector3.Dot(dir, Vector3.up);
|
||||
float dotForward = Vector3.Dot(dir, Vector3.forward);
|
||||
|
||||
float absDotRight = Mathf.Abs(dotRight);
|
||||
float absDotUp = Mathf.Abs(dotUp);
|
||||
float absDotForward = Mathf.Abs(dotForward);
|
||||
|
||||
int result = 0;
|
||||
|
||||
if (absDotUp > absDotRight && absDotUp > absDotForward)
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
else if (absDotForward > absDotRight && absDotForward > absDotUp)
|
||||
{
|
||||
result = 2;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
30
InteractionTest/ColliderTest/LineColliderTest.cs
Normal file
30
InteractionTest/ColliderTest/LineColliderTest.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using UnityEngine;
|
||||
|
||||
public static class SphereBetweenLinesHelper
|
||||
{
|
||||
public static bool IsSphereBetweenLines(Vector3 lineStart, Vector3 lineEnd, Vector3 sphereCenter, float sphereRadius)
|
||||
{
|
||||
// Calculate the closest point on the line to the sphere's center
|
||||
Vector3 closestPointOnLine = GetClosestPointOnLine(lineStart, lineEnd, sphereCenter);
|
||||
|
||||
// Calculate the distance between the sphere's center and the closest point on the line
|
||||
float distanceToLine = Vector3.Distance(sphereCenter, closestPointOnLine);
|
||||
|
||||
// Check if the sphere is between the lines
|
||||
return distanceToLine < sphereRadius;
|
||||
}
|
||||
|
||||
// Get the closest point on a line to a given point
|
||||
private static Vector3 GetClosestPointOnLine(Vector3 lineStart, Vector3 lineEnd, Vector3 point)
|
||||
{
|
||||
Vector3 lineDirection = (lineEnd - lineStart).normalized;
|
||||
float closestPointDistance = Vector3.Dot((point - lineStart), lineDirection);
|
||||
return lineStart + (closestPointDistance * lineDirection);
|
||||
}
|
||||
|
||||
public static bool IsPointWithinDistance(Vector3 position, Vector3 point, float distance)
|
||||
{
|
||||
float distanceToPosition = Vector3.Distance(position, point);
|
||||
return distanceToPosition <= distance;
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ class PuppetMasterPatches
|
|||
[HarmonyPatch(typeof(PuppetMaster), nameof(PuppetMaster.AvatarInstantiated))]
|
||||
static void Postfix_PuppetMaster_SetupAvatar(ref PuppetMaster __instance)
|
||||
{
|
||||
__instance.avatarObject.AddComponent<AutoArmIK>();
|
||||
__instance.avatarObject.AddComponent<AvatarColliders>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,6 @@ class PlayerSetupPatches
|
|||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.SetupAvatar))]
|
||||
static void Postfix_PlayerSetup_SetupAvatar(ref PlayerSetup __instance)
|
||||
{
|
||||
|
||||
__instance._avatar.AddComponent<AvatarColliders>();
|
||||
}
|
||||
}
|
|
@ -57,6 +57,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IKAdjustments", "IKAdjustme
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SmoothRay", "SmoothRay\SmoothRay.csproj", "{1BBC97C5-CC9F-4DA2-B166-F507F825DFAA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrackedPointFix", "TrackedPointFix\TrackedPointFix.csproj", "{0A6788A8-89E9-4FC4-B4FE-27FE8B39926C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -171,6 +173,10 @@ Global
|
|||
{1BBC97C5-CC9F-4DA2-B166-F507F825DFAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1BBC97C5-CC9F-4DA2-B166-F507F825DFAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1BBC97C5-CC9F-4DA2-B166-F507F825DFAA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0A6788A8-89E9-4FC4-B4FE-27FE8B39926C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0A6788A8-89E9-4FC4-B4FE-27FE8B39926C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0A6788A8-89E9-4FC4-B4FE-27FE8B39926C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0A6788A8-89E9-4FC4-B4FE-27FE8B39926C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace NAK.SmoothRay;
|
|||
|
||||
// ChilloutVR adaptation of:
|
||||
// https://github.com/kinsi55/BeatSaber_SmoothedController
|
||||
// https://github.com/kinsi55/BeatSaber_SmoothedController/blob/master/LICENSE
|
||||
|
||||
public class SmoothRay : MelonMod
|
||||
{
|
||||
|
@ -35,7 +36,7 @@ public class SmoothRay : MelonMod
|
|||
ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches));
|
||||
}
|
||||
|
||||
private void ApplyPatches(Type type)
|
||||
void ApplyPatches(Type type)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
# SmoothRay (Depricated)
|
||||
lazy af fix for a small issue
|
||||
# SmoothRay
|
||||
|
||||
Your Left/Right hand controllers will now track faster and while in the Steam overlay.
|
||||
|
||||
This approach to fixing the issue is made lazy to support DesktopVRSwitch.
|
||||
|
||||
(also because im lazy)
|
||||
Smoothes your controller while using the Quick and Main menus to make it easier to navigate.
|
||||
|
||||
---
|
||||
|
||||
|
|
|
@ -1,4 +1,28 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
/**
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Kinsi, NotAKidOnSteam
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
**/
|
||||
|
||||
using ABI_RC.Core.InteractionSystem;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using Valve.VR;
|
||||
|
@ -7,7 +31,7 @@ namespace NAK.SmoothRay;
|
|||
|
||||
public class SmoothRayer : MonoBehaviour
|
||||
{
|
||||
internal ControllerRay ray;
|
||||
public ControllerRay ray;
|
||||
|
||||
//settings
|
||||
bool isEnabled;
|
||||
|
@ -58,16 +82,14 @@ public class SmoothRayer : MonoBehaviour
|
|||
if (pose != null)
|
||||
pose.onTransformUpdatedEvent += OnTransformUpdated;
|
||||
if (tracked != null && newPosesAction != null)
|
||||
{
|
||||
newPosesAction.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
smoothedPosition = transform.localPosition;
|
||||
smoothedRotation = transform.localRotation;
|
||||
|
||||
|
||||
// desktopvrswitch support, normal use wont run this
|
||||
if (pose != null)
|
||||
pose.onTransformUpdatedEvent -= OnTransformUpdated;
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
"loaderversion": "0.5.7",
|
||||
"modtype": "Mod",
|
||||
"author": "NotAKidoS",
|
||||
"description": "Allows your controllers to track while the SteamVR overlay is open. This also fixes Quest/Touch controllers feeling slow during fast movements.",
|
||||
"description": "Smoothes your controller while using the Quick and Main menus to make it easier to navigate.",
|
||||
"searchtags": [
|
||||
"vr",
|
||||
"quest",
|
||||
"ray",
|
||||
"controller",
|
||||
"tracking"
|
||||
],
|
||||
|
@ -19,5 +19,5 @@
|
|||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/SmoothRay.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/SmoothRay/",
|
||||
"changelog": "Initial Release",
|
||||
"embedcolor": "3498db"
|
||||
"embedcolor": "dc8105"
|
||||
}
|
|
@ -10,12 +10,11 @@ class PlayerSetupPatches
|
|||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.Start))]
|
||||
static void Post_PlayerSetup_Start(ref PlayerSetup __instance)
|
||||
{
|
||||
// Add TrackedControllerFix
|
||||
var vrLeftHandTracker = __instance.vrLeftHandTracker.AddComponent<TrackedControllerFixer>();
|
||||
vrLeftHandTracker.inputSource = SteamVR_Input_Sources.LeftHand;
|
||||
var vrRightHandTracker = __instance.vrRightHandTracker.AddComponent<TrackedControllerFixer>();
|
||||
vrRightHandTracker.inputSource = SteamVR_Input_Sources.RightHand;
|
||||
vrLeftHandTracker.Initialize();
|
||||
vrRightHandTracker.Initialize();
|
||||
var leftFixer = __instance.vrLeftHandTracker.AddComponent<TrackedControllerFixer>();
|
||||
leftFixer.inputSource = SteamVR_Input_Sources.LeftHand;
|
||||
leftFixer.Initialize();
|
||||
var rightFixer = __instance.vrRightHandTracker.AddComponent<TrackedControllerFixer>();
|
||||
rightFixer.inputSource = SteamVR_Input_Sources.RightHand;
|
||||
rightFixer.Initialize();
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ public class TrackedControllerFix : MelonMod
|
|||
ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches));
|
||||
}
|
||||
|
||||
private void ApplyPatches(Type type)
|
||||
void ApplyPatches(Type type)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -25,6 +25,6 @@ using System.Reflection;
|
|||
namespace NAK.TrackedControllerFix.Properties;
|
||||
internal static class AssemblyInfoParams
|
||||
{
|
||||
public const string Version = "1.0.2";
|
||||
public const string Version = "1.0.3";
|
||||
public const string Author = "NotAKidoS";
|
||||
}
|
|
@ -6,11 +6,13 @@ namespace NAK.TrackedControllerFix;
|
|||
public class TrackedControllerFixer : MonoBehaviour
|
||||
{
|
||||
public SteamVR_Input_Sources inputSource;
|
||||
public int deviceIndex;
|
||||
public int deviceIndex = -1;
|
||||
|
||||
SteamVR_TrackedObject trackedObject;
|
||||
SteamVR_Behaviour_Pose oldBehaviourPose;
|
||||
SteamVR_Action_Pose actionPose;
|
||||
|
||||
SteamVR_RenderModel renderModel;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
|
@ -19,6 +21,8 @@ public class TrackedControllerFixer : MonoBehaviour
|
|||
oldBehaviourPose.broadcastDeviceChanges = false; //this fucks us
|
||||
oldBehaviourPose.enabled = false;
|
||||
|
||||
renderModel = gameObject.GetComponentInChildren<SteamVR_RenderModel>();
|
||||
|
||||
actionPose = SteamVR_Input.GetAction<SteamVR_Action_Pose>("Pose", false);
|
||||
if (actionPose != null) CheckDeviceIndex();
|
||||
}
|
||||
|
@ -39,6 +43,14 @@ public class TrackedControllerFixer : MonoBehaviour
|
|||
oldBehaviourPose.enabled = true;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (deviceIndex < 0)
|
||||
{
|
||||
CheckDeviceIndex();
|
||||
}
|
||||
}
|
||||
|
||||
void OnDeviceConnectedChanged(SteamVR_Action_Pose changedAction, SteamVR_Input_Sources changedSource, bool connected)
|
||||
{
|
||||
if (actionPose != changedAction) actionPose = changedAction;
|
||||
|
@ -54,7 +66,8 @@ public class TrackedControllerFixer : MonoBehaviour
|
|||
if (deviceIndex != trackedDeviceIndex)
|
||||
{
|
||||
deviceIndex = trackedDeviceIndex;
|
||||
trackedObject.SetDeviceIndex(deviceIndex);
|
||||
trackedObject?.SetDeviceIndex(deviceIndex);
|
||||
renderModel?.SetDeviceIndex(deviceIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
47
TrackedPointFix/HarmonyPatches.cs
Normal file
47
TrackedPointFix/HarmonyPatches.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
using ABI_RC.Systems.IK;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using Valve.VR;
|
||||
|
||||
namespace NAK.TrackedPointFix.HarmonyPatches;
|
||||
|
||||
class IKSystemPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(TrackingPoint), nameof(TrackingPoint.SetVisibility))]
|
||||
static void Postfix_TrackingPoint_SetVisibility(ref TrackingPoint __instance)
|
||||
{
|
||||
GameObject systemTracker = __instance.referenceTransform.Find("DisplayTracker").gameObject;
|
||||
if (systemTracker != null)
|
||||
{
|
||||
systemTracker.SetActive(__instance.displayObject.activeSelf);
|
||||
__instance.displayObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(TrackingPoint), nameof(TrackingPoint.Initialize))]
|
||||
static void Postfix_TrackingPoint_Initialize(ref TrackingPoint __instance)
|
||||
{
|
||||
GameObject systemTracker = new GameObject();
|
||||
systemTracker.name = "DisplayTracker";
|
||||
systemTracker.transform.parent = __instance.referenceTransform;
|
||||
systemTracker.transform.localPosition = Vector3.zero;
|
||||
systemTracker.transform.localRotation = Quaternion.identity;
|
||||
systemTracker.transform.localScale = Vector3.one;
|
||||
systemTracker.SetActive(false);
|
||||
|
||||
SteamVR_RenderModel renderModel = systemTracker.AddComponent<SteamVR_RenderModel>();
|
||||
renderModel.enabled = true;
|
||||
renderModel.updateDynamically = false;
|
||||
renderModel.createComponents = false;
|
||||
renderModel.SetDeviceIndex(ExtractNumberFromTrackingPoint(__instance.name));
|
||||
}
|
||||
|
||||
public static int ExtractNumberFromTrackingPoint(string inputString)
|
||||
{
|
||||
string numberString = inputString.Replace("SteamVR_", "");
|
||||
int number = int.Parse(numberString);
|
||||
return number;
|
||||
}
|
||||
}
|
24
TrackedPointFix/Main.cs
Normal file
24
TrackedPointFix/Main.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using MelonLoader;
|
||||
|
||||
namespace NAK.TrackedPointFix;
|
||||
|
||||
public class TrackedPointFix : MelonMod
|
||||
{
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
ApplyPatches(typeof(HarmonyPatches.IKSystemPatches));
|
||||
}
|
||||
|
||||
void ApplyPatches(Type type)
|
||||
{
|
||||
try
|
||||
{
|
||||
HarmonyInstance.PatchAll(type);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LoggerInstance.Msg($"Failed while patching {type.Name}!");
|
||||
LoggerInstance.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
30
TrackedPointFix/Properties/AssemblyInfo.cs
Normal file
30
TrackedPointFix/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using MelonLoader;
|
||||
using NAK.TrackedPointFix.Properties;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyTitle(nameof(NAK.TrackedPointFix))]
|
||||
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
||||
[assembly: AssemblyProduct(nameof(NAK.TrackedPointFix))]
|
||||
|
||||
[assembly: MelonInfo(
|
||||
typeof(NAK.TrackedPointFix.TrackedPointFix),
|
||||
nameof(NAK.TrackedPointFix),
|
||||
AssemblyInfoParams.Version,
|
||||
AssemblyInfoParams.Author,
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/TrackedPointFix"
|
||||
)]
|
||||
|
||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||
[assembly: HarmonyDontPatchAll]
|
||||
|
||||
namespace NAK.TrackedPointFix.Properties;
|
||||
internal static class AssemblyInfoParams
|
||||
{
|
||||
public const string Version = "1.0.3";
|
||||
public const string Author = "NotAKidoS";
|
||||
}
|
19
TrackedPointFix/README.md
Normal file
19
TrackedPointFix/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# TrackedPointFix (Depricated)
|
||||
lazy af fix for a small issue
|
||||
|
||||
Your Left/Right hand controllers will now track faster and while in the Steam overlay.
|
||||
|
||||
This approach to fixing the issue is made lazy to support DesktopVRSwitch.
|
||||
|
||||
(also because im lazy)
|
||||
|
||||
---
|
||||
|
||||
Here is the block of text where I tell you this mod is not affiliated or endorsed by ABI.
|
||||
https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games
|
||||
|
||||
> This mod is an independent creation and is not affiliated with, supported by or approved by Alpha Blend Interactive.
|
||||
|
||||
> Use of this mod is done so at the user's own risk and the creator cannot be held responsible for any issues arising from its use.
|
||||
|
||||
> To the best of my knowledge, I have adhered to the Modding Guidelines established by Alpha Blend Interactive.
|
2
TrackedPointFix/TrackedPointFix.csproj
Normal file
2
TrackedPointFix/TrackedPointFix.csproj
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk"/>
|
23
TrackedPointFix/format.json
Normal file
23
TrackedPointFix/format.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"_id": -1,
|
||||
"name": "TrackedPointFix",
|
||||
"modversion": "1.0.0",
|
||||
"gameversion": "2022r170",
|
||||
"loaderversion": "0.5.7",
|
||||
"modtype": "Mod",
|
||||
"author": "NotAKidoS",
|
||||
"description": "Allows your controllers to track while the SteamVR overlay is open. This also fixes Quest/Touch controllers feeling slow during fast movements.",
|
||||
"searchtags": [
|
||||
"vr",
|
||||
"quest",
|
||||
"controller",
|
||||
"tracking"
|
||||
],
|
||||
"requirements": [
|
||||
"None"
|
||||
],
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/TrackedPointFix.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/TrackedPointFix/",
|
||||
"changelog": "Initial Release",
|
||||
"embedcolor": "3498db"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue