Enabling 'Freeze camera used for chunk culling' from GUI. Helpful for culling debugging

This commit is contained in:
Erik Broberg
2016-05-11 18:38:19 -04:00
parent afd8ba5e9b
commit 0c9ce5af70
6 changed files with 55 additions and 13 deletions
@@ -26,7 +26,6 @@
#include <modules/globebrowsing/globes/globemesh.h>
#include <modules/globebrowsing/globes/clipmapglobe.h>
#include <modules/globebrowsing/globes/chunkedlodglobe.h>
// open space includes
#include <openspace/engine/openspaceengine.h>
@@ -52,7 +51,15 @@ namespace openspace {
RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
: _tileProviderManager(std::shared_ptr<TileProviderManager>(new TileProviderManager))
, _saveOrThrowCamera(properties::BoolProperty("saveOrThrowCamera", "saveOrThrowCamera"))
{
setName("RenderableGlobe");
addProperty(_saveOrThrowCamera);
// Read the radii in to its own dictionary
Vec3 radii;
dictionary.getValue(keyRadii, radii);
@@ -98,8 +105,11 @@ namespace openspace {
//addSwitchValue(std::shared_ptr<ClipMapGlobe>(
// new ClipMapGlobe(_ellipsoid, _tileProviderManager)), 1e8);
_distanceSwitch.addSwitchValue(std::shared_ptr<ChunkedLodGlobe>(
new ChunkedLodGlobe(_ellipsoid, _tileProviderManager)), 1e9);
_chunkedLodGlobe = std::shared_ptr<ChunkedLodGlobe>(
new ChunkedLodGlobe(_ellipsoid, _tileProviderManager));
_distanceSwitch.addSwitchValue(_chunkedLodGlobe, 1e9);
_distanceSwitch.addSwitchValue(std::shared_ptr<GlobeMesh>(new GlobeMesh()), 1e10);
}
@@ -120,6 +130,18 @@ namespace openspace {
}
void RenderableGlobe::render(const RenderData& data) {
if (_saveOrThrowCamera.value()) {
_saveOrThrowCamera.setValue(false);
if (_chunkedLodGlobe->getSavedCamera() == nullptr) { // save camera
LDEBUG("Saving snapshot of camera!");
_chunkedLodGlobe->setSaveCamera(new Camera(data.camera));
}
else { // throw camera
LDEBUG("Throwing away saved camera!");
_chunkedLodGlobe->setSaveCamera(nullptr);
}
}
_distanceSwitch.render(data);
}