This commit is contained in:
Miloslav Ciz 2025-02-01 23:11:25 +01:00
parent 4cb558b85c
commit ccbb9dfdc3
3 changed files with 32 additions and 78 deletions

View file

@ -815,13 +815,12 @@ uint8_t _LCR_racingCollisionHandler(uint16_t b1, uint16_t j1, uint16_t b2,
// Detect crashes:
TPE_Unit speed = TPE_vec3Len(
TPE_vec3Project(
TPE_vec3(
LCR_racing.carBody.joints[j1].velocity[0],
LCR_racing.carBody.joints[j1].velocity[1],
LCR_racing.carBody.joints[j1].velocity[2]),
TPE_vec3Minus(p,
LCR_racing.carBody.joints[j1].position)));
TPE_vec3Project(TPE_vec3(
LCR_racing.carBody.joints[j1].velocity[0],
LCR_racing.carBody.joints[j1].velocity[1],
LCR_racing.carBody.joints[j1].velocity[2]),
TPE_vec3Minus(p,
LCR_racing.carBody.joints[j1].position)));
LCR_racing.crashState |= ((speed >= LCR_CAR_CRASH_SPEED_BIG) << 1) |
(speed >= LCR_CAR_CRASH_SPEED_SMALL);
@ -1064,18 +1063,9 @@ TPE_Unit _LCR_applyMaterialFactor(TPE_Unit value, uint8_t mat)
{
switch (mat)
{
case LCR_BLOCK_MATERIAL_GRASS:
value *= LCR_CAR_GRASS_FACTOR;
break;
case LCR_BLOCK_MATERIAL_DIRT:
value *= LCR_CAR_DIRT_FACTOR;
break;
case LCR_BLOCK_MATERIAL_ICE:
value *= LCR_CAR_ICE_FACTOR;
break;
case LCR_BLOCK_MATERIAL_GRASS: value *= LCR_CAR_GRASS_FACTOR; break;
case LCR_BLOCK_MATERIAL_DIRT: value *= LCR_CAR_DIRT_FACTOR; break;
case LCR_BLOCK_MATERIAL_ICE: value *= LCR_CAR_ICE_FACTOR; break;
default: value *= 8; break;
}
@ -1085,8 +1075,7 @@ TPE_Unit _LCR_applyMaterialFactor(TPE_Unit value, uint8_t mat)
void _LCR_racingWheelAccelerate(unsigned int wheel, TPE_Vec3 dir,
uint8_t material, uint8_t accelerator)
{
TPE_Unit acc =
_LCR_applyMaterialFactor(LCR_CAR_ACCELERATION,material);
TPE_Unit acc = _LCR_applyMaterialFactor(LCR_CAR_ACCELERATION,material);
acc = acc / (1 + (LCR_racingGetCarSpeedUnsigned() / LCR_CAR_AIR_FRICTION));