GPv3: Material Selection node #113827

Merged
Dalai Felinto merged 4 commits from dfelinto/blender:grease-nodes-material-selection into main 2023-10-17 19:52:54 +02:00

Part of #113602.

Part of #113602.
Dalai Felinto requested review from Falk David 2023-10-17 12:57:42 +02:00
Dalai Felinto requested review from Hans Goudey 2023-10-17 12:57:42 +02:00
Dalai Felinto force-pushed grease-nodes-material-selection from e05406aee7 to 4f02b2b4fd 2023-10-17 13:01:16 +02:00 Compare
Author
Owner

Note that I didn't know how to best handle
const IndexMask domain_mask = (domain == ATTR_DOMAIN_FACE) ? mask : IndexMask(mesh->faces_num);, so it needs a closer eye

Note that I didn't know how to best handle `const IndexMask domain_mask = (domain == ATTR_DOMAIN_FACE) ? mask : IndexMask(mesh->faces_num);`, so it needs a closer eye
Member

That statement is an optimization to avoid calculating unnecessary values. If domain interpolation is necessary though, it's hard to know which face values will be needed, so we just calculate all of them. I think it can become const IndexMask domain_mask = (domain == ATTR_DOMAIN_CURVE) ? mask : IndexMask(curves.curves_num()); in this case.

That statement is an optimization to avoid calculating unnecessary values. If domain interpolation is necessary though, it's hard to know which _face_ values will be needed, so we just calculate all of them. I think it can become `const IndexMask domain_mask = (domain == ATTR_DOMAIN_CURVE) ? mask : IndexMask(curves.curves_num());` in this case.
Hans Goudey requested changes 2023-10-17 18:51:49 +02:00
@ -55,6 +57,40 @@ static VArray<bool> select_mesh_faces_by_material(const Mesh &mesh,
return VArray<bool>::ForContainer(std::move(face_selection));
}
static VArray<bool> select_grease_pencil_by_material(const GreasePencil &grease_pencil,
Member

It would be nice to see this de-duplicated with the mesh implementation. I think the arguments would be:

  • VArray<int> material_indices
  • const Span<Material *> materials
  • Material *material

And beyond that everything would be the same

It would be nice to see this de-duplicated with the mesh implementation. I think the arguments would be: - `VArray<int> material_indices` - `const Span<Material *> materials` - `Material *material` And beyond that everything would be the same
dfelinto marked this conversation as resolved
Dalai Felinto force-pushed grease-nodes-material-selection from 4f02b2b4fd to c353f676db 2023-10-17 19:37:33 +02:00 Compare
Dalai Felinto requested review from Hans Goudey 2023-10-17 19:37:39 +02:00
Hans Goudey approved these changes 2023-10-17 19:43:22 +02:00
Hans Goudey left a comment
Member

One more deduplication opportunity might be passing AttributeAccessor and the domain, so the shared function could retrieve the material indices and the domain size (with (attributes.domain_size(domain)). That sounds worth it actually. But doesn't need another round of review. Thanks!

One more deduplication opportunity might be passing `AttributeAccessor` and the domain, so the shared function could retrieve the material indices and the domain size (with (`attributes.domain_size(domain)`). That sounds worth it actually. But doesn't need another round of review. Thanks!
Dalai Felinto added 1 commit 2023-10-17 19:52:24 +02:00
Dalai Felinto merged commit 42f71c9dca into main 2023-10-17 19:52:54 +02:00
Dalai Felinto deleted branch grease-nodes-material-selection 2023-10-17 19:52:55 +02:00
Falk David approved these changes 2023-10-17 19:54:11 +02:00
@ -83,2 +114,2 @@
VArray<bool> selection = select_mesh_faces_by_material(*mesh, material_, domain_mask);
return mesh->attributes().adapt_domain<bool>(std::move(selection), ATTR_DOMAIN_FACE, domain);
switch (context.type()) {
case (GeometryComponent::Type::Mesh): {
Member

No need for the (...).

No need for the `(...)`.
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
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#113827
No description provided.