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
  Incorrect mesh alignment after extrusion on curved path Thinkurvy 10 19 Yesterday, 10:57 AM
Last Post: _Aka_
  Connections Problem Juton 3 16 03-06-2024, 10:41 AM
Last Post: _Aka_
  Combining two separate meshes ava_ava 2 7 07-26-2023, 05:49 AM
Last Post: ava_ava
  Fading in/out extrusion mesh of a spline? _RicO 3 5 07-25-2023, 09:40 PM
Last Post: _Aka_

Forum Jump: