Curves: initial surface collision for curves sculpt mode #104469
Merged
Jacques Lucke
merged 29 commits from 2023-02-11 13:46:39 +01:00
JacquesLucke/blender:temp-curves-surface-collision
into main
Reviewers
Request review
No reviewers
Labels
Clear labels
This issue affects/is about backward or forward compatibility
Issues relating to security: https://wiki.blender.org/wiki/Process/Vulnerability_Reports
Apply labels
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
This issue affects/is about backward or forward 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
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
Issues relating to security: https://wiki.blender.org/wiki/Process/Vulnerability_Reports
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 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
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
Milestone
Set milestone
Clear milestone
No items
No Milestone
Projects
Set Project
Clear projects
No project
Assignees
Assign users
Clear assignees
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#104469
Reference in New Issue
There is no content yet.
Delete Branch "JacquesLucke/blender:temp-curves-surface-collision"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
During hair grooming in curves sculpt mode, it is very useful when hair strands are prevented from intersecting with the surface mesh. Unfortunately, it also decreases performance significantly so we don't want it to be turned on all the time.
The surface collision is used by the Comb, Pinch and Puff brushes currently.
This was originally based on D15451 but I changed it quite significantly do make it more feasible to integrate in master without introducing new big abstractions that we don't know we'll need. The intersection prevention quality of this patch is worse than the original patch, it's a bit faster though. Overall, perfect collision detection at the cost of bad performance is not necessary for interactive sculpting, because the user can fix small mistakes very quickly. Nevertheless, the quality can probably still be improved significantly without too big slow-downs. This can be done separately from this patch.
Possible future improvements:
@blender-bot build
WIP: Curves: initial surface collision for curves sculpt modeto Curves: initial surface collision for curves sculpt mode@blender-bot build
Seems good to me!
Would of course be great if performance/accuracy could be tweaked more in the future but this is great for a first iteration!
Just a couple suggestions about the index mask stuff inline, and a couple other small things. Since it worked in my testing and for Simon and it will probably be changed more in the future, I didn't think too much about the specifics of the collision algorithm. What's there seems reasonable, but I didn't really think about alternatives.
At least for the guide use cases where there are very few initial curves, the performance difference isn't noticeable. It's obviously much different when there are lots of curves though.
@ -241,4 +241,10 @@ IndexMask find_indices_from_virtual_array(const IndexMask indices_to_check,
return detail::find_indices_based_on_predicate__merge(indices_to_check, sub_masks, r_indices);
}
IndexMask find_indices_from_array(const Span<bool> array, Vector<int64_t> &r_indices)
Can't seem to add a comment there, but this can replace
above.
@ -143,0 +147,4 @@
const IndexMask changed_curves_mask = index_mask_ops::find_indices_from_array(changed_curves,
indices);
const Mesh *surface = curves_id_->surface && curves_id_->surface->type == OB_MESH ?
static_cast<Mesh *>(curves_id_->surface->data) :
static_cast<Mesh *>
->static_cast<const Mesh *>
@ -157,2 +160,3 @@
this->puff(curve_weights);
this->restore_segment_lengths();
Vector<int64_t> changed_curves_indices;
What about something like this?
Also, since the mask has to be computed, would it be possible to use the mask in
this->puff()
?I might be wrong, but I think that's not equivalent currently. We could refactor things separately to clean this up though.
Note that the index used in the predicate
curve_weights[select_i] > 0.0f
isselect_i
, but the index appended tochanged_curves_indices
iscurve_selection_[select_i]
. So it's a different one.@ -0,0 +4,4 @@
#include "BKE_curves.hh"
namespace blender::geometry::curve_constraint_solver {
Suggestion:
curve_constraint_solver
->curve_constraint(s)
I'm guessing the current name is left over from when it was more object oriented
@ -0,0 +6,4 @@
#include "GEO_curve_constraint_solver.hh"
#include "BKE_bvhutils.h"
Should probably have the note about the coordinate spaces in this file too
@ -0,0 +140,4 @@
const float3 normalized_slide_direction_cu = math::normalize_and_get_length(
slide_direction_cu, slide_direction_length_cu);
/* Use pythagorian theory to determine how far to slide. */
theory
->theorem
?@ -456,0 +456,4 @@
prop = RNA_def_property(srna, "use_sculpt_collision", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CV_SCULPT_COLLISION_ENABLED);
RNA_def_property_ui_text(
prop, "Use Sculpt Collision", "Enable collision handling with the surface during sculpting");
Suggestion:
Enable collision with the surface while sculpting
This should get its own icon imho.
Reviewers