GSoC 2021: Knife Tool Improvements: Weekly Reports

Here I will be posting weekly updates about my progress on implementing the various knife tool improvements outlined in my project proposal.

If you want to share feedback you have about my project checkout the feedback thread.

Until June 7th

In the weeks running up to my official project start I have completed the following:

  • Met with my mentor (Howard Trickey)
  • Ported my proposal over to the wiki
  • Continued studying knife tool related code to gain a better understanding of how to implement my proposal plans
  • Created weekly reports post and feedback post

For the rest of this period I intend to:

  • Interact with community feedback about my project
  • Create soc-2021-knife-tools branch
  • Further experiment with the code and potentially create some minor patches
18 Likes

Week of June 7th - 13th

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

week1_1

week1_2

Global Orientation Snapping
week1_3

Toggling between Global and Local Orientation Snapping
week1_4

37 Likes

Week of June 14th - 20th

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.

Media

week2_1

week2_2
week2_3
week2_4

Visible Distance and Angle Measurements (WIP)
week2_5

35 Likes

Week of June 21st - 27th

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
week3_2

Current Snapping Angle in Header/Footer
week3_1

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

week3_3

38 Likes

Week of June 28th - July 4th

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.

Undo Preview

When cutting one segment at a time:
week4_1

When holding left click and dragging:
week4_2

36 Likes

Week of July 5th - 11th

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.

  1. 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”?

  2. 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:
week5_1

week5_2

week5_3

reply4

32 Likes

Week of July 12th - 18th

This week I worked on a lot of small quality of life improvements and bug fixes relating to the features I have implement so far.

Notes

  • Undo
    • Fixed visible distance and angle measurements being broken after an undo operation
    • Fixed bug with undo when cuts were created with cut-through enabled
      • Previously some cut segments would not be deleted
    • Dragged cuts are now entirely undone, as opposed to segment by segment as it was before
    • Fixed bug where cut segments drawn along mesh edges could not be undone
      • Removed the ability to create cut segments between mesh vertices as this was redundant in practice
  • Depth Testing Toggle
    • Pressing ‘V’ will now enable “Depth Testing”
    • This hides any cut segments which are blocked from view by objects in the scene
  • Midpoint Snapping
    • Moved midpoint snapping to ‘SHIFT’ keys default
    • Moved ignore snapping to ‘CTRL’ keys by default
    • This solves problems relating to undo outlined in last week’s report

Next week I plan to implement snapping to a given distance and add support for multi-object edit mode to the knife tool.

Media

Undo working with cut-through:
week6_1

Undo with drag cutting:
week6_2

Undo with cuts drawn along mesh edges:
week6_3

Toggling on and off Depth Testing:
week6_4

22 Likes

Great improvement, I have a suggestion, can you implement this feature from “PolyQuilt”?

Knife

12 Likes

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.

12 Likes

Thank you, I submitted this idea 1 year ago ( Right-Click Select — Blender Community).

3 Likes

THis would be Frikkin Osom! <3 +1

Week of July 19th - 25th

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

week7_1

Cuts starting in space work on last object hovered:
week7_2

When two objects intersect the object to cut is based on the nearest mesh edge to the cut start:
week7_3

24 Likes

Why not allow cutting on all selected objects ?

5 Likes

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.

16 Likes

Oh don’t be so apologetic, it’s nice as it is already. Thanks for the explanation, yes it is super interesting !

4 Likes

Week of July 26th - August 1st

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.

29 Likes

Final Report

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.

New Build

The new build of my branch soc-2021-knife-tools is now available on: Blender Builds - blender.org

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’)
week8_1

week8_4

New tool settings
week8_2

week8_3

week8_5

37 Likes

congratulations! Great to see the improvements in your reports

3 Likes

Great! It seems, “Relative” term snapped perfectly.

4 Likes

Project Update

Merge

I am super happy to announce my Knife Tool Improvements Project has now officially been merged into master! ⚙ D12600 GSOC 2021 Knife Tool Improvements Project

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
demonstration

Orientation Snapping w/ Multi-Object Edit Mode
Takes the local orientation of the object the cut segment was started on:
orientation_snapping

Complex Meshes
complex

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!

50 Likes