Search Unity

Feedback Splines Feedback

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

  1. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    2,158
    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
    gabrielw_unity, antoripa and one_one like this.
  2. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    2,158
    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:
    803
    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:
    2,158
    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:
    2,158
    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:
    2,158
    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:
    2,158
    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:
    2,158
    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.
     
    valarus and one_one like this.
  9. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    2,158
    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:

     
    valarus likes this.
  10. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    2,158
    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:
    2,158
    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
     
    valarus likes this.
  12. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    2,158
    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:
    803
    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:
    2,158
    Ah, that makes sense then.
     
  15. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    2,158
    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.
     
    one_one and Ruchir like this.
  16. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    588
    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:
    2,158
    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:
    882
    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:
    882
    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?
     
    Rowlan, one_one and polemical like this.
  20. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    477
    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, polemical and one_one like this.
  21. polemical

    polemical

    Joined:
    Jun 17, 2019
    Posts:
    1,136
    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.
     
    one_one likes this.
  22. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    2,158
    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:
    2,158
    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,044
    @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:
    2,158
    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:
    882
    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:
    882
    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:
    882
    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 polemical like this.
  29. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    247
    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:
    477
    You will need 2022.1a14 or newer.
     
  31. TerraUnity

    TerraUnity

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

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    2,158
    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:
    2,158
    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:
    477
    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:
    477
    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, polemical and Rowlan like this.
  36. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    2,158
    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. rocar

    rocar

    Joined:
    Sep 10, 2014
    Posts:
    13
    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. }
     
    kaarrrllll and Rowlan like this.
  38. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    2,158
    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:
    477
    This looks like a bug on our end. The tool handles should be responding to Spline changes.
     
    Rowlan likes this.
unityunity