mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
[SmoothRay] Fixes for 2023r172.
This commit is contained in:
parent
bec47c6a26
commit
39cbdf8ed5
3 changed files with 33 additions and 24 deletions
|
@ -28,6 +28,6 @@ namespace NAK.SmoothRay.Properties;
|
||||||
|
|
||||||
internal static class AssemblyInfoParams
|
internal static class AssemblyInfoParams
|
||||||
{
|
{
|
||||||
public const string Version = "1.0.2";
|
public const string Version = "1.0.3";
|
||||||
public const string Author = "NotAKidoS";
|
public const string Author = "NotAKidoS";
|
||||||
}
|
}
|
|
@ -26,7 +26,6 @@ using ABI_RC.Core.InteractionSystem;
|
||||||
using ABI_RC.Core.Savior;
|
using ABI_RC.Core.Savior;
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Events;
|
|
||||||
using Valve.VR;
|
using Valve.VR;
|
||||||
|
|
||||||
namespace NAK.SmoothRay;
|
namespace NAK.SmoothRay;
|
||||||
|
@ -67,7 +66,7 @@ public class SmoothRayer : MonoBehaviour
|
||||||
// TrackedControllerFix support - OpenVR
|
// TrackedControllerFix support - OpenVR
|
||||||
if (TryGetComponent(out _trackedObject))
|
if (TryGetComponent(out _trackedObject))
|
||||||
{
|
{
|
||||||
_newPosesAction = SteamVR_Events.NewPosesAppliedAction(new UnityAction(OnAppliedPoses));
|
_newPosesAction = SteamVR_Events.NewPosesAppliedAction(OnAppliedPoses);
|
||||||
UpdatePosesAction(true);
|
UpdatePosesAction(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,8 +78,9 @@ public class SmoothRayer : MonoBehaviour
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
_smoothedPosition = transform.localPosition;
|
Transform controller = transform;
|
||||||
_smoothedRotation = transform.localRotation;
|
_smoothedPosition = controller.localPosition;
|
||||||
|
_smoothedRotation = controller.localRotation;
|
||||||
|
|
||||||
// desktopvrswitch support, start handles this for normal use
|
// desktopvrswitch support, start handles this for normal use
|
||||||
UpdateTransformUpdatedEvent(true);
|
UpdateTransformUpdatedEvent(true);
|
||||||
|
@ -89,8 +89,9 @@ public class SmoothRayer : MonoBehaviour
|
||||||
|
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
{
|
{
|
||||||
_smoothedPosition = transform.localPosition;
|
Transform controller = transform;
|
||||||
_smoothedRotation = transform.localRotation;
|
_smoothedPosition = controller.localPosition;
|
||||||
|
_smoothedRotation = controller.localRotation;
|
||||||
|
|
||||||
// desktopvrswitch support, normal use wont run this
|
// desktopvrswitch support, normal use wont run this
|
||||||
UpdateTransformUpdatedEvent(false);
|
UpdateTransformUpdatedEvent(false);
|
||||||
|
@ -115,7 +116,7 @@ public class SmoothRayer : MonoBehaviour
|
||||||
if (enable && CheckVR.Instance.forceOpenXr)
|
if (enable && CheckVR.Instance.forceOpenXr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_behaviourPose == null)
|
if (_behaviourPose == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
|
@ -134,20 +135,26 @@ public class SmoothRayer : MonoBehaviour
|
||||||
_rotationSmoothingValue = Math.Max(20f - Mathf.Clamp(SmoothRay.EntryRotationSmoothing.Value, 0f, 20f), 0.1f);
|
_rotationSmoothingValue = Math.Max(20f - Mathf.Clamp(SmoothRay.EntryRotationSmoothing.Value, 0f, 20f), 0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAppliedPoses() => SmoothTransform();
|
private void OnAppliedPoses()
|
||||||
|
{
|
||||||
|
SmoothTransform();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnTransformUpdated(SteamVR_Behaviour_Pose pose, SteamVR_Input_Sources inputSource) => SmoothTransform();
|
private void OnTransformUpdated(SteamVR_Behaviour_Pose pose, SteamVR_Input_Sources inputSource)
|
||||||
|
{
|
||||||
|
SmoothTransform();
|
||||||
|
}
|
||||||
|
|
||||||
private void SmoothTransform()
|
private void SmoothTransform()
|
||||||
{
|
{
|
||||||
|
Transform controller = transform;
|
||||||
if (_isEnabled && ray.lineRenderer != null && ray.lineRenderer.enabled)
|
if (_isEnabled && ray.lineRenderer != null && ray.lineRenderer.enabled)
|
||||||
{
|
{
|
||||||
if (_menuOnly && (!ray.uiActive || (ray.hitTransform != ViewManager.Instance.transform && ray.hitTransform != CVR_MenuManager.Instance.quickMenu.transform)))
|
if (_menuOnly && (!ray.uiActive || (ray.hitTransform != ViewManager.Instance.transform &&
|
||||||
{
|
ray.hitTransform != CVR_MenuManager.Instance.quickMenu.transform)))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
var angDiff = Quaternion.Angle(_smoothedRotation, transform.localRotation);
|
var angDiff = Quaternion.Angle(_smoothedRotation, controller.localRotation);
|
||||||
_angleVelocitySnap = Mathf.Min(_angleVelocitySnap + angDiff, 90f);
|
_angleVelocitySnap = Mathf.Min(_angleVelocitySnap + angDiff, 90f);
|
||||||
|
|
||||||
var snapMulti = Mathf.Clamp(_angleVelocitySnap / _smallMovementThresholdAngle, 0.1f, 2.5f);
|
var snapMulti = Mathf.Clamp(_angleVelocitySnap / _smallMovementThresholdAngle, 0.1f, 2.5f);
|
||||||
|
@ -157,20 +164,22 @@ public class SmoothRayer : MonoBehaviour
|
||||||
|
|
||||||
if (_positionSmoothingValue < 20f)
|
if (_positionSmoothingValue < 20f)
|
||||||
{
|
{
|
||||||
_smoothedPosition = Vector3.Lerp(_smoothedPosition, transform.localPosition, _positionSmoothingValue * Time.deltaTime * snapMulti);
|
_smoothedPosition = Vector3.Lerp(_smoothedPosition, controller.localPosition,
|
||||||
transform.localPosition = _smoothedPosition;
|
_positionSmoothingValue * Time.deltaTime * snapMulti);
|
||||||
|
controller.localPosition = _smoothedPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_rotationSmoothingValue < 20f)
|
if (_rotationSmoothingValue < 20f)
|
||||||
{
|
{
|
||||||
_smoothedRotation = Quaternion.Lerp(_smoothedRotation, transform.localRotation, _rotationSmoothingValue * Time.deltaTime * snapMulti);
|
_smoothedRotation = Quaternion.Lerp(_smoothedRotation, controller.localRotation,
|
||||||
transform.localRotation = _smoothedRotation;
|
_rotationSmoothingValue * Time.deltaTime * snapMulti);
|
||||||
|
controller.localRotation = _smoothedRotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_smoothedPosition = transform.localPosition;
|
_smoothedPosition = controller.localPosition;
|
||||||
_smoothedRotation = transform.localRotation;
|
_smoothedRotation = controller.localRotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"_id": 162,
|
"_id": 162,
|
||||||
"name": "SmoothRay",
|
"name": "SmoothRay",
|
||||||
"modversion": "1.0.2",
|
"modversion": "1.0.3",
|
||||||
"gameversion": "2023r171",
|
"gameversion": "2023r172",
|
||||||
"loaderversion": "0.6.1",
|
"loaderversion": "0.6.1",
|
||||||
"modtype": "Mod",
|
"modtype": "Mod",
|
||||||
"author": "NotAKidoS",
|
"author": "NotAKidoS",
|
||||||
|
@ -16,8 +16,8 @@
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"None"
|
"None"
|
||||||
],
|
],
|
||||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r16/SmoothRay.dll",
|
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r21/SmoothRay.dll",
|
||||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/SmoothRay/",
|
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/SmoothRay/",
|
||||||
"changelog": "- Fixes for 2023r171.\n- Prevented from initializing when launching with OpenXR.",
|
"changelog": "- Fixes for 2023r172. Literally just recompiled.",
|
||||||
"embedcolor": "#dc8105"
|
"embedcolor": "#dc8105"
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue