Level editor snap functionality

Hi,
I’m making something similar to a level editor, the user can create objects and manipulate them around. I’m trying to get a smart snap functionality working, basically I want to detect surfaces of other objects and align with the current selected object’s best surface. Not very well defined, I know. What surface, of the selected object, will it chose? how to detect the surfaces? I’m a little stumped and could use some help :slight_smile:

Another idea was to let the user click the surface of the selected object and drag it to another object’s surface, all that is left to do is find the best orientation which could be left for the user.

Furthermore, if I would do what I just suggested (gluing the faces of two objects) it would still have the problem of aligning the thing. I mean, the object could be positioned in a way as the center of the faces coincide, but imagine I am gluing two slabs of stones supposed to form a floor, the floor could be misaligned that way!

Tough problem. I don’t think the solution will be something elegant and easy, it seems to need something more like every object having a bunch of children helper objects used to guide the snapping system or something clumsy like that.