GSoC 2019: Custom Bevel Profiles

Another question I (one of the mentors on this project) have been discussing with the student is: how to sample the profile if the user specifies an “number of segments” that is different from the number of segments implicit in the points drawn in the profile widget?
For the non-custom bevel, the code tries to make equal-width segments spanning the superellipse arc.

For custom bevels, this is unlikely to be what the user wants unless all the points on the profile are smooth and the number of segments is high enough that equal width segments gives a good approximation to the original profile. Otherwise, the user probably wants the points they explicitly drew in the profile widget to be points on the beveled edge profile.

Let’s call the profile that the user drew “the input profile” and the profile that the modifier will use to make the beveled edges with the specified number of segments “the output profile”.

Some likely requirements:

  • If there are sharp points in the input profile (“Vector” option in the drop-down list), then those points should be in the output profile at the same locations. If this results in more segments than the user specified, what should happen? One option: ignore the user specification of number of segments and use this requirement to set the minimum possible number of segments. Another option: remove even the sharp points, one-by-one (say, the ones with the shallowest angles first) until the number of segments constraint can apply.
  • Divide the profile into “sections”, where a section goes between two sharp points (the ends are sharp points for this purpose). Let us say that we don’t need to respect the user’s position for non-sharp points, for now. Now suppose we need to add n more intermediate points on the whole input profile to get (# of sharp points + # added points - 1) = # of segments. One way to do this would be to allocate them proportional to the length of the curve (measured along the ideal curve) for each segment. E.g., if we had three sections of lengths 1, 2, and 1 respectively, then we’d want 1/4 of the added points in the first section, 1/2 the added points in the second section, and 1/4 of the added points in the third section. One would have to do one’s best to deal with rounding n/4, n/2, and n/4 to integers such that the total of the rounded values is actually n. Another way to do it would be to try to take curviness of the sections into account, putting more segments into the curvier ones. Another variant would be to make sections go between any of the original points on the input profile, including smooth ones.

What do people think? Does this sound about right? For the places about where I have questions, what do you think the right answer is?

Of course, an easy answer would be “give the user options to choose whenever there is a choice”. I think we would prefer to avoid a proliferation of options, if possible – that is, if a particular set of choices gives most users what they would prefer most of the time.

3 Likes

It seems hard to imagine use cases for an assymetrical profile on a 3(or more)-way intersection. Two of the edges would be aligned with each other, but not with the third one, which is strange. It makes more sense to use such profiles on continuous edge loops.

But with symmetrical profiles I can imagine wanting to use them on many edges at once, which would include 3-way intersections. Think woodworking, mitering all edges. In this case the best solution for me would be your Boolean solution.

3 Likes

I would think the user would expect all of the points that they specified represented in the end result. Sharp points and smooth points should all be there. The segments setting should just adjust the number of loops created between these points. You may be able to optimize it where a sharp point adjacent to another sharp point would not insert loops, but in most cases I would think all of the points you put in your profile should be there.

It seems like your other suggestion of dividing it into sections would be nice, but it could result in unpredictable results as well. I’m mostly thinking of how the smoothing will be set and represented on the screen. For some trim that isn’t a major focus of the scene, I may want to use a small # of segments. Now, if you look at trim profiles for interiors and furniture, they often have a lot of small curvy features at the one end and maybe one long curve at the another. If you base this completely on distance, you will end up all of the detail added only to the most gentle curve. So if the curvy detail takes up 1/4 of the total length of this profile, and then you set to 4 segments, then there will be no segments added to the most detailed part. So are these points detailed parts going to be smooth shaded? Autosmooth often won’t work in these situations, because you may have parts that need to be smooth shaded that have an angle close to 90 degrees, but if you set your autosmooth angle that high, your sharp corners will be smoothed as well.

That was a lot of talk just to say that that segments need to based on Curvature, or simply be a number of subdivisions between points, but that’s my (long-winded) opinion.

1 Like

Thanks for the response and diagram. It does illustrate why this isn’t an easy problem. Basing the number of points on curvature was one of the options I mentioned above, and you made a good case for that. As well as a good case for not distinguishing between sharp and smooth points as some of my options did.

1 Like

Do we think there’s a use case for sampling fewer points than the user inputs? If there isn’t then that simplifies some of the logic quite a bit. If we ignored the segment input if it was smaller than the number of input points, then the problem becomes “How to distribute the sampling of extra points” which I think is a simpler problem.

The simplification this enables is ignoring non-curved lines between vector-handle points. So the extra points can be sampled only on the curved edges. The only problem is if all the points have vector handles, increasing the segment count beyond the number of user points wouldn’t do anything. Even though this is a bit confusing, I think it’s ok-- at that point you’re just adding redundant information.

I think another key piece of information is that in general, to have more curvature, points need to be closer together. So sampling the extra points evenly for each curved edge will put points closer together on more curved sections of the profile. And the remainder of points after this even distribution can be assigned to the most curved edges.

Here’s the algorithm that describes this plan:

  1. Make a list of only the curved edges between user defined points.
  2. Sort that list by the curvature of each edge.
  3. Assign sampled points to each edge. Assign an even number to each edge if it’s possible, then add the remainder of sampled points starting with the most curved edges.
  4. Create the table with the original user defined points and the sampled points spaced out evenly on their assigned edges.

By the way, I hope to use the same code for creating the table of points that the profile widget fill is drawn with. In that case the number of segments to sample to would probably be something like 256. The cap for user defined points will need to be smaller than this.

1 Like

@HooglyBoogly @Hadriscus @Howard_Trickey @RonanDucluzeau

Selected vertices/edge: bevel interpolation
The selected vertices/edges order of interpolation could be done using the following (user selected) options;

  1. Horizontal edges, then vertical edges.
  2. Vertical edges, then horizontal edges.
  3. Translation:
  • Rotation
  • Flip (Mirrored horizontal), then (Mirrored vertical).
  • Flop (Mirrored vertical), then (Mirrored horizontal).
  1. Equal number of vertices or edges, then unequal number of vertices or edges.
  2. User defined order.
1 Like

The idea of not adding segments to straight line sections makes sense for some use cases but not all. People still want multiple segments with profile = 0, .25, and 1 cases, to set up for future modifications I guess. And see the other Bevel (2018) thread where DanPool expresses several times how much he has wished for multiple segments on the flat sides of insets.

Hmm, I guess that makes sense. I guess I just won’t exclude them and I’ll add the same number of samples to each segment regardless of whether it’s straight or curved. When there’s a remainder the vector-handle points will just be the least curved so they won’t be prioritized. That should actually simplify what I’ve written so far.

I’m hoping to finish this up today. I’ll post here when I do.

While in general I think we should try hard not to add more options, there may be a case for having an enum option for sampling strategy, where one might be “spread the segments as evenly as possible” and another might be “adapt heavily to curvature, putting the new samples where the curve is curviest”. But for now, you might as well just choose one method and implement it. Got to concentrate on getting to a master-worthy set of well-implemented features rather than all possible things that would be useful but nothing completely done.

1 Like


I’ve added a new option to disable sampling of straight edges, here is a result.

Remaining Tasks

I’m moving on from sampling this week, so I figured I would give an update on my plans for the rest of the summer. If anyone thinks there’s something important that I should be prioritizing instead, now’s the time to make your voice heard!

  1. Cut-off vertex mesh method. A simpler, more predictable method for creating the vertex meshes. I’ll try to budget a week for this because it may require a fair amount of new code.
  1. Add “harden normals” functionality. Set custom normals for the profile’s faces based on the curvature of the profile at each vertex.

  2. Fix miter profiles. The miters should still use a normal profile rather than a custom one.

  3. Finish RNA API for profile widget. This will allow using the profile widget in other situations with Python. This isn’t strictly necessary for this project, but I shouldn’t be adding the profile widget without finishing its API.

  4. Get the profile widget into the bevel tool menu. The bevel tool is still broken. I’ve made progress on getting the new functionality into it, but I’m still working on it.

  5. Fix profile orientation next to impassable BevVerts. Just a bug that I think might take a bit of time to fix in situations like @RonanDucluzeau pointed out:

  1. Pipe ADJ vertex mesh case. This should still be a special case with custom profiles, so I’ll have to figure out how to change it to make it work properly.
    Screenshot%20from%202019-06-19%2010-17-57

  2. Bug fixing, documentation, and cleanup.

8 Likes

just applause, the rest of the words are superfluous :clap::clap:

3 Likes

Hm autoupdate for the modifier seems to be broken now? (it doesn’t update the mesh for me after moving points in the profile. (Also for is it just me or is there 2 preset drop downs)
I think user experience wise the thing I’d want most is a symmetrize button to make perfect symmetrical shapes.

Yeah, unfortunately the lack of updating makes it a bit frustrating to use. The strange thing is it was working before! I’m aiming to fix it this next week though, I’ll let you know when.

The double presets switch is just me experimenting with different methods to create the button.

For the symmetrize button, I could pretty quickly make something that could mirror the first half of the points starting from one side. What I’d like more is a symmetrical mode though like clipping where it stays on until you turn it off. I think I want to finish essential features and bugfixing before I implement this, but it can be the first thing I do after that.

2 Likes

I just pushed a fix for this problem. If you’re using the windows daily builds, they should include the fix by the end of the day.

Say would it be possible to make a Bevel option for something like this?


Instead of using a bevel profile you could just change the shape by entering the number of steps or he width you want. Could be useful for adding stairs for Architecture Visualisation or add detailing to some models. What are your opinions? Do you think this is feasible? Hope I’m not asking too much. :slightly_smiling_face:

1 Like

@13AUDDIN

A stepping profile should be possible using the curve profile implementation.

2 Likes

It’s absolutely possible to build something like this with a custom profile. In the screenshot the bottom step is incorrect though because of a bug with the sampling that I still have to fix.


We could definitely include a preset for steps, but it would only have a certain number of steps, and I’m not sure it makes sense to include a “4 steps” preset. It could be that when the Steps preset is selected there could be a slider for the number of steps and some functionality to generate the right profile. It wouldn’t be complicated but it has a relatively limited use case so I’m not going to prioritize it.

3 Likes

Thanks, makes playing around much more fun!

Well if you could just toggle option that automatically disables half of the widget space and mirrors that in real time… obviously that would be optimal. However, I felt that it might be too big so I hoped we could at least get a button that just mirrors the profile.
I recall before there was toggle to make the points on the profile set the amount of divisions to make (rather than the segments slider) but I can’t find it anymore. Was the idea scrapped?

1 Like

Don’t worry, I want to make the real-time symmetrical mode, it sounds like a fun task.

And yeah, there was a “Sample only Points” option, but after some updates I made to the sampling algorithm it was redundant with the number of segments set correctly. But we’ve discovered that it was also useful just as a way to set the right number of segments, so I’m thinking about how to get back that functionality.

3 Likes

speaking of “symmetry” some time ago I made this proposal for the evolution of the loopcut tool, but I think it could be a valid idea also for your tool …

in practice it would be an interesting thing to be able, after subdividig the segments, to scrape them, widen them and tighten them starting from the central segment “like an accordion”

imagine the ease of all the animations that would evolve …

3 Likes