I wouldn’t expect any results for a cube, because its bevel cases are all vertex meshes, which is the case I just started with. The cases that should work are the ones I’ve pictured so far, the wire case with just 2 of four intersecting edges beveled and the terminal edge case, where only one edge is beveled.
Also, right now the non “Sample only points” case is quite broken too. Also I’ve discovered another bug with loading saved files, but once I fix that I’ll start to distribute blend files.
I’m sorry it’s so buggy right now, I wish it could be perfect already! The only thing I can say is I’m working on it! : )
This week I finished much more than I expected! Here’s an overview of the biggest things I completed:
Profile Widget Fill
I was evaluating two options to fill the profile: First would draw a vertical line for each horizontal pixel and switch its color whenever it hit a line between two points. The other, which I ended up using, uses Blender’s existing polygon triangulation code to transform the profile loop into triangles. It’s been working well so far, and I think it will hold up better when I switch to drawing with the higher resolution curved profile.
Profile Preset Selection
For now the presets are defined in the C code. Eventually I’d like to store the profiles as curve objects, but I’ve finished the UI for the presets and added a few to start off.
This will be useful when you draw a profile and realize that it’s being created flipped around in the opposite direction that you expected. This image shows the result of the “reverse” button. I found a pretty good icon for it in the sheet, but it will probably need its own.
For the second half of the week I focused on understanding the way vertex meshes are created and enabling them to work with custom profiles. There’s a lot to learn here, and I’ve mostly been reading and making plans, but I have made a bit of visible progress. There’s no ideal solution in cases like these, but there’s plenty of room to improve this in the next few weeks. Here’s a work in progress image:
After a lot of confusion, discussion, and planning I’ve made some more concrete plans about how I want to improve the creation of the “vertex mesh” at the intersection of at least three beveled edges. My ideas are a bit scattered about for now, but I’ll collect them in this document in the next day or two. By the end of next week I’d like to have made good progress on this vertex mesh creation. It should be possible to make significant improvement from the smoothed out look they have now.
If I need a break from that I will work on curved sampling of the user placed points that define the profile. I will need to learn a fair amount about Bezier curves for this which should be interesting.
There was a lot of discussion about vertex mesh creation in DevTalk this week. The takeaway is that I will be targeting two options for this summer: The grid fill method with the existing bevel operator’s ADJ pattern, and the cut-off method which will generate a flat plane at the end of each profile. A boolean option would be ideal, but probably too large of an undertaking for the remaining time in the summer.
This week I mostly finished up the grid fill / ADJ pattern method.
Curved Profile Widget Sampling
Also after a lot of discussion on DevTalk, I added the ability to sample along the profile with any number of points. For the table that’s used for the widget’s display it samples at 256 segments, and for the bevel profile it samples at the input number of segments.
The same code also samples the bevel profile points:
It still needs an option to turn off the sampling of straight edges, but it’s almost there, and it saves a lot of time vs. placing points manually.
Saving and Loading and Memory Leak Fixes
I spent a while cleaning up the DNA structs which store the permanent information for the Profile Widget. In the process I fixed the memory leaks I had introduced the the modifier and the process of saving and loading bevel modifiers with custom profiles. It’s now much more viable to use / test the branch.
Initial Work Towards Custom Profiles in Bevel Tool
It’s an ongoing process, but I made some initial progress towards getting the profile widget in the tool options. I would like the widget to be in the redo panel with the other bevel tool options, but that is proving harder than I expected; I don’t think the redo panel was designed to support that.
I’m getting to the point where I can keep track of the rest of my goals for the summer on a relatively short(er) list. So I’ll be working on some combination of these tasks:
Get the profile widget into the bevel tool menu. I need to figure out how to draw in the redo menu or connect the tool menu to the redo menu call.
Cut-off vertex mesh method. The second method as an option for >2-way beveled edge intersections.
Fix profile orientation next to impassable BevVerts. Just a bug that I think might take a bit of time to fix.
Add “harden normals” functionality. Set custom normals for the profile faces using the curvature of the profile.
Fix miter profiles. The miters should still use a normal profile, not a custom one.
Finish RNA API for profile widget. This isn’t strictly necessary for this project, but I shouldn’t add the profile widget without finishing its API.
Now that I have a mostly working vertex mesh interpolation method, I started working on the backlog of items I had accumulated over the course of the summer. I finished two of the tasks I had and started another.
"Sample Straight Edges" Option
I started off by adding an option for whether or not to sample straight edges. The problem of spreading out the samples evenly in this case is interesting-- one sample is distributed to each point, and then the remaining samples are divided between the remaining curved edges.
Custom Profile in Bevel Tool
I added the custom profile functionality to the Bevel tool, which had been dysfunctional since the start of the summer. It’s great to finally get this finished! I learned a lot about the RNA system in the process, I think the next time I have to do something like this it will be much faster.
Fixed Profile Orientation
The last visible bug (that I’ve found) in the orientation-choosing code is fixed, so that part of the custom profile bevel system should be totally finished.
Progress on the “Cut-Off” Vertex Mesh Method
I’ve added the option to the tool and modifier and laid out the algorithm to create the cut-off vertex method pictured below (courtesy of @CandleComet). This step is probably the most important part of the process. If I’ve thought it through correctly, it should be relatively quick to implement.
Next week I plan to finish off the cut-off vertex method, and then get started on the remaining items in my list, most of which remain from last week (6 bigger items remaining!).
This past week I mostly spent much more time than I expected implementing the cut-off vertex mesh method. It looks great in most test cases I throw at it now! But there are still some weird edge cases that throw it off. It also currently disables miters which would add quite a lot of arbitrary complexity if they worked alongside cut-off vertex mesh methods.
The whole process was very helpful in getting a better understanding of the process the bevel code goes through to build the vertex meshes. I feel a lot more comfortable working in that area of the code now.
Miters Use Regular Profile
One of the problems with the custom profile calculation was that the miters (arcs and patches between beveled edges) would also use the custom profile. The bevel code now stores a second set of profile coordinates in these cases for the regular profile.
I’d love to have feedback everything here, but on the cut-off method especially at this point. I’ve been expanding a test file with a lot of different cases, so if you’re curious and have a binary of my branch this might be work checking out: https://developer.blender.org/F7621266
The number of larger items in my to do list is dwindling! I’d like to get some feedback on the cutoff method solution and advice to address the edge cases, and I’d also like to finish the “pipe” vertex mesh case which is pictured a couple weeks above. I also have around 40 (!) smaller “TODO” comments in the code that I’m going to start making a concerted effort to reduce.
I started off the week by working on implementing my plan for the pipe case vertex mesh, where there are two nearly parallel edges coming into a single vertex. It’s in a very rough state, but the process sparked a lot of good discussion and I’m closer than before.
Work in progress debugging image, just for a sense of what the process is like
The pipe vertex mesh is turning out to be a complicated problem! So later in the week I spread out my efforts to start to tackle the 58 TODO comments that had accumulated in the code. I’m now down to 21 of them now, which I’m really happy about. Here are some of the more interesting things I finished:
The ability to sample fewer segments from the profile widget than there are control points.
A preview of where the sampled segment locations will be in the profile widget (the smaller dots in the image).
Cleanup, better readability, and more polish everywhere!
The remainder of the TODO items are pretty evenly split between the bevel code and the profile widget. Other than the two items remaining on my list of larger items, harden normals functionality, and finishing the pipe vertex mesh, I’m almost completely in bug fixing mode.
Once I finish the pipe vertex mesh case, I would also like to do a “Call for Content” to gather profile presets from the community!
After changing my strategy a few times, I’ve finally finished both the 3-way and 4-way pipe case snapping with custom profiles enabled. We can’t just snap to the superellipse function that generates the regular profiles, so instead we do interpolation between the two profiles that make up the vertex mesh. This strategy ensures that every face is a quad and that the profiles are nice and crisp through the vertex mesh.
I’ve solved another 14 items on my to do list and I’m now down to just 10. Here are some of the more interesting changes from this process:
Only use the triangle fill vertex mesh method when the extra vertex is not planar with the profile. (939b993600c4)
Don’t use the cutoff method in the pipe case. (33141cff0f4a)
Add shortcuts for moving and deleting control points in profile widget. (e625c5a6b182)
Solved bugs with the profile widget UI and sampling.
Start Harden Normals Functionality Investigation
I’ve started talking to Howard about how to change the custom split normals generation for the custom profiles. The largest change is that there can be sharp edges within the profile which will need split normals. The cut-off vertex mesh method also has sharp edges that will need split normals.
Hopefully by the end of next week I will have finished the new harden normals functionality. I also hope to be nearly finished with the remaining bugs on my TODO list. In the next few days I’ll make a public task list for these and link it here. Finishing these two things will set me into the final phase of the project where I’ll work on final polishing, documentation, and figuring out how to move forward in merging this into master.
The best way to do that would be to pass through the data about which sample points came from sharp control points and split the normals for those, so I upgraded the sampling code to pass that information through.
Bevel Tool and Modifier UI
After a lot of time and discussion in the DevTalk thread, we’ve settled on some improvements to the bevel’s interface. The biggest change is that the tool and the modifier now share the same layout! It’s a relatively large change but I think it’s an improvement in both situations.
One bug that’s popped up is inconsistent orientations along chains of bevels. I wrote code a while ago to regularize these orientations, but there are still problems with it. After debugging the old code for a couple days, I got frustrated and rewrote it and I’ve been solving bugs with the new implementation. It’s close to a solution, but there’s still more to fix.
I gotta repeat one more time that I’m impressed by the quality of your work, your attention to detail and the quality of your communication. Not to mention we all get to play with this great tool thanks to you. Mad props !
There are still some remaining tasks to do, but having the patch submitted and possibly starting the review process is a great first step in the merging process. I’ll add some pictures to that diff and update it as I fix the few remaining bugs.
Here is the selection of presets that I’ve added so far. I’ve asked for others ideas on the other thread, so if you have input head over here.
Profile Orientation Regularization Fixed!
I finally got this working! After so much frustration and a lot of time, I found all the errors I had made writing the new version, and eventually ported those changes back to the original version which I think is faster.
Bevel Modal Keymap
Added Z for custom profile and N for intersection method toggling. I find the bevel modal keymap overwhelming, but for people who use it frequently this should be helpful.
Miscellaneous Bugs and Smaller Features
Even length sampling option
Small UI updates
Code and comments polish
Sampling bug fixed: extra samples are now assigned properly to the most curved edges
Over the next five or six days I’m going to be totally off of the internet on a hiking trip. I’m hoping to have some feedback on the patch I posted when I get back. But I’ll have to finish up and submit my final report as soon as I get back too. This means that the merge into master will have to wait until after the official end of GSoC.
I may post again with my final report, and obviously I’ll continue updating people as I continue the project and development in the fall, but I want to thank everyone that’s participated in the project for the awesome amount of support. You all made this project from a cool intellectual challenge into a passion for me, it has been a great experience!