Fix the debugging tool to be able to freeze the frustum for scene fetch and culling

This commit is contained in:
samcake 2016-02-12 14:59:43 -08:00
parent 9bfeb4a1d5
commit e3307d91ad
5 changed files with 34 additions and 13 deletions

View file

@ -27,8 +27,8 @@ panel.newCheckbox("Show Empty Cells",
function(value) { return (value); }
);
panel.newCheckbox("Freeze Frustum",
function(value) { Render.RenderDeferredTask.DrawSceneOctree.freezeFrustum = value; },
function() { return (Render.RenderDeferredTask.DrawSceneOctree.freezeFrustum); },
function(value) { Render.RenderDeferredTask.FetchSceneSelection.freezeFrustum = value; Render.RenderDeferredTask.CullSceneSelection.freezeFrustum = value; },
function() { return (Render.RenderDeferredTask.FetchSceneSelection.freezeFrustum); },
function(value) { return (value); }
);
panel.newCheckbox("Show Inside Items",

View file

@ -156,7 +156,7 @@ void FetchItems::run(const SceneContextPointer& sceneContext, const RenderContex
void FetchSpatialTree::configure(const Config& config) {
_justFrozeFrustum = (config.freezeFrustum && !_freezeFrustum);
_justFrozeFrustum = _justFrozeFrustum || (config.freezeFrustum && !_freezeFrustum);
_freezeFrustum = config.freezeFrustum;
_lodAngle = config.lodAngle;
}
@ -182,7 +182,7 @@ void FetchSpatialTree::run(const SceneContextPointer& sceneContext, const Render
// Octree selection!
float angle = glm::degrees(args->_viewFrustum->getAccuracyAngle(args->_sizeScale, args->_boundaryLevelAdjust));
float angle = glm::degrees(queryFrustum.getAccuracyAngle(args->_sizeScale, args->_boundaryLevelAdjust));
scene->getSpatialTree().selectCellItems(outSelection, _filter, queryFrustum, angle);
@ -190,6 +190,8 @@ void FetchSpatialTree::run(const SceneContextPointer& sceneContext, const Render
}
void CullSpatialSelection::configure(const Config& config) {
_justFrozeFrustum = _justFrozeFrustum || (config.freezeFrustum && !_freezeFrustum);
_freezeFrustum = config.freezeFrustum;
}
void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext,
@ -202,6 +204,17 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
auto& details = args->_details.edit(_detailType);
details._considered += inSelection.numItems();
// Eventually use a frozen frustum
auto queryFrustum = args->_viewFrustum;
auto argFrustum = args->_viewFrustum;
if (_freezeFrustum) {
if (_justFrozeFrustum) {
_justFrozeFrustum = false;
_frozenFrutstum = *args->_viewFrustum;
}
args->_viewFrustum = &_frozenFrutstum; // replace the true view frustum by the frozen one
}
// Culling Frustum / solidAngle test helper class
struct Test {
CullFunctor _functor;
@ -289,5 +302,11 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
details._rendered += outItems.size();
// Restore frustum if using the frozen one:
if (_freezeFrustum) {
args->_viewFrustum = argFrustum;
}
std::static_pointer_cast<Config>(renderContext->jobConfig)->numItems = (int)outItems.size();
}

View file

@ -108,12 +108,23 @@ namespace render {
class CullSpatialSelectionConfig : public Job::Config {
Q_OBJECT
Q_PROPERTY(int numItems READ getNumItems)
Q_PROPERTY(bool freezeFrustum MEMBER freezeFrustum WRITE setFreezeFrustum)
public:
int numItems{ 0 };
int getNumItems() { return numItems; }
bool freezeFrustum{ false };
public slots:
void setFreezeFrustum(bool enabled) { freezeFrustum = enabled; emit dirty(); }
signals:
void dirty();
};
class CullSpatialSelection {
bool _freezeFrustum{ false }; // initialized by Config
bool _justFrozeFrustum{ false };
ViewFrustum _frozenFrutstum;
public:
using Config = CullSpatialSelectionConfig;
using JobModel = Job::ModelIO<CullSpatialSelection, ItemSpatialTree::ItemSelection, ItemBounds, Config>;

View file

@ -80,9 +80,6 @@ const gpu::PipelinePointer DrawSceneOctree::getDrawLODReticlePipeline() {
void DrawSceneOctree::configure(const Config& config) {
_showVisibleCells = config.showVisibleCells;
_showEmptyCells = config.showEmptyCells;
_justFrozeFrustum = (config.freezeFrustum && !_freezeFrustum);
_freezeFrustum = config.freezeFrustum;
}

View file

@ -22,7 +22,6 @@ namespace render {
Q_PROPERTY(bool enabled MEMBER enabled NOTIFY dirty())
Q_PROPERTY(bool showVisibleCells MEMBER showVisibleCells WRITE setShowVisibleCells)
Q_PROPERTY(bool showEmptyCells MEMBER showEmptyCells WRITE setShowEmptyCells)
Q_PROPERTY(bool freezeFrustum MEMBER freezeFrustum WRITE setFreezeFrustum)
Q_PROPERTY(int numAllocatedCells READ getNumAllocatedCells)
Q_PROPERTY(int numFreeCells READ getNumFreeCells)
@ -32,7 +31,6 @@ namespace render {
bool showVisibleCells{ true };
bool showEmptyCells{ false };
bool freezeFrustum{ false };
int numAllocatedCells{ 0 };
int numFreeCells{ 0 };
@ -43,7 +41,6 @@ namespace render {
public slots:
void setShowVisibleCells(bool show) { showVisibleCells = show; emit dirty(); }
void setShowEmptyCells(bool show) { showEmptyCells = show; emit dirty(); }
void setFreezeFrustum(bool freeze) { freezeFrustum = freeze; emit dirty(); }
signals:
void dirty();
@ -63,9 +60,6 @@ namespace render {
bool _showVisibleCells; // initialized by Config
bool _showEmptyCells; // initialized by Config
bool _freezeFrustum{ false }; // initialized by Config
bool _justFrozeFrustum{ false };
ViewFrustum _frozenFrutstum;
public:
using Config = DrawSceneOctreeConfig;