Page MenuHome

Geometry Nodes: Rotate Instances Node
ClosedPublic

Authored by Erik Abrahamsson (erik85) on Sep 28 2021, 10:51 PM.

Details

Summary

Adds a node that can rotate each of a geometry's instances in global
(to the modifier object) or local space (of each point) by a specified angle around a pivot point.

Addresses T91653

Diff Detail

Repository
rB Blender
Branch
arcpatch-D12682 (branched from master)
Build Status
Buildable 17785
Build 17785: arc lint + arc unit

Event Timeline

Erik Abrahamsson (erik85) requested review of this revision.Sep 28 2021, 10:51 PM
Erik Abrahamsson (erik85) created this revision.
Hans Goudey (HooglyBoogly) requested changes to this revision.Oct 12 2021, 12:38 AM
Hans Goudey (HooglyBoogly) added inline comments.
release/scripts/startup/nodeitems_builtins.py
186

Unnecessary whitespace change here.

source/blender/nodes/geometry/nodes/node_geo_rotate_instances.cc
39–49

extract_input

54–55

Same comment as the other two nodes here:

I don't think this is quite right, the index here is the index into the mask, not the index of the index. Here's an example from the curve reverse node:

threading::parallel_for(selection.index_range(), 128, [&](IndexRange range) {
  for (const int i : range) {
    splines[selection[i]]->reverse();
  }
});
This revision now requires changes to proceed.Oct 12 2021, 12:38 AM
  • Fixed review comments
Hans Goudey (HooglyBoogly) requested changes to this revision.Oct 13 2021, 1:04 AM

Here are a few examples of simplifications for the matrix math. Maybe just multiplying all the matrices together solves it too, but I think it's better to use more precise code that's actually necessary.

I found testing with import mathutils in the python console helpful. I hope I'm correct with my comments inline. To that end, it could be helpful for you to share any files you are using for testing in the patch description.

I think these same comments will apply to the other two patches.

source/blender/nodes/geometry/nodes/node_geo_rotate_instances.cc
67

Inverting a matrix that's built from a translation is the same thing as building the matrix from the opposite of the translation, only much more expensive.

71–72

Multiplying a matrix with the identity is the same as doing nothing at all, I think the following should work here?

instance_transform = pivot_matix;
...

(Though in this case there's really no need to do the assignment.

74

I think multiplying a matrix by another matrix that was just built from the same as just translating matrix directly, like with add_v3_v3(transform.values[3]

This revision now requires changes to proceed.Oct 13 2021, 1:04 AM
source/blender/nodes/geometry/nodes/node_geo_rotate_instances.cc
74

I think this comment is wrong actually, I didn't test this properly. Feel free to ignore it.

Hans Goudey (HooglyBoogly) retitled this revision from Geometry Nodes: Rotate Instances node to Geometry Nodes: Rotate Instances Node.Oct 13 2021, 5:38 AM
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)

I think eventually we'll need to space inputs. One for Local Pivot and one for Local Orientation or so. Currently, one needs a separate node to rotate instances around the "global" Z access but using their local pivot.
If we decide at add the separate input, it well be easy to add versioning for it, so it's easy to add later.

This revision is now accepted and ready to land.Oct 13 2021, 1:21 PM
This revision was automatically updated to reflect the committed changes.