Using an angle for the LOD test

This commit is contained in:
samcake 2016-02-04 09:31:21 -08:00
parent 78b21c3f4d
commit 513561ba2d
7 changed files with 23 additions and 17 deletions

View file

@ -112,7 +112,7 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) {
// Scene Octree Debuging job
{
addJob<DrawSceneOctree>("DrawSceneOctree");
addJob<DrawSceneOctree>("DrawSceneOctree", opaqueSelection);
// _drawStatusJobIndex = (int)_jobs.size() - 1;
// enableJob(_drawStatusJobIndex, false);
}

View file

@ -159,6 +159,7 @@ void FetchItems::run(const SceneContextPointer& sceneContext, const RenderContex
void FetchSpatialTree::configure(const Config& config) {
_justFrozeFrustum = (config.freezeFrustum && !_freezeFrustum);
_freezeFrustum = config.freezeFrustum;
_lodAngle = config.lodAngle;
}
void FetchSpatialTree::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, ItemSpatialTree::ItemSelection& outSelection) {
@ -181,7 +182,7 @@ void FetchSpatialTree::run(const SceneContextPointer& sceneContext, const Render
}
// Octree selection!
scene->getSpatialTree().selectCellItems(outSelection, _filter, queryFrustum);
scene->getSpatialTree().selectCellItems(outSelection, _filter, queryFrustum, _lodAngle);
}
void CullSpatialSelection::configure(const Config& config) {

View file

@ -71,11 +71,15 @@ namespace render {
Q_OBJECT
Q_PROPERTY(int numItems READ getNumItems)
Q_PROPERTY(bool freezeFrustum MEMBER freezeFrustum WRITE setFreezeFrustum)
Q_PROPERTY(float LODAngle MEMBER lodAngle NOTIFY dirty)
public:
int numItems{ 0 };
int getNumItems() { return numItems; }
bool freezeFrustum{ false };
float lodAngle{ 2.0 };
public slots:
void setFreezeFrustum(bool enabled) { freezeFrustum = enabled; emit dirty(); }
@ -87,6 +91,7 @@ namespace render {
bool _freezeFrustum{ false }; // initialized by Config
bool _justFrozeFrustum{ false };
ViewFrustum _frozenFrutstum;
float _lodAngle;
public:
using Config = FetchSpatialTreeConfig;
using JobModel = Job::ModelO<FetchSpatialTree, ItemSpatialTree::ItemSelection, Config>;

View file

@ -59,12 +59,12 @@ void DrawSceneOctree::configure(const Config& config) {
void DrawSceneOctree::run(const SceneContextPointer& sceneContext,
const RenderContextPointer& renderContext) {
const RenderContextPointer& renderContext, const ItemSpatialTree::ItemSelection& inSelection) {
assert(renderContext->args);
assert(renderContext->args->_viewFrustum);
RenderArgs* args = renderContext->args;
auto& scene = sceneContext->_scene;
const int NUM_STATUS_VEC4_PER_ITEM = 2;
/*const int NUM_STATUS_VEC4_PER_ITEM = 2;
const int VEC4_LENGTH = 4;
// FIrst thing, we update the local buffers with the values coming from Scene octree
@ -96,10 +96,10 @@ void DrawSceneOctree::run(const SceneContextPointer& sceneContext,
}
queryFrustum = _frozenFrutstum;
}
*/
// Try that:
Octree::CellSelection selection;
scene->getSpatialTree().selectCells(selection, queryFrustum);
// Octree::CellSelection selection;
// scene->getSpatialTree().selectCells(selection, queryFrustum);
// Allright, something to render let's do it
@ -117,7 +117,7 @@ void DrawSceneOctree::run(const SceneContextPointer& sceneContext,
// bind the one gpu::Pipeline we need
batch.setPipeline(getDrawCellBoundsPipeline());
for (const auto& cellID : selection.insideCells) {
for (const auto& cellID : inSelection.cellSelection.insideCells) {
auto cell = scene->getSpatialTree().getConcreteCell(cellID);
auto cellLoc = cell.getlocation();
@ -131,7 +131,7 @@ void DrawSceneOctree::run(const SceneContextPointer& sceneContext,
batch.draw(gpu::LINES, 24, 0);
}
for (const auto& cellID : selection.partialCells) {
for (const auto& cellID : inSelection.cellSelection.partialCells) {
auto cell = scene->getSpatialTree().getConcreteCell(cellID);
auto cellLoc = cell.getlocation();

View file

@ -50,12 +50,12 @@ namespace render {
public:
using Config = DrawSceneOctreeConfig;
using JobModel = Job::Model<DrawSceneOctree, Config>;
using JobModel = Job::ModelI<DrawSceneOctree, ItemSpatialTree::ItemSelection, Config>;
DrawSceneOctree() {}
void configure(const Config& config);
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext);
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemSpatialTree::ItemSelection& selection);
const gpu::PipelinePointer getDrawCellBoundsPipeline();
};

View file

@ -424,7 +424,7 @@ int Octree::selectCellBrick(Index cellID, CellSelection& selection, bool inside)
}
int ItemSpatialTree::selectCells(CellSelection& selection, const ViewFrustum& frustum) const {
int ItemSpatialTree::selectCells(CellSelection& selection, const ViewFrustum& frustum, float lodAngle) const {
auto worldPlanes = frustum.getPlanes();
FrustumSelector selector;
for (int i = 0; i < ViewFrustum::NUM_PLANES; i++) {
@ -434,13 +434,13 @@ int ItemSpatialTree::selectCells(CellSelection& selection, const ViewFrustum& fr
}
selector.eyePos = evalCoordf(frustum.getPosition(), ROOT_DEPTH);
selector.setAngle(glm::radians(2.0f));
selector.setAngle(glm::radians(lodAngle));
return Octree::select(selection, selector);
}
int ItemSpatialTree::selectCellItems(ItemSelection& selection, const ItemFilter& filter, const ViewFrustum& frustum) const {
selectCells(selection.cellSelection, frustum);
int ItemSpatialTree::selectCellItems(ItemSelection& selection, const ItemFilter& filter, const ViewFrustum& frustum, float lodAngle) const {
selectCells(selection.cellSelection, frustum, lodAngle);
// Just grab the items in every selected bricks
for (auto brickId : selection.cellSelection.insideBricks) {

View file

@ -360,7 +360,7 @@ namespace render {
Index resetItem(Index oldCell, const ItemKey& oldKey, const AABox& bound, const ItemID& item, ItemKey& newKey);
// Selection and traverse
int selectCells(CellSelection& selection, const ViewFrustum& frustum) const;
int selectCells(CellSelection& selection, const ViewFrustum& frustum, float lodAngle) const;
class ItemSelection {
public:
@ -386,7 +386,7 @@ namespace render {
}
};
int selectCellItems(ItemSelection& selection, const ItemFilter& filter, const ViewFrustum& frustum) const;
int selectCellItems(ItemSelection& selection, const ItemFilter& filter, const ViewFrustum& frustum, float lodAngle) const;
};
}