Skip to content

Correctly offset room sprites based on their size#1415

Merged
chreden merged 2 commits intomasterfrom
issue/1414
May 16, 2025
Merged

Correctly offset room sprites based on their size#1415
chreden merged 2 commits intomasterfrom
issue/1414

Conversation

@chreden
Copy link
Owner

@chreden chreden commented May 16, 2025

Room sprite offset was assuming that sprites were had equal size on either side of the centre y.
Take into account sprite like the dangling vines that need to be moved up, not down and not just by half the object height.
Closes #1414

Room sprite offset was assuming that sprites were had equal size on either side of the centre y. Take into account sprite like the dangling vines that need to be moved up, not down.
Closes #1414
@chreden chreden added this to the Next milestone May 16, 2025
@chreden chreden requested review from lahm86 and makotocchi May 16, 2025 12:07
@chreden chreden self-assigned this May 16, 2025
@chreden chreden added bug TR2 Tomb Raider II TR1 Tomb Raider I labels May 16, 2025
@chreden chreden enabled auto-merge (squash) May 16, 2025 12:24
if (offset_mode == SpriteOffsetMode::RoomSprite)
{
offset = Vector3(0, (1 - object_height) * 0.5f, 0);
const float y_factor = (-0.5f + ((fabs(static_cast<float>(top)) / (bottom - top))));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth a guard in case bottom == top? Just thinking of TRLE world.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, not sure why they'd do that but good to avoid the div by 0

@chreden chreden merged commit 03baff6 into master May 16, 2025
1 check passed
@chreden chreden deleted the issue/1414 branch May 16, 2025 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug TR1 Tomb Raider I TR2 Tomb Raider II

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some room sprites are incorrectly positioned

2 participants