Invert Visible doesn't invert Face Sets properly in Sculpt Mode #120144

Closed
opened 2024-04-01 15:09:52 +02:00 by Tolkfan · 4 comments

System Information
Operating system: Windows 10
Graphics card: Nvidia

Blender Version
Broken: 4.1
Worked: 4.0

Short description of error

The Invert Visible operator in 4.1 doesn't invert Face Sets properly. I think the problem is that it's now inverting vertices instead of faces.

It's named Invert Visible in the Sculpt menu in both 4.0 and 4.1, but the operators are different. For 4.0 it's bpy.ops.sculpt.face_set_invert_visibility(), for 4.1 it's bpy.ops.paint.visibility_invert() and the old one is removed completely.

Exact steps for others to reproduce the error

  • subdivide the cube a few times
  • paint a few face sets
  • hide one of the face sets (H)
  • invert the visibility (Sculpt > Invert Visible)
**System Information** Operating system: Windows 10 Graphics card: Nvidia **Blender Version** Broken: 4.1 Worked: 4.0 **Short description of error** The `Invert Visible` operator in 4.1 doesn't invert Face Sets properly. I think the problem is that it's now inverting vertices instead of faces. <video src="/attachments/5c029453-84e7-4c53-a6a2-b4aed1741372" title="BlenderInvert.mp4" controls></video> It's named `Invert Visible` in the Sculpt menu in both 4.0 and 4.1, but the operators are different. For 4.0 it's `bpy.ops.sculpt.face_set_invert_visibility()`, for 4.1 it's `bpy.ops.paint.visibility_invert()` and the old one is removed completely. **Exact steps for others to reproduce the error** - subdivide the cube a few times - paint a few face sets - hide one of the face sets (H) - invert the visibility (Sculpt > Invert Visible)
Tolkfan added the
Severity
Normal
Type
Report
Status
Needs Triage
labels 2024-04-01 15:09:53 +02:00
Tolkfan changed title from Invert Visibility doesn't invert Face Sets properly in Sculpt Mode to Invert Visible doesn't invert Face Sets properly in Sculpt Mode 2024-04-01 15:11:40 +02:00
Iliya Katushenock added the
Interest
Sculpt, Paint & Texture
label 2024-04-01 15:11:44 +02:00
Member

Hi, thanks for the report. Can confirm

Hi, thanks for the report. Can confirm
Member

BTW, the old operator is replaced in 53418fc3a1
@HooglyBoogly ^

BTW, the old operator is replaced in 53418fc3a1e5579b989cd7830d82766c762493df @HooglyBoogly ^
Member

I think it's best to go with .hide_poly instead of hide_verts. corner vertices of hidden face sets are not 1/true/hidden (which is expected) so inverting them hides these corner vertices, that's why the small region of face sets is visible.

I think it's best to go with `.hide_poly` instead of `hide_verts`. corner vertices of hidden face sets are not `1/true/hidden` (which is expected) so inverting them hides these corner vertices, that's why the small region of face sets is visible.
Member

Should fix this:

diff --git a/source/blender/editors/sculpt_paint/paint_hide.cc b/source/blender/editors/sculpt_paint/paint_hide.cc
index 3b18edb19ac..699902dbe3f 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.cc
+++ b/source/blender/editors/sculpt_paint/paint_hide.cc
@@ -609,24 +609,27 @@ void PAINT_OT_hide_show_all(wmOperatorType *ot)

 static void invert_visibility_mesh(Object &object, const Span<PBVHNode *> nodes)
 {
+  PBVH &pbvh = *object.sculpt->pbvh;
   Mesh &mesh = *static_cast<Mesh *>(object.data);
   bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
-  bke::SpanAttributeWriter<bool> hide_vert = attributes.lookup_or_add_for_write_span<bool>(
-      ".hide_vert", bke::AttrDomain::Point);
+  bke::SpanAttributeWriter<bool> hide_poly = attributes.lookup_or_add_for_write_span<bool>(
+      ".hide_poly", bke::AttrDomain::Face);

   threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
     for (PBVHNode *node : nodes.slice(range)) {
-      undo::push_node(&object, node, undo::Type::HideVert);
-      for (const int vert : BKE_pbvh_node_get_unique_vert_indices(node)) {
-        hide_vert.span[vert] = !hide_vert.span[vert];
+      undo::push_node(&object, node, undo::Type::HideFace);
+      Vector<int> faces;
+      bke::pbvh::node_face_indices_calc_mesh(pbvh, *node, faces);
+      for (const int face : faces) {
+        hide_poly.span[face] = !hide_poly.span[face];
       }
       BKE_pbvh_node_mark_update_visibility(node);
-      bke::pbvh::node_update_visibility_mesh(hide_vert.span, *node);
+      //bke::pbvh::node_update_visibility_mesh(hide_poly.span, *node);
     }
   });

-  hide_vert.finish();
-  bke::mesh_hide_vert_flush(mesh);
+  hide_poly.finish();
+  bke::mesh_hide_face_flush(mesh);
Should fix this: ``` diff --git a/source/blender/editors/sculpt_paint/paint_hide.cc b/source/blender/editors/sculpt_paint/paint_hide.cc index 3b18edb19ac..699902dbe3f 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.cc +++ b/source/blender/editors/sculpt_paint/paint_hide.cc @@ -609,24 +609,27 @@ void PAINT_OT_hide_show_all(wmOperatorType *ot) static void invert_visibility_mesh(Object &object, const Span<PBVHNode *> nodes) { + PBVH &pbvh = *object.sculpt->pbvh; Mesh &mesh = *static_cast<Mesh *>(object.data); bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); - bke::SpanAttributeWriter<bool> hide_vert = attributes.lookup_or_add_for_write_span<bool>( - ".hide_vert", bke::AttrDomain::Point); + bke::SpanAttributeWriter<bool> hide_poly = attributes.lookup_or_add_for_write_span<bool>( + ".hide_poly", bke::AttrDomain::Face); threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) { for (PBVHNode *node : nodes.slice(range)) { - undo::push_node(&object, node, undo::Type::HideVert); - for (const int vert : BKE_pbvh_node_get_unique_vert_indices(node)) { - hide_vert.span[vert] = !hide_vert.span[vert]; + undo::push_node(&object, node, undo::Type::HideFace); + Vector<int> faces; + bke::pbvh::node_face_indices_calc_mesh(pbvh, *node, faces); + for (const int face : faces) { + hide_poly.span[face] = !hide_poly.span[face]; } BKE_pbvh_node_mark_update_visibility(node); - bke::pbvh::node_update_visibility_mesh(hide_vert.span, *node); + //bke::pbvh::node_update_visibility_mesh(hide_poly.span, *node); } }); - hide_vert.finish(); - bke::mesh_hide_vert_flush(mesh); + hide_poly.finish(); + bke::mesh_hide_face_flush(mesh); ```
Pratik Borhade self-assigned this 2024-04-02 08:30:22 +02:00
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-04-09 12:52:25 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
2 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#120144
No description provided.