Use custom sprite sorting rules for vehicles diagonally under bridges

Extend bb sprite south for comparisons, but only for vehicles underneath
This is to avoid creating sprite sorting problems for vehicles
on top of the bridge

Adjust ParentSpriteToDraw struct
This commit is contained in:
Jonathan G Rennison
2024-02-08 20:44:15 +00:00
parent ea8aa47832
commit a484a5eb77
6 changed files with 152 additions and 43 deletions

View File

@@ -13,6 +13,7 @@
#include "cpu.h"
#include "smmintrin.h"
#include "viewport_sprite_sorter.h"
#include "viewport_func.h"
#include "safeguards.h"
@@ -28,8 +29,8 @@ GNU_TARGET("sse4.1")
void ViewportSortParentSpritesSSE41(ParentSpriteToSortVector *psdv)
{
const __m128i mask_ptest = _mm_setr_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0);
auto const psdvend = psdv->end();
auto psd = psdv->begin();
ParentSpriteToDraw ** const psdvend = psdv->data() + psdv->size();
ParentSpriteToDraw **psd = psdv->data();
while (psd != psdvend) {
ParentSpriteToDraw * const ps = *psd;
@@ -39,12 +40,17 @@ void ViewportSortParentSpritesSSE41(ParentSpriteToSortVector *psdv)
}
ps->SetComparisonDone(true);
const bool is_special = (ps->special_flags & VSSSF_SORT_SPECIAL) != 0;
for (auto psd2 = psd + 1; psd2 != psdvend; psd2++) {
ParentSpriteToDraw * const ps2 = *psd2;
if (ps2->IsComparisonDone()) continue;
if (is_special && (ps2->special_flags & VSSSF_SORT_SPECIAL) != 0) {
if (ViewportSortParentSpritesSpecial(ps, ps2, psd, psd2)) continue;
}
/*
* Decide which comparator to use, based on whether the bounding boxes overlap
*