Fix #108105: Fix operators affecting hidden geometry #119168
No reviewers
Labels
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#119168
Loading…
Reference in New Issue
No description provided.
Delete Branch "Mangal-Kushwah/blender:operators-hidden-geometry"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem:
These operators in sculpt mode affect hidden geometry which is undesirable.
Solution:
This PR adds checks for hidden faces in these operators.
For operator
bpy.ops.sculpt.face_sets_init
it also modifies the way face sets indices were generated so generated indices is unique. This in needed so new initialized face sets do not get same indices as hidden face sets.For generating unique face set index i have created a set container which stores hidden face sets indices. Before assigning indices to a face set it checks if it is already in set container, if it is then it'll keep increasing index by 1 until it is not in set container.
Modifying Operator
bpy.ops.mesh.paint_mask_slice()
is little complex, it will not affect hidden geometry only when fill holes option is unchecked, because currently filling hole code does not take hidden geometry into account and because of this in some cases hidden part of geometry can be trapped inside mesh.WIP Fix #108105: Fix operators that affect hidden geometryto WIP: Fix #108105: Fix operators that affect hidden geometryWith this commit
bpy.ops.sculpt.face_sets_init
operations will not modify the hidden face sets, except Initialize Face Sets by Material.I'm confused for Face Sets by Materials would it be better if it can modify hidden geometry?
@HooglyBoogly @Sergey @JulienKaspar.
Not sure why material case is special here. From the perspective of operators not modifying invisible data, it will just initialize face sets based on material slots for the visible geometry.
They should just follow the operator "Modify Hidden" option. And if there is no such option for an operator, hidden geometry should generally not be modified.
WIP: Fix #108105: Fix operators that affect hidden geometryto Fix #108105: Fix operators that affect hidden geometryFix #108105: Fix operators that affect hidden geometryto Fix #108105: Fix operators affecting hidden geometryFix #108105: Fix operators affecting hidden geometryto WIP: Fix #108105: Fix operators affecting hidden geometryWIP: Fix #108105: Fix operators affecting hidden geometryto Fix #108105: Fix operators affecting hidden geometryJust some quick notes. Did not have time yet to verify the behavior on algorithmical level.
@ -246,1 +246,4 @@
BMIter face_iter;
if (BM_elem_flag_test_bool(f, BM_ELEM_HIDDEN)) {
keep_face = false;
BM_elem_flag_set(f, BM_ELEM_TAG, !keep_face);
This can just be
BM_elem_flag_set(f, BM_ELEM_TAG, true);
?Done
@ -418,6 +423,9 @@ static void slice_paint_mask(BMesh *bm, bool invert, bool fill_holes, float mask
break;
}
}
if (!fill_holes && BM_elem_flag_test_bool(f, BM_ELEM_HIDDEN)) {
Why is the visibility only checked when
!fill_holes
?Currently filling hole code does not take hidden geometry into account and because of this in some cases hidden part of geometry can be trapped inside mesh which i assumed is bad thing not entirely sure though.
Removed it
@ -421,2 +427,4 @@
keep_face = false;
};
if (invert) {
keep_face = !keep_face;
This
invert
behavior is a bit fragile, as it potentially marks faces which are hidden. From reading the code it is seems fine from the current usages of this function. However, it worth:Paint Mask Slice
with hidden faces behaves correctly.There might be some smarter and less error-prone we can do here, but I do not have quick concrete proposals.
Will look into it tomorrow
Added the comment about invert
@ -834,0 +862,4 @@
".hide_poly", bke::AttrDomain::Face, false);
const Array<int> prev_face_sets = duplicate_face_sets(*mesh);
Set<int> hidden_face_sets;
for (const int i : hide_poly.index_range()) {
Perhaps it will be more readable if the code is moved to
gather_hidden_face_sets
(or some similar name)? Currently the code seems to be duplicated between multiple operators.Ok, Should I make it static?
@Sergey I disabled visibility checks for fill holes because of this (check the video).
I have some question:
Is this a bad thing?
If yes, do you have any suggestions about how I should proceed?
Currently I'm thinking about modifying function responsible for filling holes so it takes hidden geometry into account.
It might be worth involving input from @DanielBystedt.
To me intuitively the algorithm should give the same exact results as if the hidden part of the mesh simply did not exist at the time when an operator runs, and was added later. Hope the analogy is clear :) But not sure if it has some negative implications.
What @Sergey describes would be ideal (i.e. Hidden part of mesh is not deleted during the operation). I have included a visual "step by step" that should clarify things.
Thanks for visual explanation✨, It is working exactly like that.
I have manually tested it so far everything is working as expected.
@ -735,0 +742,4 @@
".hide_poly", bke::AttrDomain::Face, false);
const Array<int> prev_face_sets = duplicate_face_sets(*mesh);
Set<int> hidden_face_sets = gather_hidden_face_sets(hide_poly, prev_face_sets);
It doesn't seem we use
prev_face_sets
for anything by calculating a set if face sets used by hidden faces. So I think there is a potential to optimize some things here, with an idea of making it sogather_hidden_face_sets
accesses face set attribute more directly. Perhaps something like this could work?@ -783,6 +804,18 @@ Array<int> duplicate_face_sets(const Mesh &mesh)
return face_sets;
}
Set<int> gather_hidden_face_sets(const VArray<bool> &hide_poly, const Span<int> prev_face_sets)
I would call it
face_sets
. The fact that caller might consider the span to be a "previously used face sets" does not really affect this function.On a code side it seems correct. But I'd like Hans to also have a look, and maybe help with double-checking that it works good (I didn't have time for that yet).
Checkout
From your project repository, check out a new branch and test the changes.