mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
rename the joint-name caches in AvatarData and Avatar so it's more clear that they are different
This commit is contained in:
parent
88c39f3237
commit
6782a891d0
4 changed files with 26 additions and 26 deletions
|
@ -1009,23 +1009,23 @@ glm::vec3 Avatar::getAbsoluteJointTranslationInObjectFrame(int index) const {
|
|||
}
|
||||
|
||||
void Avatar::invalidateJointIndicesCache() const {
|
||||
QWriteLocker writeLock(&_jointIndicesCacheLock);
|
||||
_jointsCached = false;
|
||||
QWriteLocker writeLock(&_modelJointIndicesCacheLock);
|
||||
_modelJointsCached = false;
|
||||
}
|
||||
|
||||
void Avatar::withValidJointIndicesCache(std::function<void()> const& worker) const {
|
||||
QReadLocker readLock(&_jointIndicesCacheLock);
|
||||
if (_jointsCached) {
|
||||
QReadLocker readLock(&_modelJointIndicesCacheLock);
|
||||
if (_modelJointsCached) {
|
||||
worker();
|
||||
} else {
|
||||
readLock.unlock();
|
||||
{
|
||||
QWriteLocker writeLock(&_jointIndicesCacheLock);
|
||||
if (!_jointsCached) {
|
||||
_jointIndicesCache.clear();
|
||||
QWriteLocker writeLock(&_modelJointIndicesCacheLock);
|
||||
if (!_modelJointsCached) {
|
||||
_modelJointIndicesCache.clear();
|
||||
if (_skeletonModel && _skeletonModel->isActive()) {
|
||||
_jointIndicesCache = _skeletonModel->getFBXGeometry().jointIndices;
|
||||
_jointsCached = true;
|
||||
_modelJointIndicesCache = _skeletonModel->getFBXGeometry().jointIndices;
|
||||
_modelJointsCached = true;
|
||||
}
|
||||
}
|
||||
worker();
|
||||
|
@ -1040,8 +1040,8 @@ int Avatar::getJointIndex(const QString& name) const {
|
|||
}
|
||||
|
||||
withValidJointIndicesCache([&]() {
|
||||
if (_jointIndicesCache.contains(name)) {
|
||||
result = _jointIndicesCache[name] - 1;
|
||||
if (_modelJointIndicesCache.contains(name)) {
|
||||
result = _modelJointIndicesCache[name] - 1;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
|
@ -1050,7 +1050,7 @@ int Avatar::getJointIndex(const QString& name) const {
|
|||
QStringList Avatar::getJointNames() const {
|
||||
QStringList result;
|
||||
withValidJointIndicesCache([&]() {
|
||||
result = _jointIndicesCache.keys();
|
||||
result = _modelJointIndicesCache.keys();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -270,9 +270,9 @@ protected:
|
|||
|
||||
void invalidateJointIndicesCache() const;
|
||||
void withValidJointIndicesCache(std::function<void()> const& worker) const;
|
||||
mutable QHash<QString, int> _jointIndicesCache;
|
||||
mutable QReadWriteLock _jointIndicesCacheLock;
|
||||
mutable bool _jointsCached { false };
|
||||
mutable QHash<QString, int> _modelJointIndicesCache;
|
||||
mutable QReadWriteLock _modelJointIndicesCacheLock;
|
||||
mutable bool _modelJointsCached { false };
|
||||
|
||||
glm::vec3 _skeletonOffset;
|
||||
std::vector<std::shared_ptr<Model>> _attachmentModels;
|
||||
|
|
|
@ -1462,12 +1462,12 @@ int AvatarData::getJointIndex(const QString& name) const {
|
|||
return result;
|
||||
}
|
||||
QReadLocker readLock(&_jointDataLock);
|
||||
return _jointIndices.value(name) - 1;
|
||||
return _fstJointIndices.value(name) - 1;
|
||||
}
|
||||
|
||||
QStringList AvatarData::getJointNames() const {
|
||||
QReadLocker readLock(&_jointDataLock);
|
||||
return _jointNames;
|
||||
return _fstJointNames;
|
||||
}
|
||||
|
||||
glm::quat AvatarData::getOrientationOutbound() const {
|
||||
|
@ -1720,14 +1720,14 @@ void AvatarData::setJointMappingsFromNetworkReply() {
|
|||
bool ok;
|
||||
int jointIndex = line.mid(secondSeparatorIndex + 1).trimmed().toInt(&ok);
|
||||
if (ok) {
|
||||
while (_jointNames.size() < jointIndex + 1) {
|
||||
_jointNames.append(QString());
|
||||
while (_fstJointNames.size() < jointIndex + 1) {
|
||||
_fstJointNames.append(QString());
|
||||
}
|
||||
_jointNames[jointIndex] = jointName;
|
||||
_fstJointNames[jointIndex] = jointName;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < _jointNames.size(); i++) {
|
||||
_jointIndices.insert(_jointNames.at(i), i + 1);
|
||||
for (int i = 0; i < _fstJointNames.size(); i++) {
|
||||
_fstJointIndices.insert(_fstJointNames.at(i), i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1781,8 +1781,8 @@ void AvatarData::sendIdentityPacket() {
|
|||
void AvatarData::updateJointMappings() {
|
||||
{
|
||||
QWriteLocker writeLock(&_jointDataLock);
|
||||
_jointIndices.clear();
|
||||
_jointNames.clear();
|
||||
_fstJointIndices.clear();
|
||||
_fstJointNames.clear();
|
||||
_jointData.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -704,8 +704,8 @@ protected:
|
|||
QString _displayName;
|
||||
QString _sessionDisplayName { };
|
||||
|
||||
QHash<QString, int> _jointIndices; ///< 1-based, since zero is returned for missing keys
|
||||
QStringList _jointNames; ///< in order of depth-first traversal
|
||||
QHash<QString, int> _fstJointIndices; ///< 1-based, since zero is returned for missing keys
|
||||
QStringList _fstJointNames; ///< in order of depth-first traversal
|
||||
|
||||
quint64 _errorLogExpiry; ///< time in future when to log an error
|
||||
|
||||
|
|
Loading…
Reference in a new issue