1
0
Fork 0

Fixed normalizing large angles.

This commit is contained in:
madmaxoft 2013-12-08 13:08:56 +01:00
parent 044fd237b6
commit 6785bb7c16
4 changed files with 51 additions and 8 deletions

View File

@ -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);

View File

@ -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 */

View File

@ -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)

View File

@ -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);
}