Skip to content

Commit

Permalink
Fixed bug in anim rotation state checker
Browse files Browse the repository at this point in the history
  • Loading branch information
DMD authored and DMD committed Aug 19, 2016
1 parent adccc1b commit 03705b2
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions TemplePlus/anim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 03705b2

Please sign in to comment.