Merge pull request #7613 from hyperlogic/tony/model-entity-render-fix

Reading animation properties without an entityTree lock is considered harmful
This commit is contained in:
Brad Hefta-Gaub 2016-04-08 10:37:17 -07:00
commit 7ba08dd137
2 changed files with 13 additions and 3 deletions

View file

@ -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);
}

View file

@ -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;