Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with combining shape extrusion and DistanceToTF
#1
Hello,
I have script to programmatically create intersections.
I use Shape Extrusion on road to end and start pavements, curbs and other things (cutout for intersection)
range.from and range.to are in meters.
Code:
        var shapeExtrusion = generator.AddModule<BuildShapeExtrusion>();
        shapeExtrusion.Resolution = 100;
        if (range != null && spline && (range.@from >= 0 || range.to >= 0))
        {
            var totalDistance = spline.TFToDistance(1);
            var tfFrom = 1 - (totalDistance - range.from) / totalDistance;
            shapeExtrusion.From = tfFrom;
            if (range.to > range.from)
            {
                var tfTo = 1 - (totalDistance - range.to) / totalDistance;
                shapeExtrusion.To = tfTo;
            }
        }


In intersection script I use:
DistanceStart and DistanceEnd is in meters. it has same values as range.from and range.to
Code:
            float distanceBetweenPoints = DistanceEnd - DistanceStart;
            float pointPart = 1f / (float) (PointsCount - 1);
            float[] pointsDistances = new float[PointsCount];
            for (int i = 0; i < PointsCount; i++)
            {
                pointsDistances[i] = Road.DistanceToTF(DistanceStart + distanceBetweenPoints * pointPart * i);
            }

Somewhere (near the road start) it looks great (sphere gameobjects are edge points of intersection)
[Image: iDx8f4c.png]

Somewhere is offset more visible
[Image: wtOn96b.png]

Somewhere is offset very big
[Image: a9iwZn3.png]

How to get same points for intersection script and for Shape Extrusion? I tried to turn cache off (everywhere), I'm using non-fast methods, but no success.
It's always offseted towards spline start.
Reply
#2
Hi
I don't see what's wrong from looking at your code. How do you use pointsDistances after assigning its values?
If you can send a simplified version of your project I can run it and try to find what's missing
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
I tried to dig once more deeper by myself and I found out splines were dirty. I'm creating intersections in same frame as splines.
Code:
spline.Refresh();
after spline creation helped to solve my problem.
Reply
#4
Thanks for sharing the solution.
If and when you feel like it, please leave a review for the asset, that helps a lot.
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
  Efficiently chopping up a build extrusion? blabz2007 2 7 08-05-2022, 10:43 AM
Last Post: _Aka_
  Connection extrusion briceio 1 12 08-04-2022, 12:36 PM
Last Post: _Aka_
  Shape extrusion scaling tairoark 5 18 06-07-2022, 05:35 AM
Last Post: _Aka_
Bug Extrusion and scale curve issues Sacryn 3 12 04-08-2022, 12:30 PM
Last Post: _Aka_

Forum Jump: