If this was not legal, we would all be bound to the same employer for life. This could be extrapolated to virtually any employee. Have you assembled burgers for McDonald's before? If so, you can't work at Burger King, because they also make burgers and you have proprietary knowledge of McDonald's burgers.
I have spoken with numerous individuals who added support for specification X to one vendor's product, then did the same at the next job, so on and so forth. One individual had implemented the same specification for 3 different companies, all competitors, in just a few years. When you consider the breadth and depth of some specifications, the code doubtlessly is similar in form and obviously identical in function.
I think that ZeniMax are seriously salty about shoving off VR now that it's blossoming. That being said, working on company equipment during company time? Carmack screwed up.
I'm fairly sure Carmack saw his role as one of a researcher, such that working on VR and sharing knowledge with the outside was part of what he was being paid for. I'm not familiar with his contract but I remember his communications regarding VR at the time and that's the way it appeared.
And "ideas" aren't a protected form of free speech.
In general, this argument would be laughed out of court of course. However, Carmack worked not only in the same domain, he worked on developing the exact same product at both companies - so this opens up to potential liability.
Or more specifically, if Zenimax's claims are correct, while he was working on company time and equipment.
How many people can forget everything they know every time they get a new job?
But I also think that there are some people who are exceptional cases. The real high earners in a company, especially if they're technical staff, are probably real luminaries in their field, and the company is paying them a significant premium in both money and autonomy because they believe that such an employee will produce a lot of valuable new ideas for the company.
So if your rock star programming wizard quits to start a new company, taking a project that they've been iterating on during work hours on their company computer for the past 6 months while they were drawing a paycheck...well, if you look at it from the company's point of view, you can understand why they would feel like they got robbed blind.