mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 11:07:07 +02:00
Merge pull request #11250 from jherico/thread_safety
Additional locking in model entities
This commit is contained in:
commit
d675ee9427
1 changed files with 21 additions and 12 deletions
|
@ -132,10 +132,13 @@ int ModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
||||||
if (args.bitstreamVersion < VERSION_ENTITIES_ANIMATION_PROPERTIES_GROUP) {
|
if (args.bitstreamVersion < VERSION_ENTITIES_ANIMATION_PROPERTIES_GROUP) {
|
||||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_SETTINGS, QString, setAnimationSettings);
|
READ_ENTITY_PROPERTY(PROP_ANIMATION_SETTINGS, QString, setAnimationSettings);
|
||||||
} else {
|
} else {
|
||||||
// Note: since we've associated our _animationProperties with our _animationLoop, the readEntitySubclassDataFromBuffer()
|
int bytesFromAnimation;
|
||||||
// will automatically read into the animation loop
|
withWriteLock([&] {
|
||||||
int bytesFromAnimation = _animationProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
// Note: since we've associated our _animationProperties with our _animationLoop, the readEntitySubclassDataFromBuffer()
|
||||||
propertyFlags, overwriteLocalData, animationPropertiesChanged);
|
// will automatically read into the animation loop
|
||||||
|
bytesFromAnimation = _animationProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
||||||
|
propertyFlags, overwriteLocalData, animationPropertiesChanged);
|
||||||
|
});
|
||||||
|
|
||||||
bytesRead += bytesFromAnimation;
|
bytesRead += bytesFromAnimation;
|
||||||
dataAt += bytesFromAnimation;
|
dataAt += bytesFromAnimation;
|
||||||
|
@ -188,8 +191,10 @@ void ModelEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
|
||||||
APPEND_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, getCompoundShapeURL());
|
APPEND_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, getCompoundShapeURL());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_TEXTURES, getTextures());
|
APPEND_ENTITY_PROPERTY(PROP_TEXTURES, getTextures());
|
||||||
|
|
||||||
_animationProperties.appendSubclassData(packetData, params, entityTreeElementExtraEncodeData, requestedProperties,
|
withReadLock([&] {
|
||||||
propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
_animationProperties.appendSubclassData(packetData, params, entityTreeElementExtraEncodeData, requestedProperties,
|
||||||
|
propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
||||||
|
});
|
||||||
|
|
||||||
APPEND_ENTITY_PROPERTY(PROP_SHAPE_TYPE, (uint32_t)getShapeType());
|
APPEND_ENTITY_PROPERTY(PROP_SHAPE_TYPE, (uint32_t)getShapeType());
|
||||||
|
|
||||||
|
@ -241,12 +246,14 @@ ShapeType ModelEntityItem::computeTrueShapeType() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelEntityItem::setModelURL(const QString& url) {
|
void ModelEntityItem::setModelURL(const QString& url) {
|
||||||
if (_modelURL != url) {
|
withWriteLock([&] {
|
||||||
_modelURL = url;
|
if (_modelURL != url) {
|
||||||
if (_shapeType == SHAPE_TYPE_STATIC_MESH) {
|
_modelURL = url;
|
||||||
_dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS;
|
if (_shapeType == SHAPE_TYPE_STATIC_MESH) {
|
||||||
|
_dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelEntityItem::setCompoundShapeURL(const QString& url) {
|
void ModelEntityItem::setCompoundShapeURL(const QString& url) {
|
||||||
|
@ -261,7 +268,9 @@ void ModelEntityItem::setCompoundShapeURL(const QString& url) {
|
||||||
|
|
||||||
void ModelEntityItem::setAnimationURL(const QString& url) {
|
void ModelEntityItem::setAnimationURL(const QString& url) {
|
||||||
_dirtyFlags |= Simulation::DIRTY_UPDATEABLE;
|
_dirtyFlags |= Simulation::DIRTY_UPDATEABLE;
|
||||||
_animationProperties.setURL(url);
|
withWriteLock([&] {
|
||||||
|
_animationProperties.setURL(url);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelEntityItem::setAnimationSettings(const QString& value) {
|
void ModelEntityItem::setAnimationSettings(const QString& value) {
|
||||||
|
|
Loading…
Reference in a new issue