Knowledge check on gatherRadius and minSize/maxSize

Tags: #<Tag:0x00007fb4d2ce15d8>

Just looking for a quick knowledge check here about the relationship between gatherRadius on Instance nodes and minSize/maxSize on Decoration nodes. I know there are notes here about this but I’m not super technical so looking for someone to either confirm my scenario below or help me fix it so that it’s right. Thanks!

I believe the gatherRadius node is used to determine how tightly to measure the size of the individual variants of the prefab. For example, let’s imagine you have a variant of a tree that is just a 1x1 trunk column with one leaf block on top and another tree variant that is a 3x3 trunk with some leaves on top. A large gatherRadius (1.000 to be exact) means that each of these variants are “sized” similarly in regards to the Decoration node. However, if you were to lower the gatherRadius, suddenly the 3x3 tree is measured as larger than the 1x1 tree. Thus if you set the minSize to something like 0.5 and maxSize to 1.0, then only the larger tree would spawn (assuming constraint type and whatnot are all set appropriately)?

I tried to do some testing on this myself in World Builder. I made a new prefab with 4 variants: a 1x1x4 “tree” ( A ), a 2x2x5 ( B ), a 3x3x6 ( C ), and a 4x4x7 ( D ). The caps of each one was a distinctive block to make it easier to tell what was happening…stylish glass, gleam lantern, ancient corruption, and amber respectively. I set the gatherRadius value to 0.010 for the instance.

I then loaded up a grasslands biome and attached my instance to the pre-built decoration node. I set minSize to 0.5 and maxSize to 1.0 and lo and behold only the C and D variants spawned. I was thrilled! I then set minSize to 0.25 maxSize to 0.75 expecting only the B and C variants to spawn and…only C spawned. So I went with 0 and 0.75 expecting to see A, B, and C…and only C spawned. I eventually got to a point after playing with the sliders where only type C would spawn even if I set min/max to 0 and 1.

So I moved on and deleted that decoration type and moved on to override the next flower slot with the same instance. I used 0 and 0.5, expecting to see A and B…and only got B. I tried 0 and 0.75 again like I did above and only got C again.

Not sure I understand what’s happening here.

the prefab “size” is measured as: (dimensions[0] * dimensions[1] * dimensions[2] + nonAirCount) * 0.5
so a prefab that is 3x3x3 but mostly air is “smaller” than a 3x3x3 with lots of blocks in it… and the sizes are normalized so that [min, max] of the sizes becomes [0, 1]

selection of a prefab from the set is then done like:

take a value from the sizeNoise in config (if there is none, a value of 0.5 is used), and map [0,1] to [minSize, maxSize] set in config; this is the “size” that we will try to select in the [0, 1] range.

to select a given size: start with a radius of “gatherRadius” from the config, and uniformnly select one of the prefabs that are in the [size - radius, size + radius] range of sizes. If there are none, increase the radius by 50% and try again.

so the gatherRadius controls how tight the selection is, and a gatherRadius of 1 means all the prefabs will always be in the initial search range, so it just becomes a random choice regardless of the prefab size.