Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Infinite loop in FixedDistance mesh generation
#1
Hi there,

I'm working on dynamic cylinder generation at runtime and I came across a possible infinite loop when using a SplinePathMeshBuilder with Extrusion Mode set to Fixed Distance.

I've narrowed it down to the following while loop in the Prepare() method of SplinePathMeshBuilder.

Code:
case MeshExtrusion.FixedDistance:
    float d = Spline.TFToDistance(FromTF);
    tf = Spline.DistanceToTF(d);
    while (tf < ToTF) {
        scale = getScale(tf);
        mSegmentInfo.Add(new CurvyMeshSegmentInfo(this, tf, d, scale));
        d += ExtrusionParameter;
        tf = Spline.DistanceToTF(d);
    }

Through debugging, I've found that the calculated value of tf can stay at 0.9999999 indefinitely when ToTF is 1, therefore causing an infinite loop.

A repro project is attached to this post. To repro:
  • Open the project in latest stable Unity release
  • Open the "main" scene.
  • Hit play. If Unity doesn't freeze in 2-3 seconds, exit Play mode and enter it again. It shouldn't take more then 3-4 tries to cause the infinite loop.

I figured this could be solved by using an epsilon in the while loop condition but didn't know if that would have any nasty side-effects, which is why I'm posting here.

Looking forward to a solution to this. Thanks!
Reply


Messages In This Thread
Infinite loop in FixedDistance mesh generation - by VoxelBoy - 09-20-2013, 04:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Incorrect mesh alignment after extrusion on curved path Thinkurvy 10 21 04-17-2024, 10:57 AM
Last Post: _Aka_
  Adjust radius of generated mesh via script? Shackman 1 4 03-26-2024, 01:12 PM
Last Post: _Aka_
  Not seeing mesh extended after following YT PaulM 1 3 02-02-2024, 12:01 PM
Last Post: _Aka_
  Trigger Zones along Spline Mesh dlees9191 1 5 01-05-2024, 10:18 AM
Last Post: _Aka_

Forum Jump: