mirror of https://github.com/OpenRCT2/OpenRCT2.git
Optimise tweening by skipping get_sprite() and its assert
This commit is contained in:
parent
560af48f85
commit
aa3dd894ee
|
@ -75,7 +75,7 @@ EVP_MD_CTX *gHashCTX = NULL;
|
|||
int _finished;
|
||||
|
||||
// Used for object movement tweening
|
||||
static struct { sint16 x, y, z; } _spritelocations1[MAX_SPRITES], _spritelocations2[MAX_SPRITES];
|
||||
static rct_xyz16 _spritelocations1[MAX_SPRITES], _spritelocations2[MAX_SPRITES];
|
||||
|
||||
static void openrct2_loop();
|
||||
static void openrct2_setup_rct2_hooks();
|
||||
|
@ -405,21 +405,13 @@ static void openrct2_loop()
|
|||
|
||||
while (uncapTick <= currentTick && currentTick - uncapTick > 25) {
|
||||
// Get the original position of each sprite
|
||||
for (uint16 i = 0; i < MAX_SPRITES; i++) {
|
||||
_spritelocations1[i].x = get_sprite(i)->unknown.x;
|
||||
_spritelocations1[i].y = get_sprite(i)->unknown.y;
|
||||
_spritelocations1[i].z = get_sprite(i)->unknown.z;
|
||||
}
|
||||
store_sprite_locations(_spritelocations1);
|
||||
|
||||
// Update the game so the sprite positions update
|
||||
rct2_update();
|
||||
|
||||
// Get the next position of each sprite
|
||||
for (uint16 i = 0; i < MAX_SPRITES; i++) {
|
||||
_spritelocations2[i].x = get_sprite(i)->unknown.x;
|
||||
_spritelocations2[i].y = get_sprite(i)->unknown.y;
|
||||
_spritelocations2[i].z = get_sprite(i)->unknown.z;
|
||||
}
|
||||
store_sprite_locations(_spritelocations2);
|
||||
|
||||
uncapTick += 25;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,18 @@ rct_sprite *get_sprite(size_t sprite_idx)
|
|||
return &_spriteList[sprite_idx];
|
||||
}
|
||||
|
||||
void store_sprite_locations(rct_xyz16 * sprite_locations)
|
||||
{
|
||||
for (uint16 i = 0; i < MAX_SPRITES; i++) {
|
||||
// skip going through `get_sprite` to not get stalled on assert,
|
||||
// this can get very expensive for busy parks with uncap FPS option on
|
||||
const rct_sprite *sprite = &_spriteList[i];
|
||||
sprite_locations[i].x = sprite->unknown.x;
|
||||
sprite_locations[i].y = sprite->unknown.y;
|
||||
sprite_locations[i].z = sprite->unknown.z;
|
||||
}
|
||||
}
|
||||
|
||||
uint16 sprite_get_first_in_quadrant(int x, int y)
|
||||
{
|
||||
int offset = ((x & 0x1FE0) << 3) | (y >> 5);
|
||||
|
|
|
@ -400,6 +400,7 @@ enum {
|
|||
};
|
||||
|
||||
rct_sprite *get_sprite(size_t sprite_idx);
|
||||
void store_sprite_locations(rct_xyz16 *sprite_locations);
|
||||
|
||||
// rct2: 0x00982708
|
||||
extern rct_sprite_entry g_sprite_entries[48];
|
||||
|
|
Loading…
Reference in New Issue