Mesh: Add three cached topology maps #107816

Merged
Hans Goudey merged 26 commits from HooglyBoogly/blender:mesh-cache-vert-to-poly-map into main 2023-08-30 23:42:08 +02:00
Member

Add three cached topology maps to Mesh, to avoid computations when
mesh data isn't changed. Choosing the right maps to cache is a bit
arbitrary, but generally we have to start somewhere. The limiting
factor is memory usage (all the new caches combined have about a
comparable footprint to a UV map).

For now, the caches added are:

  • Vertex to face corner
  • Vertex to face
  • Face corner to face

These caches are used in quite a few places already;

  • Face corner normal calculation
  • UV value merging
  • Setting sharp edges from face angles
  • Data transfer modifier
  • Voxel remesh attribute remapping
  • Sculpt mode painting
  • Sculpt mode normal calculation
  • Vertex paint mode
  • Splitting edges
  • Geometry nodes mesh topology nodes

For example, FPS with a large mesh using the "Corners of Vertex"
node went from 1.8 to 2.3. Entering sculpt mode is slightly faster too.

There is some obvious work for future commits:

  • Use caches in attribute domain interpolation
  • More multithreading of second phase of map building
  • Update/build caches eagerly in some geometry nodes
  • Avoid redundancy between vert to corner and vert to poly caches
Add three cached topology maps to `Mesh`, to avoid computations when mesh data isn't changed. Choosing the right maps to cache is a bit arbitrary, but generally we have to start somewhere. The limiting factor is memory usage (all the new caches combined have about a comparable footprint to a UV map). For now, the caches added are: - Vertex to face corner - Vertex to face - Face corner to face These caches are used in quite a few places already; - Face corner normal calculation - UV value merging - Setting sharp edges from face angles - Data transfer modifier - Voxel remesh attribute remapping - Sculpt mode painting - Sculpt mode normal calculation - Vertex paint mode - Splitting edges - Geometry nodes mesh topology nodes For example, FPS with a large mesh using the "Corners of Vertex" node went from 1.8 to 2.3. Entering sculpt mode is slightly faster too. There is some obvious work for future commits: - Use caches in attribute domain interpolation - More multithreading of second phase of map building - Update/build caches eagerly in some geometry nodes - Avoid redundancy between vert to corner and vert to poly caches
Hans Goudey added 9 commits 2023-05-10 18:58:03 +02:00
97918223d3 Mesh: Cache vertex to face topology map
This commit uses the `SharedCache` concept to keep a cached map from
mesh vertices to polygons available on a mesh as necessary. The map
is split into two caches internally, since the same offsets can be
reused for a potential vertex to face corner map in the future
(though that may be a bit preemptive).

Such a cache (or similar) is often used in topology-changing operations,
and in the future it can be updated as necessary. For now it's simply
calculated from scratch though, since it may take time to validate the
choice of cached map. For example, it could make sense to cache
a vertex to corner and a corner to face map instead.
buildbot/vexp-code-patch-coordinator Build done. Details
3c867cea7d
Cleanup
Hans Goudey added this to the Nodes & Physics project 2023-05-10 19:03:40 +02:00
Author
Member

@blender-bot build

@blender-bot build
Hans Goudey requested review from Jacques Lucke 2023-05-10 19:04:06 +02:00
Hans Goudey added 2 commits 2023-05-11 17:15:08 +02:00
Hans Goudey changed title from Mesh: Add three cached topology maps to WIP: Mesh: Add three cached topology maps 2023-05-11 21:10:08 +02:00
Author
Member

I'll actually reimplement the existing topology maps to make this diff clearer and smaller first.

I'll actually reimplement the existing topology maps to make this diff clearer and smaller first.
Hans Goudey added 4 commits 2023-05-24 19:57:30 +02:00
Hans Goudey added 1 commit 2023-06-07 16:32:36 +02:00
Hans Goudey added 2 commits 2023-07-03 14:22:09 +02:00
Hans Goudey added 1 commit 2023-07-03 15:30:21 +02:00
Hans Goudey added 1 commit 2023-08-29 05:16:17 +02:00
Hans Goudey added 4 commits 2023-08-30 16:25:19 +02:00
Hans Goudey changed title from WIP: Mesh: Add three cached topology maps to Mesh: Add three cached topology maps 2023-08-30 16:25:31 +02:00
Jacques Lucke approved these changes 2023-08-30 23:10:44 +02:00
Jacques Lucke left a comment
Member

Looks good to me, nice simplification.

Looks good to me, nice simplification.
@ -140,6 +140,17 @@ struct MeshRuntime {
SharedCache<Vector<float3>> vert_normals_cache;
SharedCache<Vector<float3>> face_normals_cache;
/**
Member

Unify the usage of the terms face and poly in the comments.

Unify the usage of the terms face and poly in the comments.
HooglyBoogly marked this conversation as resolved
Hans Goudey added 2 commits 2023-08-30 23:37:51 +02:00
Hans Goudey merged commit 4e94db97e2 into main 2023-08-30 23:42:08 +02:00
Hans Goudey deleted branch mesh-cache-vert-to-poly-map 2023-08-30 23:42:09 +02:00
Sign in to join this conversation.
No reviewers
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 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#107816
No description provided.