More general "Compare" node #92729

Closed
opened 2021-11-01 21:20:13 +01:00 by Hans Goudey · 8 comments
Member

Currently we have the "Compare Floats" node for comparing the values of two float inputs.
Often there is a need to compare values of different types though. For example, it would
be nice to have the ability to quickly check whether one vector is less than another, element-wise.

One initial use case is to be a more general version of the "Normal Selection" node proposed in #91843.

{F11665128 size=full}

This design task proposes to turn the "Compare Floats" node into a multi-type node, just like
the change to the "Random Float" -> "Random Value" node.

Details

The new node is called "Compare", and operates on the following types, with the following options:

All of the input sockets are just named "A" and "B"

  • Float, Integer
    • Operation: >, >=, <, <=, ==, !=
  • Vector, 2D Vector
    • Mode: Element-wise, Length, Average, Dot Product, Direction (with angle threshold)
    • Operation: >, >=, <, <=, ==, !=
  • Color
    • Operation: Brighter, Darker...
  • Euler Rotation
    • Operation: >, <, ...
  • String
    • Operation: ==
  • Possibly data-block pointer types?

Further Questions

  • Support data-block pointer types? Probably not, I don't think, but it's an interesting idea.
  • Other comparison modes for different data types?

Implementation
Each option is implemented as its own multi-function
Versioning can automatically change the old node into the new node.

Currently we have the "Compare Floats" node for comparing the values of two float inputs. Often there is a need to compare values of different types though. For example, it would be nice to have the ability to quickly check whether one vector is less than another, element-wise. One initial use case is to be a more general version of the "Normal Selection" node proposed in #91843. {[F11665128](https://archive.blender.org/developer/F11665128/image.png) size=full} This design task proposes to turn the "Compare Floats" node into a multi-type node, just like the change to the "Random Float" -> "Random Value" node. **Details** The new node is called "Compare", and operates on the following types, with the following options: All of the input sockets are just named "A" and "B" - Float, Integer - Operation: `>`, `>=`, `<`, `<=`, `==`, `!=` - Vector, 2D Vector - Mode: `Element-wise`, `Length`, `Average`, `Dot Product`, `Direction` (with angle threshold) - Operation: `>`, `>=`, `<`, `<=`, `==`, `!=` - Color - Operation: `Brighter`, `Darker`... - Euler Rotation - Operation: `>`, `<`, ... - String - Operation: `==` - Possibly data-block pointer types? **Further Questions** - Support data-block pointer types? Probably not, I don't think, but it's an interesting idea. - Other comparison modes for different data types? **Implementation** Each option is implemented as its own multi-function Versioning can automatically change the old node into the new node.
Author
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Author
Member

Added subscribers: @HooglyBoogly, @guitargeek

Added subscribers: @HooglyBoogly, @guitargeek

Added subscriber: @GeorgiaPacific

Added subscriber: @GeorgiaPacific
Johnny Matthews self-assigned this 2021-11-15 19:56:49 +01:00

Added subscriber: @HyenHks

Added subscriber: @HyenHks

While Element-wise, Length, Average are unary operations, Dot Product is binary. Do you propose that for Dot Product, that you compare two vectors vector product with a third vector? That would require three inputs. Would utility take precedent over consistency in no. of inputs in this case?

While Element-wise, Length, Average are unary operations, Dot Product is binary. Do you propose that for Dot Product, that you compare two vectors vector product with a third vector? That would require three inputs. Would utility take precedent over consistency in no. of inputs in this case?
Author
Member

Hmm, maybe I'll be more specific about what I had in mind:

  • Element-wise: Output is true if the condition is true for all of the two vector's element comparisons. A.x < B.x && A.y < B.y && A.z < B.z
  • Length: Compare the lengths of the two vectors like a float. A.length() < B.length()
  • Average: Compare the averages of the two vectors like floats (A.x + A.y + A.z)/3 < (B.x + B.y + B.z)/3
  • Dot product: Compare the dot product of the two vectors with a third float value A dot B < C
Hmm, maybe I'll be more specific about what I had in mind: - Element-wise: Output is true if the condition is true for all of the two vector's element comparisons. `A.x < B.x && A.y < B.y && A.z < B.z` - Length: Compare the lengths of the two vectors like a float. `A.length() < B.length()` - Average: Compare the averages of the two vectors like floats `(A.x + A.y + A.z)/3 < (B.x + B.y + B.z)/3` - Dot product: Compare the dot product of the two vectors with a third float value `A dot B < C`

the std:string object does support all of the comparison ops. Do we want those in there as well rather than just ==, !=?

EDIT: Nevermind I added them.

the std:string object does support all of the comparison ops. Do we want those in there as well rather than just ==, !=? EDIT: Nevermind I added them.
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sign in to join this conversation.
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
5 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#92729
No description provided.