Page MenuHome

Geometry Nodes: Attribute Vector Math Node
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Dec 21 2020, 10:53 PM.
Tokens
"Love" token, awarded by lone_noel."Love" token, awarded by kenziemac130."Like" token, awarded by DimitriBastos."Love" token, awarded by Rusculleda.

Details

Summary

This patch implements the same operations and interface as the regular
vector math node, but it runs for every element of the attribute. This
should expand what's possible with geometry nodes quite a bit, so far
not having the option to do vector math has been quite limiting.

This implements every single operation in the existing vector math node.
If there are more necessary, they will be easy to add later.

Diff Detail

Repository
rB Blender
Branch
geometry-nodes-attribute-vector-math (branched from master)
Build Status
Buildable 12108
Build 12108: arc lint + arc unit

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Dec 21 2020, 10:53 PM
Hans Goudey (HooglyBoogly) created this revision.
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/makesdna/DNA_node_types.h
1112

Wrong comment.

source/blender/nodes/NOD_math_functions.hh
236

There is safe_modf in BLI_math_base_safe.h.

source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
355

Would be nice if we could somehow do this, without having to list all the different cases again. It's not too bad here, but maybe there is a nicer way.
For example, one could use the try_dispatch_... function and check their return value.

My main goal here is to reduce the number of times the enum values are used.

But then again, it's fine as is... Just thinking out loud :D

source/blender/nodes/intern/math_functions.cc
149

This should be used in node_shader_vector_math.cc as well. But that can be updated separately.

Hans Goudey (HooglyBoogly) marked an inline comment as done.
  • Merge branch 'master' into geometry-nodes-attribute-vector-math
  • Correct comment
  • Use safe_modf, fix reflect operation
source/blender/nodes/NOD_math_functions.hh
236

Thanks, I didn't find that.

source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
355

> For example, one could use the try_dispatch_... function and check their return value.

I thought about doing something like that too, but with the different cases of number of attributes and attribute types, it seemed like the simplest way to do it. Maybe even the only way, not sure.

source/blender/nodes/intern/math_functions.cc
149

Yes, I'll do that in another patch.

Leon Schittek (lone_noel) added inline comments.
source/blender/nodes/NOD_math_functions.hh
263

I guess the third division should use the z components safe_divide(a.z, b.z)

source/blender/nodes/NOD_math_functions.hh
263

Nice catch, thanks! Copy and paste is dangerous..

There is one issue with the input type selection. When "Type B" is set to "Vector" and then the operation is changed to "Scale". The scale input can't be of type "Vector", so you get:

  • Merge branch 'master' into geometry-nodes-attribute-vector-math
  • Fix issue with type dropdown and scale operation
  • Fix issue with safe_divide operator
Hans Goudey (HooglyBoogly) marked 2 inline comments as done.
  • Fix comment, sorry for the noise
source/blender/makesrna/intern/rna_nodetree.c
2025

wrong space at start of line

2026

I'm not actually sure if this only affects Scale. I did not check the other types.

Hans Goudey (HooglyBoogly) marked 2 inline comments as done.Jan 11 2021, 5:26 PM
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/makesrna/intern/rna_nodetree.c
2026

Yeah, it's the only one that restricts the input type to just floats. For now at least.

Jacques Lucke (JacquesLucke) added inline comments.
source/blender/makesrna/intern/rna_nodetree.c
2026

Also needs to check the reverse direction, when going from Scale to something else.

source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
355

Alternatively, we can move information like this into FloatMathOperationInfo. But that's not necessary now.

This revision is now accepted and ready to land.Jan 11 2021, 6:07 PM
Hans Goudey (HooglyBoogly) marked 2 inline comments as done.Jan 11 2021, 7:04 PM

Thanks for the review!

source/blender/makesrna/intern/rna_nodetree.c
2026

Ah of course. Thanks.

This revision was automatically updated to reflect the committed changes.
Hans Goudey (HooglyBoogly) marked an inline comment as done.