2
$\begingroup$

Let's say you have a spline, indexes go from top to bottom:

enter image description here

I want to make each point in the line lower than the previous, so that line always goes down, and never goes up. I made this node setup, which looks at previous point and lower current point if it is higher than previous one:

enter image description here

This is works for that line:

enter image description here

But not for that, because 2 points in a row is higher:

enter image description here

How to make it work for every possible line?

$\endgroup$
3
  • $\begingroup$ yes, just use animation nodes ;) $\endgroup$
    – Chris
    Oct 18, 2022 at 14:05
  • 1
    $\begingroup$ this [1]: i.sstatic.net/k5sP3.png works, but i think this is not what you want? $\endgroup$
    – Chris
    Oct 18, 2022 at 14:22
  • $\begingroup$ No, @Chris, the curve is created already (by shortest path), now I want to edit it $\endgroup$
    – Crantisz
    Oct 18, 2022 at 19:34

2 Answers 2

3
+150
$\begingroup$

Unfortunately, there are no loops in Geometry Nodes...

Even with Accumulate Field you will not be able to achieve a solution here.

But with the following tricks you can achieve the goal:

Blender <= 3.3

enter image description here

  • First, capture the lowest position on the Z-axis as well as the extent on the Y-axis (or X-axis, depending on how your line is oriented).

  • Then create a grid (2x2 points) which corresponds to the length of your curve.

  • Transform this grid so that it starts at $0$ on the Y-axis, and instantiate it at each point.

    This will give you the following strange looking result:

    enter image description here

  • Then combine the lowest Z-position with the X/Y-positions of each point, and use that as the Source Position for a raycast.

    This raycast should point up to the grids and give you back as Hit Position the position you are looking for.

    enter image description here


(Blender <=3.3)

Blender 3.4+

With Blender version 3.4 the node Points of Curve was added, which returns the index of a point based on a given weighting.

For this, however, the curve must be duplicated. As weighting the Z-position is passed here. If the index of the point is higher than the spline index, an infinitely large value is used as weighting:

enter image description here

The whole thing again slightly modified and the direct passing of the final position:

enter image description here

And here is another modification, same concept, but with shortened curves:

enter image description here


(Blender 3.4+)

$\endgroup$
2
  • 1
    $\begingroup$ Good job! I was trying raycast, but was raycasting to the left (previous points) which were extruded, the logic wasn't quite right... As for Accumulate Field node, it doesn't work because you can't compare Accumulated input with output to store back in the field... I was thinking about sorting, but raycasting will definitely be more performant. $\endgroup$ Oct 21, 2022 at 15:25
  • 1
    $\begingroup$ Very neat! IMHO, the economy of the method is quite pretty :) $\endgroup$
    – Robin Betts
    Oct 23, 2022 at 17:05
2
$\begingroup$

Here's a solution using multiple stages to determine the minimum for all points:

enter image description here

This problem can't be solved locally (looking at just the next/previous points). For each point N it needs to compute the minimum of all the points 1 to N-1. Naively this would require a loop, but it can be done a bit more elegantly with a divide-and-conquer strategy in O(log(N)) time.

You already have the first step, finding the minimum between a point and the next. If you scale that up by a factor of 2 you can clamp up to a distance of 2 points, then 4, 8, 16, etc. That's because the minimum of the union of two point sets is the same as the lesser of the minima of both sets (duh). We can successively combine larger sets and avoid computing the same minima over and over.

The file handles up to 64 points atm. Just add more stages at the bottom of the tower if necessary.enter image description here

$\endgroup$
3
  • 2
    $\begingroup$ WHERE ARE WE GOING TO GET LOOPS IN GEONODES?! Sadly copy-pasting nodes is the way to go in many cases... In this case I think I'll figure something out in a moment, but still life would be much easier with loops... $\endgroup$ Oct 21, 2022 at 13:19
  • 1
    $\begingroup$ When* - my grammar is bad when I'm angry $\endgroup$ Oct 21, 2022 at 13:28
  • 1
    $\begingroup$ @MarkusvonBroady We want loops! We want loops! We want loops! We... ;-) $\endgroup$
    – quellenform
    Oct 21, 2022 at 15:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .