Merge branch 'skmp/fix-radar-masking' into 'main'

Fix radar masking

See merge request skmp/dca3-game!47
This commit is contained in:
Stefanos Kornilios Mitsis Poiitidis
2025-03-10 23:51:47 +00:00
2 changed files with 18 additions and 0 deletions

View File

@@ -752,6 +752,15 @@ void CRadar::DrawRadarMask()
CVector2D out[8];
CVector2D in;
// First draw with near Z to clear nearer Z from any 3d objects
for (int i = 0; i < 4; i++) {
in.x = corners[i].x;
in.y = corners[i].y;
TransformRadarPointToScreenSpace(out[i], in);
}
CSprite2d::SetMaskVertices(4, (float *)out);
RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::GetVertices(), 4);
// Draw the shape we want to mask out from the radar in four segments
for (int i = 0; i < 4; i++) {
// First point is always the corner itself
@@ -767,6 +776,13 @@ void CRadar::DrawRadarMask()
};
CSprite2d::SetMaskVertices(8, (float *)out);
// Make the mask depth slightly above the map depth
// Not sure how this worked in the original code tbh
auto vtx = CSprite2d::GetVertices();
for (int j = 0; j < 8; j++) {
vtx[j].w /= 5;
}
RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::GetVertices(), 8);
}
#if !defined(GTA_PS2_STUFF) && defined(RWLIBS)

View File

@@ -1074,10 +1074,12 @@ void CHud::Draw()
#else
rect.Grow(6.0f);
#endif
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
rect.Translate(SCREEN_SCALE_X_FIX(0.0f), SCREEN_SCALE_Y_FIX(2.0f));
Sprites[HUD_RADARDISC].Draw(rect, CRGBA(0, 0, 0, 255));
rect.Translate(SCREEN_SCALE_X_FIX(0.0f), SCREEN_SCALE_Y_FIX(-2.0f));
Sprites[HUD_RADARDISC].Draw(rect, RADARDISC_COLOR);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
}
CRadar::DrawBlips();
}