Now I've set the w component to 0, there's still some situations where the test fails, but these are quite rare. It'll have to do for now.

What I have so far is that I've modified my 3D model import code to create portals from brushes that are tagged as portals. Haven't figured out a way to create these automatically so I'm placing all the portals manually, actually it's not that bad because I don't have to worry that much for overdrawing stuff.

Now the next problem is that how can I figure out which sector I'm in? If I set a starting position and tell it what sector it's in, then the rest is easy when I move from sector to sector through the portals. But if I have a free moving camera that can go outside the sectors, how can I figure out when I'm inside one of the sectors again? This would also be useful when placing objects on the maps so that I don't have to tell each object what sector they belong to.

The sectors doesn't necessarily form "convex" hulls (or what are they called) so I can't just check the camera location against all face normals in a sector to figure out the sector I'm supposed to be in.