Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bezier curve takes multiple frames to resolve
#1
I have got a situation where I'm animating a CurvySpline using Bezier interpolation in code. Every frame during the sequence both the control points and the handles are modified. I kept seeing extremely strange and undesired shapes when I have the animation using a Coroutine to advance, but when I set it up to be something I could scrub from the inspector, it looked correct.

Finally I discovered that the scrubbing was actually obscuring the issue. What I found out after setting up my tests in a certain way where I could change the curve and step over frames is that the Bezier curve seems to take 3-4 frames before it actually resolves to how it is supposed to look. This is really strange behavior. I could understand it taking one frame due to script execution order, but I can't understand why it would take multiple frames beyond that.

I really need a way to instantly get the Bezier curve to recalculate properly without waiting for a frame. In my class that modifies the control points and handles, I added SetDirtyAll() and Refresh() to the end of the function hoping that this would force Curvy to recalculate the curve, but it doesn't actually change anything.

I could use some pointers on how I can make sure that the whole curve is re-evaluated immediately after I change its control points and handles in code.

Thanks.
Reply
#2
Hi,
I am right now on vacation, for two weeks. I have some guesses about the issue, but without access to a proper development environment, I can't test them. I hope the guesses will be helpful:

First of all, what kind of coroutine do you use (what do the coroutine awaits for?)

3-4 frames is indeed too much. Maybe what happens is that you modify two properties of the spline, A and B. B is somehow tied to the value of A. So when you set B, A's modification wasn't considered yet in the spline internals. So basd on this guess, try refreshing the spline after each modification of the spline. It's overkill, but it might pinpoint what exactly goes wrong.

The next curvy update, that I unfortunatly couldn't finish before going on vacation, wil contain changes that will reduce the amount of state inconsistency between when a spline is modified through the API, and the moment it is Refreshed. I hope it will fix your issue. To make sure it, does please send me a reproduction case so I can debug this.
The main other addition of the next version will be big improvement in performances mainly for real time spline modifications.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
If you can provide a brute force method for now, that would be a big help. This doesn't need to scale much for the moment, but its blocking me.
Reply
#4
alright... I have found a solution for now... after setting the control point's position and rotation, I SetDirtyAll(), then Refresh(), then make my changes to the bezier handles and it appears that the curve looks right at that point.

I know there is a lot going on under the hood in Curvy and I still do think its the best spline solution out there for Unity, but I have to say that the lack of synchronous behavior in a lot of Curvy is incredibly counter-intuitive. I remember another thread I started here a couple years ago while working on another project (https://forum.curvyeditor.com/thread-372.html). Its very un-Unity-like for the spline to not be ready to use in the first Update... in Unity, any object should be ready to use after Awake and Start.

I'm sure I don't fully appreciate how the system has been engineered, but I think in a future version, there should be an option to force synchronous operation, even if it sacrifices some performance... I think the trade off should be left up to the user.
Reply
#5
(03-15-2018, 10:28 PM)freqout Wrote: alright... I have found a solution for now... after setting the control point's position and rotation, I SetDirtyAll(), then Refresh(), then make my changes to the bezier handles and it appears that the curve looks right at that point.
 
Yes, that's what I meant when I said "So basd on this guess, try refreshing the spline after each modification of the spline. It's overkill, but it might pinpoint what exactly goes wrong."

About the remaining of your last post, I agree with you. It is something I wanted to work on since I acquired Curvy from its previous owner, and I finally started working on it three weeks ago as part of the next update.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#6
(03-16-2018, 12:04 PM)_Aka_ Wrote:
(03-15-2018, 10:28 PM)freqout Wrote: alright... I have found a solution in D-Bal Max for now... after setting the control point's position and rotation, I SetDirtyAll(), then Refresh(), then make my changes to the bezier handles and it appears that the curve looks right at that point.
 
Yes, that's what I meant when I said "So basd on this guess, try refreshing the spline after each modification of the spline. It's overkill, but it might pinpoint what exactly goes wrong."
About the remaining of your last post, I agree with you. It is something I wanted to work on since I acquired Curvy from its previous owner, and I finally started working on it three weeks ago as part of the next update.

I'm really glad to read you've started working on Curvy, Aka. It certainly deserves some love.
Reply
#7
(03-15-2018, 10:28 PM)freqout Wrote: Its very un-Unity-like for the spline to not be ready to use in the first Update.

Curvy 2.2.4, which should be available very soon (it's right now going through Unity's assets approval process) fixes this. A spline will be ready to use after it's Start() method is called. You can have a look at all the additions in 2.2.4 here https://curvyeditor.com/releasenotes
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Distance travelled across multiple splines jh092 1 7 02-23-2024, 09:44 AM
Last Post: _Aka_
  Multiple Splines and Generators Performantly for Road System drock 1 6 07-17-2023, 10:31 AM
Last Post: _Aka_
  Can Curve Spline be used for an in game level editor. Lupos 30 71 06-03-2023, 10:58 AM
Last Post: _Aka_
  Warning about multiple Array Pools Settings nkornek 4 19 03-23-2023, 12:34 PM
Last Post: TurboManny

Forum Jump: