Fix ground mat detection

This commit is contained in:
Miloslav Ciz 2025-02-19 16:49:56 +01:00
parent 9b28ed3630
commit 30d44bc8d4
2 changed files with 12 additions and 17 deletions

View file

@ -1167,7 +1167,8 @@ uint32_t LCR_racingStep(unsigned int input)
{
TPE_Unit upDot = TPE_vec3Dot(carUp,TPE_vec3(0,TPE_F,0));
// if car is "somwhat" upwards (TPE_F / 8 is a hardcoded constant):
/* if car is "somewhat" horizontal (TPE_F / 8 is a hardcoded constant)
(else we assume we're riding on wall): */
if (upDot > TPE_F / 8 || upDot < -1 * TPE_F / 8)
{
uint8_t
@ -1178,23 +1179,17 @@ uint32_t LCR_racingStep(unsigned int input)
gz = (LCR_racing.carPositions[0].z + (LCR_MAP_SIZE_BLOCKS / 2) *
LCR_GAME_UNIT) / LCR_GAME_UNIT;
/* TODO: this shit below looks wrong:
- in the conditions yMod < LCR_GAME_UNIT / 2 can't ever happen because we
did % (LCR_GAME_UNIT / 2)?
FIX
*/
TPE_Unit yMod = (LCR_racing.carPositions[0].y + LCR_MAP_SIZE_BLOCKS *
LCR_GAME_UNIT / 2) % (LCR_GAME_UNIT / 2);
if (upDot > 0 && yMod < LCR_GAME_UNIT / 2) // TODO: const
if (yMod < LCR_GAME_UNIT / 5) // if kinda at the bottom of the block
groundBlockIndex = LCR_mapGetBlockAt(gx,gy - 1,gz);
else if (upDot < 0 && yMod > LCR_GAME_UNIT / 2)
groundBlockIndex = LCR_mapGetBlockAt(gx,gy + 1,gz);
if (groundBlockIndex == -1)
groundBlockIndex = LCR_mapGetBlockAt(gx,gy,gz);
if (groundBlockIndex == -1) // still nothing? try bottom again
groundBlockIndex = LCR_mapGetBlockAt(gx,gy - 1,gz);
}
if (groundBlockIndex != -1)