properly update image3d render item

This commit is contained in:
SamGondelman 2017-08-18 14:21:46 -07:00
parent 38e5c4fde0
commit f56e952253
2 changed files with 18 additions and 0 deletions

View file

@ -19,6 +19,7 @@
#include "GeometryUtil.h"
#include "Application.h"
QString const Image3DOverlay::TYPE = "image3d";
@ -58,12 +59,28 @@ void Image3DOverlay::render(RenderArgs* args) {
if (!_isLoaded) {
_isLoaded = true;
_texture = DependencyManager::get<TextureCache>()->getTexture(_url);
_textureIsLoaded = false;
}
if (!_visible || !getParentVisible() || !_texture || !_texture->isLoaded()) {
return;
}
// Once the texture has loaded, check if we need to update the render item because of transparency
if (!_textureIsLoaded && _texture && _texture->getGPUTexture()) {
_textureIsLoaded = true;
if (_texture->getGPUTexture()->getUsage().isAlpha()) {
auto itemID = getRenderItemID();
setAlpha(0.5f);
if (render::Item::isValidID(itemID)) {
render::ScenePointer scene = qApp->getMain3DScene();
render::Transaction transaction;
transaction.updateItem(itemID);
scene->enqueueTransaction(transaction);
}
}
}
Q_ASSERT(args->_batch);
gpu::Batch* batch = args->_batch;

View file

@ -47,6 +47,7 @@ public:
private:
QString _url;
bool _textureIsLoaded;
NetworkTexturePointer _texture;
bool _emissive { false };