Above is a shot showing a debug visualization of the shadow frusta. Each set of 4 pink lines represents one shadow caster, that could be a receiver as well, in the case of doors, bridges or the main character.
Because the sunlight is directional, even an entity culled by the view frustum or the cell/portal system could potentially cast a shadow into view, causing shadows to be calculated for all objects in the temple even when very far away.
Now the temple is its own sublevel, so there are no more objects to worry about from that viewpoint anymore, and perf is better on both sublevels.
The first thing I did for the sublevel support was add a new door type called a 'leveldoor' that knows which level it links to, and made the door switch levels on you when you open it.
The downside of the first implementation was that a sublevel could only be connected in one spot to another level, which didn't work for the cavecity level.
The next change was to make each leveldoor know which trigger it should start the player at when used. This allows the sublevels to be linked in any fashion at all, and so I was able to break up the cavecity level into 2 pieces, that go from one door in A to B, then from a door in B to a different spot in A.
The challenge now is the blue crystals. Basically, you can deploy a blue crystals as a save point, creating a swirling blue sphere on your current level. If you die, or activate that crystal slot, your character will be teleported back to that location, and healed, and the crystal sphere is destroyed so you can't re-use it without spending another crystal.
This code doesn't understand the sublevel concept, and currently switching levels kills any active blue crystal save points.
So right now, when you switch sublevels you lose your active blue crystals, which sucks b/c the sublevel concept is purely a performance feature, and not a gameplay concept.
I will most likely have to change the crystal code to undestand & work with sublevels.