mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix rounding error in g/set_node caused by truncation to float
This commit is contained in:
parent
0bcc2f33eb
commit
026ad912af
3 changed files with 54 additions and 4 deletions
|
@ -254,6 +254,17 @@ inline v3s16 floatToInt(v3f p, f32 d)
|
|||
(p.Z + (p.Z > 0 ? d / 2 : -d / 2)) / d);
|
||||
}
|
||||
|
||||
/*
|
||||
Returns integer position of node in given double precision position
|
||||
*/
|
||||
inline v3s16 doubleToInt(v3d p, double d)
|
||||
{
|
||||
return v3s16(
|
||||
(p.X + (p.X > 0 ? d / 2 : -d / 2)) / d,
|
||||
(p.Y + (p.Y > 0 ? d / 2 : -d / 2)) / d,
|
||||
(p.Z + (p.Z > 0 ? d / 2 : -d / 2)) / d);
|
||||
}
|
||||
|
||||
/*
|
||||
Returns floating point position of node in given integer position
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue