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

@ -67,7 +67,7 @@ static const char *LCR_internalDataFile =
":vw0l0L" ":vw0l0L"
":vx0l0I" ":vx0l0I"
":-s0q0" ":-s0q1"
":;p0w0L :f5130" // bugs ":;p0w0L :f5130" // bugs
@ -84,11 +84,11 @@ static const char *LCR_internalDataFile =
":~t1t2 :~u1t2 :~t1u2" // bumps ":~t1t2 :~u1t2 :~t1u2" // bumps
":^t0r0 :fq110 " // ramps ":^t0r0 :fq110 " // ramps
":}n0lJ :|n1lJ :|n3lJ- :]n4lJ- :=o0l :f151" // loop ":}n0l1J :|n1l1J :|n3l1J- :]n4l1J- :=o0l1 :f151" // loop
":]n0mJ :|n1mJ :|n3mJ- :]n4mJ- :=o0m :f151" // loop ":]n0m1J :|n1m1J :|n3m1J- :]n4m1J- :=o0m1 :f151" // loop
":}l0kL :|l1kL :|l3kL- :]l4kL- :=k0k :f151" ":}l0k1L :|l1k1L :|l3k1L- :]l4k1L- :=k0k1 :f151"
":]l0jL :|l1jL :|l3jL- :]l4jL- :=k0j :f151" ":]l0j1L :|l1j1L :|l3j1L- :]l4j1L- :=k0j1 :f151"
":-k5k0 :f5120" ":-k5k1 :f5120"
" map end " " map end "
"#Rrep1;testmap;482f70f9 00000188:00c1:0089:0111:00b9:0091:0109:0028:0050:00c1:0093:0030:00d1:0069:0041:0020:0071:0013:0012:0023:0022:0050:0032:0020:0022:0060:0024:00bc:0044" "#Rrep1;testmap;482f70f9 00000188:00c1:0089:0111:00b9:0091:0109:0028:0050:00c1:0093:0030:00d1:0069:0041:0020:0071:0013:0012:0023:0022:0050:0032:0020:0022:0060:0024:00bc:0044"

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)); 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) if (upDot > TPE_F / 8 || upDot < -1 * TPE_F / 8)
{ {
uint8_t uint8_t
@ -1178,23 +1179,17 @@ uint32_t LCR_racingStep(unsigned int input)
gz = (LCR_racing.carPositions[0].z + (LCR_MAP_SIZE_BLOCKS / 2) * gz = (LCR_racing.carPositions[0].z + (LCR_MAP_SIZE_BLOCKS / 2) *
LCR_GAME_UNIT) / LCR_GAME_UNIT; 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 * TPE_Unit yMod = (LCR_racing.carPositions[0].y + LCR_MAP_SIZE_BLOCKS *
LCR_GAME_UNIT / 2) % (LCR_GAME_UNIT / 2); 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); 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) if (groundBlockIndex == -1)
groundBlockIndex = LCR_mapGetBlockAt(gx,gy,gz); groundBlockIndex = LCR_mapGetBlockAt(gx,gy,gz);
if (groundBlockIndex == -1) // still nothing? try bottom again
groundBlockIndex = LCR_mapGetBlockAt(gx,gy - 1,gz);
} }
if (groundBlockIndex != -1) if (groundBlockIndex != -1)