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
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
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
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Absolute offset for shape extrudes rickgplus 1 1,449 03-21-2025, 12:37 PM
Last Post: _Aka_
Photo Volume Spots problem with spacing Bond007 3 2,554 01-20-2025, 12:27 PM
Last Post: _Aka_
  Incorrect mesh alignment after extrusion on curved path Thinkurvy 10 5,127 04-17-2024, 10:57 AM
Last Post: _Aka_
  Connections Problem Juton 3 2,255 03-06-2024, 10:41 AM
Last Post: _Aka_

Forum Jump: