Mesh: Move face shade smooth flag to a generic attribute #104422

Merged
Hans Goudey merged 59 commits from refactor-mesh-sharp-face-generic into main 2023-03-08 15:36:28 +01:00
Member

Currently the shade smooth status for mesh faces is stored as part of
MPoly::flag. As described in #95967, this moves that information
to a separate boolean attribute. It also flips its status, so the
attribute is now called sharp_face, which mirrors the existing
sharp_edge attribute. The attribute doesn't need to be allocated
when all faces are smooth.Forward compatibility will be kept until 4.0
like the other mesh refactors.

This will reduce memory bandwidth requirements for some operations,
since the array of booleans uses 12 times less memory than MPoly.
It also allows faces to be stored with less memory, since the flag
is now unused. It's also possible to use generic functions to process
the values. For example, finding whether there is a sharp faces is just
sharp_faces.contains(true).

The shade_smooth attribute is no longer accessible with geometry nodes.
Since there were dedicated accessor nodes for that data, that shouldn't
be a problem. That's difficult to version automatically since the named
attribute nodes could be used in arbitrary combinations.

Implementation notes:

  • The attribute and array variables in the code use the sharp_faces
    term, to be consistent with the user-facing "sharp faces" wording,
    and to avoid requiring many renames when #101689 is implemented.
  • Cycles now accesses smooth face status with the generic attribute,
    to avoid overhead.
  • Changing the zero-value from "smooth" to "flat" takes some care to
    make sure defaults are the same.
    • Versioning for the edge mode extrude node is particularly complex.
      New nodes are added by versioning to propagate the attribute in its
      old inverted state.
  • A lot of access is still done through the CustomData API rather
    than the attribute API because of a few functions. That can be
    cleaned up easily in the future.
  • In the future we would benefit from a way to store attributes as a
    single value for when all faces are sharp.
Currently the shade smooth status for mesh faces is stored as part of `MPoly::flag`. As described in #95967, this moves that information to a separate boolean attribute. It also flips its status, so the attribute is now called `sharp_face`, which mirrors the existing `sharp_edge` attribute. The attribute doesn't need to be allocated when all faces are smooth.Forward compatibility will be kept until 4.0 like the other mesh refactors. This will reduce memory bandwidth requirements for some operations, since the array of booleans uses 12 times less memory than `MPoly`. It also allows faces to be stored with less memory, since the flag is now unused. It's also possible to use generic functions to process the values. For example, finding whether there is a sharp faces is just `sharp_faces.contains(true)`. The `shade_smooth` attribute is no longer accessible with geometry nodes. Since there were dedicated accessor nodes for that data, that shouldn't be a problem. That's difficult to version automatically since the named attribute nodes could be used in arbitrary combinations. **Implementation notes:** - The attribute and array variables in the code use the `sharp_faces` term, to be consistent with the user-facing "sharp faces" wording, and to avoid requiring many renames when #101689 is implemented. - Cycles now accesses smooth face status with the generic attribute, to avoid overhead. - Changing the zero-value from "smooth" to "flat" takes some care to make sure defaults are the same. - Versioning for the edge mode extrude node is particularly complex. New nodes are added by versioning to propagate the attribute in its old inverted state. - A lot of access is still done through the `CustomData` API rather than the attribute API because of a few functions. That can be cleaned up easily in the future. - In the future we would benefit from a way to store attributes as a single value for when all faces are sharp.
Hans Goudey added 34 commits 2023-02-07 19:31:23 +01:00
Hans Goudey requested review from Jacques Lucke 2023-02-07 20:57:25 +01:00
Hans Goudey requested review from Campbell Barton 2023-02-07 20:57:34 +01:00
Hans Goudey added 1 commit 2023-02-07 22:05:02 +01:00
Hans Goudey added 1 commit 2023-02-09 22:56:01 +01:00
Hans Goudey added 21 commits 2023-02-10 19:59:20 +01:00
2ee9c12a23 PyAPI: add bpy.utils.manual_locale_code()
Move the function for getting the language code associated with the
user manual into a utility function (from the generated
rna_manual_reference.py).

This allows other parts of Blender to create a manual URL based on the
current locale preferences and environment.

Ref !104494
8ac3096e24 Fix add-on & manual link in Help menu ignoring the current language
Use bpy.utils.manual_language_code() create manual URL's instead of
assuming English.
48d9363fa7 Cleanup: quiet clang compiler warnings
- undeclared variable warning.
- unreachable-code-return warnings.
- array-parameter, mismatch bound.
- 'requires' is a keyword in C++20, (rename to requires_flag).
buildbot/vdev-code-daily-coordinator Build done. Details
4cbe0bff34
Cleanup: spelling in comments
a8d951abdd Docs: remove malformed patterns for RNA mapping
The generator now skips these with a warning, they will need to be
corrected in the user manual.

This caused tests/python/bl_rna_manual_reference.py to fail looking
up URL's.
buildbot/vdev-code-daily-coordinator Build done. Details
c2c62c3618
RNA: return a dummy language value when WITH_INTERNATIONAL=OFF
Without this, every access to "language" would warn that the enum
value didn't match a value in the enum items.

This made the bl_rna_manual_reference.py test output practically
unusable.
buildbot/vdev-code-daily-coordinator Build done. Details
b77c82e2bb
Tests: minor updates to make bl_rna_manual_reference more useful
- Avoid flooding the output with every match that succeeds.
- Report patterns listed in the manual that don't match anything in
  Blender.
- Disable external URL lookups, this is too slow.
  Instead use a LOCAL_PREFIX (a local build of the manual)
  or skip the test.
buildbot/vdev-code-daily-coordinator Build done. Details
01480229b1
Cycles: Fix MetalRT checkbox not hooked up to device on AMD
(Follow on from D17043)
On AMD Navi2 devices the MetalRT checkbox was not hooked up properly and had no effect. This patch fixes it.

Co-authored-by: Michael Jones <michael_p_jones@apple.com>
Pull Request #104520
buildbot/vdev-code-daily-coordinator Build done. Details
51ceeb506f
Fix #104026: Click-Drag to select graph editor channels no longer working
Box-Selecting channels in the dope sheet with click-drag was no longer possible as of Blender 3.2

Due to the removal of tweak events the box select operator was always shadowed by the click operator.

Original Phabricator discussion here: https://archive.blender.org/developer/D17065

Use `WM_operator_flag_only_pass_through_on_press` on click operator to fix it

Co-authored-by: Christoph Lendenfeld <chris.lenden@gmail.com>
Pull Request #104505
buildbot/vdev-code-daily-coordinator Build done. Details
5d30c3994e
Sequencer: Don't create undo step when click-select does nothing
When the sequencer is empty (i.e., there are no sequences),
we would have the deselect_all variable set to true called
ED_sequencer_deselect_all to select any existing sequences.

Ref !104453
buildbot/vdev-code-daily-coordinator Build done. Details
dc9f7fe64f
Fix #104514: GPencil merge down layer misses some frames
When merging two gpencil layers, if the destination layer had a keyframe
where the source layer did not, strokes of the previous keyframe
in source layer were lost in that frame.

This happened because the merge operator was looping through
frames of the source layer and appending strokes in the
corresponding destination layer, but never completing
other frames than the ones existing in the source layer.

This patch fixes it by first adding in source layer
all frames that are in destination layer.

Co-authored-by: Amelie Fondevilla <amelie.fondevilla@les-fees-speciales.coop>
Pull Request #104558
buildbot/vdev-code-daily-coordinator Build done. Details
88f9c55f7f
Sculpt: Fix Dyntopo Warnings
Because of T95965, some attributes are stored as generic attributes
in Mesh but have special handling for the conversion to BMesh.

Expose a function to tell whether certain attribute names are handled
specially in the conversion, and refactor the error checking process
to use it. Also check for generic attributes on the face domain which
wasn't done before.

Author: Hans Goudey
Reviewed By: Joseph Eagar

Co-authored-by: Joseph Eagar <joeedh@gmail.com>
Pull Request #104567
buildbot/vdev-code-daily-coordinator Build done. Details
bad2c3b9ef
Geometry Nodes: Experimental option for Volumes
Adds an experimental option under "New Features" in preferences,
which enables visibility of the new Volume Nodes.
Right now this option does nothing but will be used during development.
See #103248

Pull Request #104552
buildbot/vdev-code-daily-coordinator Build done. Details
284cdbb6cf
Cleanup: Use lambdas in mesh mapping callback, remove unused arguments
Using callback functions didn't scale well as more arguments are added.
It got very confusing when to pass tehmarguments weren't always used.
Instead use a `FunctionRef` with indices for arguments. Also remove
unused edge arguments to topology mapping functions.
buildbot/vdev-code-daily-coordinator Build done. Details
0ea15a6fbb
Fix: Inaccessible default for node group image sockets
The type was just skipped when drawing defaults for the image sockets.
923152d180 Geometry Nodes: improve parallelization in Delete/Separate Geometry node
This just adds `threading::parallel_for` and `threading::parallel_invoke` in a few
places where it can be added trivially. The run time of the `separate_geometry`
function changes from 830 ms to 413 ms in my test file.

Pull Request #104563
buildbot/vdev-code-daily-coordinator Build done. Details
fae661a1ab
Revert "Un-ignore modules in .gitmodules configuration"
This reverts commit aab707ab70.

A different solution to the submodule problem is being considered in #104573.
Revert to the previous behavior that developers are familiar with for now.
Hans Goudey added 1 commit 2023-02-13 04:32:41 +01:00
Brecht Van Lommel added this to the Modeling project 2023-02-13 09:20:25 +01:00
Hans Goudey added 1 commit 2023-02-14 05:24:51 +01:00
Hans Goudey added 1 commit 2023-02-16 03:54:52 +01:00
Hans Goudey added 1 commit 2023-02-16 23:57:44 +01:00
Hans Goudey added 1 commit 2023-02-18 16:55:37 +01:00
Hans Goudey added 1 commit 2023-02-20 21:41:07 +01:00
Hans Goudey added this to the 3.6 LTS milestone 2023-02-21 15:28:08 +01:00
Hans Goudey added 2 commits 2023-02-22 14:12:45 +01:00
Hans Goudey added 1 commit 2023-02-23 17:26:27 +01:00
Hans Goudey added 1 commit 2023-02-23 19:25:46 +01:00
Hans Goudey added 1 commit 2023-02-27 21:41:18 +01:00
Hans Goudey added 1 commit 2023-02-28 19:10:08 +01:00
Hans Goudey added 1 commit 2023-02-28 23:48:34 +01:00
Campbell Barton approved these changes 2023-03-01 04:48:40 +01:00
Hans Goudey added 1 commit 2023-03-01 14:47:31 +01:00
Hans Goudey added 1 commit 2023-03-02 21:30:42 +01:00
Hans Goudey added 1 commit 2023-03-03 17:48:19 +01:00
Hans Goudey added 1 commit 2023-03-06 18:47:34 +01:00
Member

@blender-bot build

@blender-bot build
Jacques Lucke requested changes 2023-03-08 12:38:31 +01:00
Jacques Lucke left a comment
Member

Please double check why one of the tests is failing.

Please double check why one of the tests is failing.
@ -939,6 +940,134 @@ static void version_geometry_nodes_primitive_uv_maps(bNodeTree &ntree)
}
}
static void version_geometry_nodes_extrude_smooth_propagation(bNodeTree &ntree)
Member

This could use a comment about what it is doing at a high level.
Do we have a regression test for this case to see if this code actually helps?

This could use a comment about what it is doing at a high level. Do we have a regression test for this case to see if this code actually helps?
Author
Member

Yes, two or three of the extrude node tests require this. I added a comment.

Yes, two or three of the extrude node tests require this. I added a comment.
HooglyBoogly marked this conversation as resolved
Hans Goudey added 3 commits 2023-03-08 14:26:31 +01:00
Author
Member

The PLY tests were randomly failing in main for a while, which was fixed recently. But I found that the default sharp face value should probably be different too.

The PLY tests were randomly failing in `main` for a while, which was fixed recently. But I found that the default sharp face value should probably be different too.
Member

@blender-bot build

@blender-bot build
Jacques Lucke approved these changes 2023-03-08 15:00:47 +01:00
Hans Goudey merged commit 5876573e14 into main 2023-03-08 15:36:28 +01:00
Hans Goudey deleted branch refactor-mesh-sharp-face-generic 2023-03-08 15:36:29 +01: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
3 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#104422
No description provided.