mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-21 07:09:15 +02:00
try again on putting result of Avatar::getJointNames in index order
This commit is contained in:
parent
44de1dd2be
commit
85d0b68284
1 changed files with 26 additions and 5 deletions
|
@ -1048,17 +1048,38 @@ int Avatar::getJointIndex(const QString& name) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Avatar::getJointNames() const {
|
QStringList Avatar::getJointNames() const {
|
||||||
QVector<QString> result;
|
QStringList result;
|
||||||
withValidJointIndicesCache([&]() {
|
withValidJointIndicesCache([&]() {
|
||||||
|
// 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);
|
QHashIterator<QString, int> i(_modelJointIndicesCache);
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
i.next();
|
i.next();
|
||||||
int index = _modelJointIndicesCache[i.key()];
|
int index = i.value();
|
||||||
result.resize(index);
|
resultVector[index] = i.key();
|
||||||
result[index] = i.value();
|
}
|
||||||
|
// 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.toList();
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 Avatar::getJointPosition(int index) const {
|
glm::vec3 Avatar::getJointPosition(int index) const {
|
||||||
|
|
Loading…
Reference in a new issue