diff options
author | Jens Rottmann <30634967+JRottm@users.noreply.github.com> | 2017-08-04 21:48:32 +0200 |
---|---|---|
committer | SmallJoker <mk939@ymail.com> | 2018-06-03 17:31:59 +0200 |
commit | 90a9e4e69fac32f368b275428fa42407ea9b7883 (patch) | |
tree | b3e42ff9719b3f53f231dd6e7ea970d93b04dcc8 /src/guiEngine.h | |
parent | e5311a4d565dece751745f859ac1b8d92da67564 (diff) | |
download | minetest-90a9e4e69fac32f368b275428fa42407ea9b7883.tar.gz minetest-90a9e4e69fac32f368b275428fa42407ea9b7883.tar.bz2 minetest-90a9e4e69fac32f368b275428fa42407ea9b7883.zip |
Fix player coordinate rounding in collisionMoveSimple() (#6197)
To determine the area (nodes) where a player movement took place
collisionMoveSimple() first took the old/new player coordinates and rounded
them to integers, then added the player character's collision box and
implicitely rounded the result. This has 2 problems:
Rounding the position and the box seperately, then adding the resulting
integers means you get twice the rounding error. And implicit rounding
always rounds towards 0.0, unlike floatToInt(), which rounds towards the
closest integer.
Previous (simplified) behavior: round(pos)+(int)box, for example player at
Y=0.9, body is 1.75m high: round(0.9)+(int)1.75 = 1+1 = 2.
==> A character's height of 1.75m always got rounded down to 1m, its width
of +/-0.3 even became 0.
Fixed by adding the floats first, then rounding properly: round(pos+box) =
round(0.9+1.75) = round(2.65) = 3.
Diffstat (limited to 'src/guiEngine.h')
0 files changed, 0 insertions, 0 deletions