Simplified base color for socket types #109288
No reviewers
Labels
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#109288
Loading…
Reference in New Issue
No description provided.
Delete Branch "LukasTonne/blender:static-node-socket-type-color"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Socket types have a
draw_color
callback that defines the color of asocket in the ui (node editor, group interfaces, shader tree view, etc).
This callback is overly generic, it takes a
bContext
as well as a nodeand socket instance. Technically this callback can only be used when
there is a context and a concrete instance of a socket.
In the vast majority of cases this contextual data is not necessary and
we simply use a static type-based color. To make this less complicated,
this patch adds an alternative
base_color
type member. This is a plaincolor value which is used in place of the
draw_color
callback when itisn't defined. Standard socket types no longer define a
draw_color
callback and only use the
base_color
.Compatibility with python nodes addons is important:
draw_color
callback was required, it is now optional. Addons cankeep using it, but
bl_base_color
is recommended for new code.base_color
property is registerable, but optional so as tonot cause errors in existing scripts.
draw_color
is now optional, andbl_base_color
isused by default.
bl_base_color
property instead of thedraw_color
function.bl_base_color
property.Custom nodes colors currently seem to be somewhat broken by #109231
This should not be simplified. If we want to have dynamic socket types in the future, determined from the context of the node tree, then this will still be in demand.
This is not related. There the problem is that users need their own version of the declaration to update nodes...
Generally seems fine. I mainly wonder right now whether a better alternative could be to allow passing in null into
draw_color
to avoid having two ways to find the socket color. Can't make up my mind right now. Have you thought about that?Allowing null for context, node, and socket pointers would be ideal, yes. However, we have not stated any such requirements for custom python nodes, so we can't expect those callbacks to handle nullptr gracefully (it should not crash, but would throw lots of errors).
Right now I think the main argument for the new base color property is that it can be used without a socket instance and that may be enough reason. I think it would be ok to change the API so that passing in
None
for the context is allowed, however passingNone
for the socket would be weird and makes the callback kind of useless.@ -171,6 +171,7 @@ typedef struct bNodeSocketType {
struct PointerRNA *ptr,
struct PointerRNA *node_ptr,
float *r_color);
float base_color[4];
Add comment saying that this is only used when
draw_color
is null, or when the context is not available, or when there is no socket instance.Why
base
btw?I was thinking of how
base_cpp_type
andgeometry_nodes_cpp_type
works. It's implied that the complex type/color is a variation of the base type/color, even though they can be totally separate.No strong feelings about the name, could be
simple_color
or justcolor
. Will add more comments.Would use just
color
for now.This seems like a reasonable API change. For 4.0 we can make this sort of change, and I'd argue it makes sense when it simplifies the design.
Maybe it will be easier to change socket colors, shapes, link field interface types, and everything else when it is bound to the context of the object - the owner of the context (modifier, material, ...), so then this change is not so blocking for wounds time of socket types.
We have the
draw_color_simple
callback now, so this is redundant.Pull request closed