Add some constants

This commit is contained in:
Miloslav Ciz 2025-02-02 01:37:28 +01:00
parent e47704dbb0
commit f24db847ce

View file

@ -66,6 +66,10 @@ typedef int32_t LCR_GameUnit; ///< abstract game unit
#define LCR_CAR_STEER_SPEED (LCR_GAME_UNIT / 17) #define LCR_CAR_STEER_SPEED (LCR_GAME_UNIT / 17)
#define LCR_CAR_STEER_MAX (LCR_GAME_UNIT / 2) #define LCR_CAR_STEER_MAX (LCR_GAME_UNIT / 2)
#define LCR_CAR_ACCELERATOR_FACTOR 2
#define LCR_CAR_WHEEL_AIR_ROTATION_SPEED (LCR_GAME_UNIT / 32)
#define LCR_CAR_WHEEL_GROUND_SPEED_DIV 8
#define LCR_CAR_DRIFT_THRESHOLD_1 (LCR_GAME_UNIT / 4) #define LCR_CAR_DRIFT_THRESHOLD_1 (LCR_GAME_UNIT / 4)
#define LCR_CAR_DRIFT_THRESHOLD_0 (LCR_GAME_UNIT / 200) #define LCR_CAR_DRIFT_THRESHOLD_0 (LCR_GAME_UNIT / 200)
@ -1080,7 +1084,7 @@ void _LCR_racingWheelAccelerate(unsigned int wheel, TPE_Vec3 dir,
acc = acc / (1 + (LCR_racingGetCarSpeedUnsigned() / LCR_CAR_AIR_FRICTION)); acc = acc / (1 + (LCR_racingGetCarSpeedUnsigned() / LCR_CAR_AIR_FRICTION));
if (accelerator) if (accelerator)
acc *= 2; // TODO: constant? acc *= LCR_CAR_ACCELERATOR_FACTOR;
LCR_racing.carBody.joints[wheel].velocity[0] += (dir.x * acc) / TPE_F; LCR_racing.carBody.joints[wheel].velocity[0] += (dir.x * acc) / TPE_F;
LCR_racing.carBody.joints[wheel].velocity[1] += (dir.y * acc) / TPE_F; LCR_racing.carBody.joints[wheel].velocity[1] += (dir.y * acc) / TPE_F;
@ -1163,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 (upDot > TPE_F / 8 || upDot < -1 * TPE_F / 8) // TODO: consts // if car is "somwhat" upwards (TPE_F / 8 is a hardcoded constant):
if (upDot > TPE_F / 8 || upDot < -1 * TPE_F / 8)
{ {
uint8_t uint8_t
gx = (LCR_racing.carPositions[0].x + (LCR_MAP_SIZE_BLOCKS / 2) * gx = (LCR_racing.carPositions[0].x + (LCR_MAP_SIZE_BLOCKS / 2) *
@ -1173,6 +1178,13 @@ 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);
@ -1239,7 +1251,8 @@ uint32_t LCR_racingStep(unsigned int input)
{ {
LCR_GameUnit rotateBy = LCR_GameUnit rotateBy =
(LCR_racing.wheelCollisions & 0x0f) ? // on ground slow down wheel rot. (LCR_racing.wheelCollisions & 0x0f) ? // on ground slow down wheel rot.
(LCR_racingGetCarSpeedUnsigned() / 8) : LCR_GAME_UNIT / 32; (LCR_racingGetCarSpeedUnsigned() / LCR_CAR_WHEEL_GROUND_SPEED_DIV) :
LCR_CAR_WHEEL_AIR_ROTATION_SPEED;
if (!(input & LCR_RACING_INPUT_BACK)) if (!(input & LCR_RACING_INPUT_BACK))
rotateBy *= -1; rotateBy *= -1;