Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Gap between spline mesh segments
#10
(07-31-2022, 08:22 PM)_Aka_ Wrote: Hi
  1. I have a more precise tangent computing code that in my tests removed the gap between meshes in some cases, but other cases still have the gap, but less visible it seems. Give it a try:
    Go to the following method in CurvySplineSegment
    Code:
    public Vector3 GetTangent(float localF, Vector3 position, Space space = Space.Self)
    and add the following at its start
    Code:
    if (Spline.Interpolation == CurvyInterpolation.Bezier)
                    return CurvySpline.BezierTangent(threadSafeLocalPosition.Addition(HandleOut),
                        threadSafeLocalPosition,
                        threadSafeNextCpLocalPosition,
                        threadSafeNextCpLocalPosition.Addition(cachedNextControlPoint.HandleIn),
                        localF).normalized;
    As you can see if you check the code, the current implementation is computing the tangent by computing the delta between two very close points. The code above uses a specific implementation for Bezier splines.
  2. The handles you compute seem weird to me. It seems that, at least in some cases, the spline's first CP has a zero length handle, while the second one has a non zero length handle. This leads to a stretched spline, which you can notice from the UVs being stretched at the end of the mesh. Maybe solving this will solve the gap in mesh.
  3. This is not a solution, but as long as you are trying to fight the issue, it might be wise to set to false the Optimize parameter in the Shape Extrusion module, under the Path tab. Once the problem solved, you might then set Optimize back to true, and see if there are any regressions
  4. FYI, the tangents are computed when the mesh is rasterized in the Input Spline Path module. The equivalent class is InputSplinePath. The rasterization happens in its base class, SplineInputModuleBase, in its GetSplineData method. Look for the calls to InterpolateAndGetTangent in that method, that's where things happen.
    Those tangents are then used by the Shape Extrusion module to make the mesh volume. Look for BuildShapeExtrusion.Refersh(), and specifically its usage of path.Directions (the list of tangents of each rasterized point).
  5. To go back to the unique mesh solution: you know your use case better than me, so you are probably right when you say that this solution is not fit for your use case. But please allow me to add some points that might make that solution viable in your eyes. If these points are invalid, you don't need to take the time to explain to me why:
    You can use the Split parameter in the Volume Mesh module to split that single mesh into different meshes. The split meshes will not have the issue. The issue seems to come from using different extrusions with different splines. Single spline -> Single mesh extrusion -> Split Volume -> Different meshes with no gaps
    About joining track, you can concatenate your different track splines into one spline, then generate a single extrusion out of it.

I hope this helped
Have a nice day

Hello, I have been working on making train tracks using Curvy, and I am now trying to fix the issue in this thread again. The problem is that there are gaps between mesh segments of the tracks.

I tried some of your suggestions, but could not fix the issue. As you say in point 5, the problem seems to be that I am using different extrusions from different splines. 

However, I need different splines, as the player can place the train tracks at runtime. So I need a way for the player to add new track segments to the ends of existing tracks. 

The whole train network may end up being very big, so I cannot turn it all into a single spline to make a single mesh extrusion.

I am now trying to fix the problem by using catmull rom splines, and using connectors to join them and setting each segment's follow up to that of the other segment. However, this still leaves small gaps between the meshes.

Do you have any ideas on how I can get Curvy working to make the tracks from different splines to join without gaps?

Here is the code I am using to set the spline follow ups in the connection:

Code:
cpConnectingTo[0] = connectorUnderCursor.splineSegment;

                    CurvySplineSegment[] cpsToConnect = new CurvySplineSegment[2];

                    cpsToConnect[0] = cpConnectingTo[0];

                    cpsToConnect[1] = activeCP;

                    CurvyConnection theConnection = CurvyConnection.Create(cpsToConnect);

                    cpsToConnect[0].SetFollowUp(cpsToConnect[1], ConnectionHeadingEnum.Auto);

                    cpsToConnect[1].SetFollowUp(cpsToConnect[0], ConnectionHeadingEnum.Auto);


                    theConnection.gameObject.transform.SetParent(connectionsHolder.transform, true);
Reply


Messages In This Thread
Gap between spline mesh segments - by Beaver_Boy - 07-27-2022, 11:08 AM
RE: Gap between spline mesh segments - by _Aka_ - 07-27-2022, 02:00 PM
RE: Gap between spline mesh segments - by _Aka_ - 07-27-2022, 10:49 PM
RE: Gap between spline mesh segments - by _Aka_ - 07-29-2022, 03:01 PM
RE: Gap between spline mesh segments - by _Aka_ - 07-31-2022, 08:22 PM
RE: Gap between spline mesh segments - by dromo - 10-18-2022, 06:47 PM
RE: Gap between spline mesh segments - by _Aka_ - 10-19-2022, 08:47 PM
RE: Gap between spline mesh segments - by dromo - 10-20-2022, 09:19 AM
RE: Gap between spline mesh segments - by _Aka_ - 08-06-2022, 12:11 PM
RE: Gap between spline mesh segments - by _Aka_ - 10-21-2022, 07:29 AM
RE: Gap between spline mesh segments - by dromo - 10-24-2022, 09:37 AM

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_
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_
  Adjust radius of generated mesh via script? Shackman 1 4 03-26-2024, 01:12 PM
Last Post: _Aka_

Forum Jump: