Search Unity

Feedback Splines Feedback

Discussion in 'World Building' started by Rowlan, Oct 30, 2021.

  1. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    This a thread about the experimental package of the Splines, ie an older version. A much better newer preview version will be released soon.

    ---

    First time user and early feedback is important, so I thought I'd share my experience on the experimental package.

    Adding a spline was easy, modifying it wasn't. I had to figure out that there's a small dropdown here that you have to change:

    upload_2021-10-30_7-15-47.png

    I somehow can follow why this is there, but when I click on a spline gameobject, i'd like to be in its edit mode. However, if that separation is necessary, then there should be a keyboard shortcut.

    In order to edit a knot (why is it called knot, isn't that an anchor?), you have to first click on each and every single one of them. That's too many clicks:

    upload_2021-10-30_7-18-16.png
    The handles should all be visible and instantly modifiable.

    Inserting a new knot is circumstantial. You can only insert new ones along the spline, but not outside.

    upload_2021-10-30_7-20-33.png

    So you have to click the insert tool first, then insert the knot along the spline, then move it outside. No idea yet how to snap that point when you move it.

    Moving the start point is an arrow down. That's confusing. It should be an arrow along the spline since all you can do with it is move the knot along the spline:

    upload_2021-10-30_7-22-11.png
     
    Last edited: Oct 30, 2021
  2. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    The rotation arrow is nice, but this should be a delta. Or in addition to the arrow it should show the delta from the up direction:

    upload_2021-10-30_7-34-0.png

    Could be visualized differently, eg as cake shape with transparent fill.
     
    antoripa likes this.
  3. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    934
    It is visible if you select the Bezier mode instead of Catmull mode (which should also show the tangent direction by default though)
     
  4. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    Not for me:

    upload_2021-10-30_7-40-45.png

    I can only move 1 knot here. In order to move another I first have to click on it.
     
  5. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    I moved the spline. It's nice that all knots move with it, but the next question arises instantly: How do I snap them all to the terrain?

    upload_2021-10-30_7-43-30.png
     
  6. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    I wanted to write my own spline editor, but there doesn't seem to be an api which allows to delete a knot:

    upload_2021-10-30_7-52-1.png
     
  7. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    There's the AddPointToEnd method. But for the user it's irrelevant where the spline starts or where it ends. There should also be an AddPointToStart method. This also reflects in the UI:

    upload_2021-10-30_8-3-7.png

    I can only add a point at the end, not at the start.
     
  8. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    Here's an example about how I did the editing with YAPP:



    It would be really nice if we could get something like that from Unity.

    Or at least if we could write our own editor.
     
    valarnur and one_one like this.
  9. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    Deleting should delete the closest knot at the press of a hotkey and mouse click. Not click, then hit the delete key and that over and over. That's tedious, especially for longer splines.

    Here's an example, starts at 01:19:

     
    valarnur likes this.
  10. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    Btw regarding the above mentioned adding: The adding of a knot is nice this way:

    upload_2021-10-30_8-19-33.png

    But this kind of adding is snapping. That should happen only using a snap hotkey.
     
  11. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    Some of my knots are in the air, no idea why. I thought they should snap to the terrain.

    Also, I added 33 knots. How do I restart? There doesn't seem to be a clear or reset button:

    upload_2021-10-30_8-23-14.png
     
    valarnur likes this.
  12. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    Why are the knots using float3 instead of Vector3?

    upload_2021-10-30_8-59-47.png
     
  13. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    934
    I guess to make them compatible with burst or integrate them with DOTS in the future
     
    wyattt_, Rowlan and one_one like this.
  14. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    Ah, that makes sense then.
     
  15. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    Please add a triangulator utility class, e. g. used for the closed spline. Should consider the resolution of the curve. I tried with the Spline Square preset and a quick triangulator I took from the web:

    triangulator.gif

    It can come in very handy, e. g. using terrain projection:

    https://forum.unity.com/threads/wow-terrain-projection-is-super-fast.1005583/

    Basically one could select multiple houses as settlement, align their height, create a closed spline around their bounds with height of their lowest vertices, create a triangulated mesh (invisible, on a dedicated layer) as the "floor" and drag that settlement around while the terrain aligns properly to the mesh. Not just the houses, but the spline area around them. It's a special use case, but a valid one nonetheless. But it starts with the triangulation.
     
  16. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    That could also be cool for intersections. IIRC they want to focus on a good editor UX though so that the core functionality (creating splines) is really solid before adding more utilities though, which IMO seems like a good way to go. Otherwise I agree with all your suggestions, except that those might be a good fit for a community/open-source spline tool based on Unity's splines :)
     
    gabrielw_unity and Rowlan like this.
  17. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    It would be nice to have a simpler default constructor additionally:

    upload_2021-10-31_8-18-16.png
     
    one_one and antoripa like this.
  18. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hey! This thread is awesome, thanks! I'm super busy for the next few days, but I'll try to find time for good detailed answers. Thanks for all the info!
     
    one_one and Rowlan like this.
  19. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Yup, this gets much better in the updated Unity alpha - these "Edit Modes" are a more clear toggle.

    Yup, we also are adding a generic "Enter/Exit Editing" keyboard shortcut.

    So, both yes and kinda. We took the path of "treat all these sub-objects exactly like GameObjects, enabling anyone to use all the same selection/manipulation/snapping/etc tools". That means interacting with12 anchors/knots is the same as 12 cubes.

    However, we also prototyped a "Direct Manipulation" method, and hope to add this in the next version - essentially a way to click-drag on a thing, and immediately ("directly") manipulate it, skipping all those annoying clicks.

    That will also become (not sure when) a method available for GameObject manipulation, too!

    This was what the devs felt made sense when beginning work. Still TBD final naming.

    Just like you would for GameObjects :)
    - CTRL will snap to increments
    - CTRL+SHIFT will snap to surfaces (I believe this currently requires a collider, though)
    - V will snap to vertices

    Another item we're working on for the next version - taking it a step further into branching and merging.

    Do you mean:
    1. Hover on the knot
    2. Hit hotkey
    3. That knot is deleted

    I think I'm misunderstanding?

    What sort of "restart" would you expect? For example, would it become a straight line with two points in space ... or delete all ... not sure what "restart" would be?
     
  20. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    You could always use `default` if you just want an uninitialized knot. Otherwise I suppose we could omit rotation?

    As mentioned above, yes this is for DOTS compatibility but also because we are using the Unity.Math package rather than UnityEngine.Mathf.

    That would be cool, I agree. Possibly something we could do with ProBuilder integration, as there is already a triangulation library implemented there.

    Yeah, we'll need to add a Remove method. I believe we even have a task in the backlog for the Spline class to implement IList, which would make this much easier to work with in custom editors.
     
    Rowlan, adamgolden and one_one like this.
  21. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    An official, standalone and lightweight topology package would be ideal (for common needs like triangulation, edge loop fills, welding, simplifying, etc.), so for example if we're creating a game or asset that requires splines and triangulation, we wouldn't need to include or require people to install ProBuilder.

    Generally speaking, I think ProBuilder is being used as an editor-only tool - I don't personally include it in builds, but can toggle use with a scripting define symbol for parts of my toolset that make use of it. When some of us are putting effort into stripping every possible library from a project, needing to include ProBuilder just for access to triangulation might feel ..excessive? In other words, while a supported solution is desirable, there's less incentive for people to use it - for runtime purposes in particular - if it's only available as a part of ProBuilder. I would personally prefer to see an official and lightweight Unity package dedicated to topology (or at least triangulation).

    Maybe as a stepping stone, triangulation could be extracted from that to an early/experimental package and then ProBuilder [and whatever else] could use that? If you might now be looking at exposing it for more general purpose use anyway and will be digging around in related code.. please consider it.
     
    DragonCoder and one_one like this.
  22. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    There should also be an "always snap to y-axis-raycast" option. And a button to snap all points of the spline, so that one doesn't have to click each and every single one of them for adjustment. See video below.

    A better choice is to use the mouse and a hotkey. See video below.

    No, no point at all. It should be my choice to select a start point and the next point. If there's none or a single point, then of course then there's no spline functionality invoked.

    You can try yourself, it's free, but here's the video:

    • 00:00 always snap and add control points at the beginning or end
    • 00:12 add control points between spline points. you covered that, but what I show is the indicator and that add and remove are actually the same, but with different keyboard key pressed
    • 00:19 delete control points shows an indicator of a red line. you don't even have to hover over the control point, it just targets the closest one
    • 00:22 delete control points. you see, i don't even have to be close. i hit ctrl+shift, then i'm in delete mode and i just delete via mouse click
    • 00:36 clear removes all control points and i can start from scratch quickly
    • 00:38 setting a single control point does nothing, but it's my freedom of choice, same with the 2nd one; i don't have to mess around with predefined spline control points
    • 00:48 the difference between always snap and free movement: i can't change the y direction, but I can change x/z and it snaps to wherever i drag the control point
    • 00:52 disable snapping



    I do understand that Unity has to consider first time users and what not to make the editing easy. But my preference is to have the less clicks the better. I'd like to have freedom of choice. And hence the point: Please do give us the possibility / API to extend your editor and make our own editors :)
     
    TerraUnity and Ruchir like this.
  23. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    I'd like to have just position, nothing else. Messing around with tangents and rotation is something for fine adjustment. And not needed for Catmull-Rom. In my opinion people will mostly use Catmull-Rom. Bezier is just for finer granularity like e. g. roads. My personal preference is Catmull-Rom. If I want something smoother, I just add another control point and not mess around with handles.

    Yeah, I know. But I'd prefer to not have ProBuilder in if I don't need it. However if Unity ties ProBuilder tightly to the Splines examples like e. g. for road creation, then that's a different thing.

    Please do it asap, don't keep it in a backlog. Or provide a dedicated delete method. It's necessary right from the start for everyone who uses the API.
     
    Last edited: Nov 2, 2021
  24. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,254
    @gabrielw_unity Thanks for the early access, had a few minutes to play with it, so my biggest question is about intersections, is it allowed or in the pipeline to merge 2 or multiple splines and have the mesh generated properly at intersections? @Rowlan did you have a chance to test it out with your Terrain Align solution?
     
  25. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    I wait for the next package, ie the preview one. I'm pretty sure it'll work though.
     
    TerraUnity likes this.
  26. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    This is one of the items on our list for "Snapping an Manipulation Improvements", as a Unity-wide thing :)

    Similar to above, we have this on our list of generic Editor abilities :)

    Ah I see now - that's neat for sure. I also really dig your method of adding points between others, without requiring "click, then move to actual desired position". Very nice!

    As we are doing this work to ensure the core experience is always the same for users - here I would say, instead let's 100% all work toward building something singular and good :)
     
    Rowlan likes this.
  27. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hi! Intersections are planned for the 2.0 release, along with a few other artist-centric improvements :)

    ... and it's available now!
     
  28. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Update for all, you can now get the pre-release, 1.0 version, by typing "com.unity.splines" into the "Add Package By Name" field. Mostly changes under the hood, but also some major UX improvements - some of which you'll have wait on the latest Unity Alpha for. Sorry!
     
    Rowlan and adamgolden like this.
  29. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    484
    What editor version do we need? I'm getting The type or namespace name 'ICreateToolbar' could not be found
    with 2022.1a13
     
  30. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    You will need 2022.1a14 or newer.
     
  31. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,254
    Sounds cool, can't wait to try it out ;)
     
  32. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    2022.1a15 is finally available, looks like Unity skipped a14. Let's go testing :D
     
    kaarrrllll likes this.
  33. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    Where should we report bugs?

    Code (CSharp):
    1. StackOverflowException: The requested operation caused a stack overflow.
    2. UnityEditor.Splines.BezierEditableKnot..ctor () (at Library/PackageCache/com.unity.splines@1.0.0-pre.5/Editor/Types/BezierEditableSpline.cs:102)
    3. System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) (at <96f838c04c564175a85f709a665a953d>:0)
    Putting the splines on github would really come in handy, eg for creating issues.

    That's an awesome demo scene for showing the features by the way:

    sc.jpg
     
  34. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    Bugs can be reported through the usual Unity Bug Reporter in the Editor.

    I'd also like to see Splines available on Github, but there are processes we have to go through before any repo becomes public. Right now we're still just focusing on development.

    And thanks for the feedback on the sample scene, glad you find it useful!
     
    Rowlan likes this.
  35. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    Splines 1.0.0-pre.7 is now available, it includes bug fixes and API improvements.

    Of particular note in this update (@Rowlan), the default Spline class is now implementing IList<BezierKnot> explicitly. This makes it much easier to implement tools for working with splines.
     
    TerraUnity, adamgolden and Rowlan like this.
  36. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    What's the preferred way to modify a position of a knot? Simple use case with an extension method to set all y positions to 0 results in an error because of the Struct:

    knotmod.png

    ToArray, Transform(...) and the operators each return a copy.
     
    Last edited: Nov 23, 2021
  37. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    85
    Is this package ever going to be backwards compatible, or only 2022.1+? (I'm guessing not because of the new editor features, but thought I would ask anyway).

    @Rowlan
    Code (CSharp):
    1. for (int i = 0; i < spline.Count; ++i)
    2. {
    3.     var knot = spline[i];
    4.     knot.Position.y = 0;
    5.     spline[i] = knot;
    6. }
     
    PutridEx, kaarrrllll and Rowlan like this.
  38. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    Thank you, that works for the knots in the inspector and if the Spline isn't in edit mode. Problem is now that there's no update on the knots themselves in the scene in edit mode. Some kind of "refresh" invocation is missing.
     
  39. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    This looks like a bug on our end. The tool handles should be responding to Spline changes.
     
    samanabo and Rowlan like this.
  40. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    294
    No idea if this is still the best spot for spline feedback, but @kaarrrllll I thought I would let yall know that right now you can't have a spline field in anything but the root of a
    UnityEngine.Object
    otherwise the property drawers throw an error.
    The reason for this is because you are using a naive implementation to get the Spline value from a SerializedProperty and directly using the property path to get the field and passing the
    SerializedObject
    's
    target
    as the object for the
    GetField(..)
    .

    What you need to do is split up the path and walk over the whole think getting each field along the way. I have a implementation myself that supports both arrays/lists and
    SerializeReference
    if you want to take a look at it.
    Github Repo (MIT)
    I will most likely submit a bug report tomorrow but I figured most of the additional context and info would be lost, so writing here as well.
     
    Lars-Steenhoff and one_one like this.
  41. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    @gabrielw_unity @kaarrrllll

    I tried to create a thread about spline issues on World Building, but it says I wasn't allowed.

    I am on beta 9 and macOS Big Sur.
    1. When I am editing a spline, I cannot hit the delete key and delete the knot. It just beeps at me.
    2. According the the official docs, there is a knot move tool. I only see the knot placement tool. I have to use the regular GameObject move tool to move the knot, but I cannot place a knot on the spline like the docs mention. I have to go into the knot placement tool every time which is a bit tedious especially when that tool doesn't have a shortcut.
    Screen Shot 2022-02-24 at 12.11.17 PM.png

    Thanks!
     
  42. Ivan_br

    Ivan_br

    Joined:
    Nov 10, 2015
    Posts:
    29
    I really like where things are going with the new Unity splines, I have been waiting for this for years now and it is great to see a team at Unity working on it.

    One thing I would like to suggest is to be able to generate a spline based on an image, for instance an SVG file could be imported and the contours of the image could be generated into a spline. Here is a video of a spline asset with this functionality (1:08). This would be really helpful as it would allow users who may not be as quick and proficient in using 3D splines on a computer to quickly to sketch/prototype out a path and then test it out and tweak it in Unity.



    Another suggestion, not sure if this is already incorporated, but it would also be great of I could draw some points on a spline and then have some way of selecting those points and generating x amount of knots (or a knot at every x distance) between them. This may be helpful if you want to quickly generate knots at equal distances, say I then want to instantiate on each knot a game object (houses, trees, stones, enemies, etc.), I know they will then be of equal distance from each other.
     
    Last edited: Feb 28, 2022
    MousePods, Ruchir and TerraUnity like this.
  43. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    281
    Is there an easy way to modify spline's individual node in runtime ?
    Like for example I have a spline with 3 nodes, I want to set each node's position and update the spline in runtime.
    Right now in the example scenes, almost all the examples are about pre-defined spline. Only one exception is an example using compute shader, which is over complicated for my need.

    This is the code I'm using, way too many step to just set 3 knot's positions.
    If we can have an simple method like Spline[0].SetPosition ,and .SetTangent will be convenient.
    In runtime, I look at the inspector and noticed the spline's knots do change value, but the spline remain unchanged.

    Code (CSharp):
    1.                 var s = splineContainer.Spline;
    2.  
    3.                 var knot = s[0];
    4.                 knot.Position = firstPoint;
    5.                 s[0] = knot;
    6.  
    7.                 knot = s[1];
    8.                 knot.Position = middlePoint;
    9.                 s[1] = knot;
    10.  
    11.                 knot = s[2];
    12.                 knot.Position = dest;
    13.                 s[2] = knot;
     
    Novack likes this.
  44. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    642
    It seems to work on 2021.2 - I just copied the package into my project to try it (had to adjust the path in the code, there's a few instances of the package path for loading icons etc)

    Most obvious issue I've spotted is that after editing the spline, the yellow line drawn for the spline gizmo doesn't match the updated spline.

    upload_2022-3-28_16-14-54.png

    White dots are my quick test of evaluating the spline, yellow line is the spline gizmo - click on the View tool (hand icon) to see both at once.

    This seems to happen in 2022.1.0b13, so it's not just an issue with bringing the package into 2021.

    (edit: Looks like it needs to set s_SplineCacheTable[spline] to null from the afterSplineWasModified delegate in SplineGizmoUtility.cs, to force the positions to be recalculated?)
     
    Last edited: Mar 28, 2022
  45. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,698
    Nifty package!
    Nice to play with and usability is quite solid.

    One feature that would be cool for the "Extrude" functionality: Rounded end-caps.
    So you can create artistically pleasing things (especially at runtime where ProBuilder is not available) with it. Was planning to randomly generate something like corals.
     
  46. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    Thanks for the report, we'll get it fixed asap.
     
    bluescrn and Rowlan like this.
  47. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Where you able to find the issues I posted above?
     
  48. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    Sorry @MousePods, I missed your earlier post.

    Are you on macOS? It may be that on macOS this is mapped to `fn + delete` or `cmd + delete`, I'll need to check.

    The knot move tool is just the regular move tool. When you activate the Spline mode in the top of the toolbar, all the tools in that toolbar are now applicable to knots and tangents.
     
  49. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    No worries!

    It was fn + delete, thanks!
     
    kaarrrllll likes this.
  50. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,289
    The knot editor seems to be broken in 2022.2.0a9

    br.jpg
     
    mishakozlov74 likes this.