RTS Selecting units

Hey:)

So, I’m working on an RTS, and I’m currently thinking about how to go about boxing units. I think the idea is that I get the point on the screen where the mouse has clicked, then create a ray into the 3D world from that, and intersect it with the terrain.

I do this 4 times with each corner of the box, to get an area on the terrain that I’m selecting.

The problem is, where do I go from here? Do I check which units fall within this area? That would be quite messy, especially if a corner of the box lands over on the other side of a hill and another corner hits the hill…

Doing my own research, I’ve come across 2 methods I could use - gluUnproject and ‘picking’
using gluUnproject I can create a ray from my mouse position.
‘picking’ converts everything on the screen into a 2d image, with different colours used for different things. You then check which colours are inside the box, and select those units.

I’m thinking that picking would be the best way to go about this, but I’ve heard it’s quite slow. Does anyone have any experience with the two? Implementing one of these is going to be more than a few hours of work, as this is completely new territory for me, so I’d rather not have to redo it:P

I hope I’ve explained this well enough, thanks:)