PBVH: update mesh data pointers stored in pbvh #106271

Merged
Jacques Lucke merged 11 commits from JacquesLucke/blender:pbvh-update-pointers into main 2023-04-08 13:29:49 +02:00
Member

This is necessary for #106228. Without this, PBVH might contain pointers to data that either does not exist anymore or that must not be edited (because it is shared).

The file below shows a simple way to reproduce the issue. When only #106228 is applied, weight painting does not work correctly and also crashes in an ASAN build.

ASAN report: https://hastebin.com/share/goziwepawi.yaml

This is necessary for #106228. Without this, `PBVH` might contain pointers to data that either does not exist anymore or that must not be edited (because it is shared). The file below shows a simple way to reproduce the issue. When only #106228 is applied, weight painting does not work correctly and also crashes in an ASAN build. ASAN report: https://hastebin.com/share/goziwepawi.yaml
Jacques Lucke added 5 commits 2023-03-29 18:37:10 +02:00
Jacques Lucke added 2 commits 2023-04-07 13:05:22 +02:00
Jacques Lucke added 1 commit 2023-04-07 13:15:08 +02:00
Jacques Lucke added 1 commit 2023-04-07 13:17:49 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
0feb21e8df
cleanup
Jacques Lucke changed title from WIP: Sculpt: update mesh data pointers stored in pbvh to PBVH: update mesh data pointers stored in pbvh 2023-04-07 13:22:57 +02:00
Author
Member

@blender-bot build

@blender-bot build
Jacques Lucke requested review from Hans Goudey 2023-04-07 13:23:59 +02:00
Jacques Lucke requested review from Joseph Eagar 2023-04-07 13:24:35 +02:00
Hans Goudey approved these changes 2023-04-07 23:03:17 +02:00
Hans Goudey left a comment
Member

I left some comments about potential improvements inline, but on the whole I think this makes sense as one step on a path to a saner ownership model here. It looks good to me.

I left some comments about potential improvements inline, but on the whole I think this makes sense as one step on a path to a saner ownership model here. It looks good to me.
@ -2204,3 +2183,4 @@
BKE_pbvh_build_mesh(pbvh, me);
const bool is_deformed = check_sculpt_object_deformed(ob, true);
if (is_deformed && me_eval_deform != nullptr) {
Member

I wonder if it would make sense to check this before BKE_pbvh_build_mesh and give BKE_pbvh_build_mesh an optional argument for positions not owned by the mesh. That would go a long way to help clarify whether PBVH should reuse the arrays for the mesh's looptris and normals too, which is the biggest remaining pain point in this area IMO.

Something similar would apply to sculpt_update_object, where the chunks of code currently calling BKE_pbvh_vert_coords_apply could be moved to happen before BKE_sculpt_object_pbvh_ensure (which would also get a new non-mesh positions argument).

Not sure if you'd consider this related (feel free to disregard it). If not, I'll probably look into this in the near future.

I wonder if it would make sense to check this before `BKE_pbvh_build_mesh` and give `BKE_pbvh_build_mesh` an optional argument for positions not owned by the mesh. That would go a long way to help clarify whether `PBVH` should reuse the arrays for the mesh's looptris and normals too, which is the biggest remaining pain point in this area IMO. Something similar would apply to `sculpt_update_object`, where the chunks of code currently calling `BKE_pbvh_vert_coords_apply` could be moved to happen before `BKE_sculpt_object_pbvh_ensure` (which would also get a new non-mesh positions argument). Not sure if you'd consider this related (feel free to disregard it). If not, I'll probably look into this in the near future.
@ -840,0 +834,4 @@
pbvh->polys = mesh->polys();
pbvh->corner_verts = mesh->corner_verts().data();
if (!pbvh->deformed) {
/* If it was deformed, a new array is allocated. */
Member

This comment is a bit confusing. I think a more correct phrasing would be Deformed positions not matching the original mesh are owned directly by the PBVH, and are set separately by #BKE_pbvh_vert_coords_apply (though I do suggest tweaking that a bit below).

This comment is a bit confusing. I think a more correct phrasing would be `Deformed positions not matching the original mesh are owned directly by the PBVH, and are set separately by #BKE_pbvh_vert_coords_apply` (though I do suggest tweaking that a bit below).
JacquesLucke marked this conversation as resolved
Jacques Lucke reviewed 2023-04-08 12:48:53 +02:00
@ -2204,3 +2183,4 @@
BKE_pbvh_build_mesh(pbvh, me);
const bool is_deformed = check_sculpt_object_deformed(ob, true);
if (is_deformed && me_eval_deform != nullptr) {
Author
Member

Yeah that would probably improve the code even more, but won't integrate it into this patch.

Yeah that would probably improve the code even more, but won't integrate it into this patch.
Jacques Lucke added 2 commits 2023-04-08 12:49:12 +02:00
Jacques Lucke merged commit cde565c26c into main 2023-04-08 13:29:49 +02:00
Jacques Lucke deleted branch pbvh-update-pointers 2023-04-08 13:29:50 +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 project
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#106271
No description provided.