The branch soc-2021-knife-tools has been created and I have spent the past week implementing the following features:
Constrained Angle Mode Improvements
New setting to control snapping angle increment
Number key input also works for quickly setting the increment
Orientation Locking
Pressing X,Y or Z will restrict the current knife tool cut to the corresponding dimension in global orientation (toggle cut-through moved from âZâ to âTâ)
Pressing the same key again will restrict to local orientation
Scene orientation setting takes priority over this if any orientation except global is selected. This provides support for custom orientations or others such as gimbal and normal.
Lastly I spent a short while looking into code for next weekâs plans. Specifically relating to visible distance and angle measurements for the knife tool.
Media
Global Orientation Snapping
Toggling between Global and Local Orientation Snapping
This week I focused on adding visible distance and angle measurements and also made some small improvements:
Constrained Angle Mode
Snapped angle now updates as snapping increment changes (previously the mouse had to be moved for it to update)
Orientation Locking Header/Footer
Header/Footer now shows X,Y,Z when constrained globally in the corresponding axis and x,y,z when constrained locally
Reads OFF when not constrained
Visible Distance and Angle Measurements (WIP)
Use âMâ key to enable this new feature and toggle between displaying just distance, just angles or both
Shows distance from last cut point to current
Shows angle between current cut edge and mesh edge or previous cut edge
Next week I am going to finish implementing the visible distance and angle measurements in the first few days and spend the rest of the week looking into small improvements I can make and some user requests.
This week I finished up the visible distance and angle measurements, added a few quality of life improvements and implemented a new local constrained angle mode:
Visible Distance and Angle Measurements
Now shows a second angle, between current cut segment and previous cut segment
Support for measurements when cut intersects with vertices (works well but still not perfect)
Many bug fixes on last weekâs implementation
Quality of Life Improvements
Added current snapping angle to the header/footer for constrained angle mode alongside the previously displayed snapping angle increment
Swapped functionality of âEâ with âRight Mouse Button (RMB)â
âEâ now cancels the entire cut along with âEscapeâ and âRMBâ will break off from the current cut and alllow you to start a new one
Local Constrained Angle Mode
Pressing âCâ once will enter âscreen-spaceâ constrained angle mode (same as before), but now pressing âCâ again will enter âlocalâ constrained angle mode
In this mode the angle is snapped along the current cut segmentâs face and relative to the previous cut segment
In the case where the current cut segment started on an edge or vertex the angle is snapped along the face the mouse is currently over, if it is adjacent to that edge or vertex
When no angle can be snapped to in this mode, for example when there is no previous cut segment yet, the cut point can move freely
Next week I will be start on implementing undo capabilities for the knife tool. I expect this to be a difficult task and will likely take at least the entire week.
Media
Visible Distance and Angle Measurements
Current Snapping Angle in Header/Footer
Local Constrained Angle Mode
Initially, I show switching between the old constrained angle mode and the new
I also change the snapping increment from 30° to 20° throughout using number key input
Lastly, I show the cut moving freely when no angle can be snapped to
I spent the first half of this week studying the knife tool code to better understand how it stores data about the current cut, in preparation for implementing undo. Eventually, I had a rough plan and got started implementing it over the last two days. This report will contain a short preview of undo and notes about other changes I have made.
Notes
Following a lengthy discussion on the feedback thread, I opted to commit the following changes to the default modal key mapping for the knife tool:
Removed âEâ key for cancelling a cut (too easy to accidentally hit and cut is unrecoverable)
Moved âMâ for toggling visible distance and angle measurements to âDâ
Moved âCâ for toggling constrained angle mode to âAâ
Moved âTâ for togggling cut through to âCâ
The aim of these changes is to consolidate the default modal keys towards the left side of the keyboard, improving the workflow and efficiency of using the tool.
This week I spent the majority of my time finishing up undo functionality. I had a lot of trouble with various bugs that existed in last weekâs implementation as well as tackling the reversing of edge splitting. I am happy to say I have since committed a nearly fully working version of undo.
Notes
Implemented undo functionality for the knife tool
Pressing âCtrl-Zâ will delete the most recent segment of the cut
If the cut is still being drawn, the starting point for the next cut is adjusted accordingly
Currently visible distance and angle measurements are broken after an undo
I intend to rewrite some parts of the code for the visible measurements feature and so am holding off until next week to fix this
Midpoint snapping has been moved from âCTRLâ to âTABâ in the modal key map
This is due it not being compatible with âCtrl-Zâ for undo
Questions
I have a few questions I would like to get community feedback on. Please share your responses in the feedback thread.
Is âTABâ okay for midpoint snapping modal key? If necessary I can spend more time attempting to make both âCTRLâ for midpoint snapping and âCTRL-Zâ for undo work together. Or maybe someone can suggest a better key than âTABâ?
As shown in last weekâs report, when drag cutting with the knife tool, undo will only remove the last segment of the drag cut. Should this be changed to undo an entire drag cut in one undo operation?
Media
Here are some gifs showing undo working in various different ways:
I like the idea of having configurable snapping increments along an edge as you show. However, I am not sure if there is enough free time in my project schedule to add this feature. If you submit it as a feature request to rightclickselect maybe I or someone else in the future will be willing to spend some time to implement it.
This week I almost solely worked on multi-object edit mode support for the knife tool. It proved more challenging than I initially expected and I spent a lot of time trying various ideas for implementing it. In the end, I found a solution I was happy with and have committed it to the soc-2021-knife-tools branch.
Notes
Multi-Object Edit Mode
Added support to the Knife Tool
Cuts can be made on all objectâs while using the knife tool in multi-object edit mode
A cut which starts on a given object can only cut/interact with that objectâs mesh
A cut which starts in space can only cut/interact with the object that was last hovered by the mouse before starting the cut
I feel it would be better to be based on the nearest object to the mouse while cutting, but a short attempt at implementing this showed it would take large changes to make work
Next week I am going to add multi-object edit mode support to the knife project tool and an edge removal mode for the knife tool.
Media
Cuts starting in space work on last object hovered:
When two objects intersect the object to cut is based on the nearest mesh edge to the cut start:
I realise it would be miles better to be able to cut on multiple selected objects with one cut and I am unhappy that it does not. I should have clarified why it only works on each object seperately in the report, so I will do here.
Mainly, it is a limitation of the way the knife tool is already designed. Without going into too much technical details (unless that is preferred?), to have a semi working version of the knife tool in multi-object edit mode completed within a week I had to implement it this way. I believe the way the knife tool currently works would have to be massively changed to allow cutting of all objects with each cut (a similar problem is this) and I am not familar with the areas of blenderâs codebase that would make this work.
I am sorry I could not deliver a better version where all objects could be cut simultaneously. I hope at least I was able to lay a foundation for someone with more experience and more time than me to come in and rework the necessary things to make the knife tool work in such a way.
After receiving feedback on last weekâs report and discussing further with my mentor we have decided to make some changes to the plan for the remaining two weeks of the GSOC coding period.
Test Build
I will now be releasing a build of my branch soc-2021-knife-tools each week for everyone to help test by searching for bugs and provide feedback on the features I have implemented.
Please share any feedback you may have on my feedback thread. I will work on fixing any bugs found or making any suggested improvements over the next few weeks, alongside the plan discussed below.
New Plan
Based on feedback from last week, I am going to spend the rest of the GSOC period focusing on re-implementing a better version of multi-object edit mode support. The goal is to allow cutting across multiple objects in the scene and making cuts from one object to another. This will require a complex re-write of large parts of the Knife Tool code but should make it possible to implement much more useful features in the future as well.
The plan to implement edge removal mode has been abandoned as it seemed a rather niche feature now that undo is implemented. It also became clear that multi-object edit mode support for the knife project tool already exists in that you can use multiple objects for projection. There is no way to differentiate between objects being projected onto and being used for projection and so this feature is not necessary.
The GSOC coding period has officially come to an end as of this week and I have posted my final report over on the wiki. I apologise for the lack of a report last week, I spent the entire week working on a foundation for better multi-object edit mode and decided it was best to wait for more feedback about the build that I posted before making a report.
This report contains a list of various bug fixes and additions I have made as a result of feedback about last weekâs build as well as a new build for testing. I will also discuss the plan going forward.
End of Coding Period
Now that the official coding period has come to an end I will no longer be implementing any new features. My plan now is to spend some more time fixing any further bugs / minor improvements given as feedback about the latest build. I am going away on holidays this upcoming week and so will be slow to respond until after I return.
I will also discuss further with my mentor about continuing work on a better multi-object edit mode as well as beginning the process of merging my changes into master.
Patch notes since the previous build are outlined below and once again I would appreciate it if you shared any feedback you may have about this latest build on my feedback thread.
Notes
Angle Snapping Improvements
âLocal Angle Snappingâ renamed to âRelative Angle Snappingâ
Relative Angle Snapping now works with existing mesh edges
Fixed bug where it did not work with rotated objects
Caused by custom knife BVH code
Input snapping increment multiple times via number keys
Cannot input numbers with decimal point, this can be done with the value exposed in knife tool settings
Use alternate edges for Relative Angle Snapping
Current edge is highlighted in yellow
Press âRâ to cycle between edges
Angle measurementâs are always drawn to currently selected edge
New Knife Tool Settings
Select between default angle snapping modes of None, Screen or Relative
Select between default measurement modes of None, Both, Distance or Angle
General Improvements
Depth checking mode renamed to âX-rayâ
Press âVâ to activate
ON/OFF make more sense now
Better Multi-Object Edit Mode
New custom Knife BVH is in use
Lays the foundation for cutting across multiple objects in multi-object edit mode
Not yet implemented
Media
Alternate edges for relative angle snapping (cycling through edges using âRâ)
I am super happy to announce my Knife Tool Improvements Project has now officially been merged into master! https://developer.blender.org/D12600
Over the coming weeks I will be focusing on responding to and fixing various bug reports that come in. If you find a bug with any of the changes detailed within this thread then please submit a ticket on developer.blender.org and tag me as a reviewer (otherwise tag the project as modelling). The latest build of master can be downloaded under âAlphaâ on Blender Builds - blender.org.
Better Multi-Object Edit Mode
A variety of changes and bug fixes have been made ahead of merging into master. The largest change has been the addition of a better multi-object edit mode. It was clear from user feedback that my previous implementation was unsatisfactory and so I set out to make it work as expected.
Demonstration
Orientation Snapping w/ Multi-Object Edit Mode
Takes the local orientation of the object the cut segment was started on:
Complex Meshes
Notes
The one change I did not manage to complete is in regards to relative angle snapping. As it is in master, relative angle snapping is still limited to the existence of an adjacent face to the relative edge which is being used. This is not the greatest implementation and will need to be updated in the future, but as it is it does still allow for making more precise cuts.
There are also still some minor visual bugs with orientation snapping which will be fixed soon.
Wrap Up
Lastly, I just wanted to say I have had an amazing time working on Blender and thank everyone for their support. Seeing the things people create with Blender is one of the best parts and I intend to continue doing what I can for Blender when I find time!