Interpolate rotations
This commit is contained in:
parent
f83e7f519d
commit
09031d209d
3 changed files with 36 additions and 17 deletions
9
TODO.txt
9
TODO.txt
|
@ -2,10 +2,7 @@ fuck issue trackers :D
|
||||||
|
|
||||||
=========== GENERAL ==============
|
=========== GENERAL ==============
|
||||||
|
|
||||||
- stop playing engine sound when replay finishes
|
|
||||||
- LCR_SETTING_TEXTURE_SUBSAMPLE = 0 should turn off texturing completely
|
- LCR_SETTING_TEXTURE_SUBSAMPLE = 0 should turn off texturing completely
|
||||||
- maybe address the jerky rotations? or not?
|
|
||||||
- add (digital) controller support to SDL and CSFML?
|
|
||||||
- frontends:
|
- frontends:
|
||||||
- auto test frontend, with no I/O, that will just internally run a series of
|
- auto test frontend, with no I/O, that will just internally run a series of
|
||||||
inputs and check if the output is as expected
|
inputs and check if the output is as expected
|
||||||
|
@ -17,7 +14,7 @@ fuck issue trackers :D
|
||||||
- linux framebuffer?
|
- linux framebuffer?
|
||||||
- make some kinda repo for world record runs? how will they submit it?
|
- make some kinda repo for world record runs? how will they submit it?
|
||||||
- final tests:
|
- final tests:
|
||||||
- check every single setting individually
|
- check every single setting individually DID 1x
|
||||||
- very long replay DID 1x
|
- very long replay DID 1x
|
||||||
- absence of music file
|
- absence of music file
|
||||||
- different resolutions KINDA DID 1x
|
- different resolutions KINDA DID 1x
|
||||||
|
@ -86,6 +83,10 @@ fuck issue trackers :D
|
||||||
theory they should (enough block space to load): try to set the exact same
|
theory they should (enough block space to load): try to set the exact same
|
||||||
settings on PC and see if the maps load or what. IT'S BCS BUILDING THE MAP
|
settings on PC and see if the maps load or what. IT'S BCS BUILDING THE MAP
|
||||||
TEMPORARILY REQUIRES MORE BLOCKS
|
TEMPORARILY REQUIRES MORE BLOCKS
|
||||||
|
- maybe address the jerky rotations? or not?
|
||||||
|
- stop playing engine sound when replay finishes
|
||||||
|
- add (digital) controller support to SDL and CSFML? NOT NOW, doesn't wanna
|
||||||
|
detect it or something (or either PC)
|
||||||
- on arduinos for some reason straight triangles (floor, walls, ...) on map
|
- on arduinos for some reason straight triangles (floor, walls, ...) on map
|
||||||
don't fucking display, they seem to not be added at all, but maybe it's
|
don't fucking display, they seem to not be added at all, but maybe it's
|
||||||
something with the "instability" due to low memory... HOWEVER on ringo (enough
|
something with the "instability" due to low memory... HOWEVER on ringo (enough
|
||||||
|
|
8
game.h
8
game.h
|
@ -1865,6 +1865,14 @@ uint8_t LCR_gameStep(uint32_t time)
|
||||||
|
|
||||||
int engineIntensity = LCR_carSpeedKMH() * 2;
|
int engineIntensity = LCR_carSpeedKMH() * 2;
|
||||||
|
|
||||||
|
if (LCR_game.state == LCR_GAME_STATE_RUN_FINISHED)
|
||||||
|
{
|
||||||
|
engineIntensity -= LCR_game.time - LCR_game.stateStartTime;
|
||||||
|
|
||||||
|
if (engineIntensity < 0)
|
||||||
|
engineIntensity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
LCR_audioSetEngineIntensity(paused ? 0 :
|
LCR_audioSetEngineIntensity(paused ? 0 :
|
||||||
(engineIntensity < 256 ? engineIntensity : 255));
|
(engineIntensity < 256 ? engineIntensity : 255));
|
||||||
|
|
||||||
|
|
36
racing.h
36
racing.h
|
@ -945,18 +945,27 @@ uint8_t _LCR_racingCollisionHandler(uint16_t b1, uint16_t j1, uint16_t b2,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LCR_GameUnit _LCR_racingSmoothRot(LCR_GameUnit angleNew, LCR_GameUnit angleOld)
|
LCR_GameUnit _LCR_racingInterpolateRot(LCR_GameUnit angleNew,
|
||||||
|
LCR_GameUnit angleOld, LCR_GameUnit interpolationParam)
|
||||||
{
|
{
|
||||||
/* We'll smooth small rotations by averaging the last two angles; bigger
|
angleNew %= LCR_GAME_UNIT;
|
||||||
rotations won't be smoothed -- firstly this removes lag for fast rotations
|
|
||||||
and also deals with the issue of averaging e.g. 1 and 359 degrees. */
|
if (angleNew < 0)
|
||||||
|
angleNew += LCR_GAME_UNIT;
|
||||||
|
|
||||||
|
angleOld %= LCR_GAME_UNIT;
|
||||||
|
|
||||||
|
if (angleOld < 0)
|
||||||
|
angleOld += LCR_GAME_UNIT;
|
||||||
|
|
||||||
LCR_GameUnit diff = angleNew - angleOld;
|
LCR_GameUnit diff = angleNew - angleOld;
|
||||||
|
|
||||||
if (diff > LCR_GAME_UNIT / 8 || diff < -1 * LCR_GAME_UNIT / 8)
|
LCR_GameUnit diff2 = (diff > 0) ?
|
||||||
return angleNew;
|
-1 * (LCR_GAME_UNIT - diff) :
|
||||||
|
(LCR_GAME_UNIT + diff);
|
||||||
|
|
||||||
return angleOld + diff / 2;
|
return angleOld + ((TPE_abs(diff) < TPE_abs(diff2) ?
|
||||||
|
diff : diff2) * interpolationParam) / LCR_GAME_UNIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
TPE_Vec3 _LCR_racingGetWheelCenterPoint(void)
|
TPE_Vec3 _LCR_racingGetWheelCenterPoint(void)
|
||||||
|
@ -1121,12 +1130,13 @@ void LCR_racingGetCarTransform(LCR_GameUnit position[3],
|
||||||
position[1] = v.y;
|
position[1] = v.y;
|
||||||
position[2] = v.z;
|
position[2] = v.z;
|
||||||
|
|
||||||
rotation[0] = _LCR_racingSmoothRot(LCR_racing.carRotations[0].x,
|
rotation[0] = _LCR_racingInterpolateRot(LCR_racing.carRotations[0].x,
|
||||||
LCR_racing.carRotations[1].x);
|
LCR_racing.carRotations[1].x,interpolationParam);
|
||||||
rotation[1] = _LCR_racingSmoothRot(LCR_racing.carRotations[0].y,
|
rotation[1] = _LCR_racingInterpolateRot(LCR_racing.carRotations[0].y,
|
||||||
LCR_racing.carRotations[1].y);
|
LCR_racing.carRotations[1].y,interpolationParam);
|
||||||
rotation[2] = _LCR_racingSmoothRot(LCR_racing.carRotations[0].z,
|
rotation[2] = _LCR_racingInterpolateRot(LCR_racing.carRotations[0].z,
|
||||||
LCR_racing.carRotations[1].z);
|
LCR_racing.carRotations[1].z,interpolationParam);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
position[0] = LCR_racing.carPositions[0].x;
|
position[0] = LCR_racing.carPositions[0].x;
|
||||||
position[1] = LCR_racing.carPositions[0].y;
|
position[1] = LCR_racing.carPositions[0].y;
|
||||||
|
|
Loading…
Reference in a new issue