#Algorithm to know if block is not visible outside?

1 messages · Page 1 of 1 (latest)

nimble roost
#

Is there any way or existing algorithm to know if a block is contained or like enclosed?

stoic yoke
#

Do you mean if the air volume around the block is reasonably finite, or non-existent?

#

For a block, you can check what its six neighbours are, using Block methods .above(), .north(), etc. You could use a recursive function to check each neighbour, and each neighbour's neighbour, terminating when encountering a non-air block, and setting a limit on how many neighbours to check before you decide the air volume is infinite (ie open to outside). I'm not sure of the performance of this lookup. Better if you have known constraints on directions to search in.

#

Oh and you'd obviously have to have an algorithmic way to decide which blocks in the volume get assigned what subset of directions to search in to avoid checking the same block twice.