mirror of
https://github.com/minetest/minetest.git
synced 2024-12-24 23:22:24 +01:00
Fix short 180 degree rotation when using set_bone_position (#10405)
This commit is contained in:
parent
3250b37e32
commit
0f98b54aa4
@ -1460,24 +1460,17 @@ void GenericCAO::updateBonePosition()
|
|||||||
if (!bone)
|
if (!bone)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//If bone is manually positioned there is no need to perform the bug check
|
|
||||||
bool skip = false;
|
|
||||||
for (auto &it : m_bone_position) {
|
|
||||||
if (it.first == bone->getName()) {
|
|
||||||
skip = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (skip)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Workaround for Irrlicht bug
|
// Workaround for Irrlicht bug
|
||||||
// We check each bone to see if it has been rotated ~180deg from its expected position due to a bug in Irricht
|
// We check each bone to see if it has been rotated ~180deg from its expected position due to a bug in Irricht
|
||||||
// when using EJUOR_CONTROL joint control. If the bug is detected we update the bone to the proper position
|
// when using EJUOR_CONTROL joint control. If the bug is detected we update the bone to the proper position
|
||||||
// and update the bones transformation.
|
// and update the bones transformation.
|
||||||
v3f bone_rot = bone->getRelativeTransformation().getRotationDegrees();
|
v3f bone_rot = bone->getRelativeTransformation().getRotationDegrees();
|
||||||
float offset = fabsf(bone_rot.X - bone->getRotation().X);
|
float offset_X = fabsf(bone_rot.X - bone->getRotation().X);
|
||||||
if (offset > 179.9f && offset < 180.1f) {
|
float offset_Y = fabsf(bone_rot.Y - bone->getRotation().Y);
|
||||||
|
float offset_Z = fabsf(bone_rot.Z - bone->getRotation().Z);
|
||||||
|
if ((offset_X > 179.9f && offset_X < 180.1f)
|
||||||
|
|| (offset_Y > 179.9f && offset_Y < 180.1f)
|
||||||
|
|| (offset_Z > 179.9f && offset_Z < 180.1f)) {
|
||||||
bone->setRotation(bone_rot);
|
bone->setRotation(bone_rot);
|
||||||
bone->updateAbsolutePosition();
|
bone->updateAbsolutePosition();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user