This one works even when the indices are scrambled between the mesh islands.
In the following table, the column Viewer is the mesh island index and the ID is the calculated max point index within the concerning island:
It uses, what I call the Array Pattern. I already used this technique in the thread Select a subset of points in geometry nodes?.
The Array Pattern
Geometry nodes don’t provide a way, to store data in arrays. But there is a way to simulate arrays.
Imagine you stored the value of every index of an array on a line with x = index and y = 0. To store a value, you place a point that holds the data on this line. Every time, you want to overwrite the value of this index, you simply place a new point on this line. The only thing, you have to make sure is, that the new point is closer to z=0 than all points at this index before.
To read a value of a certain index, you can simply use the Transfer Attribute node, to read the data from the point, that is closest to (index, 0, 0). In certain cases you have to make sure, that the spacing of the indices is large enough, so that you don’t read the next index point instead of a data point.
Concrete Solution
We start by creating a copy of all the original points. These are ourone data pointspoint for every original point. Every data point represents the index of an original point:
Next, we place the data points into our array. We use the Mesh Island index of the related original point as the array index. And we calculate z to z = 1 / (index + 1)
. And then we simply iterate over all data points and place them into the array. This way, the point with the highest index of a mesh island will be closest to z in the corresponding index bucket. We have to add 1 to the index, because index 0 would otherwise lead to 1/0 which in blender is 0.
Finally, we iterate over our original points and transfer the value of the corresponding array index into the ID of the original point.