-
Notifications
You must be signed in to change notification settings - Fork 477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug with all units' voxels flipped relative to Y axis #1423
Conversation
Center of inverted unit become (7,8) and Volutar deducted that empirically and made dirty fix in commit#757d674 which (fix, not the whole commit) can now be reverted. Big units loftemps loading logic was inverted too, and I've added quick workaround to not break anything
Thank you for the report. |
As I see, part of problem is |
"reorder" means "flip it too"? Now it's in right direction. 1 << X increments X from rigth to left, to counter that we flip terrain, and apply inverted X axis to inverted terrain. My proposal is to change units' in similar manner, don't touch (1<<x) code but keep solution uniform with older terrain code. The right solution, in my opinion, should be:
|
I ask SupSuper what version he prefer, he answer that your "hack" is preferred, this will have side effect that Probably for all this 6y everybody copy paste
|
As for upd: and by "the right solution" I mean "pure, but maybe not affordable". That's why my PR is what it is ) |
@narical Have you example of case where center |
Shifting occurs in case of 1-tile units, due to flipping them along X axis. In that case, their center point (8,8) shifts to (7,8). For big 2x2 units, loftemps loading was initially made to make correct cylinder with respect to X inversion. So fixing inversion means getting big units "inverted", and moves all 1-tile units 1 voxels to the right where they intended to be. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside C++02 incomparability change look fine
cb7e45f
to
6287c3f
Compare
I changed constexpr to const, commited to my branch, and pressed "resolve conversation" here |
This PR was now merged into OXCE too. |
Sometimes TileEngine::calculateLineVoxel() successfully creates the trajectory to voxel inside a unit, but returns V_EMPTY instead of V_UNIT. As it turned out, LOFTemps data is stored in memory in "right" direction, with positive X axis from left to right, but (1 << x) in code counts X axis in negative direction, from right to left. LOFTemp becomes effectively inverted from left to right, which moves unit slightly to the left. For terrain code, this effect negated by inverting X axis beforehand, just like that:
int x = 15 - voxel.x%16;
int y = voxel.y%16;
but the unit check does:
int x = voxel.x%16;
int y = voxel.y%16;
Also, in original X-Com it was 0x8000 >> x - just shifting X in positive direction, without double inverting it
Current 2x2 units loftemps loading logic is inverted too, so I've added workaround to not break anything (switching left/right parts).
Inverted units have new center at (7,8) - Volutar has deducted that empirically somehow and "fixed" in
757d674 so I reverted those too.
Images before and after a patch.