Sculpt: Add Line Trim tool #120845

Merged
Hans Goudey merged 3 commits from Sean-Kim/blender:line-trim into main 2024-05-01 14:10:41 +02:00
Member

This PR adds the Line Trim tool to Sculpt mode. It is exposed via the toolbar along with the other Trim tools and as an entry in the Sculpt menu.

line_trim.gif

Added Features

  • Line Trim tool

Technical Approach

Line gestures are represented as two points in screen space: the start and end of the gesture. Trim tools work by taking a set of screen points as the top face of a volume, projecting a copy of the face into the scene and then using that as the operand shape for boolean operations. To behave as users would expect, the Line Trim tool does the following steps to make the initial face:

  1. Take the sculpted object's bounding box.
  2. Project the bounding box into screen space
  3. Take the magnitude of the diagonal line made from the bounding box
  4. Use the magnitude multiplied by an arbitrary factor to ensure the initial line is long enough to fully divide the object.
  5. Create two points by moving in a perpendicular direction from start and end points.
  6. Use the resulting four points as the vertices of the quad in screen space.

Differences with Other Trim Tools

  • Line Trim only supports the Difference mode. As such, the corresponding tool options have been disabled in the header.

Alternatives

  • Instead of using a boolean operation, this could be achieved by using a bisect operation when using the Fixed projection mode. While this may result in a better performing tool, it is not guaranteed and requires extra work to integrate this approach.
This PR adds the *Line Trim* tool to Sculpt mode. It is exposed via the toolbar along with the other *Trim* tools and as an entry in the *Sculpt* menu. ![line_trim.gif](/attachments/11b5c928-fd33-4a3f-ae62-586795ce61b3) ## Added Features * *Line Trim* tool ## Technical Approach Line gestures are represented as two points in screen space: the `start` and `end` of the gesture. Trim tools work by taking a set of screen points as the top face of a volume, projecting a copy of the face into the scene and then using that as the operand shape for boolean operations. To behave as users would expect, the *Line Trim* tool does the following steps to make the initial face: 1. Take the sculpted object's bounding box. 2. Project the bounding box into screen space 3. Take the magnitude of the diagonal line made from the bounding box 4. Use the magnitude multiplied by an arbitrary factor to ensure the initial line is long enough to fully divide the object. 5. Create two points by moving in a perpendicular direction from start and end points. 6. Use the resulting four points as the vertices of the quad in screen space. ## Differences with Other Trim Tools * Line Trim **only** supports the **Difference** mode. As such, the corresponding tool options have been disabled in the header. ## Alternatives * Instead of using a boolean operation, this could be achieved by using a bisect operation when using the *Fixed* projection mode. While this may result in a better performing tool, it is not guaranteed and requires extra work to integrate this approach.
Sean Kim added 1 commit 2024-04-20 00:43:41 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
c84f4051ab
Sculpt: Add Line Trim tool
Sean Kim requested review from Hans Goudey 2024-04-20 00:43:55 +02:00
Sean Kim requested review from Daniel Bystedt 2024-04-20 00:44:04 +02:00
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR120845) when ready.
Member

I am not getting expected behaviour from this build. Using the line trim tool in sculpt mode gives me a cut line on parts of the mesh. Check the attached video

I am not getting expected behaviour from this build. Using the line trim tool in sculpt mode gives me a cut line on parts of the mesh. Check the attached video
Author
Member

I am not getting expected behaviour from this build. Using the line trim tool in sculpt mode gives me a cut line on parts of the mesh. Check the attached video

Very strange behavior... I'll take a second look at this, I didn't encounter this at all in my testing.

> I am not getting expected behaviour from this build. Using the line trim tool in sculpt mode gives me a cut line on parts of the mesh. Check the attached video Very strange behavior... I'll take a second look at this, I didn't encounter this at all in my testing.
Sean Kim added 1 commit 2024-04-30 18:41:14 +02:00
Author
Member

Ok, I've fixed the issue, I think I was invoking undefined behavior that just happened to be working on my laptop.

Ok, I've fixed the issue, I think I was invoking undefined behavior that just happened to be working on my laptop.
Sean Kim reviewed 2024-04-30 18:46:50 +02:00
@ -281,3 +331,3 @@
ARegion *region = vc->region;
const Span<float2> screen_points = gesture_data.gesture_points;
std::array<float2, 4> line_points;
Author
Member

This handling of the line_points as looks rather awkward to me as it currently is, but I wasn't able to think of a good way of handling this. Another alternative here could be to modify the internal GestureData blender::Array in the above line_gesture_to_screen_points but that also had a code smell. Any thoughts on a good approach here?

This handling of the `line_points` as looks rather awkward to me as it currently is, but I wasn't able to think of a good way of handling this. Another alternative here could be to modify the internal `GestureData` `blender::Array` in the above `line_gesture_to_screen_points` but that also had a code smell. Any thoughts on a good approach here?
Member

I think this is fine. But another potentially simpler solution would be changing const Span<float2> screen_points to Array<float2>. The copying shouldn't really matter here.

I think this is fine. But another potentially simpler solution would be changing `const Span<float2> screen_points` to `Array<float2>`. The copying shouldn't really matter here.
Sean-Kim marked this conversation as resolved
Sean Kim added 1 commit 2024-04-30 22:06:17 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
af75cce650
Swap Span usage to Array
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR120845) when ready.
Daniel Bystedt approved these changes 2024-05-01 13:24:28 +02:00
Daniel Bystedt left a comment
Member

Works like a charm! Thank you for your effort 🥇

Works like a charm! Thank you for your effort 🥇
Hans Goudey approved these changes 2024-05-01 14:08:03 +02:00
Hans Goudey merged commit d4a61647bf into main 2024-05-01 14:10:41 +02:00
Sean Kim deleted branch line-trim 2024-05-02 22:22:23 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#120845
No description provided.