Skip to content

Engine: use current sector as pivot in updatesector(z) fallback

The previous fallback simply iterated over all sectors from highest to lowest index. This commit changes it so that the input sector is used as the pivot. The iteration will advance in both directions until either the limit in both directions is reached, or the sector has been found. In edge cases, it will still iterate over all sectors until a match is found.

The basic idea is that adjacent sectors are very likely to have adjacent indices, thus this will speed up the fallback code in most applications. It also gives more accurate results for SOS areas, assuming that the connected neighbor sectors have indices that are close to the current sector. As such, this greatly reduces flickering in SOS areas, such as E2L11 of Duke3D.

This addresses #130 (closed), but it is not a foolproof solution. There are still some neighboring sectors where the connected, adjacent sector has an index that is further away from the current sector than the overlayed sector. This can still be observed with some of the sectors in E2L11, for example by activating the third-person camera and moving around.

Edited by Dino Bollinger

Merge request reports