From 44b34e03416638548f05c7c821582ec22d39e879 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Wed, 14 Oct 2020 13:21:07 -0700 Subject: [PATCH] what about...this --- .../src/RenderableModelEntityItem.cpp | 24 +++++++++---------- .../src/RenderableModelEntityItem.h | 1 - libraries/entities/src/EntityItem.cpp | 6 ++--- libraries/entities/src/ModelEntityItem.cpp | 1 - 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index c8e8b999b8..ab057f9d12 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -51,12 +51,6 @@ ModelPointer ModelEntityWrapper::getModel() const { }); } -bool ModelEntityWrapper::isModelLoaded() const { - return resultWithReadLock([&] { - return _model && _model->isLoaded(); - }); -} - EntityItemPointer RenderableModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer entity(new RenderableModelEntityItem(entityID, properties.getDimensionsInitialized()), [](EntityItem* ptr) { ptr->deleteLater(); }); @@ -261,7 +255,7 @@ bool RenderableModelEntityItem::findDetailedRayIntersection(const glm::vec3& ori OctreeElementPointer& element, float& distance, BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo, bool precisionPicking) const { auto model = getModel(); - if (!model || !isModelLoaded()) { + if (!model || !model->isLoaded()) { return false; } @@ -273,7 +267,7 @@ bool RenderableModelEntityItem::findDetailedParabolaIntersection(const glm::vec3 const glm::vec3& acceleration, OctreeElementPointer& element, float& parabolicDistance, BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo, bool precisionPicking) const { auto model = getModel(); - if (!model || !isModelLoaded()) { + if (!model || !model->isLoaded()) { return false; } @@ -309,7 +303,8 @@ void RenderableModelEntityItem::setCompoundShapeURL(const QString& url) { auto currentCompoundShapeURL = getCompoundShapeURL(); ModelEntityItem::setCompoundShapeURL(url); if (getCompoundShapeURL() != currentCompoundShapeURL || !getModel()) { - if (getShapeType() == SHAPE_TYPE_COMPOUND) { + auto shapeType = getShapeType(); + if (shapeType == SHAPE_TYPE_COMPOUND || shapeType == SHAPE_TYPE_SIMPLE_COMPOUND) { fetchCollisionGeometryResource(); } } @@ -350,7 +345,7 @@ bool RenderableModelEntityItem::isReadyToComputeShape() const { // the model is still being downloaded. return false; } else if (type >= SHAPE_TYPE_SIMPLE_HULL && type <= SHAPE_TYPE_STATIC_MESH) { - return isModelLoaded(); + return model && model->isLoaded(); } return true; } @@ -1110,7 +1105,7 @@ void ModelEntityRenderer::animate(const TypedEntityPointer& entity, const ModelP QVector jointsData; - const QVector& frames = _animation->getFramesReference(); // NOTE: getFrames() is too heavy + const QVector& frames = _animation->getFramesReference(); // NOTE: getFrames() is too heavy int frameCount = frames.size(); if (frameCount <= 0) { return; @@ -1203,8 +1198,9 @@ void ModelEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint DETAILED_PROFILE_RANGE(simulation_physics, __FUNCTION__); _hasModel = entity->hasModel(); - if (_parsedModelURL != entity->getModelURL()) { - _parsedModelURL = QUrl(entity->getModelURL()); + QUrl modelURL = QUrl(entity->getModelURL()); + if (_parsedModelURL != modelURL) { + _parsedModelURL = modelURL; } ModelPointer model = resultWithReadLock([&] { @@ -1248,6 +1244,7 @@ void ModelEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint _model->setPrimitiveMode(_primitiveMode, scene); _model->setCullWithParent(_cullWithParent, scene); _model->setRenderWithZones(_renderWithZones, scene); + entity->markDirtyFlags(Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS); entity->locationChanged(); entity->dimensionsChanged(); }); @@ -1259,6 +1256,7 @@ void ModelEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint entity->_originalTexturesRead = false; entity->_needsJointSimulation = true; entity->_needsToRescaleModel = true; + entity->updateModelBounds(); emit requestRenderUpdate(); }); model->setLoadingPriority(EntityTreeRenderer::getEntityLoadingPriority(*entity)); diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.h b/libraries/entities-renderer/src/RenderableModelEntityItem.h index cef62511bb..8d91d6c84b 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.h +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.h @@ -41,7 +41,6 @@ protected: ModelEntityWrapper(const EntityItemID& entityItemID) : Parent(entityItemID) {} void setModel(const ModelPointer& model); ModelPointer getModel() const; - bool isModelLoaded() const; bool _needsInitialSimulation{ true }; private: diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index ddedf0db18..d7a5e992e1 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1911,13 +1911,11 @@ void EntityItem::setUnscaledDimensions(const glm::vec3& value) { if (glm::length2(getUnscaledDimensions() - newDimensions) > MIN_SCALE_CHANGE_SQUARED) { withWriteLock([&] { _unscaledDimensions = newDimensions; - }); - locationChanged(); - dimensionsChanged(); - withWriteLock([&] { _flags |= (Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS); _queryAACubeSet = false; }); + locationChanged(); + dimensionsChanged(); } } diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index 0e5f009065..5dea18069f 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -290,7 +290,6 @@ void ModelEntityItem::setModelURL(const QString& url) { withWriteLock([&] { if (_modelURL != url) { _modelURL = url; - _flags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; _needsRenderUpdate = true; } });