mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 12:14:00 +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;
|
||||
}
|
||||
|
||||
if (!hasAnimation() || !_jointMappingCompleted) {
|
||||
if (!hasRenderAnimation() || !_jointMappingCompleted) {
|
||||
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()) {
|
||||
|
||||
const QVector<FBXAnimationFrame>& frames = myAnimation->getFramesReference(); // NOTE: getFrames() is too heavy
|
||||
|
@ -384,7 +384,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
|||
}
|
||||
|
||||
if (_model) {
|
||||
if (hasAnimation()) {
|
||||
if (hasRenderAnimation()) {
|
||||
if (!jointsMapped()) {
|
||||
QStringList modelJointNames = _model->getJointNames();
|
||||
mapJoints(modelJointNames);
|
||||
|
@ -528,6 +528,9 @@ void RenderableModelEntityItem::update(const quint64& now) {
|
|||
}
|
||||
}
|
||||
|
||||
// make a copy of the animation properites
|
||||
_renderAnimationProperties = _animationProperties;
|
||||
|
||||
ModelEntityItem::update(now);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,11 @@ public:
|
|||
virtual int getJointIndex(const QString& name) 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:
|
||||
QVariantMap parseTexturesToMap(QString textures);
|
||||
void remapTextures();
|
||||
|
@ -97,6 +102,8 @@ private:
|
|||
QVector<QVector<glm::vec3>> _points;
|
||||
bool _dimensionsInitialized = true;
|
||||
|
||||
AnimationPropertyGroup _renderAnimationProperties;
|
||||
|
||||
render::ItemID _myMetaItem{ render::Item::INVALID_ITEM_ID };
|
||||
|
||||
bool _showCollisionHull = false;
|
||||
|
|
Loading…
Reference in a new issue