Add more accels and fans

This commit is contained in:
Miloslav Ciz 2024-12-18 13:01:27 +01:00
parent 7c3eac7d9f
commit 5d9038021a
5 changed files with 42 additions and 72 deletions

View file

@ -121,6 +121,7 @@ TPE_Vec3 _LCR_racingBlockEnvFunc(TPE_Vec3 point, const uint8_t *block)
{
case LCR_BLOCK_FULL:
case LCR_BLOCK_BOTTOM:
case LCR_BLOCK_BOTTOM_ACCEL:
case LCR_BLOCK_LEFT:
case LCR_BLOCK_BOTTOM_LEFT:
case LCR_BLOCK_BOTTOM_LEFT_FRONT:
@ -133,6 +134,7 @@ TPE_Vec3 _LCR_racingBlockEnvFunc(TPE_Vec3 point, const uint8_t *block)
LCR_PHYSICS_UNIT / 2);
if (block[0] == LCR_BLOCK_BOTTOM ||
block[0] == LCR_BLOCK_BOTTOM_ACCEL ||
block[0] == LCR_BLOCK_BOTTOM_LEFT ||
block[0] == LCR_BLOCK_BOTTOM_LEFT_FRONT)
{
@ -306,6 +308,8 @@ TPE_Vec3 _LCR_racingBlockEnvFunc(TPE_Vec3 point, const uint8_t *block)
case LCR_BLOCK_RAMP_12:
case LCR_BLOCK_RAMP_14:
case LCR_BLOCK_RAMP_STEEP:
case LCR_BLOCK_RAMP_ACCEL:
case LCR_BLOCK_RAMP_FAN:
{
uint8_t front, top;
LCR_rampGetDimensions(block[0],&top,&front);
@ -629,11 +633,6 @@ void LCR_racingInit(void)
{
LCR_LOG0("initializing racing engine");
TPE_worldInit(&(LCR_racing.physicsWorld),
&(LCR_racing.carBody),1,_LCR_racingEnvironmentFunction);
@ -1014,45 +1013,10 @@ uint32_t LCR_racingStep(unsigned int input)
LCR_racing.carSpeed = (TPE_vec3Len(carVel) * LCR_GAME_UNIT)
/ LCR_PHYSICS_UNIT;
if (TPE_vec3Dot(carVel,carForw) < 0)
LCR_racing.carSpeed *= -1;
_LCR_racingUpdateCarPosRot();
/*
TPE_Vec3 tmpVec = LCR_racing.carPositions[0];
TPE_Vec3 wheelAverage = _LCR_TPE_vec3DividePlain(
TPE_vec3Plus(
TPE_vec3Plus(
LCR_racing.carBody.joints[0].position,
LCR_racing.carBody.joints[1].position),
TPE_vec3Plus(
LCR_racing.carBody.joints[2].position,
LCR_racing.carBody.joints[3].position)),4);
LCR_racing.carPositions[0] = _LCR_TPE_vec3DividePlain(
TPE_vec3TimesPlain(wheelAverage,LCR_GAME_UNIT),LCR_PHYSICS_UNIT);
LCR_racing.carPositions[0] = // smooth the position
TPE_vec3KeepWithinBox(LCR_racing.carPositions[1],LCR_racing.carPositions[0],
TPE_vec3(
LCR_PHYSICS_UNIT / 64, // TODO: constant
LCR_PHYSICS_UNIT / 64,
LCR_PHYSICS_UNIT / 64));
LCR_racing.carPositions[1] = tmpVec;
tmpVec = _LCR_TPE_vec3DividePlain(TPE_vec3TimesPlain(TPE_bodyGetRotation(
&(LCR_racing.carBody),0,2,1),LCR_GAME_UNIT),TPE_F);
LCR_racing.carRotations[1] = LCR_racing.carRotations[0];
LCR_racing.carRotations[0] = tmpVec;
*/
if (TPE_vec3Dot(carVel,carForw) < 0)
LCR_racing.carSpeed *= -1;
_LCR_racingUpdateCarPosRot();
TPE_Unit angle = TPE_vec3Dot(carUp,TPE_vec3Normalized(TPE_vec3Minus(
LCR_racing.carBody.joints[4].position,
@ -1118,7 +1082,6 @@ _LCR_racingUpdateCarPosRot();
LCR_LOG1("car front pierced");
LCR_racing.carNotOKCount +=
//(LCR_racing.carNotOKCount < 15 ? 32 : 0); // TODO: consts
(LCR_racing.carNotOKCount < 20 ? 15 : 0); // TODO: consts
}