Page MenuHome

Geometry Nodes: Add Between operations to Compare node
Needs RevisionPublic

Authored by Charlie Jolly (charlie) on Dec 14 2021, 10:26 PM.

Details

Summary

This expands the generalised Compare node and provides users with
two built-in operation modes for testing between values.

Between: val >= min && val <= max
Not Between: val < min || val > max

The term Between is taken from SQL and Python where it is inclusive.

Supports: Float, Int and Vector data types

Diff Detail

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

Event Timeline

Charlie Jolly (charlie) requested review of this revision.Dec 14 2021, 10:26 PM
Charlie Jolly (charlie) created this revision.

We discussed this in the latest geometry nodes sub-module meeting. Here are the notes from that:

  • This looks useful, it's usually much easier to control this than an equals operation with a range.
  • Should the selection be exclusive or inclusive? "Between" sounds exlusive. "In Range" is suggested as an alternative that's a bit more descriptive.
  • The implementation of the "between" and "not between" should not be duplicated.

We couldn't find the Python "between" function you mentioned. Also, I don't really think SQL should necessarily be considered a source for our UI design. I like the patch though.

Address comments.
Change name from Between to In Range.
Use functions for comparisons.
Behaviour note, like Clamp Range it takes
into account the value of the min/max arguments
and swaps if required.

Perhaps it could help to have an "Exclusive" checkbox or option to choose whether it is inclusive or exclusive?

Similar to "Equal or greater" being separated from "Greater"

Hans Goudey (HooglyBoogly) retitled this revision from Geometry Nodes: Add Between/Not Between operation modes to Compare node to Geometry Nodes: Add Between operations to Compare node.Feb 2 2022, 6:38 PM

The code looks good to me. I think we can avoid the exclusive checkbox for now, to avoid adding options unless they're really necessary (it would also have a performance impact).

I think the socket labels are incorrect in this case (I would expect "Angle Min" and "Angle Max"

Also, when there's only one value, and the other two inputs are "Min" and "Max", what do you think about labeling the input "Value" rather than "A"?

Address comments with socket labels.
Add ui_class function for changing node header color.

source/blender/nodes/function/nodes/node_fn_compare.cc
60–64

The situation with these identifiers is totally awful, but it probably makes sense to stick with the conventions from this file here

82

Could you commit this separately? (No need for a patch, since you've already implemented it for other nodes)

106–167

This looks like a huge mess, but I'm going to count on it being improved with separate refactors like multi-type sockets and moving the is_available checks to the socket declarations later.

225–230

Do you think there's a practical benefit for switching the min and max when they're reversed? I'm wondering if maybe that's not expected or necessary. It would be nice to avoid since there's a performance cost to the branching.

Also, the patch name and description should be updated with the new behavior and naming.

Hans Goudey (HooglyBoogly) requested changes to this revision.Jun 23 2022, 11:27 PM
This revision now requires changes to proceed.Jun 23 2022, 11:27 PM

@Hans Goudey (HooglyBoogly) Since the additional sockets adds a lot of complexity to the code I wonder if this is better implemented as node groups.

I've been quiet with Blender development. If this needs taking over please do.