The real problem is the concept of a “sealed” environment like inside a building. It’s surprisingly difficult to dertermine whether it’s ok to spawn a creature inside a building or not, though I guess it’s reasonable to err on the side of assuming that building are sealed and not spawning animals inside them at all. (Just filed a bug to change this, so “bathroom bears” may soon be a thing of the past)
This gets more dificult though for fences, they won’t actually help since the ground “inside” the fence isn’t marked in any way within the game itself (building tiles get a “roof” flag, but terrain inside a fence wouldn’t) The best we could do then is a flood-fill heuristic every time a fence or wall or… anything blocking movement is either created or destroyed. This still has a problem in that the entire perimiter of the fence needs to be on the active map for it to work properly.
tl;dr it’s harder than it seems, will be making a basic change soon that covers most of the issues.