From 03705b24944f33943cafad23ee7f285728cecf69 Mon Sep 17 00:00:00 2001 From: DMD Date: Fri, 19 Aug 2016 23:01:32 +0300 Subject: [PATCH] Fixed bug in anim rotation state checker --- TemplePlus/anim.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/TemplePlus/anim.cpp b/TemplePlus/anim.cpp index a25115018..9fc053299 100644 --- a/TemplePlus/anim.cpp +++ b/TemplePlus/anim.cpp @@ -1646,17 +1646,22 @@ int GoalStateFuncs::GoalStateFunc78_IsHeadingOk(AnimSlot & slot){ auto &rot = slot.pCurrentGoal->scratchVal2.floatNum; rot = (float)(M_PI_2 + M_PI * 0.75 - atan2(nodeAbsY - objAbsY, nodeAbsX - objAbsX) ); if (rot < 0.0) { - rot += (float)6.2831855;//M_PI * 2; + rot += (float)6.2831853;//M_PI * 2; } - if (rot > 6.2831855) { - rot -= (float) 6.2831855;//M_PI * 2; + if (rot > 6.2831853) { + rot -= (float) 6.2831853;//M_PI * 2; } - + auto objRot = obj->GetFloat(obj_f_rotation); - if (fabs(objRot - rot) > 0.017453292) { // 1 degree + + + if (sin(objRot - rot) > 0.017453292) // 1 degree return 0; - } + + if (cos(objRot) - cos(rot) > 0.017453292) // in case it's a 180 degrees difference + return 0; + return 1; }