mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #10963 from sethalves/fix-sort-joints
put result of Avatar::getJointNames back in index-order
This commit is contained in:
commit
4f75558b49
1 changed files with 28 additions and 1 deletions
|
@ -1050,7 +1050,34 @@ int Avatar::getJointIndex(const QString& name) const {
|
|||
QStringList Avatar::getJointNames() const {
|
||||
QStringList result;
|
||||
withValidJointIndicesCache([&]() {
|
||||
result = _modelJointIndicesCache.keys();
|
||||
// find out how large the vector needs to be
|
||||
int maxJointIndex = -1;
|
||||
QHashIterator<QString, int> k(_modelJointIndicesCache);
|
||||
while (k.hasNext()) {
|
||||
k.next();
|
||||
int index = k.value();
|
||||
if (index > maxJointIndex) {
|
||||
maxJointIndex = index;
|
||||
}
|
||||
}
|
||||
// iterate through the hash and put joint names
|
||||
// into the vector at their indices
|
||||
QVector<QString> resultVector(maxJointIndex+1);
|
||||
QHashIterator<QString, int> i(_modelJointIndicesCache);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
int index = i.value();
|
||||
resultVector[index] = i.key();
|
||||
}
|
||||
// convert to QList and drop out blanks
|
||||
result = resultVector.toList();
|
||||
QMutableListIterator<QString> j(result);
|
||||
while (j.hasNext()) {
|
||||
QString jointName = j.next();
|
||||
if (jointName.isEmpty()) {
|
||||
j.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue