You can shoot through a tree. The only time you can't attack/shoot is when you are right in front of the obstacle.
In Distract the Guards, I killed the bowmen and then the swordsman faces Arman without attacking him. I almost always play on Normal.
I've noticed that theme elsewhere too: a character
could attack, but just chooses not to. I can only imagine that it was to save on Psy points because an "ambush" on your character would have been non-fatal, and/or to regenerate Psy points. (But the swordsman doesn't use Psy attacks.)
If the swordsman had faced
away from you and had his back to a wall, I'd say it was to avoid a backstab. (But he faced you.)
There's one other explanation, that might fit, but I don't know if the AI does this: An enemy chooses "suicide" and tries to appear harmless by not attacking. If you kill him off the next turn, he'll make room for more enemies (or a stronger or healthier one) that will hurt you more than he could have alone.... it's kind of a stretch, but I've seen it happen, though maybe for a different reason than this.