Correst ghost position
This commit is contained in:
parent
4eb589d981
commit
5141a31770
2 changed files with 14 additions and 41 deletions
15
game.h
15
game.h
|
@ -361,6 +361,7 @@ struct
|
|||
uint8_t stretch; /**< Stretch of the base sample step, as a bit shift
|
||||
(i.e. 1 means the step will be 2x as long etc.). This
|
||||
is to allow ghosts for even long replays. */
|
||||
int16_t offset[3]; ///< Small correcting position offset.
|
||||
} ghost;
|
||||
#endif
|
||||
|
||||
|
@ -538,7 +539,7 @@ void LCR_gameGhostGetTransform(uint32_t frame,
|
|||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
position[i] = position[i] + ((carTransform[i] - position[i]) * n) /
|
||||
LCR_SETTING_GHOST_STEP;
|
||||
LCR_SETTING_GHOST_STEP + LCR_game.ghost.offset[i];
|
||||
|
||||
// rotations are a bit harder to interpolate (e.g. 1 -> 359 deg.)
|
||||
carTransform[3 + i] -= rotation[i];
|
||||
|
@ -554,11 +555,6 @@ void LCR_gameGhostGetTransform(uint32_t frame,
|
|||
/ LCR_SETTING_GHOST_STEP)) % LCR_GAME_UNIT;
|
||||
}
|
||||
}
|
||||
|
||||
// offset (correct rounding down):
|
||||
position[0] += LCR_GAME_UNIT / 16;
|
||||
position[1] += LCR_GAME_UNIT / 16;
|
||||
position[2] += LCR_GAME_UNIT / 16;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -635,6 +631,13 @@ void _LCR_gamePrepareGhost(void)
|
|||
*currentSample = *(currentSample - LCR_GHOST_SAMPLE_SIZE);
|
||||
currentSample++;
|
||||
}
|
||||
|
||||
LCR_gameGetNthGhostSample(0,carTransform,carTransform + 3);
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
LCR_game.ghost.offset[i] = (((((int) LCR_currentMap.startPos[i]) -
|
||||
LCR_MAP_SIZE_BLOCKS / 2) * LCR_GAME_UNIT + LCR_GAME_UNIT / 2)
|
||||
/ (i == 1 ? 2 : 1)) - carTransform[i];
|
||||
}
|
||||
|
||||
LCR_GameUnit LCR_carSpeedKMH(void)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue