Tinker with physics a bit

This commit is contained in:
Miloslav Ciz 2025-04-28 16:06:36 +02:00
parent 71a034d74c
commit 9dfbeae0d4
3 changed files with 29 additions and 17 deletions

View file

@ -2,6 +2,12 @@ fuck issue trackers :D
=========== GENERAL ==============
- try to prevent car getting stuck at extreme speed by may just hard stopping
it if it ends up unresolved?
- car shadow idea: have shadow model, during rendering check each new triangle
agains car XY, record height, then set maimum height to shadow
- Managed to get the car stuck in non-rotating state, then after a while get
it back by crashing. MAY BE FIXED NOW, watch if it still happens
- press forward map??? :-D
- make some kinda repo for world record runs?
- fix the ramp map again due to new physics -- NOW it's almost good but it's
@ -41,6 +47,10 @@ fuck issue trackers :D
- immediately after starting the map countdown seems to be lower (seems to
perhaps be caused by nextPhysicsFrameTime, look into it)
- seems like there might be a bug in physics env function, despite it being
impossible in theory, car gets stuck after fast drive into a wall, with its
shape staying OK, but wheel being inside a block somehow, maybe there are
tiny spaces between blocks or some blocks are not checked -- resolve
=========== HANDLED ==============

View file

@ -514,9 +514,7 @@ static const char *LCR_internalDataFile =
":^C0C-I:fb11:^C1E-I:fb11:^C2F-I:fb11"
":vC2wL-:vC2F-:vM2wI-:vM2FJ-"
// top:
":^Few2:f411:^FeF2I:f411"
":vFew2L:vFeF2:vJew2I:vJeF2J"
// vertical corners:
":-Few2:f411:-FeF2:f411"
":AC3w|:f1b1:AM3w:f1b1"
":AC3FI:f1b1:AM3FL:f1b1"
// ramps:
@ -527,7 +525,7 @@ static const char *LCR_internalDataFile =
":'C1D:fb11"
":<C1C:fb11"
// finish:
":!Hgx:!HgE"
":!Hgx:!Hgw:!HgE:!HgF"
// TINY MAP 5:

View file

@ -1475,7 +1475,22 @@ uint32_t LCR_racingStep(unsigned int input)
{
TPE_Joint tmpJoint = LCR_racing.carBody.joints[i];
LCR_racing.carBody.joints[i] = joints[i];
joints[i] = tmpJoint;
if (LCR_racing.carBody.flags & TPE_BODY_FLAG_UNRESOLVED)
{
// if unsuccessful, keep the original pre-step pos. and decrease speed
joints[i].velocity[0] /= 2;
joints[i].velocity[1] /= 2;
joints[i].velocity[2] /= 2;
}
else
{
// in normal case back up this step and revert the body total lin. vel.
joints[i] = tmpJoint;
joints[i].velocity[0] /= LCR_CAR_JOINTS;
joints[i].velocity[1] /= LCR_CAR_JOINTS;
joints[i].velocity[2] /= LCR_CAR_JOINTS;
}
}
LCR_racing.carBody.flags &= ~TPE_BODY_FLAG_NONROTATING;
@ -1487,19 +1502,8 @@ uint32_t LCR_racingStep(unsigned int input)
{
LCR_LOG2("using simplified physics");
for (int i = 0; i < LCR_CAR_JOINTS; ++i) // use the first step positions
for (int i = 0; i < LCR_CAR_JOINTS; ++i) // use the first step result
LCR_racing.carBody.joints[i] = joints[i];
// If still not OK (slim chance), just stop the body (prevent uberbugs):
if ((LCR_racing.carBody.flags & TPE_BODY_FLAG_UNRESOLVED) ||
!_LCR_racingCarShapeOK())
{
TPE_bodyStop(&LCR_racing.carBody);
for (int k = 0; k < 2 * TPE_RESHAPE_ITERATIONS; ++k)
TPE_bodyReshape(&LCR_racing.carBody,_LCR_racingEnvironmentFunction);
}
}
}