Add particles

This commit is contained in:
Miloslav Ciz 2025-04-20 19:38:13 +02:00
parent 06c1d1c42e
commit d905718bab
6 changed files with 105 additions and 51 deletions

View file

@ -127,6 +127,8 @@ struct
LCR_GameUnit carSpeeds[2]; /**< Signed speed in game units per tick (negative
if backwards) and its previous value. */
uint8_t groundMaterial; ///< Material currently under car wheels.
uint16_t crashState;
uint8_t playingReplay;
@ -154,6 +156,16 @@ TPE_Vec3 _LCR_TPE_vec3DividePlain(TPE_Vec3 v, TPE_Unit d)
return v;
}
static inline int LCR_racingCarIsDrifting(void)
{
return LCR_racing.carDrifting;
}
static inline uint8_t LCR_racingCurrentGroundMaterial(void)
{
return LCR_racing.groundMaterial;
}
/**
Initializes replay for recording.
*/
@ -1139,10 +1151,11 @@ uint32_t LCR_racingStep(unsigned int input)
uint32_t result = 0;
TPE_Vec3 carForw, carRight, carUp, carVel;
uint8_t groundMat = LCR_BLOCK_MATERIAL_CONCRETE; // material under wheels
uint8_t onAccel = 0; // standing on accelerator?
int groundBlockIndex = -1;
TPE_Unit driftFriction = 0; // average wheel friction (absolute value)
LCR_racing.groundMaterial = LCR_BLOCK_MATERIAL_CONCRETE;
if (LCR_racing.playingReplay)
{
@ -1233,13 +1246,13 @@ uint32_t LCR_racingStep(unsigned int input)
result |= LCR_RACING_EVENT_FAN;
}
groundMat = LCR_mapBlockGetMaterial(
LCR_racing.groundMaterial = LCR_mapBlockGetMaterial(
LCR_currentMap.blocks + groundBlockIndex * LCR_BLOCK_SIZE);
}
}
LCR_racing.carBody.friction =
_LCR_applyMaterialFactor(LCR_CAR_FORWARD_FRICTION,groundMat);
_LCR_applyMaterialFactor(LCR_CAR_FORWARD_FRICTION,LCR_racing.groundMaterial);
if (onAccel)
{
@ -1309,13 +1322,15 @@ uint32_t LCR_racingStep(unsigned int input)
{
if (input & LCR_RACING_INPUT_FORW)
{
_LCR_racingWheelAccelerate(0,carForw,groundMat,onAccel);
_LCR_racingWheelAccelerate(1,carForw,groundMat,onAccel);
_LCR_racingWheelAccelerate(0,carForw,LCR_racing.groundMaterial,onAccel);
_LCR_racingWheelAccelerate(1,carForw,LCR_racing.groundMaterial,onAccel);
}
else if (input & LCR_RACING_INPUT_BACK)
{
_LCR_racingWheelAccelerate(0,TPE_vec3TimesPlain(carForw,-1),groundMat,onAccel);
_LCR_racingWheelAccelerate(1,TPE_vec3TimesPlain(carForw,-1),groundMat,onAccel);
_LCR_racingWheelAccelerate(0,TPE_vec3TimesPlain(carForw,-1),
LCR_racing.groundMaterial,onAccel);
_LCR_racingWheelAccelerate(1,TPE_vec3TimesPlain(carForw,-1),
LCR_racing.groundMaterial,onAccel);
}
}
@ -1347,7 +1362,7 @@ uint32_t LCR_racingStep(unsigned int input)
_LCR_applyMaterialFactor(
LCR_racing.carDrifting ?
(LCR_CAR_STEER_FRICTION * LCR_CAR_DRIFT_FACTOR) / 8 :
LCR_CAR_STEER_FRICTION,groundMat)) / TPE_F);
LCR_CAR_STEER_FRICTION,LCR_racing.groundMaterial)) / TPE_F);
driftFriction += TPE_vec3Len(fric);