I’m generating a bezier curve-based mesh (cubic 4-point beziers). The mesh is just a typical bezier function from 0 to 1.0 to create the vertices.

But the problem is, if the handles of two adjacent beziers are quite short or close together such that the curve is quite ‘sharp’, I get a gap between them in the mesh, as below. The size of the gap changes based on the position of the handles.

I’ve tried a fudge where I add a small number to the angle of each outside point so that it sort of bends it a bit more, which closes the gap. But I can’t figure out how to scale that adjustment based on the sharpness of the angle, to get an EXACT closure/alignment with no overlap. I can approximate it to look okayish in most cases but not in the more extreme cases of shorter handles. Adding 1 extra segment doesn’t work. Trying to force it to go past 1.0 doesn’t work.

Just to note, the inner side of the mesh is perfectly okay, that’s what the bezier is based on, but the projected out outer side of the mesh exhibits a gap where the triangles fan out.

Am I missing something here, why do I even see a gap at all if the bezier is going from 0…1.0 and I’ve programmatically exactly mirrored the two handles opposite each other?

Could this be a float inaccuracy issue amplified by the projected triangles?

just snap the vertices together ?

i thought about that. i could technically do it I guess… but I’d like to know what it’s even necessary to do that, shouldn’t they line up perfectly?

I think I know what the issue is but not yet how to solve it.

The issue is that the bezier points are calculated fine, and the end-points are at exactly the same coordinates, but in order to turn it into a mesh I have to project out perpendicular to the bezier at 90 degrees. The trouble is that this creates a right-angle and it’s really not supposed to do that. The ‘normal’ of the surface, at a given vertex, is really supposed to be the *average* of the slopes to the previous and next vertices, with the vertex being in the middle of them. That would then project out at the proper angle rather than being somewhat held back by being forced to be 90 degrees. Mostly you don’t really notice this effect within the main body of the mesh but at the ends in particular you do, because now the projected outer edge doesn’t meet up properly and leaves a gap. The gap is due to incorrectly calculated normals. But that also means that to calculate them correctly you’d have to a) know about the previous and next vertices, and b) you run out of vertices at the ends so then you’d have to know about the next bezier curve and what it’s 2nd-in-from-the-end point is in order to calculate the normals correctly, which adds extra complexity not only finding the attached bezier but then calculating it and finding that number, just to be able to compute the normal properly.

I had a fudge in place which slightly ‘expanded’ the range of angles generated to just try to hack a closing of the gap, but as a single scale value it either causes overlap (overshoot) or still a gap in extreme cases (undershoot). Short of programming a much more complicated normal-generating algorithm, I don’t see how else to approximate it. An approximation would be fine if it looks decent at most angles.

i see what your saying and it makes sense , i did not really understand that you were joining two beziers.

i never joined beziers before , but i think i know how you may solve it in theory .

back when i created a bezier mesh to build something to base roads on , i went about it by first creating the path in a list and then going over the path projecting out left and right pretty much the same manner .

so i was thinking , if you kept your bezier path in a list with the indexing the same as your vertex indexing , you could find the vertex index in each list which corresponds by vector positions (the two end vectors) eg. if vectora in list A equals a vectorb in list B then thats the joining points .

when you now know which are the two joining vertices on the ends , you can step one backward in the index if the vertex index is not 0 (your highest index) , and you can step one higher in the index if your end index is 0 (your minimum index) , this should get you the 3 vertex positions you require .

edit : since this is end points you can simplify by directly checking the first and last in the lists instead of all x number of points.

There’s also a catch 22 where i can’t get the vertex of the ‘next’ bezier in order to copy it to this one, because the next bezier hasn’t been built yet. I’d have to build all beziers and then go back and hack the joints.

I found that if I project the angle at 94 degrees rather than 90 degrees is sort of makes up for most of the issue. It’s not ideal or perfect, but because it’s angle based it magnifies the angle of the last segment better than adding a fixed offset. Based on the kind of curves I’m making most of them come out without too much overlap or gaps showing.