mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-12 22:39:09 -05:00
Make DebugRendering have its own SelectionProperty in GUI
This commit is contained in:
@@ -155,10 +155,12 @@ namespace openspace {
|
||||
renderChunkTree(_leftRoot.get(), data);
|
||||
renderChunkTree(_rightRoot.get(), data);
|
||||
|
||||
if (showChunkBounds) {
|
||||
renderChunkBounds(data);
|
||||
if (showChunkBounds || showChunkAABB) {
|
||||
debugRenderChunks(data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (_savedCamera != nullptr) {
|
||||
DebugRenderer::ref()->renderCameraFrustum(data, *_savedCamera);
|
||||
}
|
||||
@@ -183,25 +185,38 @@ namespace openspace {
|
||||
}
|
||||
}
|
||||
|
||||
void ChunkedLodGlobe::renderChunkBounds(const RenderData& data) const {
|
||||
void ChunkedLodGlobe::debugRenderChunks(const RenderData& data) const {
|
||||
// Calculate the MVP matrix
|
||||
dmat4 modelTransform = translate(dmat4(1), data.position.dvec3());
|
||||
dmat4 viewTransform = dmat4(data.camera.combinedViewMatrix());
|
||||
dmat4 vp = dmat4(data.camera.projectionMatrix()) * viewTransform;
|
||||
dmat4 mvp = vp * modelTransform;
|
||||
|
||||
std::function<void(const ChunkNode&)> chunkDebugRenderer = [&data, &mvp](const ChunkNode& chunkNode) {
|
||||
std::function<void(const ChunkNode&)> chunkDebugRenderer = [this, &data, &mvp](const ChunkNode& chunkNode) {
|
||||
const Chunk& chunk = chunkNode.getChunk();
|
||||
if (chunkNode.isLeaf() && chunk.isVisible()) {
|
||||
const std::vector<glm::dvec4> modelSpaceCorners = chunk.getBoundingPolyhedronCorners();
|
||||
std::vector<glm::vec4> clippingSpaceCorners(8);
|
||||
AABB3 screenSpaceBounds;
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
clippingSpaceCorners[i] = mvp * modelSpaceCorners[i];
|
||||
const vec4& clippingSpaceCorner = mvp * modelSpaceCorners[i];
|
||||
clippingSpaceCorners[i] = clippingSpaceCorner;
|
||||
|
||||
vec3 screenSpaceCorner = (1.0f / clippingSpaceCorner.w) * clippingSpaceCorner.xyz();
|
||||
screenSpaceBounds.expand(screenSpaceCorner);
|
||||
}
|
||||
|
||||
unsigned int colorBits = 1 + chunk.index().level % 6;
|
||||
vec4 color = vec4(colorBits & 1, colorBits & 2, colorBits & 4, 0.3);
|
||||
DebugRenderer::ref()->renderNiceBox(clippingSpaceCorners, color);
|
||||
|
||||
if (showChunkBounds) {
|
||||
DebugRenderer::ref()->renderNiceBox(clippingSpaceCorners, color);
|
||||
}
|
||||
|
||||
if (showChunkAABB) {
|
||||
auto& screenSpacePoints = DebugRenderer::ref()->verticesFor(screenSpaceBounds);
|
||||
DebugRenderer::ref()->renderNiceBox(screenSpacePoints, color);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -209,6 +224,8 @@ namespace openspace {
|
||||
_rightRoot->depthFirst(chunkDebugRenderer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ChunkedLodGlobe::update(const UpdateData& data) {
|
||||
_patchRenderer->update();
|
||||
}
|
||||
|
||||
@@ -108,11 +108,11 @@ namespace openspace {
|
||||
float chunkHeight;
|
||||
|
||||
// Layered rendering
|
||||
std::array<bool, LayeredTextures::NUM_TEXTURE_CATEGORIES>
|
||||
blendProperties;
|
||||
std::array<bool, LayeredTextures::NUM_TEXTURE_CATEGORIES> blendProperties;
|
||||
bool atmosphereEnabled;
|
||||
bool showChunkEdges;
|
||||
bool showChunkBounds;
|
||||
bool showChunkEdges = false;
|
||||
bool showChunkBounds = false;
|
||||
bool showChunkAABB = false;
|
||||
bool levelByProjArea;
|
||||
bool limitLevelByAvailableHeightData;
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace openspace {
|
||||
private:
|
||||
|
||||
void renderChunkTree(ChunkNode* node, const RenderData& data) const;
|
||||
void renderChunkBounds(const RenderData& data) const;
|
||||
void debugRenderChunks(const RenderData& data) const;
|
||||
|
||||
|
||||
// Covers all negative longitudes
|
||||
|
||||
@@ -70,14 +70,14 @@ namespace openspace {
|
||||
, _waterMasksSelection(properties::SelectionProperty("Water Masks", "Water Masks"))
|
||||
, _overlaysSelection(properties::SelectionProperty("Overlays", "Overlays"))
|
||||
|
||||
, debugSelection(properties::SelectionProperty("Debug", "Debug"))
|
||||
|
||||
, blendHeightMap(properties::BoolProperty("blendHeightMap", "blendHeightMap", true))
|
||||
, blendColorMap(properties::BoolProperty("blendColorMap", "blendColorMap", true))
|
||||
, blendNightTexture(properties::BoolProperty("blendNightTexture", "blendNightTexture", true))
|
||||
, blendOverlay(properties::BoolProperty("blendOverlay", "blendOverlay", true))
|
||||
, blendWaterMask(properties::BoolProperty("blendWaterMask", "blendWaterMask", true))
|
||||
, atmosphereEnabled(properties::BoolProperty("atmosphereEnabled", "atmosphereEnabled", false))
|
||||
, showChunkEdges(properties::BoolProperty("showChunkEdges", "showChunkEdges", false))
|
||||
, showChunkBounds(properties::BoolProperty("showChunkBounds", "showChunkBounds", false))
|
||||
, levelByProjArea(properties::BoolProperty("levelByProjArea", "levelByProjArea", true))
|
||||
, limitLevelByAvailableHeightData(properties::BoolProperty("limitLevelByAvailableHeightData", "limitLevelByAvailableHeightData", true))
|
||||
{
|
||||
@@ -98,6 +98,8 @@ namespace openspace {
|
||||
addProperty(_waterMasksSelection);
|
||||
addProperty(_overlaysSelection);
|
||||
|
||||
addDebugOptions();
|
||||
|
||||
addProperty(blendHeightMap);
|
||||
addProperty(blendColorMap);
|
||||
addProperty(blendNightTexture);
|
||||
@@ -105,8 +107,7 @@ namespace openspace {
|
||||
addProperty(blendWaterMask);
|
||||
addProperty(atmosphereEnabled);
|
||||
|
||||
addProperty(showChunkEdges);
|
||||
addProperty(showChunkBounds);
|
||||
|
||||
addProperty(levelByProjArea);
|
||||
addProperty(limitLevelByAvailableHeightData);
|
||||
|
||||
@@ -242,40 +243,9 @@ namespace openspace {
|
||||
_chunkedLodGlobe->blendProperties[LayeredTextures::WaterMasks] = blendWaterMask.value();
|
||||
_chunkedLodGlobe->atmosphereEnabled = atmosphereEnabled.value();
|
||||
|
||||
_chunkedLodGlobe->showChunkEdges = showChunkEdges.value();
|
||||
_chunkedLodGlobe->showChunkBounds = showChunkBounds.value();
|
||||
_chunkedLodGlobe->levelByProjArea = levelByProjArea.value();
|
||||
_chunkedLodGlobe->limitLevelByAvailableHeightData = limitLevelByAvailableHeightData.value();
|
||||
/*
|
||||
std::vector<TileProviderManager::TileProviderWithName>& colorTextureProviders =
|
||||
_tileProviderManager->getLayerCategory(LayeredTextures::ColorTextures);
|
||||
std::vector<TileProviderManager::TileProviderWithName>& nightTextureProviders =
|
||||
_tileProviderManager->getLayerCategory(LayeredTextures::NightTextures);
|
||||
std::vector<TileProviderManager::TileProviderWithName>& overlayProviders =
|
||||
_tileProviderManager->getLayerCategory(LayeredTextures::Overlays);
|
||||
std::vector<TileProviderManager::TileProviderWithName>& heightMapProviders =
|
||||
_tileProviderManager->getLayerCategory(LayeredTextures::HeightMaps);
|
||||
std::vector<TileProviderManager::TileProviderWithName>& waterMaskProviders =
|
||||
_tileProviderManager->getLayerCategory(LayeredTextures::WaterMasks);
|
||||
|
||||
|
||||
for (size_t i = 0; i < colorTextureProviders.size(); i++) {
|
||||
colorTextureProviders[i].isActive = _activeColorLayers[i].value();
|
||||
}
|
||||
for (size_t i = 0; i < nightTextureProviders.size(); i++) {
|
||||
nightTextureProviders[i].isActive = _activeNightLayers[i].value();
|
||||
}
|
||||
for (size_t i = 0; i < overlayProviders.size(); i++) {
|
||||
overlayProviders[i].isActive = _activeOverlays[i].value();
|
||||
}
|
||||
for (size_t i = 0; i < heightMapProviders.size(); i++) {
|
||||
heightMapProviders[i].isActive = _activeHeightMapLayers[i].value();
|
||||
}
|
||||
for (size_t i = 0; i < waterMaskProviders.size(); i++) {
|
||||
waterMaskProviders[i].isActive = _activeWaterMaskLayers[i].value();
|
||||
}
|
||||
*/
|
||||
// Update this after active layers have been updated
|
||||
|
||||
_tileProviderManager->prerender();
|
||||
}
|
||||
|
||||
@@ -328,4 +298,34 @@ namespace openspace {
|
||||
selectionChanged(_overlaysSelection, LayeredTextures::Overlays);
|
||||
}
|
||||
|
||||
void RenderableGlobe::addDebugOptions() {
|
||||
addProperty(debugSelection);
|
||||
|
||||
// Add options (GUI value initialized to false)
|
||||
debugSelection.addOption({ 0, "Show chunk edges" });
|
||||
debugSelection.addOption({ 1, "Show chunk bounds" });
|
||||
debugSelection.addOption({ 2, "Show chunk AABB" });
|
||||
|
||||
|
||||
// Add callback
|
||||
debugSelection.onChange([this]() {
|
||||
int nOptions = this->debugSelection.options().size();
|
||||
for (int i = 0; i < nOptions; ++i) {
|
||||
this->setDebugOption(i, false);
|
||||
}
|
||||
|
||||
const std::vector<int>& selectedIndices = this->debugSelection;
|
||||
for (auto selectedIndex : selectedIndices) {
|
||||
this->setDebugOption(selectedIndex, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void RenderableGlobe::setDebugOption(size_t index, bool value) {
|
||||
switch (index) {
|
||||
case 0: _chunkedLodGlobe->showChunkEdges = value; break;
|
||||
case 1: _chunkedLodGlobe->showChunkBounds = value; break;
|
||||
case 2: _chunkedLodGlobe->showChunkAABB = value; break;
|
||||
}
|
||||
}
|
||||
} // namespace openspace
|
||||
|
||||
@@ -93,13 +93,16 @@ public:
|
||||
properties::BoolProperty blendWaterMask;
|
||||
properties::BoolProperty atmosphereEnabled;
|
||||
|
||||
properties::BoolProperty showChunkEdges;
|
||||
properties::BoolProperty showChunkBounds;
|
||||
properties::SelectionProperty debugSelection;
|
||||
void setDebugOption(size_t index, bool value);
|
||||
|
||||
properties::BoolProperty levelByProjArea;
|
||||
properties::BoolProperty limitLevelByAvailableHeightData;
|
||||
|
||||
|
||||
private:
|
||||
void addDebugOptions();
|
||||
|
||||
std::string _frame;
|
||||
|
||||
void addToggleLayerProperties(
|
||||
@@ -130,6 +133,7 @@ private:
|
||||
std::vector<properties::BoolProperty> _activeHeightMapLayers;
|
||||
std::vector<properties::BoolProperty> _activeWaterMaskLayers;
|
||||
|
||||
|
||||
void selectionChanged(
|
||||
properties::SelectionProperty selectionProperty,
|
||||
LayeredTextures::TextureCategory textureCategory);
|
||||
|
||||
Reference in New Issue
Block a user