mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 20:06:02 +02:00
Using an angle for the LOD test
This commit is contained in:
parent
78b21c3f4d
commit
513561ba2d
7 changed files with 23 additions and 17 deletions
|
@ -112,7 +112,7 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) {
|
||||||
|
|
||||||
// Scene Octree Debuging job
|
// Scene Octree Debuging job
|
||||||
{
|
{
|
||||||
addJob<DrawSceneOctree>("DrawSceneOctree");
|
addJob<DrawSceneOctree>("DrawSceneOctree", opaqueSelection);
|
||||||
// _drawStatusJobIndex = (int)_jobs.size() - 1;
|
// _drawStatusJobIndex = (int)_jobs.size() - 1;
|
||||||
// enableJob(_drawStatusJobIndex, false);
|
// enableJob(_drawStatusJobIndex, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,7 @@ void FetchItems::run(const SceneContextPointer& sceneContext, const RenderContex
|
||||||
void FetchSpatialTree::configure(const Config& config) {
|
void FetchSpatialTree::configure(const Config& config) {
|
||||||
_justFrozeFrustum = (config.freezeFrustum && !_freezeFrustum);
|
_justFrozeFrustum = (config.freezeFrustum && !_freezeFrustum);
|
||||||
_freezeFrustum = config.freezeFrustum;
|
_freezeFrustum = config.freezeFrustum;
|
||||||
|
_lodAngle = config.lodAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FetchSpatialTree::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, ItemSpatialTree::ItemSelection& outSelection) {
|
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!
|
// Octree selection!
|
||||||
scene->getSpatialTree().selectCellItems(outSelection, _filter, queryFrustum);
|
scene->getSpatialTree().selectCellItems(outSelection, _filter, queryFrustum, _lodAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CullSpatialSelection::configure(const Config& config) {
|
void CullSpatialSelection::configure(const Config& config) {
|
||||||
|
|
|
@ -71,11 +71,15 @@ namespace render {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int numItems READ getNumItems)
|
Q_PROPERTY(int numItems READ getNumItems)
|
||||||
Q_PROPERTY(bool freezeFrustum MEMBER freezeFrustum WRITE setFreezeFrustum)
|
Q_PROPERTY(bool freezeFrustum MEMBER freezeFrustum WRITE setFreezeFrustum)
|
||||||
|
Q_PROPERTY(float LODAngle MEMBER lodAngle NOTIFY dirty)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int numItems{ 0 };
|
int numItems{ 0 };
|
||||||
int getNumItems() { return numItems; }
|
int getNumItems() { return numItems; }
|
||||||
|
|
||||||
bool freezeFrustum{ false };
|
bool freezeFrustum{ false };
|
||||||
|
|
||||||
|
float lodAngle{ 2.0 };
|
||||||
public slots:
|
public slots:
|
||||||
void setFreezeFrustum(bool enabled) { freezeFrustum = enabled; emit dirty(); }
|
void setFreezeFrustum(bool enabled) { freezeFrustum = enabled; emit dirty(); }
|
||||||
|
|
||||||
|
@ -87,6 +91,7 @@ namespace render {
|
||||||
bool _freezeFrustum{ false }; // initialized by Config
|
bool _freezeFrustum{ false }; // initialized by Config
|
||||||
bool _justFrozeFrustum{ false };
|
bool _justFrozeFrustum{ false };
|
||||||
ViewFrustum _frozenFrutstum;
|
ViewFrustum _frozenFrutstum;
|
||||||
|
float _lodAngle;
|
||||||
public:
|
public:
|
||||||
using Config = FetchSpatialTreeConfig;
|
using Config = FetchSpatialTreeConfig;
|
||||||
using JobModel = Job::ModelO<FetchSpatialTree, ItemSpatialTree::ItemSelection, Config>;
|
using JobModel = Job::ModelO<FetchSpatialTree, ItemSpatialTree::ItemSelection, Config>;
|
||||||
|
|
|
@ -59,12 +59,12 @@ void DrawSceneOctree::configure(const Config& config) {
|
||||||
|
|
||||||
|
|
||||||
void DrawSceneOctree::run(const SceneContextPointer& sceneContext,
|
void DrawSceneOctree::run(const SceneContextPointer& sceneContext,
|
||||||
const RenderContextPointer& renderContext) {
|
const RenderContextPointer& renderContext, const ItemSpatialTree::ItemSelection& inSelection) {
|
||||||
assert(renderContext->args);
|
assert(renderContext->args);
|
||||||
assert(renderContext->args->_viewFrustum);
|
assert(renderContext->args->_viewFrustum);
|
||||||
RenderArgs* args = renderContext->args;
|
RenderArgs* args = renderContext->args;
|
||||||
auto& scene = sceneContext->_scene;
|
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;
|
const int VEC4_LENGTH = 4;
|
||||||
|
|
||||||
// FIrst thing, we update the local buffers with the values coming from Scene octree
|
// 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;
|
queryFrustum = _frozenFrutstum;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// Try that:
|
// Try that:
|
||||||
Octree::CellSelection selection;
|
// Octree::CellSelection selection;
|
||||||
scene->getSpatialTree().selectCells(selection, queryFrustum);
|
// scene->getSpatialTree().selectCells(selection, queryFrustum);
|
||||||
|
|
||||||
|
|
||||||
// Allright, something to render let's do it
|
// 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
|
// bind the one gpu::Pipeline we need
|
||||||
batch.setPipeline(getDrawCellBoundsPipeline());
|
batch.setPipeline(getDrawCellBoundsPipeline());
|
||||||
|
|
||||||
for (const auto& cellID : selection.insideCells) {
|
for (const auto& cellID : inSelection.cellSelection.insideCells) {
|
||||||
auto cell = scene->getSpatialTree().getConcreteCell(cellID);
|
auto cell = scene->getSpatialTree().getConcreteCell(cellID);
|
||||||
|
|
||||||
auto cellLoc = cell.getlocation();
|
auto cellLoc = cell.getlocation();
|
||||||
|
@ -131,7 +131,7 @@ void DrawSceneOctree::run(const SceneContextPointer& sceneContext,
|
||||||
|
|
||||||
batch.draw(gpu::LINES, 24, 0);
|
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 cell = scene->getSpatialTree().getConcreteCell(cellID);
|
||||||
|
|
||||||
auto cellLoc = cell.getlocation();
|
auto cellLoc = cell.getlocation();
|
||||||
|
|
|
@ -50,12 +50,12 @@ namespace render {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using Config = DrawSceneOctreeConfig;
|
using Config = DrawSceneOctreeConfig;
|
||||||
using JobModel = Job::Model<DrawSceneOctree, Config>;
|
using JobModel = Job::ModelI<DrawSceneOctree, ItemSpatialTree::ItemSelection, Config>;
|
||||||
|
|
||||||
DrawSceneOctree() {}
|
DrawSceneOctree() {}
|
||||||
|
|
||||||
void configure(const Config& config);
|
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();
|
const gpu::PipelinePointer getDrawCellBoundsPipeline();
|
||||||
};
|
};
|
||||||
|
|
|
@ -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();
|
auto worldPlanes = frustum.getPlanes();
|
||||||
FrustumSelector selector;
|
FrustumSelector selector;
|
||||||
for (int i = 0; i < ViewFrustum::NUM_PLANES; i++) {
|
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.eyePos = evalCoordf(frustum.getPosition(), ROOT_DEPTH);
|
||||||
selector.setAngle(glm::radians(2.0f));
|
selector.setAngle(glm::radians(lodAngle));
|
||||||
|
|
||||||
return Octree::select(selection, selector);
|
return Octree::select(selection, selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ItemSpatialTree::selectCellItems(ItemSelection& selection, const ItemFilter& filter, const ViewFrustum& frustum) const {
|
int ItemSpatialTree::selectCellItems(ItemSelection& selection, const ItemFilter& filter, const ViewFrustum& frustum, float lodAngle) const {
|
||||||
selectCells(selection.cellSelection, frustum);
|
selectCells(selection.cellSelection, frustum, lodAngle);
|
||||||
|
|
||||||
// Just grab the items in every selected bricks
|
// Just grab the items in every selected bricks
|
||||||
for (auto brickId : selection.cellSelection.insideBricks) {
|
for (auto brickId : selection.cellSelection.insideBricks) {
|
||||||
|
|
|
@ -360,7 +360,7 @@ namespace render {
|
||||||
Index resetItem(Index oldCell, const ItemKey& oldKey, const AABox& bound, const ItemID& item, ItemKey& newKey);
|
Index resetItem(Index oldCell, const ItemKey& oldKey, const AABox& bound, const ItemID& item, ItemKey& newKey);
|
||||||
|
|
||||||
// Selection and traverse
|
// Selection and traverse
|
||||||
int selectCells(CellSelection& selection, const ViewFrustum& frustum) const;
|
int selectCells(CellSelection& selection, const ViewFrustum& frustum, float lodAngle) const;
|
||||||
|
|
||||||
class ItemSelection {
|
class ItemSelection {
|
||||||
public:
|
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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue