mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 08:37:19 +02:00
removed unnecessary mirror joint code and cleaned up whitespace in rig.cpp
This commit is contained in:
parent
f2c5184c95
commit
579e2dd2ee
3 changed files with 16 additions and 58 deletions
|
@ -54,7 +54,6 @@ AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) {
|
||||||
}
|
}
|
||||||
_clusterBindMatrixOriginalValues.push_back(dummyClustersList);
|
_clusterBindMatrixOriginalValues.push_back(dummyClustersList);
|
||||||
}
|
}
|
||||||
//dump(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimSkeleton::AnimSkeleton(const std::vector<HFMJoint>& joints, const QMap<int, glm::quat> jointOffsets) {
|
AnimSkeleton::AnimSkeleton(const std::vector<HFMJoint>& joints, const QMap<int, glm::quat> jointOffsets) {
|
||||||
|
@ -208,51 +207,6 @@ void AnimSkeleton::mirrorAbsolutePoses(AnimPoseVec& poses) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AnimSkeleton::checkNonMirrored(QString jointName) const {
|
|
||||||
|
|
||||||
if (_fbxToHifiJointNameMapping.contains(_fbxToHifiJointNameMapping.key(jointName))) {
|
|
||||||
jointName = _fbxToHifiJointNameMapping.key(jointName);
|
|
||||||
}
|
|
||||||
// check the unmapped name
|
|
||||||
if (jointName != "Hips" && jointName != "Spine" &&
|
|
||||||
jointName != "Spine1" && jointName != "Spine2" &&
|
|
||||||
jointName != "Neck" && jointName != "Head" &&
|
|
||||||
!((jointName.startsWith("Left") || jointName.startsWith("Right")) &&
|
|
||||||
jointName != "LeftEye" && jointName != "RightEye")) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int AnimSkeleton::containsLeft(QString jointName) const {
|
|
||||||
int mirrorJointIndex = -1;
|
|
||||||
if (_fbxToHifiJointNameMapping.contains(_fbxToHifiJointNameMapping.key(jointName))) {
|
|
||||||
jointName = _fbxToHifiJointNameMapping.key(jointName);
|
|
||||||
}
|
|
||||||
if (mirrorJointIndex < 0) {
|
|
||||||
if (jointName.startsWith("Left")) {
|
|
||||||
QString mirrorJointName = QString(jointName).replace(0, 4, "Right");
|
|
||||||
mirrorJointIndex = nameToJointIndex(mirrorJointName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mirrorJointIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
int AnimSkeleton::containsRight(QString jointName) const {
|
|
||||||
int mirrorJointIndex = -1;
|
|
||||||
if (_fbxToHifiJointNameMapping.contains(_fbxToHifiJointNameMapping.key(jointName))) {
|
|
||||||
jointName = _fbxToHifiJointNameMapping.key(jointName);
|
|
||||||
}
|
|
||||||
if (mirrorJointIndex < 0) {
|
|
||||||
if (jointName.startsWith("Right")) {
|
|
||||||
QString mirrorJointName = QString(jointName).replace(0, 5, "Left");
|
|
||||||
mirrorJointIndex = nameToJointIndex(mirrorJointName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mirrorJointIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnimSkeleton::buildSkeletonFromJoints(const std::vector<HFMJoint>& joints, const QMap<int, glm::quat> jointOffsets) {
|
void AnimSkeleton::buildSkeletonFromJoints(const std::vector<HFMJoint>& joints, const QMap<int, glm::quat> jointOffsets) {
|
||||||
|
|
||||||
_joints = joints;
|
_joints = joints;
|
||||||
|
@ -304,15 +258,26 @@ void AnimSkeleton::buildSkeletonFromJoints(const std::vector<HFMJoint>& joints,
|
||||||
_nonMirroredIndices.clear();
|
_nonMirroredIndices.clear();
|
||||||
_mirrorMap.reserve(_jointsSize);
|
_mirrorMap.reserve(_jointsSize);
|
||||||
for (int i = 0; i < _jointsSize; i++) {
|
for (int i = 0; i < _jointsSize; i++) {
|
||||||
if (checkNonMirrored(_joints[i].name)) {
|
QString jointName = _joints[i].name;
|
||||||
|
if (_fbxToHifiJointNameMapping.contains(_fbxToHifiJointNameMapping.key(jointName))) {
|
||||||
|
jointName = _fbxToHifiJointNameMapping.key(jointName);
|
||||||
|
}
|
||||||
|
if (jointName != "Hips" && jointName != "Spine" &&
|
||||||
|
jointName != "Spine1" && jointName != "Spine2" &&
|
||||||
|
jointName != "Neck" && jointName != "Head" &&
|
||||||
|
!((jointName.startsWith("Left") || jointName.startsWith("Right")) &&
|
||||||
|
jointName != "LeftEye" && jointName != "RightEye")) {
|
||||||
// HACK: we don't want to mirror some joints so we remember their indices
|
// HACK: we don't want to mirror some joints so we remember their indices
|
||||||
// so we can restore them after a future mirror operation
|
// so we can restore them after a future mirror operation
|
||||||
_nonMirroredIndices.push_back(i);
|
_nonMirroredIndices.push_back(i);
|
||||||
}
|
}
|
||||||
int mirrorJointIndex = -1;
|
int mirrorJointIndex = -1;
|
||||||
mirrorJointIndex = containsLeft(_joints[i].name);
|
if (jointName.startsWith("Left")) {
|
||||||
if (mirrorJointIndex < 0) {
|
QString mirrorJointName = QString(jointName).replace(0, 4, "Right");
|
||||||
mirrorJointIndex = containsRight(_joints[i].name);
|
mirrorJointIndex = nameToJointIndex(mirrorJointName);
|
||||||
|
} else if (jointName.startsWith("Right")) {
|
||||||
|
QString mirrorJointName = QString(jointName).replace(0, 5, "Left");
|
||||||
|
mirrorJointIndex = nameToJointIndex(mirrorJointName);
|
||||||
}
|
}
|
||||||
if (mirrorJointIndex >= 0) {
|
if (mirrorJointIndex >= 0) {
|
||||||
_mirrorMap.push_back(mirrorJointIndex);
|
_mirrorMap.push_back(mirrorJointIndex);
|
||||||
|
|
|
@ -56,9 +56,6 @@ public:
|
||||||
void saveNonMirroredPoses(const AnimPoseVec& poses) const;
|
void saveNonMirroredPoses(const AnimPoseVec& poses) const;
|
||||||
void restoreNonMirroredPoses(AnimPoseVec& poses) const;
|
void restoreNonMirroredPoses(AnimPoseVec& poses) const;
|
||||||
|
|
||||||
bool checkNonMirrored(QString jointName) const;
|
|
||||||
int containsLeft(QString jointName) const;
|
|
||||||
int containsRight(QString jointName) const;
|
|
||||||
void mirrorRelativePoses(AnimPoseVec& poses) const;
|
void mirrorRelativePoses(AnimPoseVec& poses) const;
|
||||||
void mirrorAbsolutePoses(AnimPoseVec& poses) const;
|
void mirrorAbsolutePoses(AnimPoseVec& poses) const;
|
||||||
|
|
||||||
|
@ -67,7 +64,6 @@ public:
|
||||||
|
|
||||||
std::vector<int> lookUpJointIndices(const std::vector<QString>& jointNames) const;
|
std::vector<int> lookUpJointIndices(const std::vector<QString>& jointNames) const;
|
||||||
const HFMCluster getClusterBindMatricesOriginalValues(const int meshIndex, const int clusterIndex) const { return _clusterBindMatrixOriginalValues[meshIndex][clusterIndex]; }
|
const HFMCluster getClusterBindMatricesOriginalValues(const int meshIndex, const int clusterIndex) const { return _clusterBindMatrixOriginalValues[meshIndex][clusterIndex]; }
|
||||||
const QMap<QString, QString> getFBXToHifiJointNameMapping() const { return _fbxToHifiJointNameMapping; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void buildSkeletonFromJoints(const std::vector<HFMJoint>& joints, const QMap<int, glm::quat> jointOffsets);
|
void buildSkeletonFromJoints(const std::vector<HFMJoint>& joints, const QMap<int, glm::quat> jointOffsets);
|
||||||
|
|
|
@ -363,6 +363,7 @@ void Rig::reset(const HFMModel& hfmModel) {
|
||||||
|
|
||||||
_animSkeleton = std::make_shared<AnimSkeleton>(hfmModel);
|
_animSkeleton = std::make_shared<AnimSkeleton>(hfmModel);
|
||||||
|
|
||||||
|
|
||||||
_internalPoseSet._relativePoses.clear();
|
_internalPoseSet._relativePoses.clear();
|
||||||
_internalPoseSet._relativePoses = _animSkeleton->getRelativeDefaultPoses();
|
_internalPoseSet._relativePoses = _animSkeleton->getRelativeDefaultPoses();
|
||||||
|
|
||||||
|
@ -420,11 +421,7 @@ static const uint32_t MAX_JOINT_NAME_WARNING_COUNT = 100;
|
||||||
|
|
||||||
int Rig::indexOfJoint(const QString& jointName) const {
|
int Rig::indexOfJoint(const QString& jointName) const {
|
||||||
if (_animSkeleton) {
|
if (_animSkeleton) {
|
||||||
|
|
||||||
int result = _animSkeleton->nameToJointIndex(jointName);
|
int result = _animSkeleton->nameToJointIndex(jointName);
|
||||||
if (_animSkeleton->getFBXToHifiJointNameMapping().contains(jointName)) {
|
|
||||||
result = _animSkeleton->nameToJointIndex(jointName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is a content error, so we should issue a warning.
|
// This is a content error, so we should issue a warning.
|
||||||
if (result < 0 && _jointNameWarningCount < MAX_JOINT_NAME_WARNING_COUNT) {
|
if (result < 0 && _jointNameWarningCount < MAX_JOINT_NAME_WARNING_COUNT) {
|
||||||
|
|
Loading…
Reference in a new issue