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.
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:
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!
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!