Mesh: Move edges to a generic attribute #106638

Merged
Hans Goudey merged 23 commits from HooglyBoogly/blender:refactor-mesh-edges-generic into main 2023-04-17 13:47:54 +02:00
Member

Implements #95966, as the final step of #95965.

This commit changes the storage of mesh edge vertex indices from the
MEdge type to a new generic int2 attribute type. This follows the
general design for geometry and the attribute system, where the data
storage type and the usage semantics are separated.

The main benefit of the change is reduced memory usage-- the
requirements of storing mesh edges is reduced by 1/3. For example,
this saves 8MB on a 1 million vertex grid. This also gives performance
benefits to any memory bound mesh processing algorithm that uses edges.

Another smaller benefit is that all of the edge's vertex indices are
contiguous. In a few cases, it's helpful to process all of them as
Span<int> rather than Span<int2>. Similarly, the type is more
likely to match a generic format used by a library, or code that
shouldn't know about specific Blender Mesh types.

Various Notes:

  • The .edge_verts name is used to reflect a mapping between domains,
    similar to .corner_verts, etc. The period means that it the data
    shouldn't change arbitrarily by the user or procedural operations.
  • edge[0] is now used instead of edge.v1
  • The spreadsheet and RNA API are implemeneted for new attribute type
  • Signed integers are used instead of unsigned to reduce the mixing
    of signed-ness, which can be error prone.
  • All of the previously used core mesh data types (MVert, MEdge,
    MLoop, MPoly are now deprecated. Only generic types are used).
  • The vec2i DNA type is used in the few C files where necessary.
Implements #95966, as the final step of #95965. This commit changes the storage of mesh edge vertex indices from the `MEdge` type to a new generic `int2` attribute type. This follows the general design for geometry and the attribute system, where the data storage type and the usage semantics are separated. The main benefit of the change is reduced memory usage-- the requirements of storing mesh edges is reduced by 1/3. For example, this saves 8MB on a 1 million vertex grid. This also gives performance benefits to any memory bound mesh processing algorithm that uses edges. Another smaller benefit is that all of the edge's vertex indices are contiguous. In a few cases, it's helpful to process all of them as `Span<int>` rather than `Span<int2>`. Similarly, the type is more likely to match a generic format used by a library, or code that shouldn't know about specific Blender `Mesh` types. Various Notes: - The `.edge_verts` name is used to reflect a mapping between domains, similar to `.corner_verts`, etc. The period means that it the data shouldn't change arbitrarily by the user or procedural operations. - `edge[0]` is now used instead of `edge.v1` - The spreadsheet and RNA API are implemeneted for new attribute type - Signed integers are used instead of unsigned to reduce the mixing of signed-ness, which can be error prone. - All of the previously used core mesh data types (`MVert`, `MEdge`, `MLoop`, `MPoly` are now deprecated. Only generic types are used). - The `vec2i` DNA type is used in the few C files where necessary.
Hans Goudey added 11 commits 2023-04-06 19:50:17 +02:00
Author
Member

@blender-bot build

@blender-bot build
Hans Goudey added 1 commit 2023-04-06 21:56:45 +02:00
Merge branch 'main' into refactor-mesh-edges-generic
All checks were successful
buildbot/vexp-code-patch-coordinator Build done.
57aff2a6a0
Author
Member

@blender-bot build windows

@blender-bot build windows
Hans Goudey added this to the Module: Modeling project 2023-04-06 23:52:27 +02:00
Hans Goudey added this to the 3.6 LTS milestone 2023-04-06 23:53:08 +02:00
Hans Goudey requested review from Campbell Barton 2023-04-06 23:55:49 +02:00
Hans Goudey requested review from Jacques Lucke 2023-04-06 23:55:50 +02:00
Member
  • I get a crash in the duplicate_elements_mesh_edges.blend test in a debug build.
  • Might be nice to commit the new CD_PROP_INT2 separately. Although we have to be a bit careful with the naming and might have to adjust some names (currently it looks like it's using the same name pattern that's used by CD_PROP_INT8 or CD_PROP_INT32, but it is not). Maybe something like CD_PROP_INT32_2D could work? Same thing in eSpreadsheetColumnValueType.
  • Can MEdge also be put into DNA_DEPRECATED_ALLOW?

I might be second-guessing what I told you about using int2 everywhere. It's mostly fine but it does seem like it's reducing code readibility in a few places. I think storing it as int2 is still perfectly reasonable, but maybe it would be could to have another term for working with it... Something like struct EdgeVerts { int a, b; }. I'm not entirely convinced by either approach yet.

* [x] I get a crash in the `duplicate_elements_mesh_edges.blend` test in a debug build. * [x] Might be nice to commit the new `CD_PROP_INT2` separately. Although we have to be a bit careful with the naming and might have to adjust some names (currently it looks like it's using the same name pattern that's used by `CD_PROP_INT8` or `CD_PROP_INT32`, but it is not). Maybe something like `CD_PROP_INT32_2D` could work? Same thing in `eSpreadsheetColumnValueType`. * [x] Can `MEdge` also be put into `DNA_DEPRECATED_ALLOW`? I might be second-guessing what I told you about using `int2` everywhere. It's mostly fine but it does seem like it's reducing code readibility in a few places. I think storing it as `int2` is still perfectly reasonable, but maybe it would be could to have another term for working with it... Something like `struct EdgeVerts { int a, b; }`. I'm not entirely convinced by either approach yet.
Hans Goudey added 3 commits 2023-04-07 14:22:18 +02:00
Author
Member

I do like the approach of using int2 directly when working with edges actually. In practice, the change is mostly using [0] and [1] instead of .v1 and .v2. It also places a bit more importance on variable names, but that's good anyway IMO. It helps to make the data-oriented design clear, and there are some benefits from using a VecBase type as well.

I do like the approach of using `int2` directly when working with edges actually. In practice, the change is mostly using `[0]` and `[1]` instead of `.v1` and `.v2`. It also places a bit more importance on variable names, but that's good anyway IMO. It helps to make the data-oriented design clear, and there are some benefits from using a `VecBase` type as well.
Hans Goudey added 4 commits 2023-04-14 18:10:40 +02:00
Hans Goudey added 1 commit 2023-04-16 22:03:11 +02:00

There is a crash loading from an auto-saved file (MEdge is NULL when loading /tmp/quit.blend for e.g.).

Otherwise this works well in my tests (accepting, no need for an extra review iteration).

There is a crash loading from an auto-saved file (`MEdge` is NULL when loading `/tmp/quit.blend` for e.g.). Otherwise this works well in my tests (accepting, no need for an extra review iteration).
Campbell Barton approved these changes 2023-04-17 09:39:59 +02:00
Jacques Lucke approved these changes 2023-04-17 11:14:03 +02:00
Hans Goudey added 3 commits 2023-04-17 13:35:42 +02:00
Hans Goudey merged commit 2a4323c2f5 into main 2023-04-17 13:47:54 +02:00
Hans Goudey deleted branch refactor-mesh-edges-generic 2023-04-17 13:47:55 +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
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 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#106638
No description provided.