Skip to content

Commit c425181

Browse files
committed
Render the Depth-Image only iff it is requested
1 parent 564c30e commit c425181

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

graphics/src/GraphicsManager.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,6 +1939,12 @@ namespace mars {
19391939
void GraphicsManager::removeOSGNode(void* node) {
19401940
scene->removeChild((osg::Node*)node);
19411941
}
1942+
1943+
bool GraphicsManager::isDepthImageActive(){
1944+
if(!cfg) return false;
1945+
return cfg->getOrCreateProperty("Graphics", "renderDepthImage", false, this).bValue;
1946+
}
1947+
19421948
} // end of namespace graphics
19431949
} // end of namespace mars
19441950

graphics/src/GraphicsManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ namespace mars {
296296

297297
void removeGraphicsWidget(unsigned long id);
298298
virtual bool isInitialized() const {return initialized;}
299+
virtual bool isDepthImageActive();
299300
private:
300301

301302
mars::interfaces::GraphicData graphicOptions;

graphics/src/GraphicsWidget.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,9 @@ namespace mars {
901901
rttTexture->setImage(rttImage);
902902
}
903903

904+
905+
906+
if(gm->isDepthImageActive()){
904907
// depth component
905908
rttDepthTexture = new osg::Texture2D();
906909
rttDepthTexture->setResizeNonPowerOfTwoHint(false);
@@ -919,11 +922,9 @@ namespace mars {
919922
1, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
920923

921924
osgCamera->attach(osg::Camera::DEPTH_BUFFER, rttDepthImage.get());
922-
923925
std::fill(rttDepthImage->data(), rttDepthImage->data() + widgetWidth * widgetHeight * sizeof(GLuint), 0);
924-
925926
rttDepthTexture->setImage(rttDepthImage);
926-
927+
}
927928

928929
graphicsCamera = new GraphicsCamera(osgCamera, widgetWidth, widgetHeight);
929930
}

0 commit comments

Comments
 (0)