mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 00:25:19 +02:00
Fix rounding error in g/set_node caused by truncation to float
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user