Merge pull request #12091 from SamGondelman/overlayFix

Update model render items on texture load and fix no haze issue
This commit is contained in:
Sam Gateau 2018-01-05 12:26:56 -08:00 committed by GitHub
commit 91eb718074
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 8 deletions

View file

@ -97,6 +97,11 @@ void ModelOverlay::update(float deltatime) {
_model->setLayeredInHUD(getDrawHUDLayer(), scene); _model->setLayeredInHUD(getDrawHUDLayer(), scene);
} }
scene->enqueueTransaction(transaction); scene->enqueueTransaction(transaction);
if (!_texturesLoaded && _model->getGeometry() && _model->getGeometry()->areTexturesLoaded()) {
_texturesLoaded = true;
_model->updateRenderItems();
}
} }
bool ModelOverlay::addToScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) { bool ModelOverlay::addToScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) {
@ -170,10 +175,12 @@ void ModelOverlay::setProperties(const QVariantMap& properties) {
_url = urlValue.toString(); _url = urlValue.toString();
_updateModel = true; _updateModel = true;
_isLoaded = false; _isLoaded = false;
_texturesLoaded = false;
} }
auto texturesValue = properties["textures"]; auto texturesValue = properties["textures"];
if (texturesValue.isValid() && texturesValue.canConvert(QVariant::Map)) { if (texturesValue.isValid() && texturesValue.canConvert(QVariant::Map)) {
_texturesLoaded = false;
QVariantMap textureMap = texturesValue.toMap(); QVariantMap textureMap = texturesValue.toMap();
QMetaObject::invokeMethod(_model.get(), "setTextures", Qt::AutoConnection, QMetaObject::invokeMethod(_model.get(), "setTextures", Qt::AutoConnection,
Q_ARG(const QVariantMap&, textureMap)); Q_ARG(const QVariantMap&, textureMap));

View file

@ -79,6 +79,7 @@ private:
ModelPointer _model; ModelPointer _model;
QVariantMap _modelTextures; QVariantMap _modelTextures;
bool _texturesLoaded { false };
render::ItemIDs _subRenderItemIDs; render::ItemIDs _subRenderItemIDs;

View file

@ -1080,6 +1080,10 @@ bool ModelEntityRenderer::needsRenderUpdate() const {
return true; return true;
} }
if (!_texturesLoaded && model->getGeometry() && model->getGeometry()->areTexturesLoaded()) {
return true;
}
if (model->needsReload()) { if (model->needsReload()) {
return true; return true;
} }
@ -1216,6 +1220,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
// From here on, we are guaranteed a populated model // From here on, we are guaranteed a populated model
withWriteLock([&] { withWriteLock([&] {
if (_parsedModelURL != model->getURL()) { if (_parsedModelURL != model->getURL()) {
_texturesLoaded = false;
model->setURL(_parsedModelURL); model->setURL(_parsedModelURL);
} }
}); });
@ -1247,6 +1252,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
} }
if (_lastTextures != entity->getTextures()) { if (_lastTextures != entity->getTextures()) {
_texturesLoaded = false;
_lastTextures = entity->getTextures(); _lastTextures = entity->getTextures();
auto newTextures = parseTexturesToMap(_lastTextures, entity->_originalTextures); auto newTextures = parseTexturesToMap(_lastTextures, entity->_originalTextures);
if (newTextures != _currentTextures) { if (newTextures != _currentTextures) {
@ -1301,12 +1307,17 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
} }
} }
if (!_texturesLoaded && model->getGeometry() && model->getGeometry()->areTexturesLoaded()) {
_texturesLoaded = true;
model->updateRenderItems();
}
// When the individual mesh parts of a model finish fading, they will mark their Model as needing updating // When the individual mesh parts of a model finish fading, they will mark their Model as needing updating
// we will watch for that and ask the model to update it's render items // we will watch for that and ask the model to update it's render items
if (model->getRenderItemsNeedUpdate()) { if (model->getRenderItemsNeedUpdate()) {
model->updateRenderItems(); model->updateRenderItems();
} }
// The code to deal with the change of properties is now in ModelEntityItem.cpp // The code to deal with the change of properties is now in ModelEntityItem.cpp
// That is where _currentFrame and _lastAnimated were updated. // That is where _currentFrame and _lastAnimated were updated.
if (_animating) { if (_animating) {

View file

@ -158,10 +158,11 @@ private:
virtual bool isTransparent() const override { return false; } virtual bool isTransparent() const override { return false; }
bool _hasModel { false }; bool _hasModel { false };
::ModelPointer _model; ModelPointer _model;
GeometryResource::Pointer _compoundShapeResource; GeometryResource::Pointer _compoundShapeResource;
QString _lastTextures; QString _lastTextures;
QVariantMap _currentTextures; QVariantMap _currentTextures;
bool _texturesLoaded { false };
AnimationPropertyGroup _renderAnimationProperties; AnimationPropertyGroup _renderAnimationProperties;
int _lastKnownCurrentFrame { -1 }; int _lastKnownCurrentFrame { -1 };
#ifdef MODEL_ENTITY_USE_FADE_EFFECT #ifdef MODEL_ENTITY_USE_FADE_EFFECT

View file

@ -39,7 +39,6 @@ void CauterizedMeshPartPayload::updateTransformForCauterizedMesh(const Transform
} }
void CauterizedMeshPartPayload::bindTransform(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations, RenderArgs::RenderMode renderMode) const { void CauterizedMeshPartPayload::bindTransform(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations, RenderArgs::RenderMode renderMode) const {
// Still relying on the raw data from the model
bool useCauterizedMesh = (renderMode != RenderArgs::RenderMode::SHADOW_RENDER_MODE && renderMode != RenderArgs::RenderMode::SECONDARY_CAMERA_RENDER_MODE) && _enableCauterization; bool useCauterizedMesh = (renderMode != RenderArgs::RenderMode::SHADOW_RENDER_MODE && renderMode != RenderArgs::RenderMode::SECONDARY_CAMERA_RENDER_MODE) && _enableCauterization;
if (useCauterizedMesh) { if (useCauterizedMesh) {
if (_cauterizedClusterBuffer) { if (_cauterizedClusterBuffer) {

View file

@ -71,12 +71,12 @@ enum DeferredShader_BufferSlot {
SCATTERING_PARAMETERS_BUFFER_SLOT, SCATTERING_PARAMETERS_BUFFER_SLOT,
LIGHTING_MODEL_BUFFER_SLOT = render::ShapePipeline::Slot::LIGHTING_MODEL, LIGHTING_MODEL_BUFFER_SLOT = render::ShapePipeline::Slot::LIGHTING_MODEL,
LIGHT_GPU_SLOT = render::ShapePipeline::Slot::LIGHT, LIGHT_GPU_SLOT = render::ShapePipeline::Slot::LIGHT,
LIGHT_AMBIENT_SLOT, LIGHT_AMBIENT_SLOT = render::ShapePipeline::Slot::LIGHT_AMBIENT_BUFFER,
HAZE_MODEL_BUFFER_SLOT = render::ShapePipeline::Slot::HAZE_MODEL,
LIGHT_INDEX_GPU_SLOT, LIGHT_INDEX_GPU_SLOT,
LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT, LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT,
LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT, LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT,
LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT,
HAZE_MODEL_BUFFER_SLOT
}; };
static void loadLightProgram(const char* vertSource, const char* fragSource, bool lightVolume, gpu::PipelinePointer& program, LightLocationsPtr& locations); static void loadLightProgram(const char* vertSource, const char* fragSource, bool lightVolume, gpu::PipelinePointer& program, LightLocationsPtr& locations);

View file

@ -501,7 +501,6 @@ void ModelMeshPartPayload::bindMesh(gpu::Batch& batch) {
} }
void ModelMeshPartPayload::bindTransform(gpu::Batch& batch, const ShapePipeline::LocationsPointer locations, RenderArgs::RenderMode renderMode) const { void ModelMeshPartPayload::bindTransform(gpu::Batch& batch, const ShapePipeline::LocationsPointer locations, RenderArgs::RenderMode renderMode) const {
// Still relying on the raw data from the model
if (_clusterBuffer) { if (_clusterBuffer) {
batch.setUniformBuffer(ShapePipeline::Slot::BUFFER::SKINNING, _clusterBuffer); batch.setUniformBuffer(ShapePipeline::Slot::BUFFER::SKINNING, _clusterBuffer);
} }

View file

@ -70,7 +70,7 @@ void SetupZones::run(const RenderContextPointer& context, const Inputs& inputs)
lightStage->_currentFrame.pushSunLight(0); lightStage->_currentFrame.pushSunLight(0);
lightStage->_currentFrame.pushAmbientLight(0); lightStage->_currentFrame.pushAmbientLight(0);
hazeStage->_currentFrame.pushHaze(0);
backgroundStage->_currentFrame.pushBackground(0); backgroundStage->_currentFrame.pushBackground(0);
} }

View file

@ -237,8 +237,8 @@ public:
LIGHTING_MODEL, LIGHTING_MODEL,
LIGHT, LIGHT,
LIGHT_AMBIENT_BUFFER, LIGHT_AMBIENT_BUFFER,
HAZE_MODEL,
FADE_PARAMETERS, FADE_PARAMETERS,
HAZE_MODEL
}; };
enum MAP { enum MAP {