Mesh: Remove unnecessary edge draw flag #104417

Merged
Hans Goudey merged 7 commits from HooglyBoogly/blender:refactor-mesh-edge-draw-flag-remove into main 2023-02-09 15:56:07 +01:00
Member

As described in #95966, replace the ME_EDGEDRAW flag with a bit vector
in mesh runtime data. Currently the the flag is only ever set to false for the
"optimal display" feature of the subdivision surface modifier. When creating
an "original" mesh in the main data-base, the flag is always supposed to be true.

The bit vector is now created by the modifier only as necessary, and is cleared
for topology-changing operations. This fixes incorrect interpolation of the flag
as noted in #104376. Generally it isn't possible to interpolate it through
topology-changing operations.

After this, only the seam status needs to be removed from edges before we
can replace them with the generic int2 type (or something similar) and
reduce memory usage by 1/3.

Related:

In the future BM_ELEM_DRAW could be removed as well. Currently
it is used and aliased by other defines in some non-obvious ways though.

As described in #95966, replace the `ME_EDGEDRAW` flag with a bit vector in mesh runtime data. Currently the the flag is only ever set to false for the "optimal display" feature of the subdivision surface modifier. When creating an "original" mesh in the main data-base, the flag is always supposed to be true. The bit vector is now created by the modifier only as necessary, and is cleared for topology-changing operations. This fixes incorrect interpolation of the flag as noted in #104376. Generally it isn't possible to interpolate it through topology-changing operations. After this, only the seam status needs to be removed from edges before we can replace them with the generic `int2` type (or something similar) and reduce memory usage by 1/3. Related: - 10131a6f6238e259ce673249 - 145839aa42f775f161f5c6a0 In the future `BM_ELEM_DRAW` could be removed as well. Currently it is used and aliased by other defines in some non-obvious ways though.
Hans Goudey added 2 commits 2023-02-07 18:45:28 +01:00
Hans Goudey requested review from Philipp Oeser 2023-02-07 18:46:21 +01:00
Hans Goudey requested review from Campbell Barton 2023-02-07 18:49:39 +01:00

Works well, my only concern is that none of these assignments are re-using existing memory where flags have existing values, where edge.flag = ME_EDGEDRAW; should be replaced by edge.flag = 0; however as far as I can see this is not the case.

Works well, my only concern is that none of these assignments are re-using existing memory where flags have existing values, where `edge.flag = ME_EDGEDRAW;` should be replaced by `edge.flag = 0;` however as far as I can see this is not the case.
Campbell Barton approved these changes 2023-02-08 10:59:47 +01:00
Hans Goudey requested review from Jeroen Bakker 2023-02-08 14:47:19 +01:00
Author
Member

Good point, I'll look through the patch to make sure it's okay in that respect. For newly allocated meshes, edges are allocated with CD_SET_DEFAULT, which means the flag is already zeroed and doesn't have to be manually zeroed (this affects the primitive nodes, for example).

Good point, I'll look through the patch to make sure it's okay in that respect. For newly allocated meshes, edges are allocated with `CD_SET_DEFAULT`, which means the flag is already zeroed and doesn't have to be manually zeroed (this affects the primitive nodes, for example).
Hans Goudey added 2 commits 2023-02-09 04:04:13 +01:00
Jeroen Bakker approved these changes 2023-02-09 09:54:55 +01:00
Jeroen Bakker left a comment
Member

Just some code-readability tweaks.

Just some code-readability tweaks.
@ -122,3 +122,3 @@
BLI_edgehashIterator_setValue(ehi, POINTER_FROM_UINT(e_index));
medge->flag = ME_EDGEDRAW;
medge->flag = 0;
Member

Just pattern checking. In other places you remove the assignment of flag, but here it is explicitly unset.

Just pattern checking. In other places you remove the assignment of flag, but here it is explicitly unset.
Author
Member

Yes, here I'm not totally sure that the new edges are initialized so it should be cleared to be sure.

Yes, here I'm not totally sure that the new edges are initialized so it should be cleared to be sure.
@ -125,3 +125,3 @@
const char hflag = e->head.hflag;
return ((hflag & BM_ELEM_SEAM) ? ME_SEAM : 0) | ((hflag & BM_ELEM_DRAW) ? ME_EDGEDRAW : 0);
return ((hflag & BM_ELEM_SEAM) ? ME_SEAM : 0);
Member

Outer level of () can be removed.

Outer level of () can be removed.
Philipp Oeser refused to review 2023-02-09 10:03:29 +01:00
Hans Goudey added 2 commits 2023-02-09 15:48:03 +01:00
Hans Goudey added 1 commit 2023-02-09 15:55:00 +01:00
Hans Goudey merged commit 7ca651d182 into main 2023-02-09 15:56:07 +01:00
Hans Goudey deleted branch refactor-mesh-edge-draw-flag-remove 2023-02-09 15:56:07 +01: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
FBX
Interest
Freestyle
Interest
Geometry Nodes
Interest
glTF
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 & 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
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & 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
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#104417
No description provided.