Fix bug and mod physics

This commit is contained in:
Miloslav Ciz 2025-04-15 15:04:19 +02:00
parent 00519e0116
commit 5c14eb6f45
2 changed files with 6 additions and 33 deletions

View file

@ -310,6 +310,10 @@ int LCR_replayLoadFromStr(char (*nextChar)(void),
c = nextChar();
}
for (int i = LCR_racing.replay.eventCount; // must be here
i < LCR_SETTING_REPLAY_MAX_SIZE; ++i)
LCR_racing.replay.events[i] = 0;
return 1;
}
@ -1495,37 +1499,6 @@ uint32_t LCR_racingStep(unsigned int input)
}
}
// now make a special test for a "pinch" front collision
TPE_Vec3 frontWheelMiddle = TPE_vec3Plus(
LCR_racing.carBody.joints[0].position,
LCR_racing.carBody.joints[1].position);
frontWheelMiddle.x /= 2;
frontWheelMiddle.y /= 2;
frontWheelMiddle.z /= 2;
frontWheelMiddle = TPE_vec3Minus(frontWheelMiddle,
_LCR_racingEnvironmentFunction(frontWheelMiddle,LCR_PHYSICS_UNIT / 4));
uint8_t frontCollision =
carForw.y < TPE_FRACTIONS_PER_UNIT / 4 && // only when car is horizontal
carForw.y > -1 * TPE_FRACTIONS_PER_UNIT / 4 &&
frontWheelMiddle.x == 0 && frontWheelMiddle.y == 0 &&
frontWheelMiddle.z == 0;
if (frontCollision)
{
// stop the front wheels
LCR_LOG1("car front pierced");
for (uint8_t i = 0; i < 3; ++i)
{
LCR_racing.carBody.joints[0].velocity[i] = 0;
LCR_racing.carBody.joints[1].velocity[i] = 0;
}
}
int carBlock[3];
LCR_racingGetCarBlockCoords(carBlock);