1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add Lua methods 'set_rotation()' and 'get_rotation()' (#7395)

* Adds Lua methods 'set_rotation()' and 'get_rotation'. Also changed some method names to be more clear. Instead of an f32 being sent over network for yaw, now a v3f is sent for rotation on xyz axes. Perserved Lua method set_yaw/setyaw so that old mods still work, other wise to set yaw they would need to switch to set_rotation(0, yaw, 0).
This commit is contained in:
CoderForTheBetter 2018-11-28 03:38:50 -05:00 committed by Loïc Blot
parent 9519d57017
commit faa358e797
18 changed files with 211 additions and 99 deletions

View file

@ -182,6 +182,23 @@ inline float wrapDegrees_0_360(float f)
}
/** Returns \p v3f wrapped to the range [0, 360]
*/
inline v3f wrapDegrees_0_360_v3f(v3f v)
{
v3f value_v3f;
value_v3f.X = modulo360f(v.X);
value_v3f.Y = modulo360f(v.Y);
value_v3f.Z = modulo360f(v.Z);
// Now that values are wrapped, use to get values for certain ranges
value_v3f.X = value_v3f.X < 0 ? value_v3f.X + 360 : value_v3f.X;
value_v3f.Y = value_v3f.Y < 0 ? value_v3f.Y + 360 : value_v3f.Y;
value_v3f.Z = value_v3f.Z < 0 ? value_v3f.Z + 360 : value_v3f.Z;
return value_v3f;
}
/** Returns \p f wrapped to the range [-180, 180]
*/
inline float wrapDegrees_180(float f)