Intersecting shapes vs alternative?


If I want to make a building shaped like +, the simplest would be to overlap two perpendicular rectangle blocks like above. Even roofline gable would merge without extra code. But then maybe there would be sorting problems or other issues like zfighting in the middle if flat? Alternative I could calculate all the intersections points and build the external faces where needed. But then end up with many more points and triangles per building… and more coding complexity.

I prefer the first idea, but fear it will have unwanted consequences at some point.

I understand that (in the first, simpler, idea) you want to have effectively 2 buildings, pretending to be 1, like this:

For the Castle Game Engine rendering and collisions it will be OK. In particular:

  1. No problem for shadows, by both shadow volumes and shadow maps. The algorithms will think it’s 2 separate buildings, but that’s not a problem for shadow volumes or shadow maps.
  2. Since the faces of the 2 buildings don’t overlap (they only intersect, but the intersection is an edge, not a polygon with non-zero area), you will not have Z-fighting.
  3. Collisions will be OK, assuming you don’t care how collisions work inside the buildings and only care that collisions don’t allow to enter the shape.
    I can think of one small detail: the automatic mass calculation of physics engine will be wrong (since part of the volume will be counted 2 times). But this probably completely doesn’t matter to you, if you’re not going to throw these buildings into the air like giant missiles :slight_smile:

So, you’re OK with this simple solution in this case.

Oh, one important addendum:

  1. If all faces are opaque then there will be no problem with blending. If you plan to use blending (e.g. use partially transparent windows on all building sides) then splitting such structure (since the combined 2 buildings form concave thing) into a few smaller structures (such that every 3D shape is convex) may be desirable for correct blending sorting.

Thanks. Buildings will be opaque and unmoving. So simple looks good.