I need no introduction to this story... We ALL understand this feeling when we're in the office or in a social environment where we know the people around us and then this happens.
I've come to the realisation that having to say 'hi' or 'hello' multiple times and smiling at someone every single time they pass you by is ridiculous - once or twice is ENOUGH.
How Do We Stop This?
A simple greeting with a smile on the first passing is enough. Every time after that, a determined yet approachable look forward still being open for the person to start a conversation will be your way out of the awkwardness.
It is important for both parties to understand that you have greeted, and it is now time to GET TO WORK. Sometimes we simply need the reinforcement that once is enough, especially in these circumstances...
One Last Thing...
Although being direct is important (otherwise you would look ready to compromise on your other tasks) it is important not to death stare unless of course it is intended...
Stay direct with an approachable look and you should be alright to go about your business.