Page MenuHome

Geometry Nodes: Swap IcoSphere mesh primitive inputs
Needs ReviewPublic

Authored by Jesse Yurkovich (deadpin) on Sep 25 2021, 10:28 AM.

Details

Summary

The IcoSphere node is slightly different than all the others in terms of
ordering its inputs. This patch swaps the order of inputs to match the
precedent set by the other mesh primitives.

The most difficult part of this is transferring driver and keyframe data
from the old inputs to the new. As far as I could find, there is no
built-in method for doing this type of operation so I'm not sure if it's
correct.

A file saved in 2.93

Frame 1Frame 2

The file loaded with this patch in 3.00

Frame 1Frame 2

Diff Detail

Repository
rB Blender
Branch
ico-swap (branched from master)
Build Status
Buildable 18678
Build 18678: arc lint + arc unit

Event Timeline

Jesse Yurkovich (deadpin) requested review of this revision.Sep 25 2021, 10:28 AM
  • Reduce duplicate code and handle cases where only 1 of the sockets has fcurves
Sybren A. Stüvel (sybren) requested changes to this revision.Nov 12 2021, 11:23 AM

Apart from some minor notes, I think the patch looks fine.

source/blender/blenloader/intern/versioning_300.c
456

This is not what the function does. It is what it's being used for, but that's not the right kind of thing to document here. Something like this would be better:

/**
 * Ensure the FCurve with the 1st RNA path gets the 2nd RNA path, and vice versa.
 * \param list the list of FCurves to use to find the curves.
 * \param sock0_rna_path the first RNA path.
 * \param sock1_rna_path the second RNA path.
 */

Maybe you'd also want to change the code to count from 1 instead of from 0, so that it's more natural when the documentation mentions "first" and "second" (I'm never a fan of "zeroeth" and "first").

457

The name doesn't really convey the functionality of the function. It doesn't swap the fcurves, it swaps their rna_path. swap_fcurve_rna_path would be a better name.

457

I wouldn't mind if this function were to be moved to versioning_common.cc, as it's generic enough to be reused later.

457

Change ListBase *list to ListBase /*FCurve*/ *fcurves, so that it's clearer what's actually contained in the list (note that I added a comment and renamed the parameter).

465

You can return early here, and avoid an else. This also makes it clear that after this code, nothing more happens (instead of having to look down and inspect the rest of the code to come to the same conclusion).

476

It might be nice to have a little documentation here that says what the code does.

479

This should get a comment as to why the * 2 is there (and why it's enough).

699

Swap the condition & continue early. This reduces the cognitive complexity of the remainder of the loop body.

1919–2183

Keep formatting changes out of functional patches.

This revision now requires changes to proceed.Nov 12 2021, 11:23 AM

One downside of the approach in the versioning code, is that it doesn't loop over all Actions. As such, it won't be able to apply versioning to stashed actions. Since you need to know the node type, I think this cannot really be avoided. Just make sure that you test the situation where the node is animated via the NLA as well.

  • Merge master
  • Review feedback
Jesse Yurkovich (deadpin) marked 6 inline comments as done.Nov 16 2021, 6:17 AM

Updated for review feedback. Unfortunately I don't seem to know enough about the NLA editor to test out that scenario so I've been unsuccessful at getting something set up there to try.