修改线渲染逻辑
This commit is contained in:
@@ -11,7 +11,7 @@ GameObject:
|
|||||||
- component: {fileID: 6213026895670800501}
|
- component: {fileID: 6213026895670800501}
|
||||||
- component: {fileID: 7362979975150531515}
|
- component: {fileID: 7362979975150531515}
|
||||||
- component: {fileID: 5572865435543895569}
|
- component: {fileID: 5572865435543895569}
|
||||||
m_Layer: 0
|
m_Layer: 15
|
||||||
m_Name: Start
|
m_Name: Start
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -98,7 +98,8 @@ GameObject:
|
|||||||
- component: {fileID: 5707703654405666688}
|
- component: {fileID: 5707703654405666688}
|
||||||
- component: {fileID: 3979683508768218053}
|
- component: {fileID: 3979683508768218053}
|
||||||
- component: {fileID: 250386986656750139}
|
- component: {fileID: 250386986656750139}
|
||||||
m_Layer: 0
|
- component: {fileID: 6225447558892123241}
|
||||||
|
m_Layer: 15
|
||||||
m_Name: End
|
m_Name: End
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -194,6 +195,20 @@ BoxCollider:
|
|||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
m_Size: {x: 0.02, y: 0.02, z: 0.02}
|
m_Size: {x: 0.02, y: 0.02, z: 0.02}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
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
|
--- !u!1 &5252216124238432432
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -207,7 +222,7 @@ GameObject:
|
|||||||
- component: {fileID: 9117070148710828175}
|
- component: {fileID: 9117070148710828175}
|
||||||
- component: {fileID: 4152162740525283091}
|
- component: {fileID: 4152162740525283091}
|
||||||
- component: {fileID: 2513762410452133691}
|
- component: {fileID: 2513762410452133691}
|
||||||
m_Layer: 0
|
m_Layer: 15
|
||||||
m_Name: Bobber
|
m_Name: Bobber
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -409,6 +424,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier: Assembly-CSharp::NBF.FishingLineSolver
|
m_EditorClassIdentifier: Assembly-CSharp::NBF.FishingLineSolver
|
||||||
ConfigId: 0
|
ConfigId: 0
|
||||||
LineType: 0
|
LineType: 0
|
||||||
|
PinchController: {fileID: 6225447558892123241}
|
||||||
anchorTransform: {fileID: 0}
|
anchorTransform: {fileID: 0}
|
||||||
logicalNodes:
|
logicalNodes:
|
||||||
- {fileID: 5572865435543895569}
|
- {fileID: 5572865435543895569}
|
||||||
|
|||||||
@@ -44,11 +44,6 @@ namespace NBF
|
|||||||
[SerializeField] private int stableFramesBeforeSleep = 4;
|
[SerializeField] private int stableFramesBeforeSleep = 4;
|
||||||
[Min(0f)]
|
[Min(0f)]
|
||||||
[SerializeField] private float wakeDistanceThreshold = 0.001f;
|
[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")]
|
[Header("Corner Smoothing")]
|
||||||
[SerializeField] private bool smoothCorners = true;
|
[SerializeField] private bool smoothCorners = true;
|
||||||
[Range(0f, 180f)]
|
[Range(0f, 180f)]
|
||||||
@@ -257,7 +252,8 @@ namespace NBF
|
|||||||
|
|
||||||
ApplyWaterSurfaceConstraint(stepDelta);
|
ApplyWaterSurfaceConstraint(stepDelta);
|
||||||
SolveDistanceConstraints(points, restLengths);
|
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);
|
SolveDistanceConstraints(points, restLengths);
|
||||||
PinLogicalPoints(points);
|
PinLogicalPoints(points);
|
||||||
ApplySleep();
|
ApplySleep();
|
||||||
@@ -334,89 +330,6 @@ namespace NBF
|
|||||||
positions[segmentIndex + 1] -= correction;
|
positions[segmentIndex + 1] -= correction;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StraightenTautLogicalSegments(
|
|
||||||
IReadOnlyList<FishingLineSolver.ChainPoint> points,
|
|
||||||
IReadOnlyList<float> 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<float> 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)
|
private void ApplyWaterSurfaceConstraint(float stepDelta)
|
||||||
{
|
{
|
||||||
if (!constrainToWaterSurface || positions.Count == 0)
|
if (!constrainToWaterSurface || positions.Count == 0)
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ namespace NBF
|
|||||||
|
|
||||||
[SerializeField] public LineType LineType;
|
[SerializeField] public LineType LineType;
|
||||||
|
|
||||||
|
public JointPinchController PinchController;
|
||||||
|
|
||||||
[Header("References")] [SerializeField]
|
[Header("References")] [SerializeField]
|
||||||
private Transform anchorTransform;
|
private Transform anchorTransform;
|
||||||
|
|
||||||
|
|||||||
@@ -101,10 +101,10 @@ namespace NBF
|
|||||||
var handItemView = Player.HandItem.GetComponent<PlayerItemView>();
|
var handItemView = Player.HandItem.GetComponent<PlayerItemView>();
|
||||||
if (handItemView != null && handItemView.Rod != null)
|
if (handItemView != null && handItemView.Rod != null)
|
||||||
{
|
{
|
||||||
// if (handItemView.Rod.Line.PinchController != null)
|
if (handItemView.Rod.Line.PinchController != null)
|
||||||
// {
|
{
|
||||||
// handItemView.Rod.Line.PinchController.StartPinch(view.Unity.ModelAsset.Pinch);
|
handItemView.Rod.Line.PinchController.StartPinch(view.Unity.ModelAsset.Pinch);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,10 +118,10 @@ namespace NBF
|
|||||||
var handItemView = Player.HandItem.GetComponent<PlayerItemView>();
|
var handItemView = Player.HandItem.GetComponent<PlayerItemView>();
|
||||||
if (handItemView != null && handItemView.Rod != null)
|
if (handItemView != null && handItemView.Rod != null)
|
||||||
{
|
{
|
||||||
// if (handItemView.Rod.Line.PinchController != null)
|
if (handItemView.Rod.Line.PinchController != null)
|
||||||
// {
|
{
|
||||||
// handItemView.Rod.Line.PinchController.ReleasePinch();
|
handItemView.Rod.Line.PinchController.ReleasePinch();
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user