summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Bindings/Bindings.cpp32
-rw-r--r--src/Bindings/Bindings.h2
-rw-r--r--src/Defines.h16
-rw-r--r--src/Entities/Entity.cpp9
4 files changed, 51 insertions, 8 deletions
diff --git a/src/Bindings/Bindings.cpp b/src/Bindings/Bindings.cpp
index 4037289f8..954c751d5 100644
--- a/src/Bindings/Bindings.cpp
+++ b/src/Bindings/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 12/08/13 12:15:47.
+** Generated automatically by tolua++-1.0.92 on 12/08/13 12:56:06.
*/
#ifndef __cplusplus
@@ -4299,6 +4299,35 @@ static int tolua_AllToLua_AddFaceDirection00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* function: NormalizeAngleDegrees */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_NormalizeAngleDegrees00
+static int tolua_AllToLua_NormalizeAngleDegrees00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isnumber(tolua_S,1,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const double a_Degrees = ((const double) tolua_tonumber(tolua_S,1,0));
+ {
+ double tolua_ret = (double) NormalizeAngleDegrees(a_Degrees);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'NormalizeAngleDegrees'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* function: ItemCategory::IsPickaxe */
#ifndef TOLUA_DISABLE_tolua_AllToLua_ItemCategory_IsPickaxe00
static int tolua_AllToLua_ItemCategory_IsPickaxe00(lua_State* tolua_S)
@@ -30603,6 +30632,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"IsValidBlock",tolua_AllToLua_IsValidBlock00);
tolua_function(tolua_S,"IsValidItem",tolua_AllToLua_IsValidItem00);
tolua_function(tolua_S,"AddFaceDirection",tolua_AllToLua_AddFaceDirection00);
+ tolua_function(tolua_S,"NormalizeAngleDegrees",tolua_AllToLua_NormalizeAngleDegrees00);
tolua_module(tolua_S,"ItemCategory",0);
tolua_beginmodule(tolua_S,"ItemCategory");
tolua_function(tolua_S,"IsPickaxe",tolua_AllToLua_ItemCategory_IsPickaxe00);
diff --git a/src/Bindings/Bindings.h b/src/Bindings/Bindings.h
index 6b4eff3d4..db545064b 100644
--- a/src/Bindings/Bindings.h
+++ b/src/Bindings/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 12/08/13 12:15:48.
+** Generated automatically by tolua++-1.0.92 on 12/08/13 12:56:06.
*/
/* Exported function */
diff --git a/src/Defines.h b/src/Defines.h
index 5b27f4b3f..534802d55 100644
--- a/src/Defines.h
+++ b/src/Defines.h
@@ -416,6 +416,22 @@ inline float GetSpecialSignf( float a_Val )
// tolua_begin
+
+/// Normalizes an angle in degrees to the [-180, +180) range:
+inline double NormalizeAngleDegrees(const double a_Degrees)
+{
+ double Norm = fmod(a_Degrees + 180, 360);
+ if (Norm < 0)
+ {
+ Norm += 360;
+ }
+ return Norm - 180;
+}
+
+
+
+
+
namespace ItemCategory
{
inline bool IsPickaxe(short a_ItemID)
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 91be6dd93..d728d6cbc 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -158,8 +158,7 @@ bool cEntity::Initialize(cWorld * a_World)
void cEntity::WrapHeadYaw(void)
{
- while (m_HeadYaw > 180.f) m_HeadYaw -= 360.f; // Wrap it
- while (m_HeadYaw < -180.f) m_HeadYaw += 360.f;
+ m_HeadYaw = NormalizeAngleDegrees(m_HeadYaw);
}
@@ -168,10 +167,8 @@ void cEntity::WrapHeadYaw(void)
void cEntity::WrapRotation(void)
{
- while (m_Rot.x > 180.f) m_Rot.x -= 360.f; // Wrap it
- while (m_Rot.x < -180.f) m_Rot.x += 360.f;
- while (m_Rot.y > 180.f) m_Rot.y -= 360.f;
- while (m_Rot.y < -180.f) m_Rot.y += 360.f;
+ m_Rot.x = NormalizeAngleDegrees(m_Rot.x);
+ m_Rot.y = NormalizeAngleDegrees(m_Rot.z);
}