mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 19:41:20 +02:00
Reading animation properties without an entityTree lock is considered harmful
In RenderableModelEntityItem::update() make a copy of the _animationProperties, which is under the entityTree lock. In RenderableModelEntityItem::render() read from the copy of _animationProperties when not under the entityTree lock.
This commit is contained in:
parent
2ee5b45ca6
commit
8f530ceaf9
2 changed files with 13 additions and 3 deletions
|
@ -271,10 +271,10 @@ bool RenderableModelEntityItem::getAnimationFrame() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasAnimation() || !_jointMappingCompleted) {
|
if (!hasRenderAnimation() || !_jointMappingCompleted) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
AnimationPointer myAnimation = getAnimation(_animationProperties.getURL()); // FIXME: this could be optimized
|
AnimationPointer myAnimation = getAnimation(getRenderAnimationURL()); // FIXME: this could be optimized
|
||||||
if (myAnimation && myAnimation->isLoaded()) {
|
if (myAnimation && myAnimation->isLoaded()) {
|
||||||
|
|
||||||
const QVector<FBXAnimationFrame>& frames = myAnimation->getFramesReference(); // NOTE: getFrames() is too heavy
|
const QVector<FBXAnimationFrame>& frames = myAnimation->getFramesReference(); // NOTE: getFrames() is too heavy
|
||||||
|
@ -384,7 +384,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_model) {
|
if (_model) {
|
||||||
if (hasAnimation()) {
|
if (hasRenderAnimation()) {
|
||||||
if (!jointsMapped()) {
|
if (!jointsMapped()) {
|
||||||
QStringList modelJointNames = _model->getJointNames();
|
QStringList modelJointNames = _model->getJointNames();
|
||||||
mapJoints(modelJointNames);
|
mapJoints(modelJointNames);
|
||||||
|
@ -528,6 +528,9 @@ void RenderableModelEntityItem::update(const quint64& now) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make a copy of the animation properites
|
||||||
|
_renderAnimationProperties = _animationProperties;
|
||||||
|
|
||||||
ModelEntityItem::update(now);
|
ModelEntityItem::update(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,11 @@ public:
|
||||||
virtual int getJointIndex(const QString& name) const override;
|
virtual int getJointIndex(const QString& name) const override;
|
||||||
virtual QStringList getJointNames() const override;
|
virtual QStringList getJointNames() const override;
|
||||||
|
|
||||||
|
// These operate on a copy of the renderAnimationProperties, so they can be accessed
|
||||||
|
// without having the entityTree lock.
|
||||||
|
bool hasRenderAnimation() const { return !_renderAnimationProperties.getURL().isEmpty(); }
|
||||||
|
const QString& getRenderAnimationURL() const { return _renderAnimationProperties.getURL(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVariantMap parseTexturesToMap(QString textures);
|
QVariantMap parseTexturesToMap(QString textures);
|
||||||
void remapTextures();
|
void remapTextures();
|
||||||
|
@ -97,6 +102,8 @@ private:
|
||||||
QVector<QVector<glm::vec3>> _points;
|
QVector<QVector<glm::vec3>> _points;
|
||||||
bool _dimensionsInitialized = true;
|
bool _dimensionsInitialized = true;
|
||||||
|
|
||||||
|
AnimationPropertyGroup _renderAnimationProperties;
|
||||||
|
|
||||||
render::ItemID _myMetaItem{ render::Item::INVALID_ITEM_ID };
|
render::ItemID _myMetaItem{ render::Item::INVALID_ITEM_ID };
|
||||||
|
|
||||||
bool _showCollisionHull = false;
|
bool _showCollisionHull = false;
|
||||||
|
|
Loading…
Reference in a new issue