Skip to content

Commit 0f98b54

Browse files
authoredOct 4, 2020
Fix short 180 degree rotation when using set_bone_position (#10405)
1 parent 3250b37 commit 0f98b54

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed
 

Diff for: ‎src/client/content_cao.cpp

+6-13
Original file line numberDiff line numberDiff line change
@@ -1460,24 +1460,17 @@ void GenericCAO::updateBonePosition()
14601460
if (!bone)
14611461
continue;
14621462

1463-
//If bone is manually positioned there is no need to perform the bug check
1464-
bool skip = false;
1465-
for (auto &it : m_bone_position) {
1466-
if (it.first == bone->getName()) {
1467-
skip = true;
1468-
break;
1469-
}
1470-
}
1471-
if (skip)
1472-
continue;
1473-
14741463
// Workaround for Irrlicht bug
14751464
// We check each bone to see if it has been rotated ~180deg from its expected position due to a bug in Irricht
14761465
// when using EJUOR_CONTROL joint control. If the bug is detected we update the bone to the proper position
14771466
// and update the bones transformation.
14781467
v3f bone_rot = bone->getRelativeTransformation().getRotationDegrees();
1479-
float offset = fabsf(bone_rot.X - bone->getRotation().X);
1480-
if (offset > 179.9f && offset < 180.1f) {
1468+
float offset_X = fabsf(bone_rot.X - bone->getRotation().X);
1469+
float offset_Y = fabsf(bone_rot.Y - bone->getRotation().Y);
1470+
float offset_Z = fabsf(bone_rot.Z - bone->getRotation().Z);
1471+
if ((offset_X > 179.9f && offset_X < 180.1f)
1472+
|| (offset_Y > 179.9f && offset_Y < 180.1f)
1473+
|| (offset_Z > 179.9f && offset_Z < 180.1f)) {
14811474
bone->setRotation(bone_rot);
14821475
bone->updateAbsolutePosition();
14831476
}

0 commit comments

Comments
 (0)