Fix car sliding

This commit is contained in:
Miloslav Ciz 2025-03-03 17:02:41 +01:00
parent 745067d8cc
commit 72b28f2bb0
3 changed files with 13 additions and 5 deletions

View file

@ -1,5 +1,6 @@
=========== GENERAL ============== =========== GENERAL ==============
- car deglitch idea: deglitch only if the middle joint collided this frame?
- some kinda easteregg in menu or smt - some kinda easteregg in menu or smt
- make the U-ramp map taller due to new physics - make the U-ramp map taller due to new physics
- replay format should probably record game version - replay format should probably record game version

View file

@ -1156,11 +1156,13 @@ uint32_t LCR_racingStep(unsigned int input)
LCR_racing.carBody.joints[4].velocity[1], LCR_racing.carBody.joints[4].velocity[1],
LCR_racing.carBody.joints[4].velocity[2]); LCR_racing.carBody.joints[4].velocity[2]);
// apply gravity only if wheels are on the ground (prevents sliding a bit): /* Apply gravity like this: if all wheels are on ground, we don't apply
gravity to roof. This helps prevent sliding. */
if (((LCR_racing.wheelCollisions | (LCR_racing.wheelCollisions >> 4)) for (i = 0; i < 5; ++i)
& 0x0f) != 0x0f) if (i < 4 || (((LCR_racing.wheelCollisions |
TPE_bodyApplyGravity(&(LCR_racing.carBody),LCR_GRAVITY); (LCR_racing.wheelCollisions >> 4)) & 0x0f) != 0x0f))
LCR_racing.carBody.joints[i].velocity[1] -= LCR_GRAVITY;
if (LCR_racing.wheelCollisions) // at least one wheel on ground? if (LCR_racing.wheelCollisions) // at least one wheel on ground?
{ {

View file

@ -2,6 +2,9 @@
#define _TINYPHYSICSENGINE_H #define _TINYPHYSICSENGINE_H
/** /**
NOTE: This is a Licar specific fork of the library. Changes made can be
found e.g. with diff.
tinyphysicsengine (TPE) tinyphysicsengine (TPE)
Simple/suckless header-only hybrid 3D physics engine with no floating point, Simple/suckless header-only hybrid 3D physics engine with no floating point,
@ -1038,7 +1041,9 @@ void TPE_worldStep(TPE_World *world)
if (hard) if (hard)
{ {
TPE_bodyReshape(body,world->environmentFunction); /* Licar modification: we only reshape if the tension requires it. This
prevents car from sliding when standing on ground. */
// TPE_bodyReshape(body,world->environmentFunction);
bodyTension /= body->connectionCount; bodyTension /= body->connectionCount;