Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to tell if a spline is straight? / Optimize problems with straight splines
#1
Question 
Dear members of curvy spline community.

Is there a quick wat to evaluate if a spline is straight? 

Currently, I am traversing the spline and evaluating the tangent at each control point. If the traversal detects a different normal , I consider the spline "not straight".   Not sure if this is the best or most efficient way of doing it.  I wonder If curvy have a built-in function for it .

I also want to take advantage of this post and report a weird behaviour when using "Optimize" on a straight spline.  
If a curvy generator has the shape extrusion path "Optimize" parameter enabled, some things could go wrong.

For example:
  • Split: Optimize seems to ignore the "split" parameter (which subdivides the generated extruded geometry). However, if the spline has curvature,   the "split" functionality kicks in as expected.
  • Custom spline profile: We have a code that modifies the profile shape spline based on a provided height value. If optimized is enabled, and the path is straight, curvy ignores our spline profile changes and generates a "flat" mesh (with no height) .  If we disable "optimize" or have it on a "non-straight" spline, curvy works as expected.
  • Shadows casting:  In some instances, we are using curvy spline to generate tunnel geometry. If "Optimize" is enabled on a straight path to generate the tunnel, the geometry can fail to block the light and it does not cast shadows.  once again, if "Optimize" is disabled or we use a "non-straight" spline, curvy works as expected. 

I am using Curvy spline v7.1.6 but I do not think is a problem introduced in this version. I've been using curvy since couple of years and I noticed the problem before. However it is only now that I've managed to understand that "optimize" on a "straight" spline, might cause problems. 


We have a possible work around:

  1. Evaluate if the spline is straight.
  2. If spline is straight, disable "Optimize" 

Thanks for your time and I apologize for the long post. 
Reply
#2
Hi
About checking if a spline is straight, the easier solution is indeed to check the angle between the normals. If performance is an issue, go through all the spline's segments and use the CurvySplineSegment.ApproximationT, which contains the cached tangents. You can also use CurvySpline.GetApproximationT, but this is less optimized (will allocates arrays)
Regarding the reported issues with Optimize. I have to check individually the issues you reported, which I will do early next week. But what I can say for now is that some features are indeed impacted by the Optimize option. The Split feature is one of them that I am already aware of. Will say more about this subject early next week.
Have a nice day
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
(12-24-2021, 03:16 PM)_Aka_ Wrote: Hi
About checking if a spline is straight, the easier solution is indeed to check the angle between the normals. If performance is an issue, go through all the spline's segments and use the CurvySplineSegment.ApproximationT, which contains the cached tangents. You can also use CurvySpline.GetApproximationT, but this is less optimized (will allocates arrays)
Regarding the reported issues with Optimize. I have to check individually the issues you reported, which I will do early next week. But what I can say for now is that some features are indeed impacted by the Optimize option. The Split feature is one of them that I am already aware of. Will say more about this subject early next week.
Have a nice day

Hi Aka, 

Thanks for , as usual, your quick response.   I will explore straight evaluation with the ApproximationT Smile 

In regards of the "optimize" functionality, there is no rush. Whenever you have time let me know.  As I previously mentioned the possible work around is to disable optimize if the spline is straight (not ideal, but not deal breaker either) Smile .   Just wanted to put it in your radar and let you (or anybody else facing this issue) know a possible workaround. 

Thanks for your great support. 
All the best
Mario
Reply
#4
Hi Mario

About Optimize, basically what it does is that it reduces the number of points the spline is sampled at. As long as a spline is straight or having a too low curvature, no additional point is sampled on the spline. So any feature that relies on a regular and high density of sampling get impacted by the Optimize option.

I am aware of few features that tick that box, like the Split feature. For now, I suggest to my customers to avoid using Optimize in those cases. There is also a workaround that helps in some cases, which is the Max Step Distance option.

What I would need to do to solve this issue is to modify the algorithm that decides where to sample when using Optimize so that it takes into account all those features. This modification is not on the top of my priorities, but it is in my list of enhancements I would like to implement.

About the following two cases:
  • Custom spline profile: Do you mean that you are using the Variable Mix Shapes module? If not, could you explain how you modify the shape of the extrusion?
  • Shadows casting: Can you please send me a reproduction case of this?

Thanks for you time, and have a nice day
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
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  GO can't fit end of the spline GameDeveloperek4123 3 13 03-04-2024, 11:06 AM
Last Post: _Aka_
  Using Unity's SplineContainer in Curvy Splines dlees9191 3 14 02-26-2024, 09:49 AM
Last Post: _Aka_
  Distance travelled across multiple splines jh092 1 7 02-23-2024, 09:44 AM
Last Post: _Aka_

Forum Jump: