Refactor: Sculpt: Change PBVH and PBVHNode to public classes #124919

Merged
Hans Goudey merged 6 commits from HooglyBoogly/blender:pbvh-public into main 2024-07-23 22:31:45 +02:00
Member

Part of #118145.

These days we aren't really benefiting from making PBVH an opaque type.
As we remove its responsibilities to focus it on being a BVH tree and look
to improve performance with data-oriented design, that will only become
more true.

There are some other future developments the current header structure
makes difficult:

  • Storing selections of nodes with IndexMask for simpler iteration, etc.
  • Specialization of node type for each PBVH type
  • Reducing overhead of access to node data as nodes get smaller
  • General C++ cleanliness and consistency

This PR moves PBVH to blender::bke::pbvh::Tree and moves PBVHNode
to blender::bke::pbvh::Node. Both are classes visible to elsewhere in Blender
but with private data fields.

The difficult part about the change is that we're in the middle of a transition
removing data from PBVH. Rather than making some data truly private I
chose to just give it the _ suffix, since it will ideally be removed later.
Other things should be class methods or implemented as part of friend
classes. But the "fake" private status is much simpler for now and avoids
increasing the scope of this PR too much. Though that's a bit ugly, there's a
straightforward way to resolve these issues-- it just looks like the sort of
inconsistency you'd expect in the middle of a large refactor.

Part of #118145. These days we aren't really benefiting from making PBVH an opaque type. As we remove its responsibilities to focus it on being a BVH tree and look to improve performance with data-oriented design, that will only become more true. There are some other future developments the current header structure makes difficult: - Storing selections of nodes with `IndexMask` for simpler iteration, etc. - Specialization of node type for each PBVH type - Reducing overhead of access to node data as nodes get smaller - General C++ cleanliness and consistency This PR moves `PBVH` to `blender::bke::pbvh::Tree` and moves `PBVHNode` to `blender::bke::pbvh::Node`. Both are classes visible to elsewhere in Blender but with private data fields. The difficult part about the change is that we're in the middle of a transition removing data from PBVH. Rather than making some data truly private I chose to just give it the `_` suffix, since it will ideally be removed later. Other things should be class methods or implemented as part of friend classes. But the "fake" private status is much simpler for now and avoids increasing the scope of this PR too much. Though that's a bit ugly, there's a straightforward way to resolve these issues-- it just looks like the sort of inconsistency you'd expect in the middle of a large refactor.
Hans Goudey added 1 commit 2024-07-17 20:33:25 +02:00
Hans Goudey added 2 commits 2024-07-17 21:13:08 +02:00
Fix initialization
Some checks failed
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
2bf61433dc
Hans Goudey changed title from WIP: Refactor: Sculpt: Change PBVH and PBVHNode to public classes to Refactor: Sculpt: Change PBVH and PBVHNode to public classes 2024-07-17 21:13:42 +02:00
Hans Goudey requested review from Sergey Sharybin 2024-07-17 21:13:56 +02:00
Hans Goudey requested review from Sean Kim 2024-07-17 21:13:57 +02:00
Author
Member

@blender-bot build

@blender-bot build
Hans Goudey added 1 commit 2024-07-17 21:22:59 +02:00
Formattting
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
c082c21190
Sean Kim approved these changes 2024-07-18 01:01:29 +02:00
Sean Kim left a comment
Member

Only minor comments from me. Much of the stuff outside the blenkernel directory I skimmed.

The only overall naming little nit I have is the change for function parameters from PBVH& pbvh to Tree& pbvh. I suppose it makes more sense and is less opaque, especially in the context of the full namespace, but it does read slightly odd to me.

Only minor comments from me. Much of the stuff outside the `blenkernel` directory I skimmed. The only overall naming little nit I have is the change for function parameters from `PBVH& pbvh` to `Tree& pbvh`. I suppose it makes more sense and is less opaque, especially in the context of the full namespace, but it does read slightly odd to me.
@ -82,0 +240,4 @@
public:
Tree(const Type type)
{
type_ = type;
Member

Should this just be part of the initializer list? I don't see why we would handle this differently.

Should this just be part of the initializer list? I don't see why we would handle this differently.
HooglyBoogly marked this conversation as resolved

@blender-bot build

@blender-bot build
Sergey Sharybin approved these changes 2024-07-18 17:39:58 +02:00
Sergey Sharybin left a comment
Owner

Sounds good on a top-level. Didn't go too much into the implementation details.
So make sure it compiles, and works in general cases, and land it.

Sounds good on a top-level. Didn't go too much into the implementation details. So make sure it compiles, and works in general cases, and land it.
Hans Goudey added 1 commit 2024-07-23 22:17:57 +02:00
Hans Goudey added 1 commit 2024-07-23 22:28:22 +02:00
Hans Goudey merged commit 7daefd730b into main 2024-07-23 22:31:45 +02:00
Hans Goudey deleted branch pbvh-public 2024-07-23 22:31:49 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
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
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
Core
Module
Development Management
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
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#124919
No description provided.