提交线修改
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -178,7 +178,7 @@ public class Rope : MonoBehaviour
|
|||||||
private bool _isCulledByVisibility;
|
private bool _isCulledByVisibility;
|
||||||
private int _tIdleSubdiv = -1;
|
private int _tIdleSubdiv = -1;
|
||||||
private int _tMovingSubdiv = -1;
|
private int _tMovingSubdiv = -1;
|
||||||
|
|
||||||
|
|
||||||
// Catmull t caches(只缓存 idle/moving 两档,减少每帧重复乘法)
|
// Catmull t caches(只缓存 idle/moving 两档,减少每帧重复乘法)
|
||||||
private struct TCaches
|
private struct TCaches
|
||||||
@@ -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);
|
||||||
@@ -243,7 +244,7 @@ public class Rope : MonoBehaviour
|
|||||||
_startTr = startAnchor ? startAnchor.transform : null;
|
_startTr = startAnchor ? startAnchor.transform : null;
|
||||||
_endTr = endAnchor ? endAnchor.transform : null;
|
_endTr = endAnchor ? endAnchor.transform : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Transform GetActiveCameraTransform()
|
private Transform GetActiveCameraTransform()
|
||||||
{
|
{
|
||||||
@@ -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)
|
||||||
{
|
{
|
||||||
@@ -1091,4 +1094,4 @@ public class Rope : MonoBehaviour
|
|||||||
for (int i = 0; i < _physicsNodes; i++)
|
for (int i = 0; i < _physicsNodes; i++)
|
||||||
Gizmos.DrawSphere(_pCurr[i], 0.01f);
|
Gizmos.DrawSphere(_pCurr[i], 0.01f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user