From faa358e797128ab07bb5644ce305a832d59e5596 Mon Sep 17 00:00:00 2001 From: CoderForTheBetter Date: Wed, 28 Nov 2018 03:38:50 -0500 Subject: 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). --- src/util/numeric.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/util') diff --git a/src/util/numeric.h b/src/util/numeric.h index b1e2845b8..bfdff84a0 100644 --- a/src/util/numeric.h +++ b/src/util/numeric.h @@ -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) -- cgit v1.2.3