Workbench Next: Sculpt Support #109294

Merged
Miguel Pozo merged 6 commits from pragma37/blender:pull-workbench-next-sculpt into main 2023-06-26 11:56:17 +02:00
Member

Add Sculpt support for the new Draw Manager and implement Sculpt rendering in Workbench Next.
Instead of using a callback approach, it's now possible to retrieve a vector of GPUBatches and their material index, so engines can use them as they see fit.

Add Sculpt support for the new Draw Manager and implement Sculpt rendering in Workbench Next. Instead of using a callback approach, it's now possible to retrieve a vector of GPUBatches and their material index, so engines can use them as they see fit.
Miguel Pozo added 2 commits 2023-06-23 16:12:00 +02:00
Miguel Pozo added this to the EEVEE & Viewport project 2023-06-23 16:12:43 +02:00
Miguel Pozo added the
Module
EEVEE & Viewport
label 2023-06-23 16:12:56 +02:00
Miguel Pozo requested review from Clément Foucault 2023-06-23 16:13:13 +02:00
Clément Foucault requested changes 2023-06-23 17:52:42 +02:00
Clément Foucault left a comment
Member

A few cosmetic changes but otherwise looks good to me.

A few cosmetic changes but otherwise looks good to me.
@ -0,0 +136,4 @@
int attrs_len = 0;
/* NOTE: these are NOT #eCustomDataType, they are extended values, ASAN may warn about this. */
attrs[attrs_len++].type = (eCustomDataType)CD_PBVH_CO_TYPE;

Use functional cast for all eCustomDataType.

Use functional cast for all `eCustomDataType`.

Use functional cast for all eCustomDataType.

Use functional cast for all `eCustomDataType`.
pragma37 marked this conversation as resolved
@ -0,0 +171,4 @@
}
}
return sculpt_batches_get_ex(ob, features & SCULPT_BATCH_WIREFRAME, false, attrs, attrs_len);

The feature masking here is not obvious nor safe (bool could be different from 0/1). Prefer defining bool use_wire = features & SCULPT_BATCH_WIREFRAME != 0 and use as sculpt_batches_get_ex argument.

The feature masking here is not obvious nor safe (`bool` could be different from 0/1). Prefer defining `bool use_wire = features & SCULPT_BATCH_WIREFRAME != 0` and use as `sculpt_batches_get_ex` argument.
Author
Member

I personally find flags & mask more readable than (flags & mask) != 0.
This idiom is used all over the place, including the original functions from draw_mamager_data.
Not sure why this one triggers your spider sense. 🤔

Regarding safety, it's guaranteed by the standard to be true.
AFAIK, the binary representation of a true boolean is not guaranteed in any case, but that's only relevant for serialization.
In any case, all the compilers we support do "the right thing".
https://godbolt.org/z/xbv5e6hcd

I personally find `flags & mask` more readable than `(flags & mask) != 0`. This idiom is used all over the place, including the original functions from `draw_mamager_data`. Not sure why this one triggers your spider sense. 🤔 Regarding safety, it's guaranteed by the standard to be `true`. AFAIK, the binary representation of a `true` boolean is not guaranteed in any case, but that's only relevant for serialization. In any case, all the compilers we support do "the right thing". https://godbolt.org/z/xbv5e6hcd

Might have been some gidelines we had when code was mostly C. Disregard that then.

Might have been some gidelines we had when code was mostly C. Disregard that then.
fclem marked this conversation as resolved
@ -0,0 +19,4 @@
SCULPT_BATCH_DEFAULT = 0,
SCULPT_BATCH_WIREFRAME = 1 << 0,
SCULPT_BATCH_MASK = 1 << 1,
SCULPT_BATCH_FSET = 1 << 2,

Avoid contraction. SCULPT_BATCH_FACE_SET.

Avoid contraction. SCULPT_BATCH_FACE_SET.
pragma37 marked this conversation as resolved

About the debug code, I would maybe make it part of workbench-next or overlay-next (preferably) instead.

About the debug code, I would maybe make it part of workbench-next or overlay-next (preferably) instead.
Miguel Pozo added 3 commits 2023-06-23 20:36:54 +02:00
Author
Member

The mesh color part can only be done on the Workbench side, so I implemented only that.
It matches the intended current behavior (it actually doesn't work in the current Workbench),
but I find kind of weird that the bounding box color doesn't match the mesh color.
We may want to look into that when we do the Overlay Next part.

The mesh color part can only be done on the Workbench side, so I implemented only that. It matches the intended current behavior (it actually doesn't work in the current Workbench), but I find kind of weird that the bounding box color doesn't match the mesh color. We may want to look into that when we do the Overlay Next part.
Clément Foucault approved these changes 2023-06-24 01:12:01 +02:00
@ -0,0 +63,4 @@
}
batch.material_slot = drw_pbvh_material_index_get(batches);
/** NOTE: This doesn't match the index used in DRW_sculpt_debug_cb (debug_node_nr). */

These kind of comments are better left on the PR itself. They are not really useful once the initial code gets removed.

These kind of comments are better left on the PR itself. They are not really useful once the initial code gets removed.
pragma37 marked this conversation as resolved
Miguel Pozo added 1 commit 2023-06-26 11:52:46 +02:00
Miguel Pozo merged commit b14b67db40 into main 2023-06-26 11:56:17 +02:00
Miguel Pozo deleted branch pull-workbench-next-sculpt 2023-06-26 11:56:19 +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#109294
No description provided.