提交线修改

This commit is contained in:
Bob.Song
2026-04-16 16:54:49 +08:00
parent f2803c9d74
commit e8b1a3e0f1
3 changed files with 264 additions and 719 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -296,6 +296,7 @@ namespace NBF
ropeObject.transform.SetParent(_ropeRoot); ropeObject.transform.SetParent(_ropeRoot);
var rope = ropeObject.AddComponent<Rope>(); var rope = ropeObject.AddComponent<Rope>();
node.Rope = rope; node.Rope = rope;
// rope.groundMask = LayerMask.GetMask("Terrain");
rope.startAnchor = node.Joint.connectedBody; rope.startAnchor = node.Joint.connectedBody;
rope.endAnchor = node.body; rope.endAnchor = node.body;
} }

View File

@@ -60,7 +60,7 @@ public class Rope : MonoBehaviour
[Header("Simple Ground/Water Constraint (Cheap)")] [SerializeField] [Header("Simple Ground/Water Constraint (Cheap)")] [SerializeField]
private bool constrainToGround = false; private bool constrainToGround = false;
[SerializeField] private LayerMask groundMask = ~0; [SerializeField] private LayerMask groundMask = 0;
[SerializeField, Min(0f)] private float groundRadius = 0.01f; [SerializeField, Min(0f)] private float groundRadius = 0.01f;
[SerializeField, Min(0f)] private float groundCastHeight = 1.0f; [SerializeField, Min(0f)] private float groundCastHeight = 1.0f;
[SerializeField, Min(0.01f)] private float groundCastDistance = 2.5f; [SerializeField, Min(0.01f)] private float groundCastDistance = 2.5f;
@@ -204,6 +204,7 @@ public class Rope : MonoBehaviour
RefreshVisibilityState(true); RefreshVisibilityState(true);
} }
private void OnValidate() private void OnValidate()
{ {
renderSubdivisionsIdle = Mathf.Max(renderSubdivisionsIdle, 1); renderSubdivisionsIdle = Mathf.Max(renderSubdivisionsIdle, 1);
@@ -583,9 +584,10 @@ public class Rope : MonoBehaviour
Time.fixedDeltaTime Time.fixedDeltaTime
); );
// 长度变化时额外压一点速度,减少收放线时抖动 // 仅在收线(目标长度小于当前长度)时额外压速度;
float delta = Mathf.Abs(_targetLength - _currentLength); // 放线时不要压速度,否则新增节点下落会出现“顿一下再突然加速”。
if (delta > 0.0001f && lengthChangeVelocityKill > 0f) float reelInDelta = _currentLength - _targetLength;
if (reelInDelta > 0.0001f && lengthChangeVelocityKill > 0f)
{ {
float keep = 1f - Mathf.Clamp01(lengthChangeVelocityKill); float keep = 1f - Mathf.Clamp01(lengthChangeVelocityKill);
for (int i = 1; i < _physicsNodes - 1; i++) for (int i = 1; i < _physicsNodes - 1; i++)
@@ -750,7 +752,8 @@ public class Rope : MonoBehaviour
SolveDistanceConstraintsSweep_Fast(last - 1, -1, -1, last, sweepStiffness); SolveDistanceConstraintsSweep_Fast(last - 1, -1, -1, last, sweepStiffness);
} }
private void SolveDistanceConstraintsSweep_Fast(int start, int endExclusive, int step, int last, float sweepStiffness) private void SolveDistanceConstraintsSweep_Fast(int start, int endExclusive, int step, int last,
float sweepStiffness)
{ {
for (int i = start; i != endExclusive; i += step) for (int i = start; i != endExclusive; i += step)
{ {