Add Thickness (or aribtrary overloads?) to BezierTo

Avatar
  • updated
  • Completed

I'm currently building a gameplay spline system on top of the Shapes Bezier functionality, and I'm currently looking into what the best way would be to carry additional data per-point. 

I noticed that despite the PolyLine supporting varying thicknesses, the BezierTo function cannot actually work take thickness inputs. It'd be incredibly helpful if it could, as it'd allow properly interpolated thicknesses. I can approximate it myself, but the result would be better if it was properly interpolated along with the colour.

In a similar vein (and this might be more difficult), it'd be incredibly interesting to be able to make the PolylinePoint class able to take arbitrary data, as this would open all sorts of doors for further integrations between Shapes and other systems.

I've taken a minute to look into whether I'd be able to extend this myself, and while I probably can with enough time, I'm not a world-shocking programmer and it'd take me an unreasonable amount of work, so if this could be worked into the stock version of Shapes, that'd be incredible.

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Completed

This has now been added in 4.0.0, along with similar overloads for ArcTo supporting interpolation of polyline properties.

In addition, the default ones without a color will now inherit the properties of the previous polyline point, which, is a breaking change! It used to apply default values. I've also removed the overloads that had a single color input in light of this new behavior.

New overloads for BezierTo (along with overloads for explicit point count and point density)

BezierTo( PolylinePoint, PolylinePoint, PolylinePoint );
BezierTo( Vector3, Vector3, PolylinePoint ); // simplified version, interpolates prev point with the supplied endpoint


New overload for ArcTo

ArcTo( corner Vector3 point, end PolylinePoint, radius);







Avatar
Freya Holmér creator

I think having arbitrary data attached to points in Shapes is a little out of scope, as I'm trying to stick close to making sure it's just a rendering library, and not a spline/interpolation library etc. that being said - it should be relatively easy for you to edit the code to add another field in the polyline point struct, if you need it!

anyway, interpolating thickness (and color) should be doable - basically instead of supplying Vector3s for each point, I can make an overload that takes PolylinePoints instead

Avatar
Freya Holmér creator
  • Answer
  • Completed

This has now been added in 4.0.0, along with similar overloads for ArcTo supporting interpolation of polyline properties.

In addition, the default ones without a color will now inherit the properties of the previous polyline point, which, is a breaking change! It used to apply default values. I've also removed the overloads that had a single color input in light of this new behavior.

New overloads for BezierTo (along with overloads for explicit point count and point density)

BezierTo( PolylinePoint, PolylinePoint, PolylinePoint );
BezierTo( Vector3, Vector3, PolylinePoint ); // simplified version, interpolates prev point with the supplied endpoint


New overload for ArcTo

ArcTo( corner Vector3 point, end PolylinePoint, radius);