Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solutions to a few issues
Hey there,

I've encountered a few bugs (and some minor missing features) here and there over the past several months working with Curvy; I'm post my solutions here in hopes you'll consider putting them into an upcoming release (as it will make merging new versions easier for me Tongue)

1. TCB interpolation does not respect previous and next control point positions if those positions come from different connected splines. I changed a line in CurvySplineSegment's Interpolate method from this:

return CurvySpline.TCB(PreviousTransform.position, Transform.position, NextTransform.position, NextControlPoint.NextTransform.position, localF, t0, c0, b0, t1, c1, b1);
to this:

return CurvySpline.TCB(GetPrevPosition(), Transform.position, GetNextPosition(), GetNextNextPosition(), localF, t0, c0, b0, t1, c1, b1);

It's consistent with the other interpolation modes and seems to work fine.

2. The 'MeshInfo' constructor in CurvyUtility allocates a temporary mesh when 'mirror' is set to true but forgets to destroy it after finishing. I added this to the end:

if(mirror) GameObject.DestroyImmediate(mesh);

3. FlipSpline doesn't behave very well in TCB mode; the shape changes drastically since the various parameters are not mirrored correctly between control points. My version of the function looks like this:

/// <summary>
/// Flips the direction of a spline, i.e. the first Control Point will become the last and vice versa.
/// </summary>
public static void FlipSpline(CurvySpline spline)
spline.Bias *= -1;

for(int i = spline.ControlPointCount - 1; i >= 0; i--) {
CurvySplineSegment cur = spline.ControlPoints[i];

Vector3 h = cur.HandleIn;
cur.HandleIn = cur.HandleOut;
cur.HandleOut = h;

int j = i - 1;
if(j >= 0) {
CurvySplineSegment prev = spline.ControlPoints[j];

cur.EndBias = prev.StartBias * -1;
cur.EndContinuity = prev.StartContinuity;
cur.EndTension = prev.StartTension;

cur.StartBias = prev.EndBias * -1;
cur.StartContinuity = prev.EndContinuity;
cur.StartTension = prev.EndTension;

cur.OverrideGlobalBias = prev.OverrideGlobalBias;
cur.OverrideGlobalContinuity = prev.OverrideGlobalContinuity;
cur.OverrideGlobalTension = prev.OverrideGlobalTension;

cur.SynchronizeTCB = prev.SynchronizeTCB;

spline.RefreshImmediately(true, true, false);

4. CurvySplineGroups do not check for null entries in their member array either in their OnDisable or Update methods, which is problematic when you're working in the editor and slots are temporarily left empty (spawns a bunch of needless errors). I added some simple null checks:

void OnDisable()
foreach (CurvySpline spl in Splines)
if(spl != null) spl.OnRefresh -= OnSplineRefresh;

void Update()
for (int i=0;i<Count;i++){
if(this[i] != null) {
this[i].OnRefresh -= OnSplineRefresh;
this[i].OnRefresh += OnSplineRefresh;
if (mNeedLengthRefresh || mNeedOrientationRefresh)
RefreshImmediately(mNeedLengthRefresh, mNeedOrientationRefresh, mSkipRefreshIfInitialized);

5. CurvySpline's update method can create an infinite refresh loop when two splines are connected to one another at both ends because each orders the other to refresh orientation next frame. I got around this by using kind of a hack - I just call the private doRefreshOrientation() method right away instead of scheduling it:

// refresh orientation of connected splines in the editor
if (!Application.isPlaying && ControlPointCount>0 && ControlPoints[ControlPointCount - 1].ConnectedBy.Count > 0) {
var otherSpl = ControlPoints[ControlPointCount - 1].ConnectedBy[0].Spline;
if(otherSpl.IsInitialized) {
} else {
otherSpl.Refresh(false, true, false);

I've done a bunch of work with Curvy aside from this and it is by far the most useful thing I've found in the Asset Store. Keep up the good work Big Grin

thanks a lot, I will test those issues carefully against the new version, I guess some of them might already got solved (I rewrote CP and Refresh handling), but others definitely aren't solved yet.

Again, thank you!


Possibly Related Threads…
Thread Author Replies Views Last Post
Bug Issues when working with in-place prefabs Sacryn 4 6 02-27-2024, 04:08 PM
Last Post: _Aka_
Question Generator Canvas workflow issues Sacryn 1 7 02-02-2024, 11:22 PM
Last Post: _Aka_
Lightbulb issues with the shader in URP sukhov 4 8 11-22-2023, 12:52 PM
Last Post: _Aka_
  Curvy Splines Built In Editor Undo causes issues. Lupos 1 9 10-02-2023, 08:52 AM
Last Post: _Aka_

Forum Jump: