Modify wheel collisions
This commit is contained in:
parent
d794784bab
commit
e43ed793a3
3 changed files with 28 additions and 22 deletions
28
racing.h
28
racing.h
|
@ -875,9 +875,9 @@ void _LCR_racingUpdateCarPosRot(void)
|
|||
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_PHYSICS_UNIT / 128, // hardcoded consts
|
||||
LCR_PHYSICS_UNIT / 128,
|
||||
LCR_PHYSICS_UNIT / 128));
|
||||
|
||||
LCR_racing.carPositions[1] = tmpVec;
|
||||
|
||||
|
@ -1047,12 +1047,6 @@ void LCR_racingGetCarBlockCoords(int coords[3])
|
|||
(LCR_GAME_UNIT * LCR_MAP_SIZE_BLOCKS) / 2) / LCR_GAME_UNIT;
|
||||
}
|
||||
|
||||
int LCR_racingCarWheelTouchesGround(int wheel)
|
||||
{
|
||||
return ((LCR_racing.wheelCollisions & (LCR_racing.wheelCollisions >> 4))
|
||||
>> wheel) & 0x01;
|
||||
}
|
||||
|
||||
LCR_GameUnit LCR_racingGetWheelRotation(void)
|
||||
{
|
||||
return LCR_racing.wheelAngle;
|
||||
|
@ -1160,7 +1154,10 @@ uint32_t LCR_racingStep(unsigned int input)
|
|||
LCR_racing.carBody.joints[4].velocity[1],
|
||||
LCR_racing.carBody.joints[4].velocity[2]);
|
||||
|
||||
if ((LCR_racing.wheelCollisions & 0x0f) != 0x0f) // EXPERIMENTAL: don't apply gravity with all wheels on ground
|
||||
// apply gravity only if wheels are on the ground (prevents sliding a bit):
|
||||
|
||||
if (((LCR_racing.wheelCollisions | (LCR_racing.wheelCollisions >> 4))
|
||||
& 0x0f) != 0x0f)
|
||||
TPE_bodyApplyGravity(&(LCR_racing.carBody),LCR_GRAVITY);
|
||||
|
||||
if (LCR_racing.wheelCollisions) // at least one wheel on ground?
|
||||
|
@ -1229,8 +1226,7 @@ uint32_t LCR_racingStep(unsigned int input)
|
|||
{
|
||||
unsigned char steering = 0;
|
||||
|
||||
if ((input & LCR_RACING_INPUT_BACK) &&
|
||||
(LCR_racing.wheelCollisions & 0x0f) == 0x00) // in air?
|
||||
if ((input & LCR_RACING_INPUT_BACK) && LCR_racing.wheelCollisions == 0x00)
|
||||
{
|
||||
LCR_LOG2("air brake");
|
||||
|
||||
|
@ -1243,7 +1239,7 @@ uint32_t LCR_racingStep(unsigned int input)
|
|||
if (input & (LCR_RACING_INPUT_FORW | LCR_RACING_INPUT_BACK))
|
||||
{
|
||||
LCR_GameUnit rotateBy =
|
||||
(LCR_racing.wheelCollisions & 0x0f) ? // on ground slow down wheel rot.
|
||||
LCR_racing.wheelCollisions ? // on ground slow down wheel rot.
|
||||
(LCR_racingGetCarSpeedUnsigned() / LCR_CAR_WHEEL_GROUND_SPEED_DIV) :
|
||||
LCR_CAR_WHEEL_AIR_ROTATION_SPEED;
|
||||
|
||||
|
@ -1274,7 +1270,7 @@ uint32_t LCR_racingStep(unsigned int input)
|
|||
-1 * LCR_CAR_STEER_MAX);
|
||||
}
|
||||
|
||||
if ((LCR_racing.wheelCollisions & 0x0c)) // back wheel on ground?
|
||||
if ((LCR_racing.wheelCollisions & 0xcc)) // back wheel on ground?
|
||||
{
|
||||
if (input & LCR_RACING_INPUT_FORW)
|
||||
{
|
||||
|
@ -1291,7 +1287,7 @@ uint32_t LCR_racingStep(unsigned int input)
|
|||
TPE_Unit driftFriction = 0; // average wheel friction (absolute value)
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
if (LCR_racing.wheelCollisions & (0x01 << i)) // wheel on ground?
|
||||
if (LCR_racing.wheelCollisions & (0x11 << i)) // wheel on ground?
|
||||
{
|
||||
TPE_Vec3 jv = TPE_vec3( // joint velocity
|
||||
LCR_racing.carBody.joints[i].velocity[0],
|
||||
|
@ -1346,7 +1342,7 @@ uint32_t LCR_racingStep(unsigned int input)
|
|||
|
||||
if (steering &&
|
||||
(input & (LCR_RACING_INPUT_FORW | LCR_RACING_INPUT_BACK)) &&
|
||||
(LCR_racing.wheelCollisions & 0x0f))
|
||||
(LCR_racing.wheelCollisions & 0x33))
|
||||
{
|
||||
/* When steering, also slightly spin the car. This helps fix the car
|
||||
getting "stuck" by its side to a wall when too close, becoming unable
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue