Unique Mesh IDs #89540
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#89540
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
Introduction
The number one source of bugs in the sculpt undo
code (as well as a major performance hit) was having to cache IDs in the undo stack
on exiting sculpt mode. This totally breaks if a memfile step is pushed while sculpt mode
is active (e.g. adding a modifier).
Why Its Needed - DynTopo
DynTopo's undo system (
BMLog
) assigns unique IDs to verts and faces. It does thisby maintaining a hash of element->ids and ids->elements. This has proven prone to
bugs and memory corruption.
Basic Design
IDs are stored in CustomData layers (
CD_MESH_ID
) marked withCD_FLAG_TEMPORARY
and a new flag I added--CD_FLAG_ELEM_NOCOPY
--to tell BMesh not to copy data (BMesh ignoresCD_FLAG_NOELEM
and changing that struck me as too big of a change).These ID layers are optional and can be restricted to certain element types. When creating or destroying
elements BMesh internally checks if a given layer is enabled and acts accordingly.
Elements share a common ID space and ids are reused. There is an optional id to element map;
if enabled, a simple lookup table from IDs to elements will be maintained. A simple lookup table
is possible because IDs are reused; if they were not we'd have to use a GHash.
Enabling IDs
BMeshCreateParams
has the follow new parameters:create_unique_ids
- create ID layersid_elem_mask
- Bitmask controlling which element types to create id layers forid_map
- Maintain an element to ID map.temporary_ids
- Mark id layers as temporaryBMeshToMeshParams
has these new parameters:ignore_mesh_id_layers
- Do not load id layers into Mesh.eBMCreateFlag
also has a new BM_CREATE_SKIP_ID flag for skipping ID assignment.How IDs Are Stored
IDs are stored in a new
CD_MESH_ID
customdata layer (which is just a copy ofCD_PROP_INT32
with modified copy/interpolation behavior).
In addition BMesh has the following new substructure:
The internal API for assigning IDs is:
Reuse or Not Reuse IDs?
The benefit of reusing IDs is that it lets us use a simple lookup table for the id-to-element map.
It does come at a cost however, as the following use cases are no longer possible:
You can't use IDs for simple history tracking. For example without ID reuse you can find all elements
IDs are no longer guaranteed to always belong to elements of one type (or nothing at all) after being
Update
CD_MESH_ID attribute layers are no longer flagged as temporary. So once they're created
(e.g. by the sculpt code) they stick around inside the mesh. Note that BMesh validates
the IDs when loading from Mesh (if the idmap is enabled when creating the bmesh).
ToDo
Added subscriber: @JosephEagar
Added subscriber: @GeorgiaPacific
Unique IDs For BMeshto Unique IDs For BMesh (and Mesh?)Unique IDs For BMesh (and Mesh?)to Unique Mesh IDsAdded subscriber: @lichtwerk
Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'
Not sure what the status should be here if it is "Under Discussion"?
Will set to
Needs Info from Developers
for now, feel free to set to anything butNeeds Triage
(since the triaging team cannot do much here afaict)