Search Unity

[RELEASED] Curvy: Fast Spline Interpolation

Discussion in 'Assets and Asset Store' started by Jake-L, Feb 14, 2013.

?

Is it fine to release Curvy as a Unity 4.2 package?

Poll closed Dec 27, 2014.
  1. YES, I'm already using Unity 4

    103 vote(s)
    88.0%
  2. YES, but it should work in Unity 3.5 nevertheless

    7 vote(s)
    6.0%
  3. NO, I don't have Unity 4 installed and won't be able to access it in the AssetStore

    7 vote(s)
    6.0%
Thread Status:
Not open for further replies.
  1. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Until LOD support is builtin you'll have to write a script that changes parameters based on distance to camera. Either this if the generated mesh really needs to change constantly, or - better - create multiple versions on level load and fade them using Unity's LOD-Fader.
     
  2. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    00christian00 likes this.
  3. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Thanks for those additions. Curvy 2 is shaping nicely, RC2 is about to be released.
     
  4. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    Jake, Could you explain me the point of the following kind of code? I see it often in your asset:
    Code (CSharp):
    1.  
    2. this[i].OnRefresh -= OnSplineRefresh;
    3. this[i].OnRefresh += OnSplineRefresh;
    If you remove it and the readd it back immediately, isn't same as before?!
    I need to remove these parts as they are causing garbage but I don't understand the point. Am i missing something?
     
  5. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    It ensures that the callback method is only registered once for the above event. Unless called each frame (v2 won't do this) this should be fine.
     
  6. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    They are inside the update function of many scripts, so it is called each frame and generate tons of garbage.
    I removed it and now the autorefresh the first time doesn't work if you don't first select the object as you are calling the update function from the editor script to attach the event(a very bad way to handle it).
    I could fix the autorefresh bug, but it's not worth the hassle, will keep it like this.
     
  7. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    I want to plot a set of points along the curve, I set the curve up just fine but how do I now get a bunch of points (of equal distance) along the curve?
    I checked the follow spline file but it was terribly confusing.
     
  8. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    If you just want a set of positions, use CurvySpline.InterpolateByDistance(). Be sure to wait for spline's initialization before accessing it.
     
  9. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    976
    How can I get the distance of a control point within a spline? What is each control point's T and Distance relative to the whole curve?
     
  10. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
  11. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    976
  12. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    976
    I'm getting very bad GC performance with Curvy. It allocates about 6 - 8 KB per frame (!). This is just for 1 spline with 5 control points (no mesh or anything), that are changed each frame. I can't see why so much GC should be produced? That's about 2 MB of garbage every 5 seconds!

     
  13. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    What !!! :eek:
     
  14. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    976
    Basically, the more points you have, the worse it gets. It only allocates if you change the spline. Still, 8 KB is quite a lot. It shouldn't produce this much garbage.

     
  15. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Don't fear, nothing to worry about! First, Refresh (in 1.61) works different in editor and runtime, so GC usage is higher in the editor. Then, and that is most important, we fundamentally changed the way refresh and caching works in Curvy 2.0!

    Then, if you change something (add a CP, move one around etc..), only the absolutely neccessary will be recalculated. So it doesn't matter if the spline has 20, 200 or 2000 Control Points. Though, to be absolute precise, there are differences depending on the choosen orientation mode. E.g. if you change the first spline in Tangent mode, orientation needs to be recalculated for the whole spline, if you change the last, just that segment needs to calculate. But that mode (called "Dynamic Mode" now) works with some other new concepts to offer more user control over the resulting orientation and - as a side effect - removes the need to recalculate everything.
     
    ZJP likes this.
  16. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    976
    Ah ok, good to know!

    When will Curvy 2 be released?
     
  17. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Very soon (tm)
     
    SunnySunshine likes this.
  18. QFGlenn

    QFGlenn

    Joined:
    Feb 21, 2013
    Posts:
    39
    I'm experiencing slowdown when I select the different CP points in my spline. I'm up to about 55-60 CPS and whenever I click one the application pauses for a moment and then resumes. Are you experiencing this issue as well? It shouldn't be my hardware, running strix gtx 960 and an i7 4790
     
  19. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    Hi guys, I'm looking at the 2.0 package, it looks awesome - but all links to PlayMaker actions are now dead (and when posting about it on your new website, my comment is not visible?)

    Are you not supporting PlayMaker any longer? If so, then at least for me that will mean that I will look into using other spline systems. But I hope not, are they on the way?

    Thanks!
     
  20. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    What links exactly are broken? The links on this page are working! And site comments have to be approved, that's why you don't see it instantly. In case of reported errors (typos, misleading documentation etc...) we fix the site and remove the comments. Besides blog post comments on the main page the comments functionality is meant as a quick and coventient way to point us to pages we need to improve without having to write a mail or bug report or else.

    No, we keep supporting PlayMaker!
     
    Fritsl likes this.
  21. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    Uh - awesome!
    Since your new site ( http://www.fluffyunderware.com/curvy/start ) has no search, out of habbit I just used Google, and apparently came to 1.6 documentation which is now linking to a dead page on the PlayMaker docs - which was the way one had to go before.

    Nice - -it looks great, I'll get dirty with it then :) Thanks!
     
  22. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    OMG, you DO have a search option there, and it's even working :D Sorry.

    Feedback / idea: Make background in search bar light, no italic text, black or grey bold text.. and place it on the right side ;)
     
  23. Xitech_

    Xitech_

    Joined:
    Feb 19, 2013
    Posts:
    140
    Hi, I just bought the package but I am wondering how I can create splines in code(real-time).
    And is it also possible to real-time generate a piece of the spline as a mesh? Because our mesh could become really big, so I think we need to split it up somehow.

    Kindest regards
     
  24. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    I think that for generating splines in real time, all you have to do is to look into the documentation and examples, for instance 'Paint Spline' scene..

    As for makine pieces of the mesh, that would just be to set to-and-from.. however, I'd strongly recommend that in both cases you try not to do things at playtime.

    No matter how strong Curvy and it's libraries are, generating and editing in playtime is always tough on performance (GC.collect etc) - so why not generate the entire mesh in Unity, then export as OBJ (see unity wiki for how to) and then in a 3D package (such as the free and awesome Blender or similar) work with your mesh to make it more friendly to your target platform..
     
  25. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Of course, you can setup a CG and change From/To in the Shape Extrusion module dynamically at runtime. If that works performance-wise depends on your target platform and what you're after (if you enable CG's debug view you'll notice that extrusion is quite fast, VolumeCaps are a bit slow due to triangulation. If you are only concerned about the resulting mesh having too much vertices, don't worry. You can split the mesh by length (in the VolumeMesh module). If you don't, it got splitted automatically if the vertexcount limit is reached.
     
  26. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    Wow.. I'm just diving into the new 'Curvy Generator'.. wow.. Looks really awesome guys!!!
     
  27. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
  28. Xitech_

    Xitech_

    Joined:
    Feb 19, 2013
    Posts:
    140

    Thanks both. Ill have another look. My target platform is for PC with high end specs. But the track could be 100 km big. Not sure if loading a single huge mesh is a smart option to do. I'd prefer auto generated at a radius of like 2 km. Its a train track I am creating in real time based on the real train tracks which might change. Thats also why I need to do it realtime based on information that changes a lot.

    Note: The train example scene looks fantastic!
    Note2: Ill continue on the other tread if I have any more questions.

    Kindest Regards
     
Thread Status:
Not open for further replies.