Continue antiglitch
This commit is contained in:
parent
10366c2a09
commit
4a3c9b2873
1 changed files with 18 additions and 11 deletions
17
racing.h
17
racing.h
|
@ -583,6 +583,8 @@ void LCR_racingStep(unsigned int input)
|
|||
(!(input & LCR_RACING_INPUT_RIGHT)))
|
||||
LCR_racing.wheelSteer /= 2;
|
||||
|
||||
|
||||
|
||||
if ((LCR_racing.wheelCollisions & 0x0f) != 0x0f) // EXPERIMENTAL: don't apply gravity with all wheels on ground
|
||||
TPE_bodyApplyGravity(&(LCR_racing.carBody),LCR_GRAVITY);
|
||||
|
||||
|
@ -671,8 +673,9 @@ if ((LCR_racing.carBody.flags & TPE_BODY_FLAG_UNRESOLVED) ||
|
|||
|
||||
for (int i = 0; i < LCR_CAR_JOINTS; ++i)
|
||||
{
|
||||
// iterate towards previous OK position
|
||||
|
||||
if (LCR_racing.carNotOKCount < 30) // TODO: const
|
||||
{
|
||||
// for a while try to smoothly iterate towards previous OK position
|
||||
LCR_racing.carBody.joints[i].position =
|
||||
TPE_vec3Plus(LCR_racing.carBody.joints[i].position,
|
||||
LCR_racing.carOKPositions[i]);
|
||||
|
@ -680,19 +683,23 @@ if ((LCR_racing.carBody.flags & TPE_BODY_FLAG_UNRESOLVED) ||
|
|||
LCR_racing.carBody.joints[i].position.x /= 2;
|
||||
LCR_racing.carBody.joints[i].position.y /= 2;
|
||||
LCR_racing.carBody.joints[i].position.z /= 2;
|
||||
}
|
||||
else // hard set the pos (iteration may be infinite due to sim.)
|
||||
LCR_racing.carBody.joints[i].position = LCR_racing.carOKPositions[i];
|
||||
|
||||
for (int j = 0; j < 3; ++j) // lower speed a bit
|
||||
LCR_racing.carBody.joints[i].velocity[j] =
|
||||
(7 * ((int) LCR_racing.carBody.joints[i].velocity[j])) / 8;
|
||||
}
|
||||
}
|
||||
else
|
||||
LCR_racing.carNotOKCount++;
|
||||
|
||||
LCR_racing.carNotOKCount += LCR_racing.carNotOKCount < 32 ? 1 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// car OK
|
||||
LCR_racing.carNotOKCount -= LCR_racing.carNotOKCount ? 1 : 0;
|
||||
// LCR_racing.carNotOKCount -= LCR_racing.carNotOKCount ? 1 : 0;
|
||||
LCR_racing.carNotOKCount = 0;
|
||||
|
||||
for (int i = 0; i < LCR_CAR_JOINTS; ++i)
|
||||
LCR_racing.carOKPositions[i] = LCR_racing.carBody.joints[i].position;
|
||||
|
|
Loading…
Reference in a new issue