mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 23:04:03 +02:00
Merge pull request #7514 from zzmp/guard/model-tex
Add lock on model texs
This commit is contained in:
commit
eb61a4fee9
4 changed files with 28 additions and 9 deletions
|
@ -117,12 +117,11 @@ QVariantMap RenderableModelEntityItem::parseTexturesToMap(QString textures) {
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument texturesJson = QJsonDocument::fromJson(textures.toUtf8(), &error);
|
QJsonDocument texturesJson = QJsonDocument::fromJson(textures.toUtf8(), &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qCWarning(entitiesrenderer) << "Could not evaluate textures property value:" << _textures;
|
qCWarning(entitiesrenderer) << "Could not evaluate textures property value:" << textures;
|
||||||
return _originalTextures;
|
return _originalTextures;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto parsed = texturesJson.toVariant();
|
return texturesJson.toVariant().toMap();
|
||||||
return parsed.toMap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderableModelEntityItem::remapTextures() {
|
void RenderableModelEntityItem::remapTextures() {
|
||||||
|
@ -144,11 +143,17 @@ void RenderableModelEntityItem::remapTextures() {
|
||||||
_currentTextures = _originalTextures;
|
_currentTextures = _originalTextures;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto textures = parseTexturesToMap(_textures);
|
auto textures = getTextures();
|
||||||
|
if (textures == _lastTextures) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (textures != _currentTextures) {
|
_lastTextures = textures;
|
||||||
geometry->setTextures(textures);
|
auto newTextures = parseTexturesToMap(textures);
|
||||||
_currentTextures = textures;
|
|
||||||
|
if (newTextures != _currentTextures) {
|
||||||
|
geometry->setTextures(newTextures);
|
||||||
|
_currentTextures = newTextures;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ private:
|
||||||
bool _needsInitialSimulation = true;
|
bool _needsInitialSimulation = true;
|
||||||
bool _needsModelReload = true;
|
bool _needsModelReload = true;
|
||||||
EntityTreeRenderer* _myRenderer = nullptr;
|
EntityTreeRenderer* _myRenderer = nullptr;
|
||||||
|
QString _lastTextures;
|
||||||
QVariantMap _currentTextures;
|
QVariantMap _currentTextures;
|
||||||
QVariantMap _originalTextures;
|
QVariantMap _originalTextures;
|
||||||
bool _originalTexturesRead = false;
|
bool _originalTexturesRead = false;
|
||||||
|
|
|
@ -42,6 +42,17 @@ ModelEntityItem::ModelEntityItem(const EntityItemID& entityItemID) : EntityItem(
|
||||||
_color[0] = _color[1] = _color[2] = 0;
|
_color[0] = _color[1] = _color[2] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString ModelEntityItem::getTextures() const {
|
||||||
|
QReadLocker locker(&_texturesLock);
|
||||||
|
auto textures = _textures;
|
||||||
|
return textures;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelEntityItem::setTextures(const QString& textures) {
|
||||||
|
QWriteLocker locker(&_texturesLock);
|
||||||
|
_textures = textures;
|
||||||
|
}
|
||||||
|
|
||||||
EntityItemProperties ModelEntityItem::getProperties(EntityPropertyFlags desiredProperties) const {
|
EntityItemProperties ModelEntityItem::getProperties(EntityPropertyFlags desiredProperties) const {
|
||||||
EntityItemProperties properties = EntityItem::getProperties(desiredProperties); // get the properties from our base class
|
EntityItemProperties properties = EntityItem::getProperties(desiredProperties); // get the properties from our base class
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getXColor);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getXColor);
|
||||||
|
|
|
@ -110,8 +110,8 @@ public:
|
||||||
float getAnimationFPS() const { return _animationLoop.getFPS(); }
|
float getAnimationFPS() const { return _animationLoop.getFPS(); }
|
||||||
|
|
||||||
static const QString DEFAULT_TEXTURES;
|
static const QString DEFAULT_TEXTURES;
|
||||||
const QString& getTextures() const { return _textures; }
|
const QString getTextures() const;
|
||||||
void setTextures(const QString& textures) { _textures = textures; }
|
void setTextures(const QString& textures);
|
||||||
|
|
||||||
virtual bool shouldBePhysical() const;
|
virtual bool shouldBePhysical() const;
|
||||||
|
|
||||||
|
@ -159,7 +159,9 @@ protected:
|
||||||
AnimationPropertyGroup _animationProperties;
|
AnimationPropertyGroup _animationProperties;
|
||||||
AnimationLoop _animationLoop;
|
AnimationLoop _animationLoop;
|
||||||
|
|
||||||
|
mutable QReadWriteLock _texturesLock;
|
||||||
QString _textures;
|
QString _textures;
|
||||||
|
|
||||||
ShapeType _shapeType = SHAPE_TYPE_NONE;
|
ShapeType _shapeType = SHAPE_TYPE_NONE;
|
||||||
|
|
||||||
// used on client side
|
// used on client side
|
||||||
|
|
Loading…
Reference in a new issue