Page MenuHome

Nodes: Add dynamic label support for Math Nodes
ClosedPublic

Authored by Charlie Jolly (charlie) on Dec 7 2019, 6:39 PM.

Diff Detail

Repository
rB Blender
Branch
master
Build Status
Buildable 6397
Build 6397: arc lint + arc unit

Event Timeline

Charlie Jolly (charlie) planned changes to this revision.EditedDec 7 2019, 6:43 PM

This adds label support to sockets much like nodes. This is a proof of concept to see if this approach is acceptable as changing socket name is complicated and hints at future nodes refactor.

This patch works by providing a new socket->label member.

This is only used when drawing the node and if it's not set then it falls back to the socket->name.

While this works well in theory, in practice it becomes an annoyance, this is currently the case with dynamic socket names for the new Voronoi procedural texture.

When playing around or experimenting with settings every time the socket name changes between different settings nodes are disconnected, and one must manually reconnect them again every time.
I'm not against it in principle, clearer socket names are definitely desirable, but not at the expense of keeping connections. Is there a way for socket names to change while still trying to keep current connections live?

@Duarte Farrajota Ramos (duarteframos) this doesn’t disconnect the sockets so the name changes are not disruptive

@Duarte Farrajota Ramos (duarteframos) this doesn’t disconnect the sockets so the name changes are not disruptive

Good to know, glad it doesn't. Keep up the great work :)

Additional labels to consider:

Power - "Exponent"
Logarithm - "Base"
Less Than / Greater Than - "Threshold"
Snap - "Increment"
Pingpong - "Scale"

Brecht Van Lommel (brecht) requested changes to this revision.Jan 27 2020, 5:05 PM
Brecht Van Lommel (brecht) added inline comments.
source/blender/editors/space_node/node_draw.c
422

Don't put complicated code like this in macros, assign it to a variable first.

Add a const char *nodeSocketLabel(const bNodeSocket *); utility function

Also would use (nsock->label[0] != '\0) ? nsock->name : nsock->label`, no need to compare strings here.

source/blender/makesdna/DNA_node_types.h
119

It's not really user-defined like node labels, more like a dynamic label.

source/blender/nodes/intern/node_util.c
124–132

I'm not sure about these names, I would rather keep just Value.

140–141

Maybe could be Multiplier and Addend instead, I don't much like the use of B and C here.

145

Name it just Threshold.

This revision now requires changes to proceed.Jan 27 2020, 5:05 PM
Charlie Jolly (charlie) marked 5 inline comments as done.

Address comments, thanks.
Add support for drawing node panel via py and rna (readonly).
Add support for node group sockets.

Seems fine now, with minor comment that you can address without review.

source/blender/editors/space_node/node_draw.c
358

Name this nodeSocketLabel() and put it in node.c, to match nodeLabel().

This revision is now accepted and ready to land.Feb 11 2020, 4:21 PM
Charlie Jolly (charlie) marked an inline comment as done.Feb 11 2020, 5:07 PM