Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Corner Angle Revisited
#6
(12-27-2023, 09:59 PM)SAMYTHEBIGJUICY Wrote: [quote="_Aka_" pid='6389' dateline='1703338793']
Hi Samy,

I would be surprised if the issue is due to outdate cache, but I stay open to this possibility. The problem not being easily reproducible makes it difficult to debug, but let's try something: Before using a spline in your code, force it to refresh by calling spine.Refresh().

In the lack of a reproduction case, what I suspect is a potential lack of precision in the data used to compute the tangent.
You use GetTangentByDistance. This one compares to neighboring point's position to deduce the tangent. Neighboring in this context is 0.01 tf difference. For a very long spline, 0.01 tf can be a significant distance.
If this is the issue, then I seen two solutions (and at the same time ways to confirm or not that this is the issue):
1- Use GetTangentByDistanceFast: this one used the spline's cache. You can control the caches's density in the spline's settings.
2- Modify GetTangentByDistance's code to make the delta a value other than 0.01 tf.

I hope this helped.
Have a great

PS:
Looking at your code, I see something that bothers me:
delta *= Time.deltaTime;
lastcornerangle += delta;
I don't know where lastcornerangle and delta are used later on, so maybe this code is doing what it shoudl be, but the multipication with deltaTime seems weird to me.

I found the issue after a lot of testing but happy to finally report on it. The problem arises when you have nested splines and their relative positions in the game world versus the control points underneath them. What I have discovered is that it is important where you place your spline's parent object, I can either position it close to where I expect the control points to be or I can use the automatic placing of 0,0,0.

This is easiest illustrated with an example.
See below I have two splines with almost identical first control point positions in the game world.

Currently, we are on curvy spline 16, positioned close to the player's world position, which gives us tangent differences as expected (the blue and red lines coming out of my player)
   

If I switch to spline 17 - which has a world position of 0,0,0, the tangents show the erroneous result, because the children have very high values for their local coordinates, which means the relative values of the control points have a max tolerance for accurate calculations. Or this is a floating point error issue as the values get larger. 
   
Reply


Messages In This Thread
Corner Angle Revisited - by SAMYTHEBIGJUICY - 12-21-2023, 04:54 AM
RE: Corner Angle Revisited - by SAMYTHEBIGJUICY - 12-21-2023, 12:21 PM
RE: Corner Angle Revisited - by SAMYTHEBIGJUICY - 12-22-2023, 05:40 PM
RE: Corner Angle Revisited - by _Aka_ - 12-23-2023, 01:39 PM
RE: Corner Angle Revisited - by SAMYTHEBIGJUICY - 12-27-2023, 09:59 PM
RE: Corner Angle Revisited - by SAMYTHEBIGJUICY - 12-28-2023, 12:10 PM
RE: Corner Angle Revisited - by _Aka_ - 12-29-2023, 10:26 PM
RE: Corner Angle Revisited - by SAMYTHEBIGJUICY - 01-01-2024, 04:01 PM
RE: Corner Angle Revisited - by SAMYTHEBIGJUICY - 12-28-2023, 10:59 PM
RE: Corner Angle Revisited - by _Aka_ - 12-29-2023, 08:22 PM
RE: Corner Angle Revisited - by _Aka_ - 01-02-2024, 10:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How can I find the point on the spline after applying with offset angle+radius? Chanon 1 5 10-01-2022, 11:50 AM
Last Post: _Aka_
  Make hard angle cll3m 5 1,402 07-01-2021, 04:06 PM
Last Post: _Aka_
Wink How to generate right angle road oscar.ken 6 4,687 04-30-2020, 05:38 PM
Last Post: ThomasTheTank
  Twisted mesh at corner on linear path JLeonard 0 2,176 02-24-2017, 04:42 PM
Last Post: JLeonard

Forum Jump: