From c96255aaa5040e16e192b0f229c3f97c64c28529 Mon Sep 17 00:00:00 2001 From: "Bob.Song" <605277374@qq.com> Date: Sun, 12 Apr 2026 21:45:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BA=BF=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ResRaw/Prefabs/Line/FishingLine1.prefab | 22 ++++- .../View/FishingLine/FishingLineRenderer.cs | 91 +------------------ .../New/View/FishingLine/FishingLineSolver.cs | 2 + .../View/Player/States/PlayerStageViewBase.cs | 16 ++-- 4 files changed, 31 insertions(+), 100 deletions(-) diff --git a/Assets/ResRaw/Prefabs/Line/FishingLine1.prefab b/Assets/ResRaw/Prefabs/Line/FishingLine1.prefab index 0271c9ed5..d3a7b89e9 100644 --- a/Assets/ResRaw/Prefabs/Line/FishingLine1.prefab +++ b/Assets/ResRaw/Prefabs/Line/FishingLine1.prefab @@ -11,7 +11,7 @@ GameObject: - component: {fileID: 6213026895670800501} - component: {fileID: 7362979975150531515} - component: {fileID: 5572865435543895569} - m_Layer: 0 + m_Layer: 15 m_Name: Start m_TagString: Untagged m_Icon: {fileID: 0} @@ -98,7 +98,8 @@ GameObject: - component: {fileID: 5707703654405666688} - component: {fileID: 3979683508768218053} - component: {fileID: 250386986656750139} - m_Layer: 0 + - component: {fileID: 6225447558892123241} + m_Layer: 15 m_Name: End m_TagString: Untagged m_Icon: {fileID: 0} @@ -194,6 +195,20 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 0.02, y: 0.02, z: 0.02} m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &6225447558892123241 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5077741257619886775} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1de1bec90e454664a860c5248170ff95, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::NBF.JointPinchController + moveSpeed: 5 + snapDistance: 0.1 --- !u!1 &5252216124238432432 GameObject: m_ObjectHideFlags: 0 @@ -207,7 +222,7 @@ GameObject: - component: {fileID: 9117070148710828175} - component: {fileID: 4152162740525283091} - component: {fileID: 2513762410452133691} - m_Layer: 0 + m_Layer: 15 m_Name: Bobber m_TagString: Untagged m_Icon: {fileID: 0} @@ -409,6 +424,7 @@ MonoBehaviour: m_EditorClassIdentifier: Assembly-CSharp::NBF.FishingLineSolver ConfigId: 0 LineType: 0 + PinchController: {fileID: 6225447558892123241} anchorTransform: {fileID: 0} logicalNodes: - {fileID: 5572865435543895569} diff --git a/Assets/Scripts/Fishing/New/View/FishingLine/FishingLineRenderer.cs b/Assets/Scripts/Fishing/New/View/FishingLine/FishingLineRenderer.cs index 05f1872ad..c393e827d 100644 --- a/Assets/Scripts/Fishing/New/View/FishingLine/FishingLineRenderer.cs +++ b/Assets/Scripts/Fishing/New/View/FishingLine/FishingLineRenderer.cs @@ -44,11 +44,6 @@ namespace NBF [SerializeField] private int stableFramesBeforeSleep = 4; [Min(0f)] [SerializeField] private float wakeDistanceThreshold = 0.001f; - [Min(0f)] - [SerializeField] private float tautSegmentThreshold = 0.002f; - [Min(0.001f)] - [SerializeField] private float tautTransitionRange = 0.03f; - [Header("Corner Smoothing")] [SerializeField] private bool smoothCorners = true; [Range(0f, 180f)] @@ -257,7 +252,8 @@ namespace NBF ApplyWaterSurfaceConstraint(stepDelta); SolveDistanceConstraints(points, restLengths); - StraightenTautLogicalSegments(points, restLengths); + // Keep a final pure distance solve so the render chain settles back to its rest-length budget + // without reintroducing the old forced-straightening behavior. SolveDistanceConstraints(points, restLengths); PinLogicalPoints(points); ApplySleep(); @@ -334,89 +330,6 @@ namespace NBF positions[segmentIndex + 1] -= correction; } - private void StraightenTautLogicalSegments( - IReadOnlyList points, - IReadOnlyList restLengths) - { - if (points.Count < 2 || restLengths.Count == 0) - { - return; - } - - var segmentStartIndex = 0; - while (segmentStartIndex < points.Count - 1) - { - if (!points[segmentStartIndex].IsLogical) - { - segmentStartIndex++; - continue; - } - - var segmentEndIndex = segmentStartIndex + 1; - while (segmentEndIndex < points.Count && !points[segmentEndIndex].IsLogical) - { - segmentEndIndex++; - } - - if (segmentEndIndex >= points.Count) - { - break; - } - - ProjectLogicalSegmentIfTaut(segmentStartIndex, segmentEndIndex, restLengths); - segmentStartIndex = segmentEndIndex; - } - } - - private void ProjectLogicalSegmentIfTaut( - int startIndex, - int endIndex, - IReadOnlyList restLengths) - { - if (endIndex - startIndex <= 1) - { - return; - } - - var segmentRestLength = 0f; - for (var i = startIndex; i < endIndex; i++) - { - segmentRestLength += restLengths[i]; - } - - var start = positions[startIndex]; - var end = positions[endIndex]; - var delta = end - start; - var endpointDistance = delta.magnitude; - if (endpointDistance <= 0.0001f) - { - return; - } - - var fullTautDistance = Mathf.Max(0f, segmentRestLength - tautSegmentThreshold); - var blendStartDistance = Mathf.Max(0f, fullTautDistance - tautTransitionRange); - if (endpointDistance < blendStartDistance) - { - return; - } - - var straightenBlend = blendStartDistance >= fullTautDistance - ? 1f - : Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(blendStartDistance, fullTautDistance, endpointDistance)); - - var direction = delta / endpointDistance; - var accumulatedDistance = 0f; - for (var pointIndex = startIndex + 1; pointIndex < endIndex; pointIndex++) - { - accumulatedDistance += restLengths[pointIndex - 1]; - var projectedPosition = start + direction * accumulatedDistance; - var currentPosition = positions[pointIndex]; - var blendedPosition = Vector3.Lerp(currentPosition, projectedPosition, straightenBlend); - positions[pointIndex] = blendedPosition; - previousPositions[pointIndex] = Vector3.Lerp(previousPositions[pointIndex], blendedPosition, straightenBlend); - } - } - private void ApplyWaterSurfaceConstraint(float stepDelta) { if (!constrainToWaterSurface || positions.Count == 0) diff --git a/Assets/Scripts/Fishing/New/View/FishingLine/FishingLineSolver.cs b/Assets/Scripts/Fishing/New/View/FishingLine/FishingLineSolver.cs index f2bd14984..9502aca24 100644 --- a/Assets/Scripts/Fishing/New/View/FishingLine/FishingLineSolver.cs +++ b/Assets/Scripts/Fishing/New/View/FishingLine/FishingLineSolver.cs @@ -47,6 +47,8 @@ namespace NBF [SerializeField] public LineType LineType; + public JointPinchController PinchController; + [Header("References")] [SerializeField] private Transform anchorTransform; diff --git a/Assets/Scripts/Fishing/New/View/Player/States/PlayerStageViewBase.cs b/Assets/Scripts/Fishing/New/View/Player/States/PlayerStageViewBase.cs index 396ec9daf..98d5c68b9 100644 --- a/Assets/Scripts/Fishing/New/View/Player/States/PlayerStageViewBase.cs +++ b/Assets/Scripts/Fishing/New/View/Player/States/PlayerStageViewBase.cs @@ -101,10 +101,10 @@ namespace NBF var handItemView = Player.HandItem.GetComponent(); if (handItemView != null && handItemView.Rod != null) { - // if (handItemView.Rod.Line.PinchController != null) - // { - // handItemView.Rod.Line.PinchController.StartPinch(view.Unity.ModelAsset.Pinch); - // } + if (handItemView.Rod.Line.PinchController != null) + { + handItemView.Rod.Line.PinchController.StartPinch(view.Unity.ModelAsset.Pinch); + } } } } @@ -118,10 +118,10 @@ namespace NBF var handItemView = Player.HandItem.GetComponent(); if (handItemView != null && handItemView.Rod != null) { - // if (handItemView.Rod.Line.PinchController != null) - // { - // handItemView.Rod.Line.PinchController.ReleasePinch(); - // } + if (handItemView.Rod.Line.PinchController != null) + { + handItemView.Rod.Line.PinchController.ReleasePinch(); + } } } }